org.apache.qpid.proton.engine.Event.Type Java Examples
The following examples show how to use
org.apache.qpid.proton.engine.Event.Type.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactorImpl.java From qpid-proton-j with Apache License 2.0 | 5 votes |
public SelectableImpl selectable(ReactorChild child) { SelectableImpl result = new SelectableImpl(); result.setCollector(collector); collector.put(Type.SELECTABLE_INIT, result); result.setReactor(this); children.add(child == null ? result : child); result.onRelease(new ReleaseCallback(this, child == null ? result : child)); ++selectables; return result; }
Example #2
Source File: ReactorImpl.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void update(Selectable selectable) { SelectableImpl selectableImpl = (SelectableImpl)selectable; if (!selectableImpl.isTerminated()) { if (selectableImpl.isTerminal()) { selectableImpl.terminated(); collector.put(Type.SELECTABLE_FINAL, selectable); } else { collector.put(Type.SELECTABLE_UPDATED, selectable); } } }
Example #3
Source File: ReactorImpl.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public boolean quiesced() { Event event = collector.peek(); if (event == null) return true; if (collector.more()) return false; return event.getEventType() == Type.REACTOR_QUIESCED; }
Example #4
Source File: Timer.java From qpid-proton-j with Apache License 2.0 | 5 votes |
void tick(long now) { while(!tasks.isEmpty()) { TaskImpl task = tasks.peek(); if (now >= task.deadline()) { tasks.poll(); if (!task.isCancelled()) collector.put(Type.TIMER_TASK, task); } else { break; } } }
Example #5
Source File: EventExtensibilityTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Override public void onFoo(ExtraEvent e) { assertEquals(ExtraEvent.ExtraTypes.FOO, e.getEventType()); assertEquals(ExtraEvent.ExtraTypes.FOO, e.getExtraEventType()); assertEquals(Event.Type.NON_CORE_EVENT, e.getType()); assertNotNull(e.getExtraInfo()); assertEquals(1234, e.getExtraInfo().foo); didFoo = true; }
Example #6
Source File: ReactorTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
/** * Tests adding a handler to a reactor and running the reactor. The * expected behaviour is for the reactor to return, and a number of reactor- * related events to have been delivered to the handler. * @throws IOException */ @Test public void handlerRun() throws IOException { Handler handler = reactor.getHandler(); assertNotNull(handler); TestHandler testHandler = new TestHandler(); handler.add(testHandler); reactor.run(); reactor.free(); testHandler.assertEvents(Type.REACTOR_INIT, Type.SELECTABLE_INIT, Type.SELECTABLE_UPDATED, Type.SELECTABLE_FINAL, Type.REACTOR_FINAL); }
Example #7
Source File: ReactorTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Test public void schedule() throws IOException { TestHandler reactorHandler = new TestHandler(); reactor.getHandler().add(reactorHandler); TestHandler taskHandler = new TestHandler(); reactor.schedule(0, taskHandler); reactor.run(); reactor.free(); reactorHandler.assertEvents(Type.REACTOR_INIT, Type.SELECTABLE_INIT, Type.SELECTABLE_UPDATED, Type.REACTOR_QUIESCED, Type.SELECTABLE_UPDATED, Type.SELECTABLE_FINAL, Type.REACTOR_FINAL); taskHandler.assertEvents(Type.TIMER_TASK); }
Example #8
Source File: ReactorTest.java From qpid-proton-j with Apache License 2.0 | 5 votes |
@Test public void connectionRefused() throws IOException { final ServerSocket serverSocket = new ServerSocket(0, 0); class ConnectionHandler extends TestHandler { @Override public void onConnectionInit(Event event) { super.onConnectionInit(event); Connection connection = event.getConnection(); connection.open(); try { serverSocket.close(); } catch(IOException e) { AssertionFailedError afe = new AssertionFailedError(); afe.initCause(e); throw afe; } } } TestHandler connectionHandler = new ConnectionHandler(); reactor.connectionToHost("127.0.0.1", serverSocket.getLocalPort(), connectionHandler); reactor.run(); reactor.free(); serverSocket.close(); connectionHandler.assertEvents(Type.CONNECTION_INIT, Type.CONNECTION_LOCAL_OPEN, Type.CONNECTION_BOUND, Type.TRANSPORT_ERROR, Type.TRANSPORT_TAIL_CLOSED, Type.TRANSPORT_HEAD_CLOSED, Type.TRANSPORT_CLOSED, Type.CONNECTION_UNBOUND, Type.TRANSPORT); }
Example #9
Source File: ReactorImpl.java From qpid-proton-j with Apache License 2.0 | 4 votes |
@Override public boolean process() throws HandlerException { mark(); EventType previous = null; while (true) { Event event = collector.peek(); if (event != null) { if (yield) { yield = false; return true; } Handler handler = eventHandler(event); dispatch(event, handler); dispatch(event, global); if (event.getEventType() == Type.CONNECTION_FINAL) { children.remove(event.getConnection()); } this.previous = event.getEventType(); previous = this.previous; collector.pop(); } else { if (!stop && more()) { if (previous != Type.REACTOR_QUIESCED && this.previous != Type.REACTOR_FINAL) { collector.put(Type.REACTOR_QUIESCED, this); } else { return true; } } else { if (selectable != null) { selectable.terminate(); update(selectable); selectable = null; } else { collector.put(Type.REACTOR_FINAL, this); return false; } } } } }
Example #10
Source File: ReactorImpl.java From qpid-proton-j with Apache License 2.0 | 4 votes |
@Override public void start() { collector.put(Type.REACTOR_INIT, this); selectable = timerSelectable(); }
Example #11
Source File: EventExtensibilityTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
@Override public Type getType() { return impl.getType(); }
Example #12
Source File: EventExtensibilityTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
@Test public void test() { Event.Type t = Type.NON_CORE_EVENT; switch (extracted(t)) { case CONNECTION_BOUND: fail(); case CONNECTION_FINAL: fail(); case CONNECTION_INIT: fail(); case CONNECTION_LOCAL_CLOSE: fail(); case CONNECTION_LOCAL_OPEN: fail(); case CONNECTION_REMOTE_CLOSE: fail(); case CONNECTION_REMOTE_OPEN: fail(); case CONNECTION_UNBOUND: fail(); case DELIVERY: fail(); case LINK_FINAL: fail(); case LINK_FLOW: fail(); case LINK_INIT: fail(); case LINK_LOCAL_CLOSE: fail(); case LINK_LOCAL_DETACH: fail(); case LINK_LOCAL_OPEN: fail(); case LINK_REMOTE_CLOSE: fail(); case LINK_REMOTE_DETACH: fail(); case LINK_REMOTE_OPEN: fail(); case REACTOR_FINAL: fail(); case REACTOR_INIT: fail(); case REACTOR_QUIESCED: fail(); case SELECTABLE_ERROR: fail(); case SELECTABLE_EXPIRED: fail(); case SELECTABLE_FINAL: fail(); case SELECTABLE_INIT: fail(); case SELECTABLE_READABLE: fail(); case SELECTABLE_UPDATED: fail(); case SELECTABLE_WRITABLE: fail(); case SESSION_FINAL: fail(); case SESSION_INIT: fail(); case SESSION_LOCAL_CLOSE: fail(); case SESSION_LOCAL_OPEN: fail(); case SESSION_REMOTE_CLOSE: fail(); case SESSION_REMOTE_OPEN: fail(); case TIMER_TASK: fail(); case TRANSPORT: fail(); case TRANSPORT_CLOSED: fail(); case TRANSPORT_ERROR: fail(); case TRANSPORT_HEAD_CLOSED: fail(); case TRANSPORT_TAIL_CLOSED: fail(); case NON_CORE_EVENT: break; } }
Example #13
Source File: EventExtensibilityTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
private Type extracted(Event.Type t) { return t; }
Example #14
Source File: ReactorTest.java From qpid-proton-j with Apache License 2.0 | 4 votes |
public void assertEvents(Type...expected) { assertArrayEquals(expected, actual.toArray()); }
Example #15
Source File: AmqpConnection.java From activemq-artemis with Apache License 2.0 | 4 votes |
private void processUpdates() { try { Event protonEvent = null; while ((protonEvent = protonCollector.peek()) != null) { if (!protonEvent.getType().equals(Type.TRANSPORT)) { LOG.trace("Client: New Proton Event: {}", protonEvent.getType()); } AmqpEventSink amqpEventSink = null; switch (protonEvent.getType()) { case CONNECTION_REMOTE_CLOSE: amqpEventSink = (AmqpEventSink) protonEvent.getConnection().getContext(); amqpEventSink.processRemoteClose(this); break; case CONNECTION_REMOTE_OPEN: amqpEventSink = (AmqpEventSink) protonEvent.getConnection().getContext(); amqpEventSink.processRemoteOpen(this); break; case SESSION_REMOTE_CLOSE: amqpEventSink = (AmqpEventSink) protonEvent.getSession().getContext(); amqpEventSink.processRemoteClose(this); break; case SESSION_REMOTE_OPEN: amqpEventSink = (AmqpEventSink) protonEvent.getSession().getContext(); amqpEventSink.processRemoteOpen(this); break; case LINK_REMOTE_CLOSE: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); amqpEventSink.processRemoteClose(this); break; case LINK_REMOTE_DETACH: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); amqpEventSink.processRemoteDetach(this); break; case LINK_REMOTE_OPEN: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); amqpEventSink.processRemoteOpen(this); break; case LINK_FLOW: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); amqpEventSink.processFlowUpdates(this); break; case DELIVERY: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); amqpEventSink.processDeliveryUpdates(this, (Delivery) protonEvent.getContext()); break; default: break; } protonCollector.pop(); } // We have to do this to pump SASL bytes in as SASL is not event driven yet. if (!authenticated) { processSaslAuthentication(); } } catch (Exception ex) { LOG.warn("Caught Exception during update processing: {}", ex.getMessage(), ex); fireClientException(ex); } }
Example #16
Source File: AmqpProvider.java From qpid-jms with Apache License 2.0 | 4 votes |
private void processUpdates() { try { Event protonEvent = null; while ((protonEvent = protonCollector.peek()) != null) { if (!protonEvent.getType().equals(Type.TRANSPORT)) { LOG.trace("New Proton Event: {}", protonEvent.getType()); } AmqpEventSink amqpEventSink = null; switch (protonEvent.getType()) { case CONNECTION_REMOTE_CLOSE: amqpEventSink = (AmqpEventSink) protonEvent.getConnection().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteClose(this); } break; case CONNECTION_REMOTE_OPEN: amqpEventSink = (AmqpEventSink) protonEvent.getConnection().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteOpen(this); } break; case SESSION_REMOTE_CLOSE: amqpEventSink = (AmqpEventSink) protonEvent.getSession().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteClose(this); } break; case SESSION_REMOTE_OPEN: amqpEventSink = (AmqpEventSink) protonEvent.getSession().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteOpen(this); } break; case LINK_REMOTE_CLOSE: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteClose(this); } break; case LINK_REMOTE_DETACH: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteDetach(this); } break; case LINK_REMOTE_OPEN: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); if (amqpEventSink != null) { amqpEventSink.processRemoteOpen(this); } break; case LINK_FLOW: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); if (amqpEventSink != null) { amqpEventSink.processFlowUpdates(this); } break; case DELIVERY: amqpEventSink = (AmqpEventSink) protonEvent.getLink().getContext(); if (amqpEventSink != null) { amqpEventSink.processDeliveryUpdates(this, (Delivery) protonEvent.getContext()); } break; case TRANSPORT_ERROR: // We handle authentication failure elsewhere, but in doing so we close the transport // head which would also get us here, so only action this if auth succeeded. if (authenticator == null || (authenticator.isComplete() && authenticator.wasSuccessful())) { protonTransportErrorHandled = true; ErrorCondition transportCondition = protonTransport.getCondition(); String message = extractTransportErrorMessage(transportCondition); // Transport has failed, ensure that we see local end of connection as closed // so other shutdown processing doesn't mistakenly assume we can still get a // close from the remote. protonConnection.setCondition(transportCondition); protonConnection.close(); throw new ProviderFailedException(message); } break; default: break; } protonCollector.pop(); } } catch (Throwable t) { try { LOG.warn("Caught problem during update processing: {}", t.getMessage(), t); } finally { fireProviderException(ProviderExceptionSupport.createOrPassthroughFatal(t)); } } }