[haizea-commit] r458 - trunk/src/haizea/resourcemanager/frontends
haizea-commit at mailman.cs.uchicago.edu
haizea-commit at mailman.cs.uchicago.edu
Mon Aug 4 10:23:00 CDT 2008
Author: borja
Date: 2008-08-04 10:23:00 -0500 (Mon, 04 Aug 2008)
New Revision: 458
Added:
trunk/src/haizea/resourcemanager/frontends/rpc.py
Removed:
trunk/src/haizea/resourcemanager/frontends/cli.py
Log:
RPC request frontend
Deleted: trunk/src/haizea/resourcemanager/frontends/cli.py
===================================================================
--- trunk/src/haizea/resourcemanager/frontends/cli.py 2008-08-04 15:22:40 UTC (rev 457)
+++ trunk/src/haizea/resourcemanager/frontends/cli.py 2008-08-04 15:23:00 UTC (rev 458)
@@ -1,18 +0,0 @@
-# -------------------------------------------------------------------------- #
-# Copyright 2006-2008, University of Chicago #
-# Copyright 2008, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
-# #
-# 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. #
-# -------------------------------------------------------------------------- #
-
Copied: trunk/src/haizea/resourcemanager/frontends/rpc.py (from rev 390, trunk/src/haizea/resourcemanager/frontends/cli.py)
===================================================================
--- trunk/src/haizea/resourcemanager/frontends/rpc.py (rev 0)
+++ trunk/src/haizea/resourcemanager/frontends/rpc.py 2008-08-04 15:23:00 UTC (rev 458)
@@ -0,0 +1,80 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2006-2008, University of Chicago #
+# Copyright 2008, Distributed Systems Architecture Group, Universidad #
+# Complutense de Madrid (dsa-research.org) #
+# #
+# 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. #
+# -------------------------------------------------------------------------- #
+import haizea.common.constants as constants
+from haizea.resourcemanager.datastruct import ARLease, BestEffortLease, ImmediateLease, ResourceTuple
+from haizea.resourcemanager.frontends.base import RequestFrontend
+from haizea.common.utils import roundDateTime
+from mx.DateTime import DateTimeDelta, TimeDelta, ISO
+
+HAIZEA_START_NOW = "now"
+HAIZEA_START_BESTEFFORT = "best_effort"
+HAIZEA_DURATION_UNLIMITED = "unlimited"
+
+class RPCFrontend(RequestFrontend):
+ def __init__(self, rm):
+ self.rm = rm
+ self.logger = self.rm.logger
+ self.accumulated = []
+ config = self.rm.config
+ self.rm.rpc_server.register_rpc(self.create_lease)
+
+ def getAccumulatedRequests(self):
+ acc = self.accumulated
+ self.accumulated = []
+ return acc
+
+ def existsMoreRequests(self):
+ return True
+
+ def create_lease(self, start, duration, preemptible, numnodes, cpu, mem, vmimage, vmimagesize):
+ tSubmit = roundDateTime(self.rm.clock.get_time())
+ resreq = ResourceTuple.create_empty()
+ resreq.set_by_type(constants.RES_CPU, float(cpu))
+ resreq.set_by_type(constants.RES_MEM, int(mem))
+ if duration == HAIZEA_DURATION_UNLIMITED:
+ # This is an interim solution (make it run for a century).
+ # TODO: Integrate concept of unlimited duration in the lease datastruct
+ duration = DateTimeDelta(36500)
+ else:
+ duration = ISO.ParseTimeDelta(duration)
+
+ if start == HAIZEA_START_NOW:
+ leasereq = ImmediateLease(tSubmit, duration, vmimage, vmimagesize, numnodes, resreq, preemptible)
+ elif start == HAIZEA_START_BESTEFFORT:
+ leasereq = BestEffortLease(tSubmit, duration, vmimage, vmimagesize, numnodes, resreq, preemptible)
+ else:
+ if start[0] == "+":
+ # Relative time
+ start = roundDateTime(tSubmit + ISO.ParseTime(start[1:]))
+ else:
+ start = ISO.ParseDateTime(start)
+ leasereq = ARLease(tSubmit, start, duration, vmimage, vmimagesize, numnodes, resreq, preemptible)
+
+ leasereq.state = constants.LEASE_STATE_PENDING
+ leasereq.set_scheduler(self.rm.scheduler)
+
+ self.accumulated.append(leasereq)
+
+ return leasereq.id
+
+
+
+
+
+
+
More information about the Haizea-commit
mailing list