def check(self): ''' Check this event is in a coherent state ''' if self.startOffset < 0: raise errors.AgentInternalError("Start offset must be positive") if self.startOffset > _ONE_WEEK_IN_SECS: raise errors.AgentInternalError( "Start offset must be lesser than %s" % _ONE_WEEK_IN_SECS) if self.duration < 1: raise errors.AgentConfigFileError( "An event must last a least one second (not enforced by XSD)") if self.duration >= _ONE_WEEK_IN_SECS: raise errors.AgentInternalError( "An event cannot last more than 7 days (not enforced by XSD)") self.config.check()
def __getActions(self): def offset_in_origin_week(agent_time): now = int(time.time()) return now - agent_time.origin if len(self.events) == 0: raise errors.AgentInternalError("No calendars event") agent_time = AgentTime() index = None wasStart = None weeks = 0 # Tries to find the first event according to the current time offset since the start of the week for i in range(len(self.events)): if self.events[i].startOffset >= offset_in_origin_week(agent_time): index = i wasStart = True yield (StartEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].startOffset)), index) break if self.events[i].stopOffset >= offset_in_origin_week(agent_time): index = i wasStart = True # yield (StartEvent(self.events[index], int(time.time())), index) yield (StartEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].startOffset)), index) break mustResetWeeks = False if index is None: # No event until next week weeks += 1 if self.events[0].startOffset < self.events[-1].stopOffset: index = 0 wasStart = True yield (StartEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].startOffset)), index) else: index = len(self.events) - 1 wasStart = False mustResetWeeks = True # Ugly hack, to avoid double weeks increment yield (StopEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].stopOffset)), index) if mustResetWeeks: weeks = 0 # Subsequent calls # Since no overlapping is allowed we just have to loop over the events while True: if wasStart: # Return the stop offset of the current event if self.events[index].stopOffset > self.events[ index].startOffset: yield (StopEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].stopOffset)), index) else: # stop is next week yield (StopEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].stopOffset + _ONE_WEEK_IN_SECS)), index) wasStart = False else: # Go to the next event index += 1 if index == len(self.events ): # End of the list reached, hello new week ! index = 0 weeks += 1 yield (StartEvent( self.events[index], agent_time.event_date_in_epoch( weeks, self.events[index].startOffset)), index) wasStart = True
def getArguments(self): ''''Return the Java arguments ''' raise errors.AgentInternalError("Not implemented")
def check(self): ''' Check the state of this event is consistent ''' if self.proactiveHome is None: raise errors.AgentConfigFileError("ProActive home is not set") if len(self.proactiveHome) < 1: # FIXME: Should be enforced by the XSD raise errors.AgentConfigFileError("ProActive home cannot be empty") if self.javaHome is None: raise errors.AgentConfigFileError("Java home is not set") if len(self.javaHome) < 1: # FIXME: Should be enforce by the XSD raise errors.AgentConfigFileError("Java home cannot be empty") if self.memoryLimit < 0: raise errors.AgentInternalError( "Memory limit must be a positive integer") if self.memoryLimit != 0: if self.memoryLimit < 128: logger.warning( "Warning memory limit is set below 128MB. JVMs will likely crash due to the memory constraint" ) if self.cgroup_mnt_point is None: raise errors.AgentInternalError( "cgroup mount point is not defined but memory limit is set" ) if len(self.cgroup_mnt_point) == 0: raise errors.AgentInternalError( "cgroup mount point lenght is 0 but memory limit is set") if not os.path.exists(self.cgroup_mnt_point): raise errors.AgentConfigFileError( "cgroup is not mounted at %s. Please mount the cgroup filesystem or remove the <memoryLimit> element from the configuration file" % self.cgroup_mnt_point) if self.nbRuntimes < 0: raise errors.AgentInternalError( "The number of runtimes must be a positive integer") if self.protocol is None: raise errors.AgentInternalError( "ProActive communication protocol is not set") if len(self.protocol) < 1: raise errors.AgentConfigFileError( "ProActive communication protocol cannot be empty") if self.portRange[0] < 0 or self.portRange[0] > 65536: raise errors.AgentInternalError( "First TCP port must be an integer between 0 and 65536") if self.portRange[1] < 0 or self.portRange[1] > 65536: raise errors.AgentInternalError( "Last TCP port must be an integer between 0 and 65536") if self.portRange[0] > self.portRange[1]: raise errors.AgentInternalError( "Last TCP port must be greater or equals to the first TCP port" ) if self.portRange[1] + 1 - self.portRange[0] < self.nbRuntimes: raise errors.AgentInternalError( "The port range is too small according to the number of runtimes" ) if self.nice < -20 or self.nice > 19: raise errors.AgentInternalError( "Invalid nice value. Must be betweeon -20 and 19") if self.ionice is not None: if self.ionice["class"] == 1 or self.ionice["class"] == 2: if self.ionice["classdata"] is None: raise errors.AgentConfigFileError( "A class data is mandatory with the best effort and real time ionice classes" ) else: if self.ionice["classdata"] is not None: raise errors.AgentConfigFileError( "none and idle ionice classes does not accept any class data argument" )
def getClass(self): ''' Return the Java class to start ''' raise errors.AgentInternalError("Not implemented")