Package org.apache.falcon.resource

Examples of org.apache.falcon.resource.InstancesResult$InstanceAction


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


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

            Map<String, InstancesResult> results = new HashMap<String, InstancesResult>();
            for (String colo : colos) {
                try {
                    InstancesResult resultHolder = doExecute(colo);
                    results.put(colo, resultHolder);
                } catch (FalconException 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 FalconWebException.newException(finalResult, Response.Status.BAD_REQUEST);
            } else {
                return finalResult;
            }
        }
View Full Code Here

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

        } catch (OozieClientException e) {
            throw new FalconException(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 FalconException(e);
        }
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

            String nominalTime = mapMessage.getString(ARG.nominalTime.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

        Assert.assertTrue(sourceFS.exists(new Path(SOURCE_LOCATION + PARTITION_VALUE)));
        // verify if the partition on the target exists
        FileSystem fs = FileSystem.get(ClusterHelper.getConfiguration(targetContext.getCluster().getCluster()));
        Assert.assertTrue(fs.exists(new Path(TARGET_LOCATION + PARTITION_VALUE)));

        InstancesResult response = targetContext.getService().path("api/instance/running/feed/" + feedName)
                .header("Remote-User", "guest")
                .accept(MediaType.APPLICATION_JSON)
                .get(InstancesResult.class);
        Assert.assertEquals(response.getStatus(), APIResult.Status.SUCCEEDED);

        TestContext.executeWithURL("entity -delete -type feed -name " + feedName);
        TestContext.executeWithURL("entity -delete -type cluster -name primary-cluster");
        TestContext.executeWithURL("entity -delete -type cluster -name bcp-cluster");
    }
View Full Code Here

        FileSystem gamma = FileSystem.get(ClusterHelper.getConfiguration(targetGammaContext.getCluster().getCluster()));
        Assert.assertTrue(
                gamma.exists(new Path("/falcon/test/target-cluster-gamma/customer_gamma/" + PARTITION_VALUE)));

        InstancesResult response = targetContext.getService().path("api/instance/running/feed/" + feedName)
                .header("Remote-User", "guest")
                .accept(MediaType.APPLICATION_JSON)
                .get(InstancesResult.class);
        Assert.assertEquals(response.getStatus(), APIResult.Status.SUCCEEDED);

        TestContext.executeWithURL("entity -delete -type feed -name " + feedName);
        TestContext.executeWithURL("entity -delete -type cluster -name primary-cluster");
        TestContext.executeWithURL("entity -delete -type cluster -name target-cluster-alpha");
        TestContext.executeWithURL("entity -delete -type cluster -name target-cluster-beta");
View Full Code Here

        Assert.assertTrue(alpha.exists(new Path("/localDC/rc/billing/ua1/" + partitionValue)));

        FileSystem beta = FileSystem.get(ClusterHelper.getConfiguration(targetBetaContext.getCluster().getCluster()));
        Assert.assertTrue(beta.exists(new Path("/localDC/rc/billing/ua2/" + partitionValue)));

        InstancesResult response = targetContext.getService().path("api/instance/running/feed/" + feedName)
                .header("Remote-User", "guest")
                .accept(MediaType.APPLICATION_JSON)
                .get(InstancesResult.class);
        Assert.assertEquals(response.getStatus(), APIResult.Status.SUCCEEDED);

        TestContext.executeWithURL("entity -delete -type feed -name " + feedName);
        TestContext.executeWithURL("entity -delete -type cluster -name primary-cluster");
        TestContext.executeWithURL("entity -delete -type cluster -name target-cluster-alpha");
        TestContext.executeWithURL("entity -delete -type cluster -name target-cluster-beta");
View Full Code Here

TOP

Related Classes of org.apache.falcon.resource.InstancesResult$InstanceAction

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.