Package org.apache.falcon.rerun.policy

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


        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


    }

    @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

    }

    @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

TOP

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

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.