Package org.apache.falcon.resource

Examples of org.apache.falcon.resource.InstancesSummaryResult


    public static FalconWebException newInstanceSummaryException(Throwable e, Response.Status status) {
        LOG.error("Failure reason", e);
        String message = e.getMessage() + "\n" + getAddnInfo(e);
        LOG.error("Action failed: " + status + "\nError:" + message);
        APIResult result = new InstancesSummaryResult(APIResult.Status.FAILED, message);
        return new FalconWebException(Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
    }
View Full Code Here


        StringBuilder requestIds = new StringBuilder();
        List<InstanceSummary> instances = new ArrayList<InstanceSummary>();
        int statusCount = 0;
        for (Map.Entry<String, InstancesSummaryResult> entry : results.entrySet()) {
            String colo = entry.getKey();
            InstancesSummaryResult 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.getInstancesSummary() == null) {
                continue;
            }

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

            Set<String> colos = getColosFromExpression(coloExpr, type, name);

            Map<String, InstancesSummaryResult> results = new HashMap<String, InstancesSummaryResult>();
            for (String colo : colos) {
                try {
                    InstancesSummaryResult resultHolder = doExecute(colo);
                    results.put(colo, resultHolder);
                } catch (FalconException e) {
                    results.put(colo, new InstancesSummaryResult(APIResult.Status.FAILED,
                            e.getClass().getName() + "::" + e.getMessage(),
                            new InstancesSummaryResult.InstanceSummary[0]));
                }
            }
            InstancesSummaryResult finalResult = consolidateInstanceSummaryResult(results);
            if (finalResult.getStatus() != APIResult.Status.SUCCEEDED) {
                throw FalconWebException.newException(finalResult, Response.Status.BAD_REQUEST);
            } else {
                return finalResult;
            }
        }
View Full Code Here

            InstanceSummary summary = new InstanceSummary(cluster, instancesSummary);
            instances.add(summary);
        }

        InstancesSummaryResult instancesSummaryResult =
            new InstancesSummaryResult(APIResult.Status.SUCCEEDED, JobAction.SUMMARY.name());
        instancesSummaryResult.setInstancesSummary(instances.toArray(new InstanceSummary[instances.size()]));
        return instancesSummaryResult;
    }
View Full Code Here

        return clientResponse.getEntity(String.class);
    }

    private String summarizeProcessInstanceResult(ClientResponse clientResponse) {
        InstancesSummaryResult result = clientResponse
                .getEntity(InstancesSummaryResult.class);
        StringBuilder sb = new StringBuilder();
        String toAppend;

        sb.append("Consolidated Status: ").append(result.getStatus()).append("\n");
        sb.append("\nInstances Summary:\n");

        if (result.getInstancesSummary() != null) {
            for (InstancesSummaryResult.InstanceSummary summary : result.getInstancesSummary()) {
                toAppend = summary.getCluster() != null ? summary.getCluster() : "-";
                sb.append("Cluster: ").append(toAppend).append("\n");

                sb.append("Status\t\tCount\n");
                sb.append("-------------------------\n");

                for (Map.Entry<String, Long> entry : summary.getSummaryMap().entrySet()) {
                    sb.append(entry.getKey()).append("\t\t").append(entry.getValue()).append("\n");
                }
            }
        }

        sb.append("\nAdditional Information:\n");
        sb.append("Response: ").append(result.getMessage());
        sb.append("Request Id: ").append(result.getRequestId());
        return sb.toString();
    }
View Full Code Here

TOP

Related Classes of org.apache.falcon.resource.InstancesSummaryResult

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.