[Swift-commit] cog r4017

swift at ci.uchicago.edu swift at ci.uchicago.edu
Wed Jul 9 13:30:03 CDT 2014


------------------------------------------------------------------------
r4017 | timgarmstrong | 2014-07-09 13:29:43 -0500 (Wed, 09 Jul 2014) | 1 line

Modify argument types and documents to reflect that configId is required
------------------------------------------------------------------------
Index: modules/provider-coaster-c-client/src/CoasterClient.cpp
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClient.cpp	(revision 4016)
+++ modules/provider-coaster-c-client/src/CoasterClient.cpp	(working copy)
@@ -140,7 +140,7 @@
 	return *id;
 }
 
-void CoasterClient::submit(Job& job, const std::string* configId) {
+void CoasterClient::submit(Job& job, const std::string& configId) {
 	{ Lock::Scoped l(lock);
 		jobs[job.getIdentity()] = &job;
 	}
Index: modules/provider-coaster-c-client/src/CoasterClientTest.cpp
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClientTest.cpp	(revision 4016)
+++ modules/provider-coaster-c-client/src/CoasterClientTest.cpp	(working copy)
@@ -35,8 +35,8 @@
 		j2.addArgument("testing");
 		j2.addArgument("1, 2, 3");
 
-		client.submit(j1, &configId);
-		client.submit(j2, &configId);
+		client.submit(j1, configId);
+		client.submit(j2, configId);
 
 		client.waitForJob(j1);
 		client.waitForJob(j2);
Index: modules/provider-coaster-c-client/src/RunCoasterJob.cpp
===================================================================
--- modules/provider-coaster-c-client/src/RunCoasterJob.cpp	(revision 4016)
+++ modules/provider-coaster-c-client/src/RunCoasterJob.cpp	(working copy)
@@ -258,7 +258,7 @@
 		j.setStderrLocation(*str);
 	}
 
-	client.submit(j, &configId);
+	client.submit(j, configId);
 
 	client.waitForJob(j);
 
Index: modules/provider-coaster-c-client/src/coasters.cpp
===================================================================
--- modules/provider-coaster-c-client/src/coasters.cpp	(revision 4016)
+++ modules/provider-coaster-c-client/src/coasters.cpp	(working copy)
@@ -103,7 +103,7 @@
   try {
     client->client.stop();
     client->loop.stop();
-    
+
     delete client;
     return COASTER_SUCCESS;
   } catch (const CoasterError& err) {
@@ -118,7 +118,7 @@
   try {
     *settings = new Settings();
     COASTER_CHECK_MALLOC(*settings);
- 
+
     return COASTER_SUCCESS;
   } catch (const CoasterError& err) {
     return coaster_error_rc(err);
@@ -139,7 +139,7 @@
   COASTER_CONDITION(str != NULL, COASTER_ERROR_INVALID,
                     "Null Coaster settings string");
   string key, value; // Storage for current key and value
-  
+
   bool in_key = true; // Either in key or value
   bool in_quotes = false;
   bool in_escape = false;
@@ -174,9 +174,9 @@
       } else if (c == separator) {
         COASTER_CONDITION(!in_key, COASTER_ERROR_INVALID,
                   "',' not allowed in unquoted Coaster settings key");
-        
-        settings_emit(settings, key, value);          
-        
+
+        settings_emit(settings, key, value);
+
         in_key = true;
       } else {
         curr.push_back(c);
@@ -207,7 +207,7 @@
     string old_value;
     settings->get(key, old_value);
     LogWarn << "Overwrote previous Coaster settings value for "
-                "key: \"" << key << "\".  Old value: \"" << 
+                "key: \"" << key << "\".  Old value: \"" <<
                 old_value << "\", New value: \"" <<
                 value << "\"." << endl;
   }
@@ -222,7 +222,7 @@
           const char *key, size_t key_len,
           const char *value, size_t value_len) COASTER_THROWS_NOTHING {
   try {
-    settings->set(key, key_len, value, value_len); 
+    settings->set(key, key_len, value, value_len);
     return COASTER_SUCCESS;
   } catch (const CoasterError& err) {
     return coaster_error_rc(err);
@@ -259,7 +259,7 @@
     // Use malloc so C client code can free
     *keys = (const char**)malloc(sizeof((*keys)[0]) * (*count));
     COASTER_CHECK_MALLOC(*keys);
-    
+
     if (key_lens != NULL) {
       *key_lens = (size_t *)malloc(sizeof((*key_lens)[0]) * (*count));
       if (!(*key_lens)) {
@@ -267,7 +267,7 @@
         COASTER_CHECK_MALLOC(*key_lens);
       }
     }
-    
+
     int pos = 0;
     for(std::map<string, string>::iterator iter = map.begin();
         iter != map.end(); ++iter) {
@@ -331,7 +331,7 @@
   try {
     assert(executable != NULL);
     Job *j = new Job(string(executable, executable_len));
-   
+
     for (int i = 0; i < argc; i++)
     {
       assert(argv[i] != NULL);
@@ -390,7 +390,7 @@
   if (job == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "invalid arg");
   }
-  
+
   try {
     // job expects to get ownership of references, so use new
     if (stdin_loc != NULL) {
@@ -419,7 +419,7 @@
   if (job == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "");
   }
-  
+
   try {
     if (dir != NULL) {
       job->setDirectory(*new string(dir, dir_len));
@@ -440,7 +440,7 @@
   if (job == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "invalid arg");
   }
-  
+
   try {
     for (int i = 0; i < nvars; i++)
     {
@@ -469,11 +469,11 @@
 coaster_job_set_attrs(coaster_job *job, int nattrs,
         const char **names, size_t *name_lens,
         const char **values, size_t *value_lens) COASTER_THROWS_NOTHING {
- 
+
   if (job == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "invalid job");
   }
-  
+
   try {
     for (int i = 0; i < nattrs; i++)
     {
@@ -498,11 +498,11 @@
 coaster_job_add_cleanups(coaster_job *job, int ncleanups,
         const char **cleanups, size_t *cleanup_lens)
         COASTER_THROWS_NOTHING {
- 
+
   if (job == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "invalid job");
   }
-  
+
   try {
     for (int i = 0; i < ncleanups; i++) {
       const char *cleanup = cleanups[i];
@@ -529,14 +529,14 @@
   if (job == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "invalid job");
   }
-  
+
   try {
     for (int i = 0; i < nstageins; i++) {
       coaster_stage_entry *s = &stageins[i];
       job->addStageIn(string(s->src, s->src_len),
                       string(s->dst, s->dst_len), s->mode);
     }
-    
+
     for (int i = 0; i < nstageouts; i++) {
       coaster_stage_entry *s = &stageouts[i];
       job->addStageOut(string(s->src, s->src_len),
@@ -566,7 +566,7 @@
     return coaster_return_error(COASTER_ERROR_INVALID,
                                 "invalid or unsubmitted job");
   }
-  
+
   *code = status->getStatusCode();
   return COASTER_SUCCESS;
 }
@@ -605,8 +605,15 @@
 coaster_rc
 coaster_submit(coaster_client *client, const coaster_config_id *config,
                coaster_job *job) COASTER_THROWS_NOTHING {
+  if (client == NULL) {
+    return coaster_return_error(COASTER_ERROR_INVALID, "invalid client");
+  }
+  if (config == NULL) {
+    return coaster_return_error(COASTER_ERROR_INVALID, "invalid config");
+  }
+
   try {
-    client->client.submit(*job, config);
+    client->client.submit(*job, *config);
     return COASTER_SUCCESS;
   } catch (const CoasterError& err) {
     return coaster_error_rc(err);
@@ -622,12 +629,12 @@
   if (client == NULL) {
     return coaster_return_error(COASTER_ERROR_INVALID, "invalid client");
   }
-  
+
   try {
     if (wait) {
       client->client.waitForAnyJob();
     }
-    
+
     int n = client->client.getAndPurgeDoneJobs(maxjobs, jobs);
 
     *njobs = n;
@@ -689,7 +696,7 @@
   if (prev != NULL) {
     cleanup_err_key(prev);
   }
-  
+
   coaster_err_info *err_info = new coaster_err_info(msg);
   pthread_setspecific(err_key, static_cast<void*>(err_info));
 }
@@ -699,7 +706,7 @@
   if (prev != NULL) {
     cleanup_err_key(prev);
   }
-  
+
   pthread_setspecific(err_key, NULL);
 }
 
@@ -708,7 +715,7 @@
  */
 static coaster_rc coaster_return_error(coaster_rc code,
                                     const string& msg) {
-  set_err_info(msg);  
+  set_err_info(msg);
   return code;
 }
 
@@ -738,7 +745,7 @@
 }
 
 coaster_rc coaster_set_log_threshold(coaster_log_level threshold) {
-  
+
   Logger::singleton().setThreshold(threshold);
 
   return COASTER_SUCCESS;
Index: modules/provider-coaster-c-client/src/JobSubmitCommand.h
===================================================================
--- modules/provider-coaster-c-client/src/JobSubmitCommand.h	(revision 4016)
+++ modules/provider-coaster-c-client/src/JobSubmitCommand.h	(working copy)
@@ -13,11 +13,10 @@
 	private:
 		Job* job;
 		std::string ss;
-                bool haveConfigId;
 		std::string configId;
 	public:
 		static std::string NAME;
-		JobSubmitCommand(Job* job, const std::string* configId);
+		JobSubmitCommand(Job* job, const std::string& configId);
 		virtual void send(CoasterChannel* channel, CommandCallback* cb);
 		Job* getJob();
 		std::string getRemoteId();
Index: modules/provider-coaster-c-client/src/CoasterClient.h
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClient.h	(revision 4016)
+++ modules/provider-coaster-c-client/src/CoasterClient.h	(working copy)
@@ -75,9 +75,9 @@
 		 * with the caller, but this client will retain a reference
 		 * to the job until done jobs are purged.
                  *
-                 * configId: if non-null, uses specific server-side config
+                 * configId: service-side config to use
 		 */
-		void submit(Job& job, const std::string* configId);
+		void submit(Job& job, const std::string& configId);
 
 		/*
 		 * Wait for job to be done.  Upon completion no actions
Index: modules/provider-coaster-c-client/src/coasters.h
===================================================================
--- modules/provider-coaster-c-client/src/coasters.h	(revision 4016)
+++ modules/provider-coaster-c-client/src/coasters.h	(working copy)
@@ -313,6 +313,8 @@
  * Ownership of the job is shared between the caller and
  * the client until the job has completed, or the client
  * shuts down.
+ *
+ * config: required, must be non-null
  */
 coaster_rc
 coaster_submit(coaster_client *client, const coaster_config_id *config,
Index: modules/provider-coaster-c-client/src/JobSubmitCommand.cpp
===================================================================
--- modules/provider-coaster-c-client/src/JobSubmitCommand.cpp	(revision 4016)
+++ modules/provider-coaster-c-client/src/JobSubmitCommand.cpp	(working copy)
@@ -19,15 +19,9 @@
 
 string JobSubmitCommand::NAME("SUBMITJOB");
 
-JobSubmitCommand::JobSubmitCommand(Job* pjob, const std::string* pconfigId): Command(&NAME) {
+JobSubmitCommand::JobSubmitCommand(Job* pjob, const std::string& pconfigId): Command(&NAME) {
 	job = pjob;
-	if (pconfigId != NULL) {
-		haveConfigId = true;
-		configId = *pconfigId;
-	}
-	else {
-		haveConfigId = false;
-	}
+	configId = pconfigId;
 }
 
 void JobSubmitCommand::send(CoasterChannel* channel, CommandCallback* cb) {
@@ -51,9 +45,7 @@
 void JobSubmitCommand::serialize() {
 	stringstream idSS;
 	idSS << job->getIdentity();
-	if (haveConfigId) {
-		add(ss, "configid", configId);
-	}
+	add(ss, "configid", configId);
 	add(ss, "identity", idSS.str());
 	add(ss, "executable", job->getExecutable());
 	add(ss, "directory", job->getDirectory());



More information about the Swift-commit mailing list