Examples of Reactor


Examples of bgu.bio.com.reactor.Reactor

        return new ScriptProtocol(data);
      }
    };

    //run the reactor as a thread
    reactor = new Reactor(port, poolSize, protocol);
    Thread reactorThread = new Thread(reactor,"Reactor");
    threads.add(reactorThread);
  }
View Full Code Here

Examples of com.google.code.yanf4j.nio.impl.Reactor

    @Test
    public void testNextReactor() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            Reactor reactor = this.selectorManager.nextReactor();
            Assert.assertNotNull(reactor);
            Assert.assertTrue(reactor.getReactorIndex() > 0);
        }
        System.out.println(System.currentTimeMillis() - start);
    }
View Full Code Here

Examples of com.google.code.yanf4j.nio.impl.Reactor

    @Test
    public void testRegisterOpenChannel() throws Exception {
        MockSelectableChannel channel = new MockSelectableChannel();
        channel.selectionKey = new MockSelectionKey();
        Reactor reactor = this.selectorManager.registerChannel(channel, 1, "hello");
        Thread.sleep(Reactor.DEFAULT_WAIT * 3);
        Assert.assertSame(reactor.getSelector(), channel.selector);
        Assert.assertSame(reactor.getSelector(), channel.selectionKey.selector);
        Assert.assertEquals(1, channel.ops);
        Assert.assertEquals("hello", channel.attch);
    }
View Full Code Here

Examples of com.google.code.yanf4j.nio.impl.Reactor

    public void testRegisterOpenSession() throws Exception {
        IMocksControl control = EasyMock.createControl();
        NioSession session = control.createMock(NioSession.class);
        EasyMock.makeThreadSafe(session, true);
        // next reactor��index=2
        Reactor nextReactor = this.selectorManager.getReactorByIndex(2);
        session.onEvent(EventType.ENABLE_READ, nextReactor.getSelector());
        EasyMock.expectLastCall();
        EasyMock.expect(session.isClosed()).andReturn(false).times(2);
        EasyMock.expect(session.getAttribute(SelectorManager.REACTOR_ATTRIBUTE)).andReturn(null);
        EasyMock.expect(session.setAttributeIfAbsent(SelectorManager.REACTOR_ATTRIBUTE, nextReactor)).andReturn(null);
View Full Code Here

Examples of org.agilewiki.jactor2.core.reactors.Reactor

*/
@GwtIncompatible
public class Test1 extends CallTestBase {
    public void testI() throws Exception {
        new Plant();
        final Reactor reactor = new IsolationReactor();
        final BladeA bladeA = new BladeA(reactor);
        try {
            call(bladeA.throwAOp);
        } catch (final IOException se) {
            Plant.close();
View Full Code Here

Examples of org.agilewiki.jactor2.core.reactors.Reactor

    public void testReactor() throws Exception {
        System.out.println("R");
        new Plant();
        try {
            final Reactor reactor = new NonBlockingReactor();

            final MyCloseable mac1 = new MyCloseable();
            final MyCloseable mac2 = new MyCloseable();
            final MyCloseable mac3 = new MyCloseable();
            final MyCloseable mac4 = new MyCloseable();
            final MyFailedCloseable mfac = new MyFailedCloseable();
            reactor.addCloseable(mac1);
            reactor.addCloseable(mac2);
            reactor.addCloseable(mac3);
            reactor.addCloseable(mac4);
            reactor.addCloseable(mfac);
            reactor.removeCloseable(mac4);

            reactor.close();

            assertEquals(mac1.closed, 1);
            assertEquals(mac2.closed, 1);
            assertEquals(mac3.closed, 1);
            assertEquals(mac4.closed, 0);
View Full Code Here

Examples of org.agilewiki.jactor2.core.reactors.Reactor

     * if the reactor is not a common reactor, sends a response of null via
     * a bound response processor.
     */
    public void onCancel() {
        cancelAll();
        final Reactor targetReactor = getTargetReactor();
        if (!(targetReactor instanceof CommonReactor)) {
            try {
                new BoundResponseProcessor<RESPONSE_TYPE>(targetReactor, this)
                        .processAsyncResponse(null);
            } catch (final Exception e) {
View Full Code Here

Examples of org.jvnet.hudson.reactor.Reactor

            plugins.remove(p);
            throw new IOException2("Failed to install "+ sn +" plugin",e);
        }

        // run initializers in the added plugin
        Reactor r = new Reactor(InitMilestone.ordering());
        r.addAll(new InitializerFinder(p.classLoader) {
            @Override
            protected boolean filter(Method e) {
                return e.getDeclaringClass().getClassLoader()!=p.classLoader || super.filter(e);
            }
        }.discoverTasks(r));
View Full Code Here

Examples of org.jvnet.hudson.reactor.Reactor

     *
     * @param is
     *      If non-null, this can be consulted for ignoring some tasks. Only used during the initialization of Hudson.
     */
    private void executeReactor(final InitStrategy is, TaskBuilder... builders) throws IOException, InterruptedException, ReactorException {
        Reactor reactor = new Reactor(builders) {
            /**
             * Sets the thread name to the task for better diagnostics.
             */
            @Override
            protected void runTask(Task task) throws Exception {
View Full Code Here

Examples of org.jvnet.hudson.reactor.Reactor

     *
     * @param is
     *      If non-null, this can be consulted for ignoring some tasks. Only used during the initialization of Hudson.
     */
    private void executeReactor(final InitStrategy is, TaskBuilder... builders) throws IOException, InterruptedException, ReactorException {
        Reactor reactor = new Reactor(builders) {

            /**
             * Sets the thread name to the task for better diagnostics.
             */
            @Override
            protected void runTask(Task task) throws Exception {
                if (is != null && is.skipInitTask(task)) {
                    return;
                }

                SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM);   // full access in the initialization thread
                String taskName = task.getDisplayName();

                Thread t = Thread.currentThread();
                String name = t.getName();
                if (taskName != null) {
                    t.setName(taskName);
                }
                try {
                    long start = System.currentTimeMillis();
                    super.runTask(task);
                    if (LOG_STARTUP_PERFORMANCE) {
                        LOGGER.info(String.format("Took %dms for %s by %s",
                                System.currentTimeMillis() - start, taskName, name));
                    }
                } finally {
                    t.setName(name);
                    SecurityContextHolder.clearContext();
                }
            }
        };

        ExecutorService es;
        if (PARALLEL_LOAD) {
            es = new ThreadPoolExecutor(
                    TWICE_CPU_NUM, TWICE_CPU_NUM, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new DaemonThreadFactory());
        } else {
            es = Executors.newSingleThreadExecutor(new DaemonThreadFactory());
        }
        try {
            reactor.execute(es, buildReactorListener());
        } finally {
            es.shutdownNow();   // upon a successful return the executor queue should be empty. Upon an exception, we want to cancel all pending tasks
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.