Example #1
0
    def execConnectionLost(self, key):
        if not self.__ready: return
        LOG(
            "Executor manager lost connection with executor: " +
            repr(self.__procId), LOG_WARN)

        self.__execStatus = server.executor.status.ERROR

        # Notify error to clients
        msg = MessageClass()
        msg.setReceiver(key)
        msg = MsgHelper.createError(
            MSG_TYPE_ERROR, msg, "Execution aborted",
            " lost connection with executor " + repr(self.__procId))
        msg[ExcMessages.FIELD_PROC_ID] = self.__procId
        msg[FIELD_FATAL] = "True"

        # Notify my clients
        clientList = self.getClients()

        if self.getParent() is not None:
            clientList += [self.getParent()]
        self.messageToClients(msg, clientList)

        # Notify the rest of clients
        self.__context.notifyExecutorOperation(self.__procId,
                                               CtxMessages.DATA_EXOP_CRASH)

        #Remove process instance from the ProcessManager
        ProcessManager.instance().removeProcess(self.__procId)

        self.__ready = False
Example #2
0
    def execConnectionLost(self, key):
        if not self.__ready:
            return
        LOG("Executor manager lost connection with executor: " + repr(self.__procId), LOG_WARN)

        self.__execStatus = server.executor.status.ERROR

        # Notify error to clients
        msg = MessageClass()
        msg.setReceiver(key)
        msg = MsgHelper.createError(
            MSG_TYPE_ERROR, msg, "Execution aborted", " lost connection with executor " + repr(self.__procId)
        )
        msg[ExcMessages.FIELD_PROC_ID] = self.__procId
        msg[FIELD_FATAL] = "True"

        # Notify my clients
        clientList = self.getClients()

        if self.getParent() is not None:
            clientList += [self.getParent()]
        self.messageToClients(msg, clientList)

        # Notify the rest of clients
        self.__context.notifyExecutorOperation(self.__procId, CtxMessages.DATA_EXOP_CRASH)

        # Remove process instance from the ProcessManager
        ProcessManager.instance().removeProcess(self.__procId)

        self.__ready = False
Example #3
0
 def __startExecutor(self):
     
     LOG("Starting executor for procedure: '" + self.__procId + "'", level = LOG_PROC)
     command = self.__execScript + " -s " + str(self.__execIFC.port)
     self.__execPID = ProcessManager.instance().startProcess( self.__procId, command )
     
     try:
         # Wait until executor starts properly
         self.__waitExecutorOpen()
         self.__ready = True
     except Exception,ex:
         # Kill the process on error
         ProcessManager.instance().killProcess(self.__procId)
         self.setError("Unable to start executor",repr(ex))
Example #4
0
 def __waitExecutorClose(self):
     # Wait until the open notification from executor arrives
     # see __execProcessLogout method
     LOG("Executor closed, waiting confirmation", level = LOG_PROC)
     confirm = self.__execLock.get(True, STOP_TIMEOUT)
     if confirm is None or confirm != self.__procId:
         LOG("Did not get close confirmation on time")
         self.setError("Could not get executor confirmation","Executor failed to close")
         return False
     LOG("Got confirmation, waiting process to finish", level = LOG_PROC)
     ret = ProcessManager.instance().waitProcess( self.__procId )
     LOG("Process finished with value " + str(ret))
     ProcessManager.instance().removeProcess( self.__procId )
     self.__contextLock.put(1)
     return True
Example #5
0
 def __waitExecutorClose(self):
     # Wait until the open notification from executor arrives
     # see __execProcessLogout method
     LOG("Executor closed, waiting confirmation", level=LOG_PROC)
     confirm = self.__execLock.get(True, STOP_TIMEOUT)
     if confirm is None or confirm != self.__procId:
         LOG("Did not get close confirmation on time")
         self.setError("Could not get executor confirmation",
                       "Executor failed to close")
         return False
     LOG("Got confirmation, waiting process to finish", level=LOG_PROC)
     ret = ProcessManager.instance().waitProcess(self.__procId)
     LOG("Process finished with value " + str(ret))
     ProcessManager.instance().removeProcess(self.__procId)
     self.__contextLock.put(1)
     return True
Example #6
0
    def __startExecutor(self):

        LOG("Starting executor for procedure: '" + self.__procId + "'",
            level=LOG_PROC)
        command = self.__execScript + " -s " + str(self.__execIFC.port)
        self.__execPID = ProcessManager.instance().startProcess(
            self.__procId, command)

        try:
            # Wait until executor starts properly
            self.__waitExecutorOpen()
            self.__ready = True
        except Exception, ex:
            # Kill the process on error
            ProcessManager.instance().killProcess(self.__procId)
            self.setError("Unable to start executor", repr(ex))
Example #7
0
    def execConnectionLost(self, key):
        if not self.__ready: return
        LOG(
            "Executor manager lost connection with executor: " +
            repr(self.__procId), LOG_WARN)

        self.__execStatus = server.executor.status.ERROR

        # Notify error to clients
        msg = MessageClass()
        msg.setReceiver(key)
        msg = MsgHelper.createError(
            MSG_TYPE_ERROR, msg, "Execution aborted",
            " lost connection with executor " + repr(self.__procId))
        msg[ExcMessages.FIELD_PROC_ID] = self.__procId

        if self.getParent() is not None:
            clientList = [self.getParent()] + self.getClients()
        else:
            clientList = self.getClients()

        self.messageToClients(msg, clientList)

        # Notify the procedure status to clients
        msg = MessageClass()
        data = {
            ExcMessages.FIELD_PROC_ID: self.__procId,
            ExcMessages.FIELD_CSP: self.__procId,
            FIELD_DATA_TYPE: ExcMessages.DATA_TYPE_STATUS,
            ExcMessages.FIELD_EXEC_STATUS: self.__execStatus,
            ExcMessages.FIELD_LINE: 0
        }
        msg.setProps(data)
        msg.setId(MSG_TYPE_NOTIFY)
        msg.setType(MSG_TYPE_NOTIFY)

        self.messageToClients(msg, clientList)

        #Remove process instance from the ProcessManager
        ProcessManager.instance().removeProcess(self.__procId)

        self.__ready = False
Example #8
0
 def execConnectionLost(self,key):
     if not self.__ready: return
     LOG("Executor manager lost connection with executor: " + repr(self.__procId), LOG_WARN)
     
     self.__execStatus = server.executor.status.ERROR
     
     # Notify error to clients
     msg = MessageClass()
     msg.setReceiver(key)
     msg = MsgHelper.createError(MSG_TYPE_ERROR, msg, "Execution aborted", 
                             " lost connection with executor " + repr(self.__procId))
     msg[ExcMessages.FIELD_PROC_ID] = self.__procId
     
     if self.getParent() is not None:
         clientList = [self.getParent()] + self.getClients()
     else:
         clientList = self.getClients()
         
     self.messageToClients(msg, clientList)
     
     # Notify the procedure status to clients
     msg = MessageClass()
     data = { ExcMessages.FIELD_PROC_ID: self.__procId, 
              ExcMessages.FIELD_CSP: self.__procId,
              FIELD_DATA_TYPE: ExcMessages.DATA_TYPE_STATUS, 
              ExcMessages.FIELD_EXEC_STATUS: self.__execStatus,
              ExcMessages.FIELD_LINE: 0 } 
     msg.setProps(data)
     msg.setId(MSG_TYPE_NOTIFY)
     msg.setType(MSG_TYPE_NOTIFY)
     
     self.messageToClients(msg, clientList)
     
     #Remove process instance from the ProcessManager
     ProcessManager.instance().removeProcess( self.__procId )
     
     self.__ready = False
Example #9
0
    def __closeExecutor(self, force):
        if not self.__ready or force:
            # When forcing
            self.__ready = False
            self.__execIFC.disconnect(eoc=False)
            ProcessManager.instance().killProcess(self.__procId)
            LOG("Executor closed (force=True)", level=LOG_PROC)
            return
        # Send the close command to the executor
        msg = MsgHelper.createMessage(ExcMessages.CMD_CLOSE)
        msg[ExcMessages.FIELD_PROC_ID] = self.__procId
        msg.setSender("CTX")
        msg.setReceiver(self.__procId)
        LOG("Send close command to executor " + self.__procId, level=LOG_COMM)
        self.__execIFC.sendMessage(msg, self.__execKey)

        try:
            # Wait until executor stops properly
            self.__waitExecutorClose()
        except Exception, ex:
            # Remove the process from process manager
            LOG("Unable to close executor (" + repr(ex) + "), killing it")
            ProcessManager.instance().killProcess(self.__procId)
            self.setError("Unable to stop executor", repr(ex))
Example #10
0
 def __closeExecutor(self, force):
     if not self.__ready or force:
         # When forcing
         self.__ready = False
         self.__execIFC.disconnect( eoc = False ) 
         ProcessManager.instance().killProcess(self.__procId)
         LOG("Executor closed (force=True)", level = LOG_PROC)
         return
     # Send the close command to the executor
     msg = MsgHelper.createMessage(ExcMessages.CMD_CLOSE)
     msg[ExcMessages.FIELD_PROC_ID] = self.__procId
     msg.setSender("CTX")
     msg.setReceiver(self.__procId)
     LOG("Send close command to executor " + self.__procId, level = LOG_COMM )
     self.__execIFC.sendMessage(msg,self.__execKey)
 
     try:
         # Wait until executor stops properly
         self.__waitExecutorClose()
     except Exception,ex:
         # Remove the process from process manager
         LOG("Unable to close executor (" + repr(ex) + "), killing it")
         ProcessManager.instance().killProcess(self.__procId)
         self.setError("Unable to stop executor",repr(ex))