Package org.apache.falcon.resource

Examples of org.apache.falcon.resource.APIResult


            public APIResult execute() {
                try {
                    EntityUtil.getEntity(type, entity);
                    return super.execute();
                } catch (EntityNotRegisteredException e) {
                    return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") removed successfully");
                } catch (FalconException e) {
                    throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
                }
            }
View Full Code Here


        StringBuilder buffer = new StringBuilder();
        StringBuilder requestIds = new StringBuilder();
        int statusCount = 0;
        for (Entry<String, APIResult> entry : results.entrySet()) {
            String colo = entry.getKey();
            APIResult result = entry.getValue();
            buffer.append(colo).append('/').append(result.getMessage()).append('\n');
            requestIds.append(colo).append('/').append(result.getRequestId()).append('\n');
            statusCount += result.getStatus().ordinal();
        }

        APIResult.Status status = (statusCount == 0) ? APIResult.Status.SUCCEEDED
                : ((statusCount == results.size() * 2) ? APIResult.Status.FAILED : APIResult.Status.PARTIAL);
        APIResult result = new APIResult(status, buffer.toString());
        result.setRequestId(requestIds.toString());
        return result;
    }
View Full Code Here

            for (String colo : colos) {
                try {
                    results.put(colo, doExecute(colo));
                } catch (FalconException e) {
                    results.put(colo,
                            new APIResult(APIResult.Status.FAILED, e.getClass().getName() + "::" + e.getMessage()));
                }
            }
            APIResult finalResult = consolidateResult(results);
            if (finalResult.getStatus() != APIResult.Status.SUCCEEDED) {
                throw FalconWebException.newException(finalResult, Response.Status.BAD_REQUEST);
            } else {
                return finalResult;
            }
        }
View Full Code Here

    }

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

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

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

    }

    private String parseAPIResult(ClientResponse clientResponse)
        throws FalconCLIException {

        APIResult result = clientResponse.getEntity(APIResult.class);
        return result.getMessage();
    }
View Full Code Here

    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

    }

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

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

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

            public APIResult execute() {
                try {
                    EntityUtil.getEntity(type, entity);
                    return super.execute();
                } catch (EntityNotRegisteredException e) {
                    return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") removed successfully");
                } catch (FalconException e) {
                    throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
                }
            }
View Full Code Here

TOP

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

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.