Refine search
static private String hex(SocketAddress address) { if( address instanceof InetSocketAddress ) { InetSocketAddress isa = (InetSocketAddress)address; return HexSupport.toHexFromBuffer(new Buffer(isa.getAddress().getAddress()))+Integer.toHexString(isa.getPort()); } return ""; }
public byte[] getPayload() { return payload.toByteArray(); }
public void onPublish(UTF8Buffer topic, final Buffer payload, final Callback<Callback<Void>> onComplete) { getDispatchQueue().assertExecuting(); receiveBufferRemaining -= payload.length(); if( !receiveBufferFull && receiveBufferRemaining <=0 ) { receiveBufferFull = true; suspend(); } deliverMessage(new Message(getDispatchQueue(), topic, payload, new Callback<Callback<Void>>() { public void onSuccess(Callback<Void> value) { processed(); onComplete.onSuccess(value); } public void onFailure(Throwable value) { processed(); onComplete.onFailure(value); } private void processed() { getDispatchQueue().assertExecuting(); receiveBufferRemaining += payload.length(); if( receiveBufferFull && receiveBufferRemaining >0 ) { receiveBufferFull = false; resume(); } } })); }
final public Buffer compact() { if (length != data.length) { return new Buffer(toByteArray()); } return this; }
public void writeExternal(java.io.DataOutput out) throws java.io.IOException { out.writeLong(bean.f_key); if( bean.f_bindingKind!=null ) { out.writeInt(bean.f_bindingKind.getLength()); out.write(bean.f_bindingKind.getData(), bean.f_bindingKind.getOffset(), bean.f_bindingKind.getLength()); } else { out.writeInt(-1); } if( bean.f_bindingData!=null ) { out.writeInt(bean.f_bindingData.getLength()); out.write(bean.f_bindingData.getData(), bean.f_bindingData.getOffset(), bean.f_bindingData.getLength()); } else { out.writeInt(-1); } }
public void readHeader() { buffer = paged.slice(SliceType.READ, page, 1); Buffer m = new Buffer(magic.length); buffer.get(m.data); if( !magic.equals(m) ) { throw new IOPagingException("Invalid extent read request. The requested page was not an extent: "+page); } IntBuffer ib = buffer.asIntBuffer(); length = ib.get(); next = ib.get(); }
public void setBuffer(Buffer value, boolean validate) { if (validate && !value.startsWith(PREFIX) || value.length() != 8) { throw new IllegalArgumentException("Not an AMQP header buffer"); } buffer = value.buffer(); }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj.getClass() != Buffer.class) return false; return equals((Buffer) obj); }
@Override public int hashCode() { if( hashCode==0 ) { hashCode = super.hashCode();; } return hashCode; }
/** * Converts a Binary value to a long assuming that the contained value is * stored in Big Endian encoding. * * @param value the Binary object whose payload is converted to a long. * @return a long value constructed from the bytes of the Binary instance. */ public static long toLong(Binary value) { Buffer buffer = new Buffer(value.getArray(), value.getArrayOffset(), value.getLength()); return buffer.bigEndianEditor().readLong(); }
public void addContentLengthHeader() { addHeader(CONTENT_LENGTH, new AsciiBuffer(Integer.toString(content.length()))); }
public boolean equals(Bean obj) { if (hasKey() ^ obj.hasKey() ) return false; if (hasKey() && ( getKey()!=obj.getKey() )) return false; if (hasBindingKind() ^ obj.hasBindingKind() ) return false; if (hasBindingKind() && ( !getBindingKind().equals(obj.getBindingKind()) )) return false; if (hasBindingData() ^ obj.hasBindingData() ) return false; if (hasBindingData() && ( !getBindingData().equals(obj.getBindingData()) )) return false; return true; }
public StompFrame createCreditFrame(StompJmsMessageConsumer consumer, StompFrame messageFrame) { final Buffer content = messageFrame.content(); String credit = "1"; if( content!=null ) { credit += ","+content.length(); } StompFrame frame = new StompFrame(); frame.action(ACK); frame.headerMap().put(SUBSCRIPTION, consumer.id); frame.headerMap().put(CREDIT, AsciiBuffer.ascii(credit)); return frame; }
public int size() { int rc = action.length() + 1; if( headerList!=null ) { for (HeaderEntry entry : headerList) { rc += entry.getKey().length() + entry.getValue().length() + 2; } } else { for (Map.Entry<AsciiBuffer,AsciiBuffer> entry : headerMap.entrySet()) { rc += entry.getKey().length() + entry.getValue().length() + 2; } } rc += content.length() + 3; return rc; }