Create a work unit for each configuration defined or a single work unit if no configurations are defined
@param state see {@link org.apache.gobblin.configuration.SourceState}
@return list of workunits
338463
@Override
  public List<WorkUnit> getWorkunits(SourceState state) {
    List<WorkUnit> workUnits = Lists.newArrayList();
    Config config = ConfigUtils.propertiesToConfig(state.getProperties());
    Config sourceConfig = ConfigUtils.getConfigOrEmpty(config, DATASET_CLEANER_SOURCE_PREFIX);
    List<String> configurationNames = ConfigUtils.getStringList(config, DATASET_CLEANER_CONFIGURATIONS);

    // use a dummy configuration name if none set
    if (configurationNames.isEmpty()) {
      configurationNames = ImmutableList.of("DummyConfig");
    }

    for (String configurationName: configurationNames) {
      WorkUnit workUnit = WorkUnit.createEmpty();

      // specific configuration prefixed by the configuration name has precedence over the source specific configuration
      // and the source specific configuration has precedence over the general configuration
      Config wuConfig = ConfigUtils.getConfigOrEmpty(sourceConfig, configurationName).withFallback(sourceConfig)
          .withFallback(config);

      workUnit.setProps(ConfigUtils.configToProperties(wuConfig), new Properties());
      TaskUtils.setTaskFactoryClass(workUnit, DatasetCleanerTaskFactory.class);
      workUnits.add(workUnit);
    }

    return workUnits;
  }
568953
@SuppressWarnings("unchecked")
    private State create(Class<? extends State> state)
    {
        try
        {
            if (configurer.isPresent())
            {
                final AnimationConfig configAnimations = AnimationConfig.imports(configurer.get());
                final String name = converter.apply(state);
                final Animation animation = configAnimations.getAnimation(name);
                final Class<? extends Feature> feature;
                feature = (Class<? extends Feature>) UtilReflection.getCompatibleConstructor(state,
                                                                                             FeatureProvider.class,
                                                                                             Animation.class)
                                                                   .getParameters()[PARAM_FEATURE_INDEX].getType();
                return UtilReflection.create(state,
                                             UtilReflection.getParamTypes(feature, animation),
                                             getFeature(feature),
                                             animation);
            }
            return UtilReflection.createReduce(state);
        }
        catch (final NoSuchMethodException exception)
        {
            throw new LionEngineException(exception);
        }
    }
1347959
@Override
  public void publishData(Collection<? extends WorkUnitState> states)
      throws IOException {
    for (WorkUnitState state: states)
    {
      if (state.getWorkingState() == WorkUnitState.WorkingState.SUCCESSFUL)
      {
        state.setWorkingState(WorkUnitState.WorkingState.COMMITTED);
        log.info("Marking state committed");
      }
    }
  }
414898
protected void setLowWatermark(SourceState state) {
    this.lowWatermark = getWatermarkFromPreviousWorkUnits(state, ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK);
    log.info("Setting low watermark for the job: " + this.lowWatermark);
  }
688006
function Application (state) {
  this.state   = state;
  this.Members  = state.get('Member');
  this.Projects = state.get('Project');
  this.Tasks    = state.get('Task');

  // Panel "Members"
  this.MembersView      = new MembersView({app: this, html: '.main-list-members'});
  this.SideProjectsView = new SideProjectsView({app: this, html: '.side-list-projects'});
  this.membersTab       = [this.MembersView, this.SideProjectsView];

  // Panel "Projects"
  this.ProjectsView     = new ProjectsView({app: this, html: '.main-list-projects'});
  this.SideMembersView  = new SideMembersView({ app: this, html: '.side-list-members'});
  this.projectsTab      = [this.ProjectsView, this.SideMembersView];

  this.activate('#members');
}
445765
protected static String getWatermarkFromPreviousWorkUnits(SourceState state, String watermark) {
    if (state.getPreviousWorkUnitStates().isEmpty()) {
      return ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK;
    }
    return state.getPreviousWorkUnitStates().get(0)
        .getProp(watermark, ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK);
  }
457598
private CmsUUID getResourceIdFromState(String state) {

        CmsUUID result = null;
        String id = A_CmsWorkplaceApp.getParamFromState(state, RESOURCE_ID_PREFIX);
        if (CmsUUID.isValidUUID(id)) {
            result = new CmsUUID(id);
        }

        return result;
    }
1188650
protected List<WorkUnit> squeezeMultiWorkUnits(List<MultiWorkUnit> multiWorkUnits) {
    List<WorkUnit> workUnits = Lists.newArrayList();
    for (MultiWorkUnit multiWorkUnit : multiWorkUnits) {
      workUnits.add(squeezeMultiWorkUnit(multiWorkUnit));
    }
    return workUnits;
  }
246562
public SourceUnit addSource(URL url) {
        return addSource(new SourceUnit(url, configuration, classLoader, getErrorCollector()));
    }
662726
public static CompactionSuiteFactory getCompactionSuiteFactory(State state) {
    try {
      String factoryName =
          state.getProp(ConfigurationKeys.COMPACTION_SUITE_FACTORY, ConfigurationKeys.DEFAULT_COMPACTION_SUITE_FACTORY);

      ClassAliasResolver<CompactionSuiteFactory> conditionClassAliasResolver =
          new ClassAliasResolver<>(CompactionSuiteFactory.class);
      CompactionSuiteFactory factory = conditionClassAliasResolver.resolveClass(factoryName).newInstance();
      return factory;
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      throw new IllegalArgumentException(e);
    }
  }
792497
def expand_state_definition(source, loc, tokens):
    
    indent = " " * (pp.col(loc, source) - 1)
    statedef = []

    # build list of states
    states = set()
    fromTo = {}
    for tn in tokens.transitions:
        states.add(tn.from_state)
        states.add(tn.to_state)
        fromTo[tn.from_state] = tn.to_state

    # define base class for state classes
    baseStateClass = tokens.name
    statedef.extend([
        "class %s(object):" % baseStateClass,
        "    def __str__(self):",
        "        return self.__class__.__name__",

        "    @classmethod",
        "    def states(cls):",
        "        return list(cls.__subclasses__())",

        "    def next_state(self):",
        "        return self._next_state_class()",
    ])

    # define all state classes
    statedef.extend("class {0}({1}): pass".format(s, baseStateClass) for s in states)

    # define state->state transitions
    statedef.extend("{0}._next_state_class = {1}".format(s, fromTo[s]) for s in states if s in fromTo)

    statedef.extend([
        "class {baseStateClass}Mixin:".format(baseStateClass=baseStateClass),
        "    def __init__(self):",
        "        self._state = None",

        "    def initialize_state(self, init_state):",
        "        self._state = init_state",

        "    @property",
        "    def state(self):",
        "        return self._state",

        "    # get behavior/properties from current state",
        "    def __getattr__(self, attrname):",
        "        attr = getattr(self._state, attrname)",
        "        return attr",

        "    def __str__(self):",
        "       return '{0}: {1}'.format(self.__class__.__name__, self._state)",
        ])

    return indent + ("\n" + indent).join(statedef) + "\n"
687679
protected DatasetDescriptor createDestinationDescriptor(WorkUnitState state, int branchId) {
    Path publisherOutputDir = getPublisherOutputDir(state, branchId);
    FileSystem fs = this.publisherFileSystemByBranches.get(branchId);
    DatasetDescriptor destination = new DatasetDescriptor(fs.getScheme(), publisherOutputDir.toString());
    destination.addMetadata(DatasetConstants.FS_URI, fs.getUri().toString());
    destination.addMetadata(DatasetConstants.BRANCH, String.valueOf(branchId));
    return destination;
  }
348382
public List<TaskState> getTaskStates() {
    return ImmutableList.<TaskState>builder().addAll(this.taskStates.values()).build();
  }
233612
public static String getJobRunState(int state) {
    if (state < 1 || state >= runStates.length) {
      return UNKNOWN;
    }
    return runStates[state];
  }
689841
protected function initializeStates()
    {
        if (!array_key_exists('states', $this->vars)) {
            throw new WorkflowException("You must define some states:\n", 99, NULL);
        }

        //check if all the methods for each status is callable
        $methods_not_implemented = '';
        try {
            foreach ($this->vars['states'] as $status) {
                array_push($this->states, new Status($status));

                /*
                 * The initial state will never be executed but only the transitions, therefore it will be excluded
                 * from the list of methods which must be implemented
                 */
                if (!method_exists($this, $status['name'])
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
                    $methods_not_implemented .= $status['name'] . "\n";
                }
            }
        } catch (StatusException $ex) {
            throw new WorkflowException("Error in one state of the workflow:\n" . $ex->getMessage(), 79);
        }

        if (strlen($methods_not_implemented) > 0) {
            throw new WorkflowException(
                "This methods are not implemented in the workflow:\n" .
                $methods_not_implemented, 79, NULL
            );
        }
    }
1162411
private String persistWorkUnit(final Path workUnitFileDir, final WorkUnit workUnit, ParallelRunner stateSerDeRunner)
      throws IOException {
    final StateStore stateStore;
    String workUnitFileName = workUnit.getId();

    if (workUnit instanceof MultiWorkUnit) {
      workUnitFileName += MULTI_WORK_UNIT_FILE_EXTENSION;
      stateStore = stateStores.getMwuStateStore();
    } else {
      workUnitFileName += WORK_UNIT_FILE_EXTENSION;
      stateStore = stateStores.getWuStateStore();
    }

    Path workUnitFile = new Path(workUnitFileDir, workUnitFileName);
    final String fileName = workUnitFile.getName();
    final String storeName = workUnitFile.getParent().getName();
    stateSerDeRunner.submitCallable(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        stateStore.put(storeName, fileName, workUnit);
        return null;
      }
    }, "Serialize state to store " + storeName + " file " + fileName);

    return workUnitFile.toString();
  }
699489
protected void createWorkUnits(SourceState state)
      throws IOException {
    createWorkunitsFromPreviousState(state);
    if (this.datasets.isEmpty()) {
      return;
    }
    for (HivePartitionDataset dataset : this.datasets) {
      Optional<String> owner = dataset.getOwner();
      if (workUnitsExceeded()) {
        log.info("Workunits exceeded");
        setJobWatermark(state, dataset.datasetURN());
        return;
      }
      if (!this.policy.shouldPurge(dataset)) {
        continue;
      }
      WorkUnit workUnit = createNewWorkUnit(dataset);
      log.info("Created new work unit with partition " + workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME));
      this.workUnitMap.put(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), workUnit);
      this.workUnitsCreatedCount++;
    }
    if (!state.contains(ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK)) {
      this.setJobWatermark(state, ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK);
    }
  }