本文整理了Java中org.apache.qpid.proton.engine.Transport.head()
方法的一些代码示例,展示了Transport.head()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transport.head()
方法的具体详情如下:
包路径:org.apache.qpid.proton.engine.Transport
类名称:Transport
方法名:head
暂无
代码示例来源:origin: org.apache.activemq/artemis-proton-plug
@Override
public ByteBuf outputBuffer() {
synchronized (lock) {
int pending = transport.pending();
if (pending < 0) {
return null;//throw new IllegalStateException("xxx need to close the connection");
}
int size = pending - offset;
if (size < 0) {
throw new IllegalStateException("negative size: " + pending);
}
if (size == 0) {
return null;
}
// For returning PooledBytes
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(size);
ByteBuffer head = transport.head();
head.position(offset);
head.limit(offset + size);
buffer.writeBytes(head);
offset += size; // incrementing offset for future calls
return buffer;
}
}
代码示例来源:origin: EnMasseProject/enmasse
private void writeToNetwork(Connection connection, OutputStream out) throws IOException {
Transport transport = connection.getTransport();
while(transport.pending() > 0)
{
ByteBuffer outputBuf = transport.head();
final int size = outputBuf.remaining();
byte[] tmpBuf = new byte[size];
outputBuf.get(tmpBuf);
LOG.tracev("writing {0} bytes", size);
out.write(tmpBuf);
transport.pop(size);
}
}
代码示例来源:origin: org.apache.qpid/proton-j-impl
private boolean write() throws IOException
{
boolean processed = false;
int interest = _key.interestOps();
int pending = _transport.pending();
if (pending >= 0)
{
int wrote = _channel.write(_transport.head());
if (wrote > 0) {
processed = true;
_transport.pop(wrote);
}
}
else
{
_outputDone = true;
}
pending = _transport.pending();
if (pending > 0) {
interest |= SelectionKey.OP_WRITE;
} else {
interest &= ~SelectionKey.OP_WRITE;
if (pending < 0) {
_outputDone = true;
}
}
_key.interestOps(interest);
return processed;
}
代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot
while (_transport.pending() > 0 && !writeBlocked)
ByteBuffer head = _transport.head();
int wrote = _channel.write(head);
if (wrote > 0) {
代码示例来源:origin: org.apache.activemq/artemis-amqp-protocol
public void flushBytes() {
for (EventHandler handler : handlers) {
if (!handler.flowControl(readyListener)) {
return;
}
}
lock.lock();
try {
while (true) {
ByteBuffer head = transport.head();
int pending = head.remaining();
if (pending <= 0) {
break;
}
// We allocated a Pooled Direct Buffer, that will be sent down the stream
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.directBuffer(pending);
buffer.writeBytes(head);
for (EventHandler handler : handlers) {
handler.pushBytes(buffer);
}
transport.pop(pending);
}
} finally {
lock.unlock();
}
}
代码示例来源:origin: com.ibm.mqlight/mqlight-api
private void writeToNetwork(EngineConnection engineConnection) {
final String methodName = "writeToNetwork";
logger.entry(this, methodName, engineConnection);
if (engineConnection.transport.pending() > 0) {
ByteBuffer head = engineConnection.transport.head();
int amount = head.remaining();
engineConnection.channel.write(head, new NetworkWritePromiseImpl(this, amount, engineConnection));
engineConnection.transport.pop(amount);
engineConnection.transport.tick(System.currentTimeMillis());
}
logger.exit(this, methodName);
}
代码示例来源:origin: apache/activemq-artemis
private void actualFlush() {
requireHandler();
for (EventHandler handler : handlers) {
if (!handler.flowControl(readyListener)) {
scheduledFlush = false;
return;
}
}
try {
while (true) {
ByteBuffer head = transport.head();
int pending = head.remaining();
if (pending <= 0) {
break;
}
// We allocated a Pooled Direct Buffer, that will be sent down the stream
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.directBuffer(pending);
buffer.writeBytes(head);
for (EventHandler handler : handlers) {
handler.pushBytes(buffer);
}
transport.pop(pending);
}
} finally {
scheduledFlush = false;
}
}
代码示例来源:origin: org.apache.qpid/proton-j
@Override
public void run(Selectable selectable) {
Reactor reactor = selectable.getReactor();
Transport transport = ((SelectableImpl)selectable).getTransport();
int pending = transport.pending();
if (pending > 0) {
SocketChannel channel = (SocketChannel)selectable.getChannel();
try {
int n = channel.write(transport.head());
if (n < 0) {
transport.close_head();
} else {
transport.pop(n);
}
} catch(IOException ioException) {
ErrorCondition condition = new ErrorCondition();
condition.setCondition(Symbol.getSymbol("proton:io"));
condition.setDescription(ioException.getMessage());
transport.setCondition(condition);
transport.close_head();
}
}
int newPending = transport.pending();
if (newPending != pending) {
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 pending = transport.pending();
if (pending > 0) {
SocketChannel channel = (SocketChannel)selectable.getChannel();
try {
int n = channel.write(transport.head());
if (n < 0) {
transport.close_head();
} else {
transport.pop(n);
}
} catch(IOException ioException) {
ErrorCondition condition = new ErrorCondition();
condition.setCondition(Symbol.getSymbol("proton:io"));
condition.setDescription(ioException.getMessage());
transport.setCondition(condition);
transport.close_head();
}
}
int newPending = transport.pending();
if (newPending != pending) {
update(selectable);
reactor.update(selectable);
}
}
};
代码示例来源:origin: com.ibm.mqlight/mqlight-api
int delta = engineConnection.transport.head().remaining();
内容来源于网络,如有侵权,请联系作者删除!