Java Code Examples for org.apache.helix.HelixDataAccessor#getPropertyStat()

The following examples show how to use org.apache.helix.HelixDataAccessor#getPropertyStat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskUtil.java    From helix with Apache License 2.0 5 votes vote down vote up
/**
 * Cleans up IdealState and external view associated with a job/workflow resource.
 */
private static boolean cleanupIdealStateExtView(final HelixDataAccessor accessor,
    String workflowJobResource) {
  boolean success = true;
  PropertyKey isKey = accessor.keyBuilder().idealStates(workflowJobResource);
  if (accessor.getPropertyStat(isKey) != null) {
    if (!accessor.removeProperty(isKey)) {
      LOG.warn(String.format(
          "Error occurred while trying to remove IdealState for %s. Failed to remove node %s.",
          workflowJobResource, isKey));
      success = false;
    }
  }

  // Delete external view
  PropertyKey evKey = accessor.keyBuilder().externalView(workflowJobResource);
  if (accessor.getPropertyStat(evKey) != null) {
    if (!accessor.removeProperty(evKey)) {
      LOG.warn(String.format(
          "Error occurred while trying to remove ExternalView of resource %s. Failed to remove node %s.",
          workflowJobResource, evKey));
      success = false;
    }
  }

  return success;
}
 
Example 2
Source File: TaskUtil.java    From helix with Apache License 2.0 5 votes vote down vote up
/**
 * Remove workflow or job config.
 * @param accessor
 * @param workflowJobResource the workflow or job name
 */
private static boolean removeWorkflowJobConfig(HelixDataAccessor accessor,
    String workflowJobResource) {
  PropertyKey cfgKey = accessor.keyBuilder().resourceConfig(workflowJobResource);
  if (accessor.getPropertyStat(cfgKey) != null) {
    if (!accessor.removeProperty(cfgKey)) {
      LOG.warn(String.format(
          "Error occurred while trying to remove config for %s. Failed to remove node %s.",
          workflowJobResource, cfgKey));
      return false;
    }
  }

  return true;
}