Index: trunk/ll_drmaa/job.c
===================================================================
--- trunk/ll_drmaa/job.c	(revision 27)
+++ trunk/ll_drmaa/job.c	(revision 1)
@@ -1,3 +1,3 @@
-/* $Id$ */
+/* $Id: job.c 227 2010-05-25 13:14:20Z mamonski $ */
 /*
  * PSNC DRMAA for LL
@@ -35,6 +35,4 @@
 
 #include <llapi.h>
-
-#define LL_DRMAA_MAX_MISSING_TIME (60)
 
 static void
@@ -202,7 +200,4 @@
 	self->last_update_time = time(NULL);
 
-        if( self->state >= DRMAA_PS_DONE )
-                fsd_cond_broadcast( &self->status_cond );
-
 	fsd_log_return(( "" ));
 }
@@ -292,37 +287,8 @@
 		}
 
-		data = ll_get_objs(job, LL_CM, NULL, &obj_count, &err_code);
+		data = ll_get_objs(job, LL_SCHEDD, NULL, &obj_count, &err_code);
 		if (data == NULL) {
-			if (err_code == LL_GET_OBJS_NO_OBJECTS_ERR)
-			  {
-				if (self->state != DRMAA_PS_UNDETERMINED) 
-				  {
-					fsd_log_info(("Job %s missing. Assuming finished", self->job_id));
-					self->state = DRMAA_PS_DONE;
-					self->exit_status = 0;
-                			fsd_cond_broadcast( &self->status_cond );
-				  }
-				else if (llself->missing_time == 0)
-				 {
-					llself->missing_time = time(NULL);
-					fsd_log_debug(("Job %s missing for the first time", self->job_id)); /* Job may not yet be visible in LL */
-                			fsd_cond_broadcast( &self->status_cond );
-				 }
-				else if (time(NULL) - llself->missing_time > LL_DRMAA_MAX_MISSING_TIME)
-				 {
-					fsd_log_error(("Job %s missing for more then %d seconds. Assuming failed", self->job_id, LL_DRMAA_MAX_MISSING_TIME)); 
-					/* Job may not yet be visible in LL */
-					self->state = DRMAA_PS_FAILED;
-					self->exit_status = -1;
-				 }
-				else
-				 {
-					fsd_log_debug(("Job %s still missing", self->job_id));
-				 }
-			  }
-			else
-			  {
-				fsd_log_error(("Code: %d,%d ll_get_objs() returns NULL. %s", err_code, lldrmaa_map_get_objs(err_code), lldrmaa_err_get_objs(err_code) ));
-			  }
+			fsd_log_debug(("Code: %d ll_get_objs() returns NULL. %s",lldrmaa_map_get_objs(err_code), lldrmaa_err_get_objs(err_code) ));
+			/* This error means that there is no info in LL_SCHEDD but this job have probably ended and will be detected by wait_thread. This won't be fsd_log_warning because displays too often during program execution */
 		} else {
 
@@ -346,7 +312,7 @@
 			}
 
-			llself->read_job_info(self, step_state, hold_type);
-
-			fsd_log_info(("Job %s LL State: %d -> DRMAA: %s", self->job_id, step_state, drmaa_job_ps_to_str(self->state)));
+			llself->read_job_info( self, step_state, hold_type);
+
+			fsd_log_info(("LL State: %d -> DRMAA: %s",step_state,drmaa_job_ps_to_str(self->state)));
 		}
 	}
@@ -386,5 +352,4 @@
 	self->super.control = lldrmaa_job_control;
 	self->super.update_status = lldrmaa_job_update_status;
-	self->missing_time = 0;
 	self->read_job_info_mon = lldrmaa_job_read_job_info_mon;
 	self->read_job_info = lldrmaa_job_read_job_info;
@@ -481,4 +446,139 @@
 		fprintf(fd,"# File created by LoadLeveler DRMAA. If no LL DRMAA applications are running you can delete this file\n");
 
+		/* job name */
+		value = jt->get_attr( jt, DRMAA_JOB_NAME );
+		if( value )
+		{
+			fprintf(fd,"# @ job_name = %s\n",value);
+			fsd_log_debug(("# @ job_name = %s",value));
+		}
+
+		/* job state at submit */
+		value = jt->get_attr( jt, DRMAA_JS_STATE );
+		if( value )
+	 	{
+			if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_ACTIVE ) )
+			{}
+			else if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_HOLD ) )
+			{
+				fprintf(fd,"# @ hold = user\n");
+				fsd_log_debug(("# @ hold = user"));
+			}
+			else
+				fsd_exc_raise_msg(
+					FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
+					"invalid value of drmaa_js_state attribute" );
+	 	}
+
+		TRY
+		{
+			const char *command = NULL;
+			char *command_expanded = NULL;
+			const char *const *i;
+			int j;
+
+			/* remote command */
+			command = jt->get_attr( jt, DRMAA_REMOTE_COMMAND );
+			if( command == NULL )
+				fsd_exc_raise_msg(
+						FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES,
+						"drmaa_remote_command not set for job template"
+						);
+
+			command_expanded = expand->expand( expand, fsd_strdup(command), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
+
+			fprintf(fd,"# @ executable = %s\n", command_expanded);
+			fsd_log_debug(("# @ executable = %s\n", command_expanded));
+
+			fsd_free(command_expanded);
+
+			/* arguments list */
+			vector = jt->get_v_attr( jt, DRMAA_V_ARGV );
+
+			if( vector )
+		 	{
+				fprintf(fd,"# @ arguments =");
+				fsd_log_debug(("# @ arguments ="));
+
+				for( i = vector, j = 2;  *i;  i++, j++ )
+				{
+					char *arg_expanded = expand->expand( expand, fsd_strdup(*i), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
+
+					fprintf(fd," '%s'", arg_expanded);
+					fsd_log_debug(("%s", arg_expanded));
+
+					fsd_free(arg_expanded);
+				}
+			}
+
+			fprintf(fd," \n");
+		}
+		END_TRY
+
+		/* start time */
+		value = jt->get_attr( jt, DRMAA_START_TIME );
+		if( value )
+	 	{
+			char buf[30];
+			const time_t time_ll = fsd_datetime_parse( value );
+			struct tm temp;
+			localtime_r(&time_ll,&temp);
+ 			strftime(buf, sizeof(buf),"%m/%d/%Y %H:%M:%S", &temp );
+			fprintf(fd,"# @ startdate = %s\n", buf);
+			fsd_log_debug(("# @ startdate = %s", buf));
+			fsd_log_debug(( "\n  drmaa_start_time: %s -> %ld",	value, (long)time_ll ));
+		 }
+
+		/* environment */
+		vector = jt->get_v_attr( jt, DRMAA_V_ENV );
+		if( vector )
+		{
+			const char *const *i;
+
+			fprintf(fd,"# @ environment =");
+			fsd_log_debug(("# @ environment ="));
+			for( i = vector;  *i;  i++ )
+	 		{
+				fprintf(fd," %s;",*i);
+				fsd_log_debug((" %s;",*i));
+			}
+			fprintf(fd," \n");
+		 }
+
+		 /* wall clock time soft and hard limit */
+		{
+		 	const char *value2;
+			value = jt->get_attr( jt, DRMAA_WCT_SLIMIT );
+			value2 = jt->get_attr( jt, DRMAA_WCT_HLIMIT );
+			if( value && value2)
+			{
+				fprintf(fd,"# @ wall_clock_limit = %s,%s\n",value,value2);
+				fsd_log_debug(("# @ wall_clock_limit = %s,%s",value,value2));
+			}
+			else if (value)
+			{
+				fprintf(fd,"# @ wall_clock_limit = %s\n",value);
+				fsd_log_debug(("# @ wall_clock_limit = %s",value));
+			}
+			else if (value2)
+			{
+				fprintf(fd,"# @ wall_clock_limit = ,%s\n",value);
+				fsd_log_debug(("# @ wall_clock_limit = ,%s",value));
+			}
+		}
+
+		/* native specification */
+		value = jt->get_attr( jt, DRMAA_NATIVE_SPECIFICATION );
+		if( value )
+		{
+			char * temp = fsd_strdup(value);
+			temp = fsd_replace(temp,"@","\n# $"); /* infinite loop when try replace @ with # @ */
+			temp = fsd_replace(temp,"# $","# @ ");
+
+			fprintf(fd,"# Native specification:%s\n", temp);
+			fsd_log_debug(("Native specification:%s", temp));
+			fsd_free(temp);
+		}
+
 		/* job category */
 		value = jt->get_attr( jt, DRMAA_JOB_CATEGORY );
@@ -515,95 +615,4 @@
 		 	}
 	 	}
-
-		/* job name */
-		value = jt->get_attr( jt, DRMAA_JOB_NAME );
-		if( value )
-		{
-			fprintf(fd,"# @ job_name = %s\n",value);
-			fsd_log_debug(("# @ job_name = %s",value));
-		}
-
-		/* job state at submit */
-		value = jt->get_attr( jt, DRMAA_JS_STATE );
-		if( value )
-	 	{
-			if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_ACTIVE ) )
-			{}
-			else if( 0 == strcmp( value, DRMAA_SUBMISSION_STATE_HOLD ) )
-			{
-				fprintf(fd,"# @ hold = user\n");
-				fsd_log_debug(("# @ hold = user"));
-			}
-			else
-				fsd_exc_raise_msg(
-					FSD_DRMAA_ERRNO_INVALID_ATTRIBUTE_VALUE,
-					"invalid value of drmaa_js_state attribute" );
-	 	}
-
-		/* start time */
-		value = jt->get_attr( jt, DRMAA_START_TIME );
-		if( value )
-	 	{
-			char buf[30];
-			const time_t time_ll = fsd_datetime_parse( value );
-			struct tm temp;
-			localtime_r(&time_ll,&temp);
- 			strftime(buf, sizeof(buf),"%m/%d/%Y %H:%M:%S", &temp );
-			fprintf(fd,"# @ startdate = %s\n", buf);
-			fsd_log_debug(("# @ startdate = %s", buf));
-			fsd_log_debug(( "\n  drmaa_start_time: %s -> %ld",	value, (long)time_ll ));
-		 }
-
-		/* environment */
-		vector = jt->get_v_attr( jt, DRMAA_V_ENV );
-		if( vector )
-		{
-			const char *const *i;
-
-			fprintf(fd,"# @ environment =");
-			fsd_log_debug(("# @ environment ="));
-			for( i = vector;  *i;  i++ )
-	 		{
-				fprintf(fd," %s;",*i);
-				fsd_log_debug((" %s;",*i));
-			}
-			fprintf(fd," \n");
-		 }
-
-		 /* wall clock time soft and hard limit */
-		{
-		 	const char *value2;
-			value = jt->get_attr( jt, DRMAA_WCT_SLIMIT );
-			value2 = jt->get_attr( jt, DRMAA_WCT_HLIMIT );
-			if( value && value2)
-			{
-				fprintf(fd,"# @ wall_clock_limit = %s,%s\n",value,value2);
-				fsd_log_debug(("# @ wall_clock_limit = %s,%s",value,value2));
-			}
-			else if (value)
-			{
-				fprintf(fd,"# @ wall_clock_limit = %s\n",value);
-				fsd_log_debug(("# @ wall_clock_limit = %s",value));
-			}
-			else if (value2)
-			{
-				fprintf(fd,"# @ wall_clock_limit = ,%s\n",value);
-				fsd_log_debug(("# @ wall_clock_limit = ,%s",value));
-			}
-		}
-
-		/* native specification */
-		value = jt->get_attr( jt, DRMAA_NATIVE_SPECIFICATION );
-		if( value )
-		{
-			char * temp = fsd_strdup(value);
-			temp = fsd_replace(temp,"@","\n# $"); /* infinite loop when try replace @ with # @ */
-			temp = fsd_replace(temp,"# $","# @ ");
-
-			fprintf(fd,"# Native specification:%s\n", temp);
-			fsd_log_debug(("Native specification:%s", temp));
-			fsd_free(temp);
-		}
-
 
 
@@ -770,54 +779,4 @@
 				fprintf(fd,"# @ queue\n");
 				fsd_log_debug(("# @ queue"));
-				
-				fprintf(fd,"\n");
-				fprintf(fd,"echo >&2\n"); /* this line forces creation of stderr file */
-
-				TRY
-				{
-					const char *command = NULL;
-					char *command_expanded = NULL;
-					const char *const *i;
-					int j;
-
-					/* remote command */
-					command = jt->get_attr( jt, DRMAA_REMOTE_COMMAND );
-					if( command == NULL )
-						fsd_exc_raise_msg(
-								FSD_DRMAA_ERRNO_CONFLICTING_ATTRIBUTE_VALUES,
-								"drmaa_remote_command not set for job template"
-								);
-
-					command_expanded = expand->expand( expand, fsd_strdup(command), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
-
-					fprintf(fd,"%s", command_expanded); /* we put the commmand at the end of script (instead of using @executable keyword
-										 in roder to avoid coping of the binary */
-					fsd_log_debug(("command = %s\n", command_expanded));
-
-					fsd_free(command_expanded);
-
-					/* arguments list */
-					vector = jt->get_v_attr( jt, DRMAA_V_ARGV );
-
-					if( vector )
-					{
-						fsd_log_debug(("arguments = "));
-
-						for( i = vector, j = 2;  *i;  i++, j++ )
-						{
-							char *arg_expanded = expand->expand( expand, fsd_strdup(*i), FSD_DRMAA_PH_HD | FSD_DRMAA_PH_WD );
-
-							fprintf(fd," '%s'", arg_expanded);
-							fsd_log_debug(("%s", arg_expanded));
-
-							fsd_free(arg_expanded);
-						}
-					}
-
-					fprintf(fd," \n");
-				}
-				END_TRY
-
-
 			}
 		}
