From 78045dc6fefceab146ecf87c6429787e2f6e0e04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Fri, 1 Jun 2012 09:21:27 +0000 Subject: [PATCH] virtual machine code initial commit (dummy, stub for further development) --- org.glite.lb.client/examples/job_reg.c | 15 ++-- org.glite.lb.client/src/logevent.c.T | 2 +- org.glite.lb.state-machine/src/process_event.c | 6 ++ .../src/process_event_virtual_machine.c | 93 ++++++++++++++++++++++ org.glite.lb.types/events.T | 10 ++- org.glite.lb.types/status.T | 1 + 6 files changed, 119 insertions(+), 8 deletions(-) create mode 100644 org.glite.lb.state-machine/src/process_event_virtual_machine.c diff --git a/org.glite.lb.client/examples/job_reg.c b/org.glite.lb.client/examples/job_reg.c index 5e33246..2f87adf 100644 --- a/org.glite.lb.client/examples/job_reg.c +++ b/org.glite.lb.client/examples/job_reg.c @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) { char *src = NULL,*job = NULL,*server = NULL,*seq,*jdl = NULL, *seed = NULL; int lbproxy = 0; - int done = 0,num_subjobs = 0,reg_subjobs = 0,i, collection = 0, pbs=0, cream=0, type, flags=0; + int done = 0,num_subjobs = 0,reg_subjobs = 0,i, collection = 0, pbs=0, cream=0, vm = 0, type, flags=0; edg_wll_Context ctx; edg_wlc_JobId jobid,*subjobs; @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) opterr = 0; do { - switch (getopt(argc,argv,"xX:s:j:m:n:SCl:e:PcE")) { + switch (getopt(argc,argv,"xX:s:j:m:n:SCl:e:PcvE")) { case 'x': lbproxy = 1; break; case 'X': lbproxy = 1; edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_STORE_SOCK, optarg); @@ -68,6 +68,7 @@ int main(int argc, char *argv[]) case 'C': collection = 1; break; case 'P': pbs = 1; break; case 'c': cream = 1; break; + case 'v': vm = 1; break; case 'l': jdl = (char *) strdup(optarg); break; case 'e': seed = strdup(optarg); break; case 'E': flags = flags | EDG_WLL_LOGLFLAG_EXCL; break; @@ -125,10 +126,12 @@ int main(int argc, char *argv[]) type = pbs ? EDG_WLL_REGJOB_PBS : (cream ? EDG_WLL_REGJOB_CREAM - : (num_subjobs ? - (collection?EDG_WLL_REGJOB_COLLECTION:EDG_WLL_REGJOB_DAG) - :EDG_WLL_REGJOB_SIMPLE - ) + : (vm ? EDG_WLL_REGJOB_VIRTUAL_MACHINE + : (num_subjobs ? + (collection?EDG_WLL_REGJOB_COLLECTION:EDG_WLL_REGJOB_DAG) + :EDG_WLL_REGJOB_SIMPLE + ) + ) ); if (lbproxy) { diff --git a/org.glite.lb.client/src/logevent.c.T b/org.glite.lb.client/src/logevent.c.T index 2cf2a47..4979540 100644 --- a/org.glite.lb.client/src/logevent.c.T +++ b/org.glite.lb.client/src/logevent.c.T @@ -342,7 +342,7 @@ static int flesh_seq(int event) { switch (event) { @@@{ - %seq = ( CREAM => 'CREAM', 'PBS' => 'PBS', 'gLite' => 'NORMAL', Condor=>'CONDOR', Transfer=>'NORMAL' ); + %seq = ( CREAM => 'CREAM', 'PBS' => 'PBS', 'gLite' => 'NORMAL', Condor=>'CONDOR', Transfer=>'NORMAL', 'VirtualMachine'=>'NORMAL' ); for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } $event->getTypes) { diff --git a/org.glite.lb.state-machine/src/process_event.c b/org.glite.lb.state-machine/src/process_event.c index c6b3060..e43c270 100644 --- a/org.glite.lb.state-machine/src/process_event.c +++ b/org.glite.lb.state-machine/src/process_event.c @@ -49,6 +49,7 @@ int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, int processData_Cream(intJobStat *js, edg_wll_Event *e); int processEvent_FileTransfer(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); int processEvent_FileTransferCollection(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); +int processEvent_VirtualMachine(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); int add_stringlist(char ***lptr, const char *new_item); @@ -82,6 +83,9 @@ int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char case EDG_WLL_REGJOB_FILE_TRANSFER_COLLECTION: js->pub.jobtype = EDG_WLL_STAT_FILE_TRANSFER_COLLECTION; break; + case EDG_WLL_REGJOB_VIRTUAL_MACHINE: + js->pub.jobtype = EDG_WLL_STAT_VIRTUAL_MACHINE; + break; default: trio_asprintf(errstring,"unknown job type %d in registration",e->regJob.jobtype); return RET_FAIL; @@ -102,6 +106,8 @@ int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char return processEvent_FileTransfer(js,e,ev_seq,strict,errstring); case EDG_WLL_STAT_FILE_TRANSFER_COLLECTION: return processEvent_FileTransferCollection(js,e,ev_seq,strict,errstring); + case EDG_WLL_STAT_VIRTUAL_MACHINE: + return processEvent_VirtualMachine(js,e,ev_seq,strict,errstring); case -1: return RET_UNREG; default: trio_asprintf(errstring,"undefined job type %d",js->pub.jobtype); diff --git a/org.glite.lb.state-machine/src/process_event_virtual_machine.c b/org.glite.lb.state-machine/src/process_event_virtual_machine.c new file mode 100644 index 0000000..02193c2 --- /dev/null +++ b/org.glite.lb.state-machine/src/process_event_virtual_machine.c @@ -0,0 +1,93 @@ +#ident "$Header:" +/* +Copyright (c) Members of the EGEE Collaboration. 2004-2010. +See http://www.eu-egee.org/partners for details on the copyright holders. + +Licensed 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 +#include +#include +#include +#include +#include + +#include "glite/lb/context-int.h" + +#include "glite/lbu/trio.h" + +#include "intjobstat.h" +#include "seqcode_aux.h" + +/* TBD: share in whole logging or workload */ +#ifdef __GNUC__ +#define UNUSED_VAR __attribute__((unused)) +#else +#define UNUSED_VAR +#endif + +/*static int compare_timestamps(struct timeval a, struct timeval b) +{ + if ( (a.tv_sec > b.tv_sec) || + ((a.tv_sec == b.tv_sec) && (a.tv_usec > b.tv_usec)) ) return 1; + if ( (a.tv_sec < b.tv_sec) || + ((a.tv_sec == b.tv_sec) && (a.tv_usec < b.tv_usec)) ) return -1; + return 0; +}*/ + + +// XXX move this defines into some common place to be reusable +#define USABLE(res) ((res) == RET_OK) +#define USABLE_DATA(res) (1) +#define rep(a,b) { free(a); a = (b == NULL) ? NULL : strdup(b); } +#define rep_cond(a,b) { if (b) { free(a); a = strdup(b); } } + + +int processEvent_VirtualMachine(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring) +{ + edg_wll_JobStatCode old_state = js->pub.state; + int res = RET_OK; + + + switch (e->any.type) { + case EDG_WLL_EVENT_REGJOB: + if (USABLE(res)) { + js->pub.state = EDG_WLL_JOB_SUBMITTED; + } + /*if (USABLE_DATA(res)) { + edg_wlc_JobIdFree(js->pub.parent_job); + edg_wlc_JobIdDup(e->regJob.parent, &js->pub.parent_job); + }*/ + break; + default: + break; + } + + if (USABLE(res)) { + rep(js->last_seqcode, e->any.seqcode); + + js->pub.lastUpdateTime = e->any.timestamp; + if (old_state != js->pub.state) { + js->pub.stateEnterTime = js->pub.lastUpdateTime; + js->pub.stateEnterTimes[1 + js->pub.state] + = (int)js->pub.lastUpdateTime.tv_sec; + } + } + if (! js->pub.location) js->pub.location = strdup("this is FILE TRANSFER"); + + + return RET_OK; +} + diff --git a/org.glite.lb.types/events.T b/org.glite.lb.types/events.T index fc9ad19..2c99a09 100644 --- a/org.glite.lb.types/events.T +++ b/org.glite.lb.types/events.T @@ -152,7 +152,7 @@ jobid parent Grid job id of the parent job registering this new one. _optional_ - int jobtype Type of the job being registered (SIMPLE, DAG, PARTITIONABLE or PARTITIONED). + int jobtype Type of the job being registered (SIMPLE, DAG, PARTITIONABLE etc.). _code_ SIMPLE The job is simple job. _code_ DAG The job is dag (containing static set of subjobs). _code_ PARTITIONABLE The job is partitionable (may become partitioned). @@ -163,6 +163,7 @@ _code_ CREAM CREAM job _code_ FILE_TRANSFER_COLLECTION File transfer collection _code_ FILE_TRANSFER File transfer + _code_ VIRTUAL_MACHINE Virtual machine int nsubjobs Number of subjobs this job plans to spawn. _optional_ @@ -521,3 +522,10 @@ string compute_job Jobid of (compute) job the sandbox belongs. Exclusive with transfer_job. _optional_ + +@flesh VirtualMachine + +@type VMCreate create (register) virtual machine + string name machine name + +@type VMRunning machine running diff --git a/org.glite.lb.types/status.T b/org.glite.lb.types/status.T index f774008..cc01f60 100644 --- a/org.glite.lb.types/status.T +++ b/org.glite.lb.types/status.T @@ -15,6 +15,7 @@ int jobtype Type of job _code_ CREAM CREAM job _code_ FILE_TRANSFER_COLLECTION job containing all file transfers (i.e. sandbox) _code_ FILE_TRANSFER subjob holding one file transfer + _code_ VIRTUAL_MACHINE job representing virtual machine jobid parent_job parent job of subjob string seed string used for generation of subjob IDs -- 1.8.2.3