The purpose of user defined content store is to provide an easy use feature for some task dedicated meta temporary store. In this chapter, we'll learn how to implement and use content store in the user defined tasks.

Content Store Implementation

Extends abstract class UserContentStore.

private static class ContentStoreTask extends UserContentStore implements Task {
  @Override public TaskResult run() {
    ...
  }
  @Override public void cancel() {
    ...
  }
}

The default methods support 3 types of scopes:

  1. WORKFLOW: Define the content store in workflow level
  2. JOB: Define the content store in job level
  3. TASK: Define the content store in task level

Content Store Usage

Access content store in Task.run() method.

  private static class ContentStoreTask extends UserContentStore implements Task {
    @Override public TaskResult run() {
      // put values into the store
      putUserContent("ContentTest", "Value1", Scope.JOB);
      putUserContent("ContentTest", "Value2", Scope.WORKFLOW);
      putUserContent("ContentTest", "Value3", Scope.TASK);
      
      // get the values with the same key in the different scopes
      if (!getUserContent("ContentTest", Scope.JOB).equals("Value1") ||
          !getUserContent("ContentTest", Scope.WORKFLOW).equals("Value2") ||
          !getUserContent("ContentTest", Scope.TASK).equals("Value3")) {
        return new TaskResult(TaskResult.Status.FAILED, null);
      }
      
      return new TaskResult(TaskResult.Status.COMPLETED, null);
    }
  }

Back to top

Reflow Maven skin maintained by Olivier Lamy.

Apache Helix, Apache, the Apache feather logo, and the Apache Helix project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Privacy Policy