hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1076893 [1/3] - in /hadoop/common/branches/branch-0.20-security-patches: ./ conf/ src/c++/task-controller/
Date Thu, 03 Mar 2011 23:50:58 GMT
Author: omalley
Date: Thu Mar  3 23:50:57 2011
New Revision: 1076893

URL: http://svn.apache.org/viewvc?rev=1076893&view=rev
Log: (empty)

Added:
    hadoop/common/branches/branch-0.20-security-patches/conf/taskcontroller.cfg
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/Makefile.in
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.c
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.h.in
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configure
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configure.ac
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/main.c
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/task-controller.c
    hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/task-controller.h
Modified:
    hadoop/common/branches/branch-0.20-security-patches/build.xml

Modified: hadoop/common/branches/branch-0.20-security-patches/build.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/build.xml?rev=1076893&r1=1076892&r2=1076893&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/build.xml (original)
+++ hadoop/common/branches/branch-0.20-security-patches/build.xml Thu Mar  3 23:50:57 2011
@@ -147,6 +147,21 @@
   <property name="patch.cmd" value="patch"/>
   <property name="make.cmd" value="make"/>
 
+  <!-- task-controller properties set here -->
+  <!-- Source directory from where configure is run and files are copied
+  -->
+	
+  <property name="c++.task-controller.src" 
+    value="${basedir}/src/c++/task-controller" />
+  <!-- directory where autoconf files + temporary files and src is 
+    stored for compilation -->
+  <property name="build.c++.task-controller" 
+    value="${build.c++}/task-controller" />
+  <!-- the default install dir is build directory override it using
+   -Dtask-controller.install.dir=$HADOOP_HOME/bin -->
+  <property name="task-controller.install.dir" value="${dist.dir}/bin" />
+  <!-- end of task-controller properties -->
+	
   <!-- IVY properteis set here -->
   <property name="ivy.dir" location="ivy" />
   <loadproperties srcfile="${ivy.dir}/libraries.properties"/>
@@ -1797,4 +1812,52 @@
 
   </target>
 
+  <!-- taskcontroller targets -->
+  <target name="init-task-controller-build">
+    <mkdir dir="${build.c++.task-controller}" />
+    <copy todir="${build.c++.task-controller}">
+      <fileset dir="${c++.task-controller.src}" includes="*.c">
+      </fileset>
+      <fileset dir="${c++.task-controller.src}" includes="*.h">
+      </fileset>
+    </copy>
+    <chmod file="${c++.task-controller.src}/configure" perm="ugo+x"/> 
+    <condition property="task-controller.conf.dir.passed">
+      <not>
+        <equals arg1="${hadoop.conf.dir}" arg2="$${hadoop.conf.dir}"/>
+      </not>
+    </condition>
+  </target>
+  <target name="configure-task-controller" depends="init,
+          init-task-controller-build,
+          task-controller-configuration-with-confdir,
+          task-controller-configuration-with-no-confdir">
+  </target>
+  <target name="task-controller-configuration-with-confdir" 
+          if="task-controller.conf.dir.passed" >
+    <exec executable="${c++.task-controller.src}/configure" 
+          dir="${build.c++.task-controller}" failonerror="yes">
+      <arg value="--prefix=${task-controller.install.dir}" />
+      <arg value="--with-confdir=${hadoop.conf.dir}" />
+    </exec>
+  </target>
+  <target name="task-controller-configuration-with-no-confdir" 
+          unless="task-controller.conf.dir.passed">
+    <exec executable="${c++.task-controller.src}/configure" 
+          dir="${build.c++.task-controller}" failonerror="yes">
+      <arg value="--prefix=${task-controller.install.dir}" />
+    </exec>
+  </target>
+  <!--
+    * Create the installation directory.
+    * Do a make install.
+   -->
+  <target name="task-controller" depends="configure-task-controller">
+    <mkdir dir="${task-controller.install.dir}" />
+    <exec executable="${make.cmd}" dir="${build.c++.task-controller}" 
+        searchpath="yes" failonerror="yes">
+      <arg value="install" />
+    </exec>
+  </target>
+  <!-- end of task-controller target -->
 </project>

Added: hadoop/common/branches/branch-0.20-security-patches/conf/taskcontroller.cfg
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/conf/taskcontroller.cfg?rev=1076893&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/conf/taskcontroller.cfg (added)
+++ hadoop/common/branches/branch-0.20-security-patches/conf/taskcontroller.cfg Thu Mar  3
23:50:57 2011
@@ -0,0 +1,4 @@
+mapred.local.dir=#configured value of hadoop.tmp.dir it can be a list of paths comma seperated
+hadoop.pid.dir=#configured HADOOP_PID_DIR
+hadoop.indent.str=#configured HADOOP_IDENT_STR
+mapred.tasktracker.tasks.sleeptime-before-sigkill=#sleep time before sig kill is to be sent
to process group after sigterm is sent. Should be in seconds

Added: hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/Makefile.in
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/c%2B%2B/task-controller/Makefile.in?rev=1076893&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/Makefile.in
(added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/Makefile.in
Thu Mar  3 23:50:57 2011
@@ -0,0 +1,46 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+OBJS=main.o task-controller.o configuration.o
+CC=@CC@
+CFLAGS = @CFLAGS@
+BINARY=task-controller
+installdir = @prefix@
+
+
+all: $(OBJS)
+	$(CC) $(CFLAG) -o $(BINARY) $(OBJS)
+
+main.o: main.c task-controller.h
+	$(CC) $(CFLAG) -o main.o -c main.c
+
+task-controller.o: task-controller.c task-controller.h 
+	$(CC) $(CFLAG) -o task-controller.o -c task-controller.c
+
+configuration.o: configuration.h configuration.c
+	$(CC) $(CFLAG) -o configuration.o -c configuration.c
+
+
+clean:
+	rm -rf $(BINARY) $(OBJS)
+
+install: all
+	cp $(BINARY) $(installdir)
+
+uninstall:
+	rm -rf $(installdir)/$(BINARY)
+	rm -rf $(BINARY)

Added: hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/c%2B%2B/task-controller/configuration.c?rev=1076893&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.c
(added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.c
Thu Mar  3 23:50:57 2011
@@ -0,0 +1,201 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "configuration.h"
+
+char * hadoop_conf_dir;
+
+//clean up method for freeing configuration
+void free_configurations() {
+  int i = 0;
+  for (i = 0; i < config.size; i++) {
+    if (config.confdetails[i]->key != NULL) {
+      free((void *)config.confdetails[i]->key);
+    }
+    if (config.confdetails[i]->value != NULL) {
+      free((void *)config.confdetails[i]->value);
+    }
+    free(config.confdetails[i]);
+  }
+  if (config.size > 0) {
+    free(config.confdetails);
+  }
+  config.size = 0;
+}
+
+//function used to load the configurations present in the secure config
+void get_configs() {
+  FILE *conf_file;
+  char *line;
+  char *equaltok;
+  char *temp_equaltok;
+  size_t linesize = 1000;
+  int size_read = 0;
+  int str_len = 0;
+  char *file_name = NULL;
+
+#ifndef HADOOP_CONF_DIR
+  str_len = strlen(CONF_FILE_PATTERN) + strlen(hadoop_conf_dir);
+  file_name = (char *) malloc(sizeof(char) * (str_len + 1));
+#else
+  str_len = strlen(CONF_FILE_PATTERN) + strlen(HADOOP_CONF_DIR);
+  file_name = (char *) malloc(sizeof(char) * (str_len + 1));
+#endif
+
+  if (file_name == NULL) {
+    fprintf(LOGFILE, "Malloc failed :Out of memory \n");
+    return;
+  }
+  memset(file_name,'\0',str_len +1);
+#ifndef HADOOP_CONF_DIR
+  snprintf(file_name,str_len, CONF_FILE_PATTERN, hadoop_conf_dir);
+#else
+  snprintf(file_name, str_len, CONF_FILE_PATTERN, HADOOP_CONF_DIR);
+#endif
+
+#ifdef DEBUG
+  fprintf(LOGFILE,"get_configs :Conf file name is : %s \n", file_name);
+#endif
+  //allocate space for ten configuration items.
+  config.confdetails = (struct confentry **) malloc(sizeof(struct confentry *)
+      * MAX_SIZE);
+  config.size = 0;
+  conf_file = fopen(file_name, "r");
+  if (conf_file == NULL) {
+    fprintf(LOGFILE, "Invalid conf file provided : %s \n", file_name);
+    free(file_name);
+    return;
+  }
+  while(!feof(conf_file)) {
+    line = (char *) malloc(linesize);
+    if(line == NULL) {
+      fprintf(LOGFILE,"malloc failed while reading configuration file.\n");
+      goto cleanup;
+    }
+    size_read = getline(&line,&linesize,conf_file);
+    //feof returns true only after we read past EOF.
+    //so a file with no new line, at last can reach this place
+    //if size_read returns negative check for eof condition
+    if (size_read == -1) {
+      if(!feof(conf_file)){
+        fprintf(LOGFILE, "getline returned error.\n");
+        goto cleanup;
+      }else {
+        break;
+      }
+    }
+    //trim the ending new line
+    line[strlen(line)-1] = '\0';
+    //comment line
+    if(line[0] == '#') {
+      free(line);
+      continue;
+    }
+    //tokenize first to get key and list of values.
+    //if no equals is found ignore this line, can be an empty line also
+    equaltok = strtok_r(line, "=", &temp_equaltok);
+    if(equaltok == NULL) {
+      free(line);
+      continue;
+    }
+    config.confdetails[config.size] = (struct confentry *) malloc(
+            sizeof(struct confentry));
+    if(config.confdetails[config.size] == NULL) {
+      fprintf(LOGFILE,
+          "Failed allocating memory for single configuration item\n");
+      goto cleanup;
+    }
+#ifdef DEBUG
+    fprintf(LOGFILE,"get_configs : Adding conf key : %s \n", equaltok);
+#endif
+    memset(config.confdetails[config.size], 0, sizeof(struct confentry));
+    config.confdetails[config.size]->key = (char *) malloc(
+            sizeof(char) * (strlen(equaltok)+1));
+    strcpy((char *)config.confdetails[config.size]->key, equaltok);
+    equaltok = strtok_r(NULL, "=", &temp_equaltok);
+    if (equaltok == NULL) {
+      fprintf(LOGFILE, "configuration tokenization failed \n");
+      goto cleanup;
+    }
+    //means value is commented so don't store the key
+    if(equaltok[0] == '#') {
+      free(line);
+      free((void *)config.confdetails[config.size]->key);
+      free(config.confdetails[config.size]);
+      continue;
+    }
+#ifdef DEBUG
+    fprintf(LOGFILE,"get_configs : Adding conf value : %s \n", equaltok);
+#endif
+    config.confdetails[config.size]->value = (char *) malloc(
+            sizeof(char) * (strlen(equaltok)+1));
+    strcpy((char *)config.confdetails[config.size]->value, equaltok);
+    if((config.size + 1) % MAX_SIZE  == 0) {
+      config.confdetails = (struct confentry **) realloc(config.confdetails,
+          sizeof(struct confentry **) * (MAX_SIZE + config.size));
+      if (config.confdetails == NULL) {
+        fprintf(LOGFILE,
+            "Failed re-allocating memory for configuration items\n");
+        goto cleanup;
+      }
+    }
+    if(config.confdetails[config.size] )
+    config.size++;
+    free(line);
+  }
+
+  //close the file
+  fclose(conf_file);
+  //clean up allocated file name
+  free(file_name);
+  return;
+  //free spaces alloced.
+  cleanup:
+  if (line != NULL) {
+    free(line);
+  }
+  fclose(conf_file);
+  free(file_name);
+  free_configurations();
+  return;
+}
+
+/*
+ * function used to get a configuration value.
+ * The function for the first time populates the configuration details into
+ * array, next time onwards used the populated array.
+ *
+ */
+
+const char * get_value(char* key) {
+  int count;
+  if (config.size == 0) {
+    get_configs();
+  }
+  if (config.size == 0) {
+    fprintf(LOGFILE, "Invalid configuration provided\n");
+    return NULL;
+  }
+  for (count = 0; count < config.size; count++) {
+    if (strcmp(config.confdetails[count]->key, key) == 0) {
+      return config.confdetails[count]->value;
+    }
+  }
+  return NULL;
+}
+

Added: hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.h.in
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/c%2B%2B/task-controller/configuration.h.in?rev=1076893&view=auto
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.h.in
(added)
+++ hadoop/common/branches/branch-0.20-security-patches/src/c++/task-controller/configuration.h.in
Thu Mar  3 23:50:57 2011
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#define INCREMENT_SIZE 1000
+#define MAX_SIZE 10
+
+//would be defined by the autoconfiguration tool
+#undef HADOOP_CONF_DIR
+
+struct confentry {
+  const char *key;
+  const char *value;
+};
+
+
+struct configuration {
+  int size;
+  struct confentry **confdetails;
+};
+
+FILE *LOGFILE;
+
+#ifdef HADOOP_CONF_DIR
+  #define CONF_FILE_PATTERN "%s/taskcontroller.cfg"
+#else
+  #define CONF_FILE_PATTERN "%s/conf/taskcontroller.cfg"
+#endif
+
+struct configuration config;
+//configuration file contents
+#ifndef HADOOP_CONF_DIR
+  extern char *hadoop_conf_dir;
+#endif
+//method exposed to get the configurations
+const char * get_value(char* key);
+//method to free allocated configuration
+void free_configurations();
+



Mime
View raw message