cbaWorkflowNode is the base class. the derived classes will be accessed using base class pointer, or RTTI(if no uniform design is possible)



  • Derived classes must override generateCommandString to generate the string. it can be either put in constructor or called by the framework.
  • Derived classes may override run(), but ideally the base class implementation will do the uniform work for all the nodes. In case it is overrode, the base class run() should be called as cbaWorkflowNode::run()
  • Framework cbaWorkflow will instantiate the class and call its run() method.
  • Each derived class is implemented in a separate shared object(i, libcbaHdfsToTarballNode.so)
  • Each derived class library will have a getClass function (export as external C) which will create a derived class and return a base class pointer to it.
  • cbaWorkflow will implement a  class factory  pattern to create an instance of a specific derived class of cbaWorkflowNode.
  • While instantiating  the class  cbaWorkflow framework will dynamically load the library and call its getClass function
  • getClass function is declared as follows: extern "C" {cbaWorkflowNode* getClass();}
  • getClass function is implemented as follows(example uses cbaSparkSubmitNode):
    cbaWorkflowNode* getClass()
    {
              cbaWorkflowNode* ptr = new cbaSparkSubmitNode();
              return ptr;
    }
  • Derived classes are loaded using getInstance function, which will be wrapped into cbaWorkflow  class factory createNode method :

    cbaWorkflowNode* getInstance(string libname)
    {
               void *nodeso = dlopen(libname.c_str(), RTLD_LAZY);

              cbaWorkflowNode*(*ptr)()=(cbaWorkflowNode* (*)())dlsym(nodeso,"getClass");

               cbaWorkflowNode* node = (*ptr)();
               cout<<nodeso<<endl;
               return node;
    }

    The dynamic loader will return the same library handle if the node type has already been loaded, which can be verified by printing nodeso(lib handle) . The string with shared object name is stored in the repository, so the class factory could make use of it.

Attachments:

cbaWorkflowNode.png (image/png)
cbaWorkflowNode.png (image/png)
cbaNode.png (image/png)