Package com.asakusafw.yaess.core

Examples of com.asakusafw.yaess.core.ExecutionLock


        conf.put(BasicLockProvider.KEY_DIRECTORY, lockDir.getAbsolutePath());

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader()));
        ExecutionLockProvider instance = profile.newInstance();
        ExecutionLock lock = instance.newInstance("batch");
        try {
            lock.beginFlow("flow", "exec");
            assertThat(lockDir.list().length, is(greaterThan(start)));
        } finally {
            lock.close();
        }
        assertThat(lockDir.list().length, is(start));
    }
View Full Code Here


        conf.put(BasicLockProvider.KEY_DIRECTORY, "${LOCATION}");

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, new ProfileContext(getClass().getClassLoader(), var));
        ExecutionLockProvider instance = profile.newInstance();
        ExecutionLock lock = instance.newInstance("batch");
        try {
            lock.beginFlow("flow", "exec");
            assertThat(lockDir.list().length, is(greaterThan(start)));
        } finally {
            lock.close();
        }
        assertThat(lockDir.list().length, is(start));
    }
View Full Code Here

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader()));
        ExecutionLockProvider instance1 = profile.newInstance();
        ExecutionLockProvider instance2 = profile.newInstance();

        ExecutionLock lock = instance1.newInstance("batch1");
        try {
            try {
                instance2.newInstance("batch1");
                fail("cannot run same batch");
            } catch (IOException e) {
                // ok.
            }
            try {
                instance2.newInstance("batch2");
                fail("cannot run any batch");
            } catch (IOException e) {
                // ok.
            }
            // can acquire any flow/exec lock in same
            lock.beginFlow("flow1", "exec1");
            lock.beginFlow("flow2", "exec1");
            try {
                lock.beginFlow("flow1", "exec1");
                fail("cannot reentrant same flow");
            } catch (IOException e) {
                // ok.
            }
        } finally {
            lock.close();
        }
    }
View Full Code Here

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader()));
        ExecutionLockProvider instance1 = profile.newInstance();
        ExecutionLockProvider instance2 = profile.newInstance();

        ExecutionLock lock = instance1.newInstance("batch1");
        try {
            lock.beginFlow("flow1", "exec1");
            try {
                instance2.newInstance("batch1");
                fail("cannot run same batch");
            } catch (IOException e) {
                // ok.
            }
            ExecutionLock other = instance2.newInstance("batch2");
            try {
                // can acquire any flow/exec lock
                other.beginFlow("flow2", "exec1");
                other.endFlow("flow2", "exec1");
                other.beginFlow("flow1", "exec2");
                other.endFlow("flow1", "exec2");
                other.beginFlow("flow2", "exec2");
                other.endFlow("flow2", "exec2");
            } finally {
                other.close();
            }
        } finally {
            lock.close();
        }
    }
View Full Code Here

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader()));
        ExecutionLockProvider instance1 = profile.newInstance();
        ExecutionLockProvider instance2 = profile.newInstance();

        ExecutionLock lock = instance1.newInstance("batch1");
        try {
            lock.beginFlow("flow1", "exec1");
            ExecutionLock other = instance2.newInstance("batch1");
            try {
                // can acquire other flow lock
                other.beginFlow("flow2", "exec1");
                other.endFlow("flow2", "exec1");
                other.beginFlow("flow2", "exec2");
                other.endFlow("flow2", "exec2");

                try {
                    other.beginFlow("flow1", "exec2");
                    fail("cannot run same flow");
                } catch (IOException e) {
                    // ok.
                }
            } finally {
                other.close();
            }

            other = instance2.newInstance("batch2");
            try {
                // can acquire any flow lock if batch is different
                other.beginFlow("flow1", "exec1");
            } finally {
                other.close();
            }
        } finally {
            lock.close();
        }
    }
View Full Code Here

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader()));
        ExecutionLockProvider instance1 = profile.newInstance();
        ExecutionLockProvider instance2 = profile.newInstance();

        ExecutionLock lock = instance1.newInstance("batch1");
        try {
            lock.beginFlow("flow1", "exec1");
            ExecutionLock other = instance2.newInstance("batch1");
            try {
                // can acquire other flow lock
                other.beginFlow("flow2", "exec1");
                other.endFlow("flow2", "exec1");
                other.beginFlow("flow2", "exec2");
                other.endFlow("flow2", "exec2");

                // can acquire other execution lock
                other.beginFlow("flow1", "exec2");
                other.endFlow("flow1", "exec2");

                try {
                    other.beginFlow("flow1", "exec1");
                    fail("cannot run same execution");
                } catch (IOException e) {
                    // ok.
                }
            } finally {
                other.close();
            }

            other = instance2.newInstance("batch2");
            try {
                // can acquire any flow lock if batch is different
                other.beginFlow("flow1", "exec1");
            } finally {
                other.close();
            }
        } finally {
            lock.close();
        }
    }
View Full Code Here

        conf.put(BasicLockProvider.KEY_DIRECTORY, lockDir.getAbsolutePath());

        ServiceProfile<ExecutionLockProvider> profile = new ServiceProfile<ExecutionLockProvider>(
                "testing", BasicLockProvider.class, conf, ProfileContext.system(getClass().getClassLoader()));
        ExecutionLockProvider instance = profile.newInstance();
        ExecutionLock lock = instance.newInstance("batch");
        try {
            lock.beginFlow("a", "b");
            lock.endFlow("a", "b");
        } finally {
            lock.close();
        }
    }
View Full Code Here

        }
        ExecutorService executor = createJobflowExecutor(batchId);
        YSLOG.info("I01000", batchId);
        long start = System.currentTimeMillis();
        try {
            ExecutionLock lock = acquireExecutionLock(batchId);
            try {
                BatchScheduler batchScheduler = new BatchScheduler(batchId, script, lock, executor);
                batchScheduler.run();
            } finally {
                lock.close();
            }
            YSLOG.info("I01001", batchId);
        } catch (ExitCodeException e) {
            YSLOG.error("E01001", batchId);
            throw e;
View Full Code Here

                    "Flow is undefined: batchId={0}, flowId={1}, executionId={2}",
                    batchId,
                    flowId,
                    executionId));
        }
        ExecutionLock lock = acquireExecutionLock(batchId);
        try {
            lock.beginFlow(flowId, executionId);
            executeFlow(batchId, flow, executionId);
            lock.endFlow(flowId, executionId);
        } finally {
            lock.close();
        }
    }
View Full Code Here

                    context.getBatchId(),
                    context.getFlowId(),
                    context.getExecutionId()));
        }
        Set<ExecutionScript> executions = flow.getScripts().get(context.getPhase());
        ExecutionLock lock = acquireExecutionLock(context.getBatchId());
        try {
            lock.beginFlow(context.getFlowId(), context.getExecutionId());
            executePhase(context, executions);
            lock.endFlow(context.getFlowId(), context.getExecutionId());
        } finally {
            lock.close();
        }
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.yaess.core.ExecutionLock

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.