Package org.apache.ivory.entity.v0.process

Examples of org.apache.ivory.entity.v0.process.Process


        newFeed.getLateArrival().setCutOff(Frequency.fromString("hours(8)"));
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, cluster));
        newFeed.setFrequency(Frequency.fromString("days(1)"));
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, cluster));

        Process oldProcess = processParser.parseAndValidate(this.getClass().
                getResourceAsStream(PROCESS_XML));
        Process newProcess = (Process) oldProcess.copy();

        newProcess.getRetry().setPolicy(PolicyType.FINAL);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster));
        newProcess.getLateProcess().getLateInputs().remove(1);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster));
        newProcess.getLateProcess().setPolicy(PolicyType.PERIODIC);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster));
        newProcess.setFrequency(Frequency.fromString("days(1)"));
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster));
    }
View Full Code Here


        Assert.assertEquals(view.getClusters().getClusters().size(), 2);
    }

    @Test
    public void testEquals() throws Exception {
        Process process1 = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
                getClass().getResourceAsStream(PROCESS_XML));
        Process process2 = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
                getClass().getResourceAsStream(PROCESS_XML));
        Assert.assertTrue(EntityUtil.equals(process1, process2));
        Assert.assertTrue(EntityUtil.md5(process1).equals(EntityUtil.md5(process2)));

        process2.getClusters().getClusters().get(0).getValidity().setEnd(
                SchemaHelper.parseDateUTC("2013-04-21T00:00Z"));
        Assert.assertFalse(EntityUtil.equals(process1, process2));
        Assert.assertFalse(EntityUtil.md5(process1).equals(EntityUtil.md5(process2)));
        Assert.assertTrue(EntityUtil.equals(process1, process2, new String[]{"clusters.clusters[\\d+].validity.end"}));
    }
View Full Code Here

    public void testShouldUpdate() throws Exception {
        Feed oldFeed = parser.parseAndValidate(this.getClass()
                .getResourceAsStream(FEED_XML));

        Feed newFeed = (Feed) oldFeed.copy();
        Process process = processParser.parseAndValidate(this.getClass().
                getResourceAsStream(PROCESS_XML));

        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        newFeed.getLateArrival().setCutOff(Frequency.fromString("hours(1)"));
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        newFeed.getLateArrival().setCutOff(oldFeed.getLateArrival().getCutOff());
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        getLocation(newFeed, LocationType.DATA).setPath("/test");
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        getLocation(newFeed, LocationType.DATA).setPath(
                getLocation(oldFeed, LocationType.DATA).getPath());
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        newFeed.setFrequency(Frequency.fromString("months(1)"));
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        newFeed.setFrequency(oldFeed.getFrequency());
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        Partition partition = new Partition();
        partition.setName("1");
        newFeed.getPartitions().getPartitions().add(partition);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        Property property = new Property();
        property.setName("1");
        property.setValue("1");
        newFeed.setProperties(new Properties());
        newFeed.getProperties().getProperties().add(property);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        newFeed.getProperties().getProperties().remove(0);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        FeedHelper.getCluster(newFeed, process.getClusters().getClusters().get(0).getName()).getValidity().setStart(
                SchemaHelper.parseDateUTC("2012-11-01T00:00Z"));
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));

        FeedHelper.getCluster(newFeed, process.getClusters().getClusters().get(0).getName()).getValidity().
                setStart(FeedHelper.getCluster(oldFeed,
                        process.getClusters().getClusters().get(0).getName()).getValidity().getStart());
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldFeed, newFeed, process));
    }
View Full Code Here

        table.setUri("catalog:default:clicks-blah#ds=${YEAR}-${MONTH}-${DAY}-${HOUR}");
        newTableFeed.setTable(table);
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldTableFeed, newTableFeed, cluster));

        inputStream = getClass().getResourceAsStream("/config/process/process-table.xml");
        Process oldProcess = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(inputStream);
        Process newProcess = (Process) oldProcess.copy();

        newProcess.getRetry().setPolicy(PolicyType.FINAL);
        Assert.assertFalse(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster));
        newProcess.setFrequency(Frequency.fromString("days(1)"));
        Assert.assertTrue(UpdateHelper.shouldUpdate(oldProcess, newProcess, cluster));
    }
View Full Code Here

    private EntityGraph graph = EntityGraph.get();

    @Test
    public void testOnAdd() throws Exception {

        Process process = new Process();
        process.setName("p1");
        Cluster cluster = new Cluster();
        cluster.setName("c1");
        cluster.setColo("1");
        Feed f1 = addInput(process, "f1", cluster);
        Feed f2 = addInput(process, "f2", cluster);
        Feed f3 = addOutput(process, "f3", cluster);
        Feed f4 = addOutput(process, "f4", cluster);
        org.apache.falcon.entity.v0.process.Cluster processCluster = new org.apache.falcon.entity.v0.process.Cluster();
        processCluster.setName("c1");
        process.setClusters(new org.apache.falcon.entity.v0.process.Clusters());
        process.getClusters().getClusters().add(processCluster);

        store.publish(EntityType.CLUSTER, cluster);
        store.publish(EntityType.FEED, f1);
        store.publish(EntityType.FEED, f2);
        store.publish(EntityType.FEED, f3);
View Full Code Here

        return f1;
    }

    @Test
    public void testOnRemove() throws Exception {
        Process process = new Process();
        process.setName("rp1");
        Cluster cluster = new Cluster();
        cluster.setName("rc1");
        cluster.setColo("2");
        org.apache.falcon.entity.v0.process.Cluster processCluster = new org.apache.falcon.entity.v0.process.Cluster();
        processCluster.setName("rc1");
        process.setClusters(new org.apache.falcon.entity.v0.process.Clusters());
        process.getClusters().getClusters().add(processCluster);

        store.publish(EntityType.CLUSTER, cluster);
        store.publish(EntityType.PROCESS, process);

        Set<Entity> entities = graph.getDependents(process);
        Assert.assertEquals(entities.size(), 1);
        Assert.assertTrue(entities.contains(cluster));

        entities = graph.getDependents(cluster);
        Assert.assertEquals(entities.size(), 1);
        Assert.assertTrue(entities.contains(process));

        store.remove(EntityType.PROCESS, process.getName());
        entities = graph.getDependents(cluster);
        Assert.assertTrue(entities == null);

        entities = graph.getDependents(process);
        Assert.assertTrue(entities == null);
View Full Code Here

    }

    @Test
    public void testOnRemove2() throws Exception {

        Process p1 = new Process();
        p1.setName("ap1");
        Process p2 = new Process();
        p2.setName("ap2");
        Cluster cluster = new Cluster();
        cluster.setName("ac1");
        cluster.setColo("3");
        Feed f1 = addInput(p1, "af1", cluster);
        Feed f3 = addOutput(p1, "af3", cluster);
        Feed f2 = addOutput(p2, "af2", cluster);
        attachInput(p2, f3);
        org.apache.falcon.entity.v0.process.Cluster processCluster = new org.apache.falcon.entity.v0.process.Cluster();
        processCluster.setName("ac1");
        p1.setClusters(new org.apache.falcon.entity.v0.process.Clusters());
        p1.getClusters().getClusters().add(processCluster);
        processCluster = new org.apache.falcon.entity.v0.process.Cluster();
        processCluster.setName("ac1");
        p2.setClusters(new org.apache.falcon.entity.v0.process.Clusters());
        p2.getClusters().getClusters().add(processCluster);

        store.publish(EntityType.CLUSTER, cluster);
        store.publish(EntityType.FEED, f1);
        store.publish(EntityType.FEED, f2);
        store.publish(EntityType.FEED, f3);
        store.publish(EntityType.PROCESS, p1);
        store.publish(EntityType.PROCESS, p2);

        Set<Entity> entities = graph.getDependents(p1);
        Assert.assertEquals(entities.size(), 3);
        Assert.assertTrue(entities.contains(cluster));
        Assert.assertTrue(entities.contains(f1));
        Assert.assertTrue(entities.contains(f3));

        entities = graph.getDependents(p2);
        Assert.assertEquals(entities.size(), 3);
        Assert.assertTrue(entities.contains(cluster));
        Assert.assertTrue(entities.contains(f2));
        Assert.assertTrue(entities.contains(f3));

        entities = graph.getDependents(f1);
        Assert.assertEquals(entities.size(), 2);
        Assert.assertTrue(entities.contains(p1));
        Assert.assertTrue(entities.contains(cluster));

        entities = graph.getDependents(f2);
        Assert.assertEquals(entities.size(), 2);
        Assert.assertTrue(entities.contains(p2));
        Assert.assertTrue(entities.contains(cluster));

        entities = graph.getDependents(f3);
        Assert.assertEquals(entities.size(), 3);
        Assert.assertTrue(entities.contains(p2));
        Assert.assertTrue(entities.contains(p1));
        Assert.assertTrue(entities.contains(cluster));

        entities = graph.getDependents(cluster);
        Assert.assertEquals(entities.size(), 5);
        Assert.assertTrue(entities.contains(p1));
        Assert.assertTrue(entities.contains(p2));
        Assert.assertTrue(entities.contains(f1));
        Assert.assertTrue(entities.contains(f2));
        Assert.assertTrue(entities.contains(f3));

        store.remove(EntityType.PROCESS, p2.getName());
        store.remove(EntityType.FEED, f2.getName());

        entities = graph.getDependents(p1);
        Assert.assertEquals(entities.size(), 3);
        Assert.assertTrue(entities.contains(cluster));
View Full Code Here

            store(EntityType.valueOf(type.toUpperCase()), xml);
        }

        entity = args[2];
        Entity obj = EntityUtil.getEntity(type, entity);
        Process newEntity = (Process) obj.copy();
        newEntity.setFrequency(Frequency.fromString("minutes(5)"));
        System.out.println("##############OLD ENTITY " + EntityUtil.md5(obj));
        System.out.println("##############NEW ENTITY " + EntityUtil.md5(newEntity));


//        OozieWorkflowEngine engine = new OozieWorkflowEngine();
//        Date start = FORMATTER.parse("2010-01-02 01:05 UTC");
//        Date end = FORMATTER.parse("2010-01-02 01:21 UTC");
//        InstancesResult status = engine.suspendInstances(obj, start, end, new Properties());
//        System.out.println(Arrays.toString(status.getInstances()));
//        AbstractInstanceManager manager = new InstanceManager();
//        InstancesResult result = manager.suspendInstance(new NullServletRequest(), type, entity,
//                "2010-01-02T01:05Z", "2010-01-02T01:21Z", "*");

        DeploymentProperties.get().setProperty("deploy.mode", "standalone");
        StartupProperties.get().setProperty("current.colo", "ua1");
        OozieWorkflowEngine engine = new OozieWorkflowEngine();
        ConfigurationStore.get().initiateUpdate(newEntity);
        engine.update(obj, newEntity, newEntity.getClusters().getClusters().get(0).getName());
        engine.delete(newEntity);
        System.exit(0);
    }
View Full Code Here

            endTime = EntityUtil.parseDateUTC(nominalTime);
            long feedCutOffPeriod = evaluator.evaluate(lateCutOff, Long.class);
            endTime = addTime(endTime, feedCutOffPeriod);
            return endTime;
        } else if (entity.getEntityType() == EntityType.PROCESS) {
            Process process = (Process) entity;
            ConfigurationStore store = ConfigurationStore.get();
            for (LateInput lp : process.getLateProcess().getLateInputs()) {
                Feed feed = null;
                String endInstanceTime = "";
                for (Input input : process.getInputs().getInputs()) {
                    if (input.getName().equals(lp.getInput())) {
                        endInstanceTime = input.getEnd();
                        feed = store.get(EntityType.FEED, input.getFeed());
                        break;
                    }
View Full Code Here

                }
            }
            return (T) feed;

        case PROCESS:
            Process process = (Process) entity.copy();
            Iterator<org.apache.falcon.entity.v0.process.Cluster> procItr =
                process.getClusters().getClusters().iterator();
            while (procItr.hasNext()) {
                org.apache.falcon.entity.v0.process.Cluster cluster = procItr.next();
                if (!cluster.getName().equals(clusterName)) {
                    procItr.remove();
                }
View Full Code Here

TOP

Related Classes of org.apache.ivory.entity.v0.process.Process

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.