Beispiel #1
0
            def do_instance_alloc(
                self,
                component_handle,
                tasklet_info,
                instance_url,
            ):
                """Create a tasklet instance

                Arguments:
                    component_handle - the handle associated with this
                                       component
                    tasklet_info     - information about the tasklet that is
                                       being created
                    instance_url     - the instance URL

                Returns:
                    An instance handle

                """
                instance_handle = rwtasklet.InstanceHandle()

                # NB: this is essentially the reason for the metaclass. Here we
                # are using the new tasklet type that was created above.
                tasklet = tasklet_type(tasklet_info)

                # Add the new tasklet to the dict of tasklets and use the
                # component and instances handles (as a pair) to define the
                # key.
                self.tasklets[(component_handle, instance_handle)] = tasklet

                return instance_handle
Beispiel #2
0
 def do_component_init(self):
     """This function is called once during the compoenent
     initialization.
     """
     logger.debug("RwDtsScheduler: do_component_init function called")
     component_handle = RwTaskletPlugin.ComponentHandle()
     return component_handle
Beispiel #3
0
    def do_instance_alloc(self, component_handle, tasklet_info, instance_url):
        """This function is called for each new instance of the tasklet.
        The tasklet specific information such as scheduler instance,
        trace context, logging context are passed in 'tasklet_info' variable.
        This function stores the tasklet information locally.
        """
        logger.debug("RwdtstaskletPython: do_instance_alloc function called")

        self.taskletinfo = tasklet_info

        # Save the scheduler instance and tasklet instance objects
        #self.rwsched = tasklet_info.rwsched_instance
        #self.tasklet = tasklet_info.rwsched_tasklet_info
        #self.rwlog_instance = tasklet_info.rwlog_instance


        tasklet_logger = rwlogger.RwLogger(subcategory="rw-vcs",
                                           log_hdl=self.taskletinfo.rwlog_ctx)
        logger.addHandler(tasklet_logger)

        # After this point, all logger calls will log events to rw_vcs using
        # the tasklets rwlog handle
        logger.debug("Added rwlogger handler to tasklet logger")

        instance_handle = RwTaskletPlugin.InstanceHandle()
        return instance_handle
Beispiel #4
0
 def do_instance_alloc(self, component_handle, tasklet_info, instance_url):
     """This function is called for each new instance of the tasklet.
     The tasklet specific information such as scheduler instance,
     trace context, logging context are passed in 'tasklet_info' variable.
     This function stores the tasklet information locally.
     """
     logger.debug("RwDtsScheduler: do_instance_alloc function called")
     self.taskletinfo = tasklet_info
     instance_handle = RwTaskletPlugin.InstanceHandle()
     return instance_handle
Beispiel #5
0
    def setUpScheduler(self):
      logger.debug("setUpScheduler")
      instance_url = RwTaskletPlugin._RWExecURL()
      logger.debug("main: url=%s type=%s" % (instance_url, type(instance_url)))

      sched = RwDtsScheduler(self)
      component_handle = sched.component_init()
      sched_instance_handle = sched.instance_alloc(component_handle, self.taskletinfo, instance_url)
      sched.instance_start(component_handle, sched_instance_handle)
      self.sched = sched
      logger.debug("main: component=%s type=%s" % (component_handle, type(component_handle)))
Beispiel #6
0
            def do_component_init(self):
                """Initialize the component

                This function initializes the component and returns the
                component handle.

                Returns:
                    A component handle

                """
                return rwtasklet.ComponentHandle()
Beispiel #7
0
    def setUpScheduler(self):
        logger.debug("setUpScheduler")
        instance_url = RwTaskletPlugin._RWExecURL()
        logger.debug("main: url=%s type=%s" %
                     (instance_url, type(instance_url)))

        sched = RwDtsScheduler(self)
        component_handle = sched.component_init()
        sched_instance_handle = sched.instance_alloc(component_handle,
                                                     self.taskletinfo,
                                                     instance_url)
        sched.instance_start(component_handle, sched_instance_handle)
        self.sched = sched
        logger.debug("main: component=%s type=%s" %
                     (component_handle, type(component_handle)))
Beispiel #8
0
        foo = Callback()
        #sub = SubscribeInsideXactExample(self)
        self.dts_api = RwDts.Api.new(self.taskletinfo,                 # tasklet object
                                     RwDtsToyTaskletYang.get_schema(), # Schema object
                                     foo.rwdts_tasklet_state_change_cb,      # The callback for DTS state change
                                     #sub.rwdts_tasklet_state_change_cb,
                                     self)                             # user data in the callback - in this case self


    def do_instance_stop(self, component_handle, instance_handle):
        logger.debug("RwdtstaskletPython: do_instance_stop function called")

if __name__ == "__main__":
    #add your test code to execute this as a standalone program
    tasklet = RwdtstaskletPython()

    component_handle = tasklet.component_init()
    logger.debug("main: componente=%s" % (component_handle))
    logger.debug("main: component-type=%s" % type(component_handle))
    tasklet_info = RwTaskletPlugin._RWTaskletInfo()
    instance_url = RwTaskletPlugin._RWExecURL()
    logger.debug("main: tasklet=%s" % (tasklet_info))
    logger.debug("main: tasklet-type=%s" % type(tasklet_info))
    logger.debug("main: url=%s" % (instance_url))
    logger.debug("main: url-type=%s" % type(instance_url))
    instance_handle = tasklet.instance_alloc(component_handle, tasklet_info, instance_url)
    logger.debug("main: instance=%s" % (instance_handle))
    logger.debug("main: instance-type=%s" % type(instance_handle))
    tasklet.instance_start(component_handle, instance_handle)
Beispiel #9
0
        foo = Callback()
        #sub = SubscribeInsideXactExample(self)
        self.dts_api = RwDts.Api.new(self.taskletinfo,                 # tasklet object
                                     RwDtsToyTaskletYang.get_schema(), # Schema object
                                     foo.rwdts_tasklet_state_change_cb,      # The callback for DTS state change
                                     #sub.rwdts_tasklet_state_change_cb,
                                     self)                             # user data in the callback - in this case self


    def do_instance_stop(self, component_handle, instance_handle):
        logger.debug("RwdtstaskletPython: do_instance_stop function called")

if __name__ == "__main__":
    #add your test code to execute this as a standalone program
    tasklet = RwdtstaskletPython()

    component_handle = tasklet.component_init()
    logger.debug("main: componente=%s" % (component_handle))
    logger.debug("main: component-type=%s" % type(component_handle))
    tasklet_info = RwTaskletPlugin._RWTaskletInfo()
    instance_url = RwTaskletPlugin._RWExecURL()
    logger.debug("main: tasklet=%s" % (tasklet_info))
    logger.debug("main: tasklet-type=%s" % type(tasklet_info))
    logger.debug("main: url=%s" % (instance_url))
    logger.debug("main: url-type=%s" % type(instance_url))
    instance_handle = tasklet.instance_alloc(component_handle, tasklet_info, instance_url)
    logger.debug("main: instance=%s" % (instance_handle))
    logger.debug("main: instance-type=%s" % type(instance_handle))
    tasklet.instance_start(component_handle, instance_handle)