Package org.apache.falcon.rerun.policy

Examples of org.apache.falcon.rerun.policy.AbstractRerunPolicy


*/
public class AbstractRerunPolicyTest {

    @Test
    public void testGetDurationInMillis() throws FalconException {
        AbstractRerunPolicy policy = new AbstractRerunPolicy() {

            @Override
            public long getDelay(Frequency delay, Date nominaltime,
                                 Date cutOffTime) throws FalconException {
                return 0;
            }

            @Override
            public long getDelay(Frequency delay, int eventNumber) throws FalconException {
                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


        Assert.assertEquals(policy.getDurationInMilliSec(frequency), 7200000);
    }

    @Test
    public void testExpBackoffPolicy() throws FalconException {
        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

        Assert.assertEquals(delay, 900000);
    }

    @Test
    public void testPeriodicPolicy() throws FalconException, 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

            LOG.warn("Feed Cut Off time: "
                    + SchemaHelper.formatDateUTC(cutOffTime)
                    + " has expired, Late Rerun can not be scheduled");
            return -1;
        } else {
            AbstractRerunPolicy rerunPolicy = RerunPolicyFactory
                    .getRetryPolicy(latePolicy);
            wait = rerunPolicy.getDelay(lateProcess.getDelay(), instanceDate,
                    cutOffTime);
        }
        return wait;
    }
View Full Code Here

            Frequency delay = retry.getDelay();
            PolicyType policy = retry.getPolicy();
            int intRunId = Integer.parseInt(runId);

            if (attempts > intRunId) {
                AbstractRerunPolicy rerunPolicy = RerunPolicyFactory.getRetryPolicy(policy);
                long delayTime = rerunPolicy.getDelay(delay, Integer.parseInt(runId));
                RetryEvent event = new RetryEvent(cluster, wfId,
                        msgReceivedTime, delayTime, entityType, entityName,
                        nominalTime, intRunId, attempts, 0);
                offerToQueue(event);
            } else {
View Full Code Here

    }

    @Override
    public void run() {
        int attempt = 1;
        AbstractRerunPolicy policy = new ExpBackoffPolicy();
        Frequency frequency = new Frequency("minutes(1)");
        while (true) {
            try {
                T message = null;
                try {
                    message = handler.takeFromQueue();
                    attempt = 1;
                } catch (FalconException e) {
                    LOG.error("Error while reading message from the queue: ", e);
                    GenericAlert.alertRerunConsumerFailed(
                            "Error while reading message from the queue: ", e);
                    Thread.sleep(policy.getDelay(frequency, attempt));
                    handler.reconnect();
                    attempt++;
                    continue;
                }
                String jobStatus = handler.getWfEngine().getWorkflowStatus(
View Full Code Here

            LOG.warn("Feed Cut Off time: "
                    + SchemaHelper.formatDateUTC(cutOffTime)
                    + " has expired, Late Rerun can not be scheduled");
            return -1;
        } else {
            AbstractRerunPolicy rerunPolicy = RerunPolicyFactory
                    .getRetryPolicy(latePolicy);
            wait = rerunPolicy.getDelay(lateProcess.getDelay(), instanceDate,
                    cutOffTime);
        }
        return wait;
    }
View Full Code Here

            Frequency delay = retry.getDelay();
            PolicyType policy = retry.getPolicy();
            int intRunId = Integer.parseInt(runId);

            if (attempts > intRunId) {
                AbstractRerunPolicy rerunPolicy = RerunPolicyFactory.getRetryPolicy(policy);
                long delayTime = rerunPolicy.getDelay(delay, Integer.parseInt(runId));
                RetryEvent event = new RetryEvent(clusterName, wfId,
                        msgReceivedTime, delayTime, entityType, entityName,
                        nominalTime, intRunId, attempts, 0, workflowUser);
                offerToQueue(event);
            } else {
View Full Code Here

    }

    @Override
    public void run() {
        int attempt = 1;
        AbstractRerunPolicy policy = new ExpBackoffPolicy();
        Frequency frequency = new Frequency("minutes(1)");
        while (true) {
            try {
                T message;
                try {
                    message = handler.takeFromQueue();
                    attempt = 1;
                } catch (FalconException e) {
                    LOG.error("Error while reading message from the queue: ", e);
                    GenericAlert.alertRerunConsumerFailed(
                            "Error while reading message from the queue: ", e);
                    Thread.sleep(policy.getDelay(frequency, attempt));
                    handler.reconnect();
                    attempt++;
                    continue;
                }
View Full Code Here

            LOG.warn("Feed Cut Off time: "
                    + SchemaHelper.formatDateUTC(cutOffTime)
                    + " has expired, Late Rerun can not be scheduled");
            return -1;
        } else {
            AbstractRerunPolicy rerunPolicy = RerunPolicyFactory
                    .getRetryPolicy(latePolicy);
            wait = rerunPolicy.getDelay(lateProcess.getDelay(), instanceDate,
                    cutOffTime);
        }
        return wait;
    }
View Full Code Here

TOP

Related Classes of org.apache.falcon.rerun.policy.AbstractRerunPolicy

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.