// Populates the InstancesResult.Instance instance using ExecutionInstance
 private void populateInstanceInfo(
     InstancesResult.Instance instanceInfo, ExecutionInstance instance)
     throws StateStoreException {
   instanceInfo.cluster = instance.getCluster();
   InstanceState.STATE state =
       STATE_STORE.getExecutionInstance(instance.getId()).getCurrentState();
   switch (state) {
     case SUCCEEDED:
       instanceInfo.status = InstancesResult.WorkflowStatus.SUCCEEDED;
       break;
     case FAILED:
       instanceInfo.status = InstancesResult.WorkflowStatus.FAILED;
       break;
     case KILLED:
       instanceInfo.status = InstancesResult.WorkflowStatus.KILLED;
       break;
     case READY:
       instanceInfo.status = InstancesResult.WorkflowStatus.READY;
       break;
     case WAITING:
       instanceInfo.status = InstancesResult.WorkflowStatus.WAITING;
       break;
     case SUSPENDED:
       instanceInfo.status = InstancesResult.WorkflowStatus.SUSPENDED;
       break;
     case RUNNING:
       instanceInfo.status = InstancesResult.WorkflowStatus.RUNNING;
       break;
     default:
       instanceInfo.status = InstancesResult.WorkflowStatus.UNDEFINED;
       break;
   }
   // Mask wfParams by default
   instanceInfo.wfParams = null;
 }
 private InstancesResult.Instance performAction(
     String cluster,
     Entity entity,
     JobAction action,
     ExecutionInstance instance,
     Properties userProps,
     boolean isForced)
     throws FalconException {
   EntityExecutor executor = EXECUTION_SERVICE.getEntityExecutor(entity, cluster);
   InstancesResult.Instance instanceInfo = null;
   LOG.debug("Retrieving information for {} for action {}", instance.getId(), action);
   if (StringUtils.isNotEmpty(instance.getExternalID())) {
     instanceInfo = DAGEngineFactory.getDAGEngine(cluster).info(instance.getExternalID());
   } else {
     instanceInfo = new InstancesResult.Instance();
   }
   switch (action) {
     case KILL:
       executor.kill(instance);
       populateInstanceInfo(instanceInfo, instance);
       break;
     case SUSPEND:
       executor.suspend(instance);
       populateInstanceInfo(instanceInfo, instance);
       break;
     case RESUME:
       executor.resume(instance);
       populateInstanceInfo(instanceInfo, instance);
       break;
     case RERUN:
       executor.rerun(instance, userProps, isForced);
       populateInstanceInfo(instanceInfo, instance);
       break;
     case STATUS:
       // Mask wfParams
       instanceInfo.wfParams = null;
       if (StringUtils.isNotEmpty(instance.getExternalID())) {
         List<InstancesResult.InstanceAction> instanceActions =
             DAGEngineFactory.getDAGEngine(cluster).getJobDetails(instance.getExternalID());
         instanceInfo.actions =
             instanceActions.toArray(new InstancesResult.InstanceAction[instanceActions.size()]);
         // If not scheduled externally yet, get details from state
       } else {
         populateInstanceInfo(instanceInfo, instance);
       }
       break;
     case PARAMS:
       // Mask details, log
       instanceInfo.details = null;
       instanceInfo.logFile = null;
       Properties props =
           DAGEngineFactory.getDAGEngine(cluster).getConfiguration(instance.getExternalID());
       InstancesResult.KeyValuePair[] keyValuePairs =
           new InstancesResult.KeyValuePair[props.size()];
       int i = 0;
       for (String name : props.stringPropertyNames()) {
         keyValuePairs[i++] = new InstancesResult.KeyValuePair(name, props.getProperty(name));
       }
       instanceInfo.wfParams = keyValuePairs;
       break;
     default:
       throw new IllegalArgumentException("Unhandled action " + action);
   }
   return instanceInfo;
 }