org.apache.qpid.proton.engine.Transport.tail()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.apache.qpid.proton.engine.Transport.tail()方法的一些代码示例,展示了Transport.tail()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transport.tail()方法的具体详情如下:
包路径:org.apache.qpid.proton.engine.Transport
类名称:Transport
方法名:tail

Transport.tail介绍

暂无

代码示例

代码示例来源:origin: io.vertx/vertx-proton

private void pumpInbound(Buffer buffer) {
 if (failed) {
  LOG.trace("Skipping processing of data following transport error: {0}", buffer);
  return;
 }
 // Lets push bytes from vert.x to proton engine.
 try {
  ByteBuf data = buffer.getByteBuf();
  do {
   ByteBuffer transportBuffer = transport.tail();
   int amount = Math.min(transportBuffer.remaining(), data.readableBytes());
   transportBuffer.limit(transportBuffer.position() + amount);
   data.readBytes(transportBuffer);
   transport.process();
  } while (data.isReadable());
 } catch (Exception te) {
  failed = true;
  LOG.trace("Exception while processing transport input", te);
 }
}

代码示例来源:origin: org.apache.qpid/qpid-jms-client

@Override
public void onData(final ByteBuf input) {
  try {
    if (isTraceBytes()) {
      TRACE_BYTES.info("Received: {}", ByteBufUtil.hexDump(input));
    }
    do {
      ByteBuffer buffer = protonTransport.tail();
      int chunkSize = Math.min(buffer.remaining(), input.readableBytes());
      buffer.limit(buffer.position() + chunkSize);
      input.readBytes(buffer);
      protonTransport.process();
    } while (input.isReadable());
    // Process the state changes from the latest data and then answer back
    // any pending updates to the Broker.
    processUpdates();
    pumpToProtonTransport();
  } catch (Throwable t) {
    LOG.warn("Caught problem during data processing: {}", t.getMessage(), t);
    fireProviderException(t);
  }
}

代码示例来源:origin: apache/qpid-jms

@Override
public void onData(final ByteBuf input) {
  try {
    if (isTraceBytes()) {
      TRACE_BYTES.info("Received: {}", ByteBufUtil.hexDump(input));
    }
    do {
      ByteBuffer buffer = protonTransport.tail();
      int chunkSize = Math.min(buffer.remaining(), input.readableBytes());
      buffer.limit(buffer.position() + chunkSize);
      input.readBytes(buffer);
      protonTransport.process();
    } while (input.isReadable());
    // Process the state changes from the latest data and then answer back
    // any pending updates to the Broker.
    processUpdates();
    pumpToProtonTransport();
  } catch (Throwable t) {
    LOG.warn("Caught problem during data processing: {}", t.getMessage(), t);
    fireProviderException(t);
  }
}

代码示例来源:origin: org.apache.activemq/artemis-amqp-protocol

public void inputBuffer(ByteBuf buffer) {
 dataReceived = true;
 lock.lock();
 try {
   while (buffer.readableBytes() > 0) {
    int capacity = transport.capacity();
    if (!receivedFirstPacket) {
      handleFirstPacket(buffer);
      // there is a chance that if SASL Handshake has been carried out that the capacity may change.
      capacity = transport.capacity();
    }
    if (capacity > 0) {
      ByteBuffer tail = transport.tail();
      int min = Math.min(capacity, buffer.readableBytes());
      tail.limit(min);
      buffer.readBytes(tail);
      flush();
    } else {
      if (capacity == 0) {
       log.debugf("abandoning: readableBytes=%d", buffer.readableBytes());
      } else {
       log.debugf("transport closed, discarding: readableBytes=%d, capacity=%d", buffer.readableBytes(), transport.capacity());
      }
      break;
    }
   }
 } finally {
   lock.unlock();
 }
}

代码示例来源:origin: apache/activemq-artemis

public void inputBuffer(ByteBuf buffer) {
 requireHandler();
 dataReceived = true;
 while (buffer.readableBytes() > 0) {
   int capacity = transport.capacity();
   if (!receivedFirstPacket) {
    handleFirstPacket(buffer);
    // there is a chance that if SASL Handshake has been carried out that the capacity may change.
    capacity = transport.capacity();
   }
   if (capacity > 0) {
    ByteBuffer tail = transport.tail();
    int min = Math.min(capacity, buffer.readableBytes());
    tail.limit(min);
    buffer.readBytes(tail);
    flush();
   } else {
    if (capacity == 0) {
      log.debugf("abandoning: readableBytes=%d", buffer.readableBytes());
    } else {
      log.debugf("transport closed, discarding: readableBytes=%d, capacity=%d", buffer.readableBytes(), transport.capacity());
    }
    break;
   }
 }
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

ByteBuffer tail = _transport.tail();
int bytesRead = _channel.read(tail);
if (bytesRead < 0) {

代码示例来源:origin: org.apache.qpid/proton-j-impl

int bytesRead = _channel.read(_transport.tail());
if (bytesRead < 0) {
  _transport.close_tail();

代码示例来源:origin: org.apache.activemq/artemis-proton-plug

ByteBuffer tail = transport.tail();
int min = Math.min(capacity, buffer.readableBytes());
tail.limit(min);

代码示例来源:origin: org.apache.qpid/proton-j

@Override
  public void run(Selectable selectable) {
    Reactor reactor = selectable.getReactor();
    Transport transport = ((SelectableImpl)selectable).getTransport();
    int capacity = transport.capacity();
    if (capacity > 0) {
      SocketChannel socketChannel = (SocketChannel)selectable.getChannel();
      try {
        int n = socketChannel.read(transport.tail());
        if (n == -1) {
          transport.close_tail();
        } else {
          transport.process();
        }
      } catch (IOException | TransportException e) {
        ErrorCondition condition = new ErrorCondition();
        condition.setCondition(Symbol.getSymbol("proton:io"));
        condition.setDescription(e.getMessage());
        transport.setCondition(condition);
        transport.close_tail();
      }
    }
    // (Comment from C code:) occasionally transport events aren't
    // generated when expected, so the following hack ensures we
    // always update the selector
    update(selectable);
    reactor.update(selectable);
  }
};

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

@Override
  public void run(Selectable selectable) {
    Reactor reactor = selectable.getReactor();
    Transport transport = ((SelectableImpl)selectable).getTransport();
    int capacity = transport.capacity();
    if (capacity > 0) {
      SocketChannel socketChannel = (SocketChannel)selectable.getChannel();
      try {
        int n = socketChannel.read(transport.tail());
        if (n == -1) {
          transport.close_tail();
        } else {
          transport.process();
        }
      } catch (IOException e) {
        ErrorCondition condition = new ErrorCondition();
        condition.setCondition(Symbol.getSymbol("proton:io"));
        condition.setDescription(e.getMessage());
        transport.setCondition(condition);
        transport.close_tail();
      }
    }
    // (Comment from C code:) occasionally transport events aren't
    // generated when expected, so the following hack ensures we
    // always update the selector
    update(selectable);
    reactor.update(selectable);
  }
};

代码示例来源:origin: com.ibm.mqlight/mqlight-api

int bytesAvailable;
while ((bytesAvailable = dr.buffer.readableBytes()) > 0) {
  ByteBuffer tail = engineConnection.transport.tail();
  if (bytesAvailable > tail.remaining()) {
    int max = tail.capacity() - tail.position();

相关文章