Package org.apache.ivory.resource

Examples of org.apache.ivory.resource.InstancesResult$Instance


                        }
                        runInstances.add(instance);
                    }
                }
            }
            return new InstancesResult("Running Instances",
                    runInstances.toArray(new Instance[runInstances.size()]));

        } catch (OozieClientException e) {
            throw new IvoryException(e);
        }
View Full Code Here


            }
        }
        if (instanceCount < 2 && overallStatus == APIResult.Status.PARTIAL) {
            overallStatus = APIResult.Status.FAILED;
        }
        InstancesResult instancesResult = new InstancesResult(overallStatus,
                action.name());
        instancesResult.setInstances(instances.toArray(new Instance[instances
                .size()]));
        return instancesResult;
    }
View Full Code Here

            } else {
                instance.endTime = jobInfo.getEndTime();
            }
            instance.cluster = cluster;
            instances[0] = instance;
            return new InstancesResult("Instance for workflow id:" + jobId,
                    instances);
        } catch (Exception e) {
            throw new IvoryException(e);
        }
View Full Code Here

                entity(result).type(MediaType.TEXT_XML_TYPE).build());
    }

    public static IvoryWebException newInstanceException(String message, Response.Status status) {
        LOG.error("Action failed: " + status + "\nError:" + message);
        APIResult result = new InstancesResult(APIResult.Status.FAILED, message);
        return new IvoryWebException(Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
    }
View Full Code Here

    return clientResponse.getEntity(String.class);
  }

  private String parseProcessInstanceResult(ClientResponse clientResponse) {
    InstancesResult result = clientResponse
        .getEntity(InstancesResult.class);
    StringBuffer sb = new StringBuffer();
    String toAppend = null;
   
    sb.append("Consolidated Status: " + result.getStatus() + "\n");
   
    sb.append("\nInstances:\n");
    sb.append("Instance\t\tCluster\t\tSourceCluster\t\tStatus\t\tStart\t\tEnd\t\tDetails\t\t\t\t\tLog\n");
    sb.append("----------------------------------------------------------------------------------------------------------------------------------------\n");
    if(result.getInstances() != null){
      for (InstancesResult.Instance instance : result.getInstances()) {
       
        toAppend = instance.getInstance() != null  ? instance.getInstance() : "-";
        sb.append(toAppend + "\t");
       
        toAppend = instance.getCluster() != null ? instance.getCluster() : "-";
        sb.append(toAppend + "\t");
       
        toAppend = instance.getSourceCluster() != null ? instance.getSourceCluster() : "-";
        sb.append(toAppend + "\t")
       
        toAppend =  (instance.getStatus() != null ? instance.getStatus().toString() : "-");
        sb.append(toAppend + "\t")
       
        toAppend = instance.getStartTime() != null ? SchemaHelper.formatDateUTC(instance.getStartTime()) : "-";
        sb.append(toAppend + "\t")
       
        toAppend = instance.getEndTime() != null ? SchemaHelper.formatDateUTC(instance.getEndTime()) : "-";
        sb.append(toAppend + "\t");
       
        toAppend = (instance.getDetails() != null && !instance.getDetails().equals("")) ? instance.getDetails() : "-";
        sb.append(toAppend + "\t");
       
        toAppend = instance.getLogFile() != null ? instance.getLogFile() : "-";
        sb.append(toAppend + "\n")
       
      }
    }
    sb.append("\nAdditional Information:\n");
    sb.append("Response: " + result.getMessage());
    sb.append("Request Id: " + result.getRequestId() );
    return sb.toString();
  }
View Full Code Here

    sb.append("Request Id: " + result.getRequestId() );
    return sb.toString();
  }
 
  private String parseProcessInstanceResultLogs(ClientResponse clientResponse, String runid) {
    InstancesResult result = clientResponse
        .getEntity(InstancesResult.class);
    StringBuffer sb = new StringBuffer();
    String toAppend = null;
   
    sb.append("Consolidated Status: " + result.getStatus() + "\n");
   
    sb.append("\nInstances:\n");
    sb.append("Instance\t\tCluster\t\tSourceCluster\t\tStatus\t\tRunID\t\t\tLog\n");
    sb.append("----------------------------------------------------------------------------------------------------\n");
    if(result.getInstances() != null){
      for (InstancesResult.Instance instance : result.getInstances()) {
       
        toAppend = (instance.getInstance() != null ) ? instance.getInstance() : "-";
        sb.append(toAppend + "\t");
       
        toAppend = instance.getCluster() != null ? instance.getCluster() : "-";
        sb.append(toAppend + "\t");
       
        toAppend = instance.getSourceCluster() != null ? instance.getSourceCluster() : "-";
        sb.append(toAppend + "\t")
       
        toAppend =  (instance.getStatus() != null ? instance.getStatus().toString() : "-");
        sb.append(toAppend + "\t")
       
        toAppend =  (runid != null ? runid : "latest");
        sb.append(toAppend + "\t")
       
        toAppend = instance.getLogFile() != null ? instance.getLogFile() : "-";
        sb.append(toAppend + "\n")
       
       
        if (instance.actions != null) {
          sb.append("actions:\n");
          for (InstancesResult.InstanceAction action : instance.actions) {
            sb.append("    ").append(action.getAction()+ "\t" + action.getStatus() + "\t" + action.getLogFile()).append("\n");
          }
        }
      }
    }
    sb.append("\nAdditional Information:\n");
    sb.append("Response: " + result.getMessage());
    sb.append("Request Id: " + result.getRequestId() );
    return sb.toString();
  }
View Full Code Here

          .getArgName());
      String status = mapMessage.getString(ARG.status.getArgName());
      String operation = mapMessage.getString(ARG.operation.getArgName());

      AbstractWorkflowEngine wfEngine = WorkflowEngineFactory.getWorkflowEngine();
      InstancesResult result = wfEngine
          .getJobDetails(cluster, workflowId);
            Date startTime = result.getInstances()[0].startTime;
            Date endTime = result.getInstances()[0].endTime;
            Long duration = (endTime.getTime() - startTime.getTime()) * 1000000;
      if (status.equalsIgnoreCase("FAILED")) {
        retryHandler.handleRerun(cluster, entityType, entityName,
            nominalTime, runId, workflowId,
            System.currentTimeMillis());
View Full Code Here

        StringBuilder message = new StringBuilder();
        StringBuilder requestIds = new StringBuilder();
        List<Instance> instances = new ArrayList<Instance>();
        int statusCount = 0;
        for (String colo:results.keySet()) {
            InstancesResult result = results.get(colo);
            message.append(colo).append('/').append(result.getMessage()).append('\n');
            requestIds.append(colo).append('/').append(result.getRequestId()).append('\n');
            statusCount += result.getStatus().ordinal();

            if (result.getInstances() == null) continue;

            for (Instance instance : result.getInstances()) {
              instance.instance = instance.getInstance();
              instances.add(instance);
            }
        }
        Instance[] arrInstances = new Instance[instances.size()];
        APIResult.Status status = (statusCount == 0) ? APIResult.Status.SUCCEEDED
                : ((statusCount == results.size() * 2) ? APIResult.Status.FAILED : APIResult.Status.PARTIAL);
        InstancesResult result = new InstancesResult(status, message.toString(), instances.toArray(arrInstances));
        result.setRequestId(requestIds.toString());
        return result;
    }
View Full Code Here

                        results.put(colo, (InstancesResult) resultHolder);
                    } else {
                        throw new IvoryException(resultHolder.getMessage());
                    }
                } catch (IvoryException e) {
                    results.put(colo, new InstancesResult(APIResult.Status.FAILED,
                            e.getClass().getName() + "::" + e.getMessage(),
                            new InstancesResult.Instance[0]));
                }
            }
            InstancesResult finalResult = consolidateInstanceResult(results);
            if (finalResult.getStatus() != APIResult.Status.SUCCEEDED) {
                throw IvoryWebException.newException(finalResult, Response.Status.BAD_REQUEST);
            } else {
                return finalResult;
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.ivory.resource.InstancesResult$Instance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.