Example #1
0
    def closeExecutor(self, procId):
        LOG("Requested closing executor " + repr(procId))

        executor = self.getExecutor(procId)

        if executor is None:
            raise ContextError("No such executor: " + repr(procId))

        LOG("Closing executor")
        executor.stop()
        success = executor.waitForClose()
        LOG("Executor closed (" + repr(success) + ")")

        if not success:
            error, reason = executor.getError()
            self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
            self.killExecutor(procId)
            self.clearExecutor(procId)
            raise ContextError("Could not close executor",
                               error + ":" + reason)
        else:
            LOG("Notifying executor close", level=LOG_PROC)
            self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
            self.clearExecutor(procId)
            LOG("Close finished")

        return
Example #2
0
    def closeExecutor(self, procId):
        LOG("Requested closing executor " + repr(procId))

        executor = self.getExecutor(procId)
        
        if executor is None:
            raise ContextError("No such executor: " + repr(procId))
        
        LOG("Closing executor")
        executor.stop()
        success = executor.waitForClose()
        LOG("Executor closed (" + repr(success) + ")")
        
        if not success: 
            error,reason = executor.getError()
            self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
            self.killExecutor(procId)
            self.clearExecutor(procId)
            raise ContextError("Could not close executor",error + ":" + reason)
        else:
            LOG("Notifying executor close", level = LOG_PROC)
            self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
            self.clearExecutor(procId)
            LOG("Close finished")
            
        return 
Example #3
0
    def openExecutor(self,
                     procId,
                     clientKey,
                     clientMode,
                     openMode={},
                     arguments=None,
                     condition=None,
                     parentId=None):
        ctxInfo = Config.instance().getContextConfig(self.ctxName)
        driverName = ctxInfo.getDriver()
        maxProcs = int(
            Config.instance().getDriverConfig(driverName).getMaxProcs())
        if maxProcs > 0:
            activeProcs = self.getNumActiveProcs()
            if (activeProcs >= maxProcs):
                raise ContextError(
                    "Could not launch executor. Maximum number of processes reached ("
                    + str(maxProcs) + ")")

        success = False
        LOG("Requested opening executor " + repr(procId), level=LOG_PROC)
        executor = self.createExecutor(procId)

        # Update the proc id with the instance number
        procId = executor.getProcId()

        # Get configuration defaults for open mode and update it
        #TODO: get open mode defaults from config
        useOpenMode = {Automatic: False, Visible: True, Blocking: True}
        useOpenMode.update(openMode)

        # Set the controlling client key if the procedure is visible
        if useOpenMode[Visible] == True:
            clientInfo = self.getClient(clientKey)
            executor.addClient(clientInfo, True)
            clientInfo.addExecutor(procId)
            clientInfo.setMode(clientMode)

        LOG("Launching executor " + repr(procId) + " in mode " +
            repr(useOpenMode),
            level=LOG_PROC)

        if arguments:
            executor.setArguments(arguments)
        if condition:
            executor.setCondition(condition)
        if parentId:
            executor.setParent(parentId)

        # Set the open mode and open the executor
        executor.setOpenMode(useOpenMode)

        executor.start()
        success = executor.waitForOpen()
        LOG("Executor launched (" + repr(success) + ")", level=LOG_PROC)

        if not success:
            error, reason = executor.getError()
            self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
            self.killExecutor(procId)
            self.clearExecutor(procId)
            raise ContextError("Could not launch executor",
                               error + ":" + reason)
        else:
            initialStatus = executor.getStatus()
            if initialStatus == server.executor.status.ERROR:
                error, reason = executor.getError()
                self.notifyExecutorOperation(procId,
                                             CtxMessages.DATA_EXOP_CLOSE)
                self.killExecutor(procId)
                self.clearExecutor(procId)
                raise ContextError("Executor failed startup",
                                   error + ":" + reason)
            else:
                pid = executor.getExecutorPid()
                self.__executorsRegistry.addProcess(pid, procId)

                LOG("Notifying executor open", level=LOG_PROC)
                self.notifyExecutorOperation(procId,
                                             CtxMessages.DATA_EXOP_OPEN,
                                             clientKey, clientMode)
                LOG("Open finished")
        return
Example #4
0
    def openExecutor(self, procId, clientKey, clientMode, openMode = {},
                     arguments = None, condition = None, parentId = None):
        ctxInfo = Config.instance().getContextConfig(self.ctxName)
        driverName = ctxInfo.getDriver()
        maxProcs = int(Config.instance().getDriverConfig(driverName).getMaxProcs())
        if maxProcs>0:
            activeProcs = self.getNumActiveProcs()
            if (activeProcs >= maxProcs):
                raise ContextError("Could not launch executor. Maximum number of processes reached (" + str(maxProcs) + ")")
        
        success = False
        LOG("Requested opening executor " + repr(procId), level = LOG_PROC)
        executor = self.createExecutor(procId)
        
        # Update the proc id with the instance number
        procId = executor.getProcId()
        
        # Get configuration defaults for open mode and update it
        #TODO: get open mode defaults from config
        useOpenMode = {Automatic:False,Visible:True,Blocking:True}
        useOpenMode.update(openMode)

        # Set the controlling client key if the procedure is visible
        if useOpenMode[Visible] == True:
            clientInfo = self.getClient(clientKey)
            executor.addClient(clientInfo, True)
            clientInfo.addExecutor(procId) 
            clientInfo.setMode(clientMode)
        
        LOG("Launching executor " + repr(procId) + " in mode " + repr(useOpenMode), level = LOG_PROC)

        if arguments:
            executor.setArguments(arguments)
        if condition:
            executor.setCondition(condition)
        if parentId:
            executor.setParent(parentId)
            
        # Set the open mode and open the executor
        executor.setOpenMode(useOpenMode)
        
        executor.start()
        success = executor.waitForOpen()
        LOG("Executor launched (" + repr(success) + ")", level = LOG_PROC)

        if not success:
            error,reason = executor.getError()
            self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
            self.killExecutor(procId)
            self.clearExecutor(procId)
            raise ContextError("Could not launch executor",error + ":" + reason)
        else:
            initialStatus = executor.getStatus()
            if initialStatus == server.executor.status.ERROR:
                error,reason = executor.getError()
                self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_CLOSE)
                self.killExecutor(procId)
                self.clearExecutor(procId)
                raise ContextError("Executor failed startup",error + ":" + reason)
            else:
                pid = executor.getExecutorPid()
                self.__executorsRegistry.addProcess(pid,procId)
                
                LOG("Notifying executor open", level = LOG_PROC)
                self.notifyExecutorOperation(procId, CtxMessages.DATA_EXOP_OPEN, clientKey, clientMode)
                LOG("Open finished")
        return