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

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


    @Test
    public void testGetInstanceSequence6() throws Exception {
        Date instance = getDate("2010-01-01 01:04 UTC");
        Date start = getDate("2010-01-01 01:01 UTC");

        Frequency frequency = Frequency.fromString("minutes(3)");
        Assert.assertEquals(2, EntityUtil.getInstanceSequence(start,
                frequency, tz, instance));
    }
View Full Code Here


    @Test
    public void testGetInstanceSequence7() throws Exception {
        Date instance = getDate("2010-01-01 01:03 UTC");
        Date start = getDate("2010-01-01 01:01 UTC");

        Frequency frequency = Frequency.fromString("minutes(1)");
        Assert.assertEquals(3, EntityUtil.getInstanceSequence(start,
                frequency, tz, instance));
    }
View Full Code Here

        // TODO Auto-generated method stub
        return 0;
      }
    };

    Frequency frequency = new Frequency("minutes(1)");
    Assert.assertEquals(policy.getDurationInMilliSec(frequency), 60000);
    frequency = new Frequency("minutes(15)");
    Assert.assertEquals(policy.getDurationInMilliSec(frequency), 900000);
    frequency = new Frequency("hours(2)");
    Assert.assertEquals(policy.getDurationInMilliSec(frequency), 7200000);
  }
View Full Code Here

  }

  @Test
  public void TestExpBackoffPolicy() throws IvoryException {
    AbstractRerunPolicy backoff = new ExpBackoffPolicy();
    long delay = backoff.getDelay(new Frequency("minutes(2)"), 2);
    Assert.assertEquals(delay, 480000);

    long currentTime = System.currentTimeMillis();
    delay = backoff.getDelay(new Frequency("minutes(2)"), new Date(
        currentTime - 1 * 4 * 60 * 1000), new Date(currentTime + 1 * 60
        * 60 * 1000));
    Assert.assertEquals(delay, 1 * 6 * 60 * 1000);
   
    currentTime = System.currentTimeMillis();
    delay = backoff.getDelay(new Frequency("minutes(1)"), new Date(
        currentTime - 1 * 9 * 60 * 1000), new Date(currentTime + 1 * 60
        * 60 * 1000));
    Assert.assertEquals(delay, 900000);
  }
View Full Code Here

  }

  @Test
  public void TestPeriodicPolicy() throws IvoryException, InterruptedException {
    AbstractRerunPolicy periodic = new PeriodicPolicy();
    long delay = periodic.getDelay(new Frequency("minutes(2)"), 2);
    Assert.assertEquals(delay, 120000);
    delay = periodic.getDelay(new Frequency("minutes(2)"), 5);
    Assert.assertEquals(delay, 120000);

    long currentTime = System.currentTimeMillis();
    //Thread.sleep(1000);
    delay = periodic.getDelay(new Frequency("minutes(3)"), new Date(
        currentTime), new Date(currentTime + 1 * 60
        * 60 * 1000));
    Assert.assertEquals(delay, 180000);
  }
View Full Code Here

     
            replicationCoord.getControls().setTimeout(String.valueOf(timeout_ms / (1000 * 60)));
            replicationCoord.getControls().setThrottle(String.valueOf(timeout_ms / frequency_ms * 2));
            replicationCoord.getControls().setConcurrency(String.valueOf(parallel));
           
      Frequency replicationDelay = FeedHelper.getCluster(feed,
          srcCluster.getName()).getDelay();
      long delay_ms=0;
      if (replicationDelay != null) {
        delay_ms = ExpressionHelper.get().evaluate(
            replicationDelay.toString(), Long.class);
        long delay_mins = -1 * delay_ms / (1000 * 60);
        String elExp = "${now(0," + delay_mins + ")}";
        replicationCoord.getInputEvents().getDataIn().get(0)
            .getInstance().set(0, elExp);
        replicationCoord.getOutputEvents().getDataOut().get(0)
View Full Code Here

                if (entity == null) {
                    LOG.warn("No entity for " + key);
                    continue;
                }
                Date startTime = EntityUtil.getStartTime(entity, cluster);
                Frequency frequency = EntityUtil.getFrequency(entity);
                TimeZone timeZone = EntityUtil.getTimeZone(entity);
                Date nextStart = EntityUtil.getNextStartTime(startTime, frequency, timeZone, now);
                if (nextStart.after(windowEndTime)) continue;
                ConcurrentMap<Date, Date> pendingInstances = pendingJobs.get(key);
                while (!nextStart.after(windowEndTime)) {
                    if (pendingInstances == null) {
                        pendingJobs.putIfAbsent(key, new ConcurrentHashMap<Date, Date>());
                        pendingInstances = pendingJobs.get(key);
                    }
                    Long latency = monitoredEntities.get(key);
                    if (latency == null) break;
                    pendingInstances.putIfAbsent(nextStart, new Date(nextStart.getTime() +
                            latency * 1500))//1.5 times latency is when it is supposed to have breached
                    LOG.debug("Adding to pending jobs: " + key + " ---> " +
                            SchemaHelper.formatDateUTC(nextStart));
                    Calendar startCal = Calendar.getInstance(timeZone);
                    startCal.setTime(nextStart);
                    startCal.add(frequency.getTimeUnit().getCalendarUnit(), frequency.getFrequency());
                    nextStart = startCal.getTime();
                }
            }
        }
View Full Code Here

        String coordName = EntityUtil.getWorkflowName(Tag.RETENTION, feed).toString();
        retentionApp.setName(coordName);
        retentionApp.setEnd(SchemaHelper.formatDateUTC(feedCluster.getValidity().getEnd()));
        retentionApp.setStart(SchemaHelper.formatDateUTC(new Date()));
        retentionApp.setTimezone(feed.getTimezone().getID());
        TimeUnit timeUnit = feed.getFrequency().getTimeUnit();
        if (timeUnit == TimeUnit.hours || timeUnit == TimeUnit.minutes) {
            retentionApp.setFrequency("${coord:hours(6)}");
        } else {
            retentionApp.setFrequency("${coord:days(1)}");
        }
View Full Code Here

    public FileSystem getFileSystem() throws IOException {
        return FileSystem.get(conf);
    }

    private void buildClusterObject(String name) {
        clusterEntity = new Cluster();
        clusterEntity.setName(name);
        clusterEntity.setColo("local");
        clusterEntity.setDescription("Embeded cluster: " + name);

        Interfaces interfaces = new Interfaces();
View Full Code Here

        Assert.assertEquals(FeedHelper.normalizePartitionExpression(null, null), "");
    }
   
    @Test
    public void testEvaluateExpression() throws Exception {
        Cluster cluster = new Cluster();
        cluster.setName("name");
        cluster.setColo("colo");
        cluster.setProperties(new Properties());
        Property prop = new Property();
        prop.setName("pname");
        prop.setValue("pvalue");
        cluster.getProperties().getProperties().add(prop);
       
        Assert.assertEquals(FeedHelper.evaluateClusterExp(cluster, "${cluster.colo}/*/US"), "colo/*/US");
        Assert.assertEquals(FeedHelper.evaluateClusterExp(cluster, "${cluster.name}/*/${cluster.pname}"), "name/*/pvalue");
        Assert.assertEquals(FeedHelper.evaluateClusterExp(cluster, "IN"), "IN");
    }
View Full Code Here

TOP

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

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.