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

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


    store.publish(EntityType.FEED, feed1);
    store.publish(EntityType.FEED, feed2);
    store.publish(EntityType.FEED, feed3);

    Process process1 = (Process) EntityType.PROCESS.getUnmarshaller()
        .unmarshal(this.getClass().getResource(PROCESS1_XML));
    store.publish(EntityType.PROCESS, process1);
    Process process2 = (Process) EntityType.PROCESS.getUnmarshaller()
        .unmarshal(this.getClass().getResource(PROCESS2_XML));
    store.publish(EntityType.PROCESS, process2);

  }
View Full Code Here


     * @return COORDINATORAPP
     * @throws IvoryException
     *             on Error
     */
    public COORDINATORAPP createDefaultCoordinator(Cluster cluster, Path bundlePath) throws IvoryException {
        Process process = getEntity();
        if (process == null)
            return null;

        COORDINATORAPP coord = new COORDINATORAPP();
        String coordName = EntityUtil.getWorkflowName(Tag.DEFAULT,process).toString();
        Path coordPath = getCoordPath(bundlePath, coordName);

        // coord attributes
        coord.setName(coordName);
        org.apache.ivory.entity.v0.process.Cluster processCluster = ProcessHelper.getCluster(process, cluster.getName());
        coord.setStart(SchemaHelper.formatDateUTC(processCluster.getValidity().getStart()));
        coord.setEnd(SchemaHelper.formatDateUTC(processCluster.getValidity().getEnd()));
        coord.setTimezone(process.getTimezone().getID());
        coord.setFrequency("${coord:" + process.getFrequency().toString() + "}");

        // controls
        CONTROLS controls = new CONTROLS();
        controls.setConcurrency(String.valueOf(process.getParallel()));
        controls.setExecution(process.getOrder().name());

        Frequency timeout = process.getTimeout();
        long frequency_ms = ExpressionHelper.get().
                evaluate(process.getFrequency().toString(), Long.class);
        long timeout_ms;
        if (timeout != null) {
            timeout_ms = ExpressionHelper.get().
                    evaluate(process.getTimeout().toString(), Long.class);
        } else {
            timeout_ms = frequency_ms * 6;
            if (timeout_ms < THIRTY_MINUTES) timeout_ms = THIRTY_MINUTES;
        }
        controls.setTimeout(String.valueOf(timeout_ms / (1000 * 60)));
        if (timeout_ms / frequency_ms * 2 > 0) {
            controls.setThrottle(String.valueOf(timeout_ms / frequency_ms * 2));
        }
        coord.setControls(controls);

        // Configuration
        Map<String, String> props = createCoordDefaultConfiguration(cluster, coordPath, coordName);

        List<String> inputFeeds = new ArrayList<String>();
        List<String> inputPaths = new ArrayList<String>();
        // inputs
        if (process.getInputs() != null) {           
            for (Input input : process.getInputs().getInputs()) {
                if(!input.isOptional()) {
                    if (coord.getDatasets() == null)
                        coord.setDatasets(new DATASETS());
                    if (coord.getInputEvents() == null)
                        coord.setInputEvents(new INPUTEVENTS());

                    SYNCDATASET syncdataset = createDataSet(input.getFeed(), cluster, input.getName(), LocationType.DATA);
                    coord.getDatasets().getDatasetOrAsyncDataset().add(syncdataset);
   
                    DATAIN datain = createDataIn(input);
                    coord.getInputEvents().getDataIn().add(datain);
                }

                String inputExpr = getELExpression("dataIn('" + input.getName() + "', '" + input.getPartition() + "')");
                props.put(input.getName(), inputExpr);
                inputFeeds.add(input.getName());
                inputPaths.add(inputExpr);

            }
        }
        props.put("ivoryInPaths", join(inputPaths.iterator(), '#'));
        props.put("ivoryInputFeeds", join(inputFeeds.iterator(), '#'));

        // outputs
        List<String> outputFeeds = new ArrayList<String>();
        List<String> outputPaths = new ArrayList<String>();
        if (process.getOutputs() != null) {
            if (coord.getDatasets() == null)
                coord.setDatasets(new DATASETS());
            if (coord.getOutputEvents() == null)
                coord.setOutputEvents(new OUTPUTEVENTS());
           
            for (Output output : process.getOutputs().getOutputs()) {
                SYNCDATASET syncdataset = createDataSet(output.getFeed(), cluster, output.getName(),LocationType.DATA);
                coord.getDatasets().getDatasetOrAsyncDataset().add(syncdataset);

                DATAOUT dataout = createDataOut(output);
                coord.getOutputEvents().getDataOut().add(dataout);
View Full Code Here

        return expr;
    }

    @Override
    protected Map<String, String> getEntityProperties() {
        Process process = getEntity();
        Map<String, String> props = new HashMap<String, String>();
        if (process.getProperties() != null) {
            for (Property prop : process.getProperties().getProperties())
                props.put(prop.getName(), prop.getValue());
        }
        return props;
    }
View Full Code Here

  @Override
  public void cleanup() throws IvoryException {
    Collection<String> processes = STORE.getEntities(EntityType.PROCESS);
    for (String processName : processes) {
      Process process;
      process = STORE.get(EntityType.PROCESS, processName);
      long retention = getRetention(process, process.getFrequency()
          .getTimeUnit());
      for (org.apache.ivory.entity.v0.process.Cluster cluster : process
          .getClusters().getClusters()) {
        Cluster currentCluster = STORE.get(EntityType.CLUSTER,
            cluster.getName());
        if(currentCluster.getColo().equals(getCurrentColo())){
          LOG.info("Cleaning up logs for process:" + processName
View Full Code Here

public class EntityUtilTest extends AbstractTestBase{
    private static TimeZone tz = TimeZone.getTimeZone("UTC");

    @Test
    public void testProcessView() throws Exception {
        Process process = (Process) EntityType.PROCESS.getUnmarshaller().unmarshal(
                getClass().getResourceAsStream(PROCESS_XML));
        Cluster cluster = new Cluster();
        cluster.setName("newCluster");
        cluster.setValidity(process.getClusters().getClusters().get(0).getValidity());
        process.getClusters().getClusters().add(cluster);
        Assert.assertEquals(process.getClusters().getClusters().size(), 2);
        String currentCluster = process.getClusters().getClusters().get(0).getName();
        Process newProcess = EntityUtil.getClusterView(process, currentCluster);
        Assert.assertFalse(EntityUtil.equals(process, newProcess));
        Assert.assertEquals(newProcess.getClusters().getClusters().size(), 1);
        Assert.assertEquals(newProcess.getClusters().getClusters().get(0).getName(), currentCluster);
    }
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

        // TODO for retry and late policy
    }

    @Test
    public void testELExpressions() throws Exception {
        Process process = parser.parseAndValidate(getClass().getResourceAsStream(PROCESS_XML));
        process.getInputs().getInputs().get(0).setStart("lastMonth(0,0,0)");
        try {
            parser.validate(process);
            throw new AssertionError("Expected ValidationException!");
        } catch (ValidationException e) { }

        process.getInputs().getInputs().get(0).setStart("today(0,0)");
        process.getInputs().getInputs().get(0).setEnd("lastMonth(0,0,0)");
        try {
            parser.validate(process);
            throw new AssertionError("Expected ValidationException!");
        } catch (ValidationException e) { }

        process.getInputs().getInputs().get(0).setStart("today(2,0)");
        process.getInputs().getInputs().get(0).setEnd("today(0,0)");
        try {
            parser.validate(process);
            throw new AssertionError("Expected ValidationException!");
        } catch (ValidationException e) { }
View Full Code Here

        parser.parseAndValidate(this.getClass().getResourceAsStream(INVALID_PROCESS_XML ));
    }

    @Test(expectedExceptions = ValidationException.class)
    public void applyValidationInvalidProcess() throws Exception {
        Process process = (Process) parser.parseAndValidate(getClass().getResourceAsStream(PROCESS_XML));
        process.getClusters().getClusters().get(0).setName("invalid cluster");
        parser.validate(process);
    }
View Full Code Here

        }
    }

  @Test(expectedExceptions = ValidationException.class)
  public void testInvalidProcessValidity() throws Exception {
    Process process = parser
        .parseAndValidate((ProcessEntityParserTest.class
            .getResourceAsStream(PROCESS_XML)));
    process.getClusters().getClusters().get(0).getValidity().setStart(SchemaHelper.parseDateUTC("2011-12-31T00:00Z"));
    parser.validate(process);
  }
View Full Code Here

    parser.validate(process);
  }
 
  @Test(expectedExceptions = ValidationException.class)
  public void testInvalidDependentFeedsRetentionLimit() throws Exception {
    Process process = parser
        .parseAndValidate((ProcessEntityParserTest.class
            .getResourceAsStream(PROCESS_XML)));
    process.getInputs().getInputs().get(0).setStart("today(-48,0)");
    parser.validate(process);
  }
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.