[Swift-commit] cog r4016
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Wed Jul 9 13:05:02 CDT 2014
------------------------------------------------------------------------
r4016 | timgarmstrong | 2014-07-09 13:01:28 -0500 (Wed, 09 Jul 2014) | 1 line
Update to work with new configId scheme
------------------------------------------------------------------------
Index: modules/provider-coaster-c-client/src/CoasterClient.cpp
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClient.cpp (revision 4015)
+++ modules/provider-coaster-c-client/src/CoasterClient.cpp (working copy)
@@ -129,14 +129,18 @@
started = false;
}
-std::string CoasterClient::setOptions(Settings& s) {
+string CoasterClient::setOptions(Settings& s) {
LogInfo << "Setting options: " << s << endl;
ServiceConfigurationCommand scc(s);
scc.execute(channel);
- return scc.getConfigId();
+ string *id = scc.getConfigId();
+ if (id == NULL) {
+ throw CoasterError("Did not get expected response for config");
+ }
+ return *id;
}
-void CoasterClient::submit(Job& job, 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 4015)
+++ modules/provider-coaster-c-client/src/CoasterClientTest.cpp (working copy)
@@ -28,15 +28,15 @@
s.set(Settings::Key::MAX_NODES, "1");
s.set(Settings::Key::JOBS_PER_NODE, "2");
- std::string* configId = client.setOptions(s);
+ std::string configId = client.setOptions(s);
Job j1("/bin/date");
Job j2("/bin/echo");
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 4015)
+++ modules/provider-coaster-c-client/src/RunCoasterJob.cpp (working copy)
@@ -226,7 +226,7 @@
s.set(*skey, pair.value);
}
- std::string* configId = client.setOptions(s);
+ std::string configId = client.setOptions(s);
Job j(executable);
@@ -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 4015)
+++ modules/provider-coaster-c-client/src/coasters.cpp (working copy)
@@ -299,14 +299,16 @@
*/
coaster_rc
coaster_apply_settings(coaster_client *client,
- coaster_settings *settings)
+ coaster_settings *settings, coaster_config_id **config)
COASTER_THROWS_NOTHING {
- if (settings == NULL || client == NULL) {
+ if (settings == NULL || client == NULL || config == NULL) {
return coaster_return_error(COASTER_ERROR_INVALID, "invalid arg");
}
try {
- client->client.setOptions(*settings);
+ string *configId = new string;
+ *configId = client->client.setOptions(*settings);
+ *config = configId;
return COASTER_SUCCESS;
} catch (const CoasterError& err) {
return coaster_error_rc(err);
@@ -316,6 +318,12 @@
}
coaster_rc
+coaster_config_id_free(coaster_config_id *config) COASTER_THROWS_NOTHING {
+ delete config;
+ return COASTER_SUCCESS;
+}
+
+coaster_rc
coaster_job_create(const char *executable, size_t executable_len,
int argc, const char **argv, const size_t *arg_lens,
const char *job_manager, size_t job_manager_len,
@@ -595,10 +603,10 @@
}
coaster_rc
-coaster_submit(coaster_client *client, coaster_job *job)
- COASTER_THROWS_NOTHING {
+coaster_submit(coaster_client *client, const coaster_config_id *config,
+ coaster_job *job) COASTER_THROWS_NOTHING {
try {
- client->client.submit(*job);
+ client->client.submit(*job, config);
return COASTER_SUCCESS;
} catch (const CoasterError& err) {
return coaster_error_rc(err);
Index: modules/provider-coaster-c-client/src/JobSubmitCommand.h
===================================================================
--- modules/provider-coaster-c-client/src/JobSubmitCommand.h (revision 4015)
+++ modules/provider-coaster-c-client/src/JobSubmitCommand.h (working copy)
@@ -13,7 +13,8 @@
private:
Job* job;
std::string ss;
- std::string* configId;
+ bool haveConfigId;
+ std::string configId;
public:
static std::string NAME;
JobSubmitCommand(Job* job, const std::string* configId);
Index: modules/provider-coaster-c-client/src/CoasterClient.h
===================================================================
--- modules/provider-coaster-c-client/src/CoasterClient.h (revision 4015)
+++ modules/provider-coaster-c-client/src/CoasterClient.h (working copy)
@@ -67,15 +67,17 @@
void stop();
// TODO: how long does this hold a reference to settings?
- std::string* setOptions(Settings& settings);
+ std::string setOptions(Settings& settings);
/*
* Submit a job. The job should have been filled in with
* all properties. The ownership of the job object stays
* 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
*/
- void submit(Job& job);
+ 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/ServiceConfigurationCommand.cpp
===================================================================
--- modules/provider-coaster-c-client/src/ServiceConfigurationCommand.cpp (revision 4015)
+++ modules/provider-coaster-c-client/src/ServiceConfigurationCommand.cpp (working copy)
@@ -10,7 +10,7 @@
ServiceConfigurationCommand::ServiceConfigurationCommand(Settings& s): Command(&NAME) {
settings = &s;
- configId = null;
+ configId = NULL;
}
void ServiceConfigurationCommand::send(CoasterChannel* channel, CommandCallback* cb) {
@@ -35,6 +35,6 @@
configId = getInData()->at(0)->str();
}
-std::string* getConfigId() {
+std::string* ServiceConfigurationCommand::getConfigId() {
return configId;
}
Index: modules/provider-coaster-c-client/src/coasters.h
===================================================================
--- modules/provider-coaster-c-client/src/coasters.h (revision 4015)
+++ modules/provider-coaster-c-client/src/coasters.h (working copy)
@@ -29,6 +29,10 @@
#define COASTERS_H_
#ifdef __cplusplus
+#include <string>
+#endif
+
+#ifdef __cplusplus
extern "C" {
#endif
@@ -55,10 +59,12 @@
}
typedef class Coaster::Settings coaster_settings;
+typedef std::string coaster_config_id;
typedef class Coaster::Job coaster_job;
#else
// Treat these types as opaque pointer to unimplemented struct for C
typedef struct coaster_settings_opaque_ coaster_settings;
+typedef struct coaster_config_id_opaque_ coaster_config_id;
typedef struct coaster_job_opaque_ coaster_job;
#endif
@@ -177,12 +183,18 @@
* Apply settings to started coasters client.
* TODO: currently it isn't safe to free settings until client is shut
* down
+ *
+ * config: set to identifer for this service config, must be freed with
+ * coaster_free_config_id
*/
coaster_rc
coaster_apply_settings(coaster_client *client,
- coaster_settings *settings)
+ coaster_settings *settings, coaster_config_id **config)
COASTER_THROWS_NOTHING;
+coaster_rc
+coaster_config_id_free(coaster_config_id *config) COASTER_THROWS_NOTHING;
+
/*
* Create a new coasters job for later submission.
* Some standard arguments can be specified now, or left as NULL to be
@@ -303,8 +315,8 @@
* shuts down.
*/
coaster_rc
-coaster_submit(coaster_client *client, coaster_job *job)
- COASTER_THROWS_NOTHING;
+coaster_submit(coaster_client *client, const coaster_config_id *config,
+ coaster_job *job) COASTER_THROWS_NOTHING;
/*
* Check for completion of jobs.
Index: modules/provider-coaster-c-client/src/JobSubmitCommand.cpp
===================================================================
--- modules/provider-coaster-c-client/src/JobSubmitCommand.cpp (revision 4015)
+++ modules/provider-coaster-c-client/src/JobSubmitCommand.cpp (working copy)
@@ -21,7 +21,13 @@
JobSubmitCommand::JobSubmitCommand(Job* pjob, const std::string* pconfigId): Command(&NAME) {
job = pjob;
- configId = pconfigId;
+ if (pconfigId != NULL) {
+ haveConfigId = true;
+ configId = *pconfigId;
+ }
+ else {
+ haveConfigId = false;
+ }
}
void JobSubmitCommand::send(CoasterChannel* channel, CommandCallback* cb) {
@@ -45,7 +51,9 @@
void JobSubmitCommand::serialize() {
stringstream idSS;
idSS << job->getIdentity();
- add(ss, "configid", configId);
+ if (haveConfigId) {
+ 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