コード例 #1
0
 protected void sendClientMessage(ClientMessage resultClientMessage) {
   resultClientMessage.setCorrelationId(clientMessage.getCorrelationId());
   resultClientMessage.addFlag(ClientMessage.BEGIN_AND_END_FLAGS);
   resultClientMessage.setVersion(ClientMessage.VERSION);
   final Connection connection = endpoint.getConnection();
   // TODO framing not implemented yet, should be split into frames before writing to connection
   connection.write(resultClientMessage);
 }
コード例 #2
0
ファイル: ClientEngineImpl.java プロジェクト: notz/hazelcast
 public void sendResponse(ClientEndpoint endpoint, Object response) {
   if (response instanceof Throwable) {
     response =
         ClientExceptionConverters.get(endpoint.getClientType()).convert((Throwable) response);
   }
   final Data resultData = response != null ? serializationService.toData(response) : NULL;
   Connection conn = endpoint.getConnection();
   conn.write(new DataAdapter(resultData, serializationService.getSerializationContext()));
 }
コード例 #3
0
  @Override
  public boolean transmit(Packet packet, Connection connection) {
    checkNotNull(packet, "Packet can't be null");

    if (connection == null) {
      return false;
    }

    return connection.write(packet);
  }
コード例 #4
0
  private boolean send(Packet packet, Address target, SendTask sendTask) {
    Connection connection = getConnection(target);
    if (connection != null) {
      return connection.write(packet);
    }

    if (sendTask == null) {
      sendTask = new SendTask(packet, target);
    }

    int retries = sendTask.retries;
    if (retries < RETRY_NUMBER && ioService.isActive()) {
      getOrConnect(target, true);
      // TODO: Caution: may break the order guarantee of the packets sent from the same thread!
      scheduler.schedule(sendTask, (retries + 1) * DELAY_FACTOR, TimeUnit.MILLISECONDS);
      return true;
    }
    return false;
  }
コード例 #5
0
 @Override
 public boolean transmit(Packet packet, Connection connection) {
   return (connection != null && connection.write(packet));
 }