Examples of AsyncCallback


Examples of org.apache.camel.AsyncCallback

            return true;
        }

        // need to declare as final
        final Channel channel = existing;
        final AsyncCallback producerCallback = new NettyProducerCallback(channel, callback);

        // setup state as attachment on the channel, so we can access the state later when needed
        channel.setAttachment(new NettyCamelState(producerCallback, exchange));

        // write body
        NettyHelper.writeBodyAsync(LOG, channel, null, body, exchange, new ChannelFutureListener() {
            public void operationComplete(ChannelFuture channelFuture) throws Exception {
                LOG.trace("Operation complete {}", channelFuture);
                if (!channelFuture.isSuccess()) {
                    // no success the set the caused exception and signal callback and break
                    exchange.setException(channelFuture.getCause());
                    producerCallback.done(false);
                    return;
                }

                // if we do not expect any reply then signal callback to continue routing
                if (!configuration.isSync()) {
                    try {
                        // should channel be closed after complete?
                        Boolean close;
                        if (ExchangeHelper.isOutCapable(exchange)) {
                            close = exchange.getOut().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class);
                        } else {
                            close = exchange.getIn().getHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, Boolean.class);
                        }

                        // should we disconnect, the header can override the configuration
                        boolean disconnect = getConfiguration().isDisconnect();
                        if (close != null) {
                            disconnect = close;
                        }
                        if (disconnect) {
                            if (LOG.isTraceEnabled()) {
                                LOG.trace("Closing channel when complete at address: {}", getEndpoint().getConfiguration().getAddress());
                            }
                            NettyHelper.close(channel);
                        }
                    } finally {
                        // signal callback to continue routing
                        producerCallback.done(false);
                    }
                }
            }
        });
View Full Code Here

Examples of org.apache.helix.messaging.AsyncCallback

      HelixTaskResult result = new HelixTaskResult();
      assert (_correlationId.equalsIgnoreCase(_message.getCorrelationId()));
      _logger.info("invoking reply message " + _message.getMsgId()
          + ", correlationid:" + _correlationId);

      AsyncCallback callback = _callbackMap.get(_correlationId);
      synchronized (callback)
      {
        callback.onReply(_message);
        if (callback.isDone())
        {
          _logger.info("Removing finished callback, correlationid:"
              + _correlationId);
          _callbackMap.remove(_correlationId);
        }
View Full Code Here

Examples of org.apache.helix.messaging.AsyncCallback

    Criteria cr = new Criteria();
    cr.setInstanceName(hostDest);
    cr.setRecipientInstanceType(InstanceType.PARTICIPANT);
    cr.setSessionSpecific(false);

    AsyncCallback asyncCallback = new MockAsyncCallback();
    int messagesSent = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, asyncCallback, 60000);

    AssertJUnit.assertTrue(asyncCallback.getMessageReplied().get(0).getRecord()
        .getMapField(Message.Attributes.MESSAGE_RESULT.toString())
        .get("ReplyMessage").equals("TestReplyMessage"));
    AssertJUnit.assertTrue(asyncCallback.getMessageReplied().size() == 1);


    AsyncCallback asyncCallback2 = new MockAsyncCallback();
    messagesSent = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, asyncCallback2, 500);
    AssertJUnit.assertTrue(asyncCallback2.isTimedOut());

  }
View Full Code Here

Examples of org.apache.helix.messaging.AsyncCallback

    Criteria cr = new Criteria();
    cr.setInstanceName("%");
    cr.setRecipientInstanceType(InstanceType.PARTICIPANT);
    cr.setSessionSpecific(false);
    AsyncCallback callback1 = new MockAsyncCallback();
    int messageSent1 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback1, 10000);

    AssertJUnit.assertTrue(callback1.getMessageReplied().get(0).getRecord()
        .getMapField(Message.Attributes.MESSAGE_RESULT.toString())
        .get("ReplyMessage").equals("TestReplyMessage"));
    AssertJUnit.assertTrue(callback1.getMessageReplied().size() == NODE_NR - 1);

    AsyncCallback callback2 = new MockAsyncCallback();
    int messageSent2 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback2, 500);
    AssertJUnit.assertTrue(callback2.isTimedOut());

    cr.setPartition("TestDB_17");
    AsyncCallback callback3 = new MockAsyncCallback();
    int messageSent3 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback3, 10000);
    AssertJUnit.assertTrue(callback3.getMessageReplied().size() == _replica - 1);


    cr.setPartition("TestDB_15");
    AsyncCallback callback4 = new MockAsyncCallback();
    int messageSent4 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback4, 10000);
    AssertJUnit.assertTrue(callback4.getMessageReplied().size() == _replica);
   
    cr.setPartitionState("SLAVE");
    AsyncCallback callback5 = new MockAsyncCallback();
    int messageSent5 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback5, 10000);
    AssertJUnit.assertTrue(callback5.getMessageReplied().size() == _replica - 1);
   
    cr.setDataSource(DataSource.IDEALSTATES);
    AsyncCallback callback6 = new MockAsyncCallback();
    int messageSent6 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback6, 10000);
    AssertJUnit.assertTrue(callback6.getMessageReplied().size() == _replica - 1);
  }
View Full Code Here

Examples of org.apache.helix.messaging.AsyncCallback

    Criteria cr = new Criteria();
    cr.setInstanceName("%");
    cr.setRecipientInstanceType(InstanceType.PARTICIPANT);
    cr.setSessionSpecific(false);
    cr.setSelfExcluded(false);
    AsyncCallback callback1 = new MockAsyncCallback();
    int messageSent1 = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback1, 10000);

    AssertJUnit.assertTrue(callback1.getMessageReplied().size() == NODE_NR);
    AssertJUnit.assertTrue(callback1.getMessageReplied().get(0).getRecord()
                           .getMapField(Message.Attributes.MESSAGE_RESULT.toString())
                           .get("ReplyMessage").equals("TestReplyMessage"));
  }
View Full Code Here

Examples of org.apache.helix.messaging.AsyncCallback

    Criteria cr = new Criteria();
    cr.setInstanceName("*");
    cr.setRecipientInstanceType(InstanceType.CONTROLLER);
    cr.setSessionSpecific(false);

    AsyncCallback callback1 = new MockAsyncCallback();
    int messagesSent = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback1, 10000);

    AssertJUnit.assertTrue(callback1.getMessageReplied().get(0).getRecord()
        .getMapField(Message.Attributes.MESSAGE_RESULT.toString())
        .get("ControllerResult").indexOf(hostSrc) != -1);
    AssertJUnit.assertTrue(callback1.getMessageReplied().size() == 1);

    msgId = UUID.randomUUID().toString();
    msg.setMsgId(msgId);
    cr.setPartition("TestDB_17");
    AsyncCallback callback2 = new MockAsyncCallback();
    messagesSent = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback2, 10000);
    AssertJUnit.assertTrue(callback2.getMessageReplied().get(0).getRecord()
        .getMapField(Message.Attributes.MESSAGE_RESULT.toString())
        .get("ControllerResult").indexOf(hostSrc) != -1);

    AssertJUnit.assertTrue(callback2.getMessageReplied().size() == 1);

    msgId = UUID.randomUUID().toString();
    msg.setMsgId(msgId);
    cr.setPartitionState("SLAVE");
    AsyncCallback callback3 = new MockAsyncCallback();
    messagesSent = _startCMResultMap.get(hostSrc)._manager.getMessagingService()
        .sendAndWait(cr, msg, callback3, 10000);
    AssertJUnit.assertTrue(callback3.getMessageReplied().get(0).getRecord()
        .getMapField(Message.Attributes.MESSAGE_RESULT.toString())
        .get("ControllerResult").indexOf(hostSrc) != -1);

    AssertJUnit.assertTrue(callback3.getMessageReplied().size() == 1);
  }
View Full Code Here

Examples of org.apache.xmlrpc.AsyncCallback

            if( log.isDebugEnabled() )
                log.debug("Pinging weblogs.com with URL: "+engine.getURL( WikiContext.VIEW, blogName, null, true ));

            xmlrpc.executeAsync("weblogUpdates.ping", params,
                                new AsyncCallback()
                                {
                                    public void handleError( Exception ex,
                                                             URL url,
                                                             String method )
                                    {
View Full Code Here

Examples of org.apache.xmlrpc.client.AsyncCallback

     */
    public Object execute(String command, Object[] args) throws XmlRpcException {
        final Object[] result = new Object[] { null };

        //make an async call so that we can keep track of not actually having an answer.
        this.impl.executeAsync(command, args, new AsyncCallback() {

            public void handleError(XmlRpcRequest request, Throwable error) {
                result[0] = new Object[] { error.getMessage() };
            }

View Full Code Here

Examples of org.deftserver.web.AsyncCallback

  }
 
  public static Timeout newKeepAliveTimeout(final SelectableChannel clientChannel, long keepAliveTimeout) {
    return new Timeout(
        System.currentTimeMillis() + keepAliveTimeout,
        new AsyncCallback() { public void onCallback() { Closeables.closeQuietly(clientChannel); } }
    );
  }
View Full Code Here

Examples of org.deftserver.web.AsyncCallback

   */
  public void start() {
    IOLoop.INSTANCE.addTimeout(
        new Timeout(
            System.currentTimeMillis() + period,
            new AsyncCallback() { @Override public void onCallback() { run(); }}
        )
    );
  }
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.