static public void byteBuffer2Record(ByteBuffer bb, Record record) throws IOException { BinaryInputArchive ia; ia = BinaryInputArchive.getArchive(new ByteBufferInputStream(bb)); record.deserialize(ia, "request"); }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
private Record processSasl(ByteBuffer incomingBuffer, ServerCnxn cnxn) throws IOException { LOG.debug("Responding to client SASL token."); GetSASLRequest clientTokenRecord = new GetSASLRequest(); ByteBufferInputStream.byteBuffer2Record(incomingBuffer,clientTokenRecord); byte[] clientToken = clientTokenRecord.getToken(); LOG.debug("Size of client SASL token: " + clientToken.length);
public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException { InputStream bais = new ByteBufferInputStream(incomingBuffer); BinaryInputArchive bia = BinaryInputArchive.getArchive(bais); RequestHeader h = new RequestHeader(); LOG.info("got auth packet " + cnxn.getRemoteSocketAddress()); AuthPacket authPacket = new AuthPacket(); ByteBufferInputStream.byteBuffer2Record(incomingBuffer, authPacket); String scheme = authPacket.getScheme(); ServerAuthenticationProvider ap = ProviderRegistry.getServerProvider(scheme);
public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException { InputStream bais = new ByteBufferInputStream(incomingBuffer); BinaryInputArchive bia = BinaryInputArchive.getArchive(bais); RequestHeader h = new RequestHeader(); LOG.info("got auth packet " + cnxn.getRemoteSocketAddress()); AuthPacket authPacket = new AuthPacket(); ByteBufferInputStream.byteBuffer2Record(incomingBuffer, authPacket); String scheme = authPacket.getScheme(); AuthenticationProvider ap = ProviderRegistry.getProvider(scheme);
static public void byteBuffer2Record(ByteBuffer bb, Record record) throws IOException { BinaryInputArchive ia; ia = BinaryInputArchive.getArchive(new ByteBufferInputStream(bb)); record.deserialize(ia, "request"); }
@Override public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
private Record processSasl(ByteBuffer incomingBuffer, ServerCnxn cnxn) throws IOException { LOG.debug("Responding to client SASL token."); GetSASLRequest clientTokenRecord = new GetSASLRequest(); ByteBufferInputStream.byteBuffer2Record(incomingBuffer,clientTokenRecord); byte[] clientToken = clientTokenRecord.getToken(); LOG.debug("Size of client SASL token: " + clientToken.length);
@Before public void setUp() throws Exception { bb = ByteBuffer.wrap(DATA_BYTES); in = new ByteBufferInputStream(bb); bs = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 }; }
@Test(expected=IndexOutOfBoundsException.class) public void testReadArrayOffsetLength_LengthTooLarge() throws Exception { in.read(bs, 2, 3); } @Test public void testReadArrayOffsetLength_HitEndOfStream()
MultiTransactionRecord multiTransactionRecord = new MultiTransactionRecord(); request.request.rewind(); ByteBufferInputStream.byteBuffer2Record(request.request, multiTransactionRecord); request.request.rewind(); boolean containsEphemeralCreate = false; CreateRequest createRequest = new CreateRequest(); request.request.rewind(); ByteBufferInputStream.byteBuffer2Record(request.request, createRequest); request.request.rewind(); CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags());
void readConnectResult() throws IOException { if (LOG.isTraceEnabled()) { StringBuilder buf = new StringBuilder("0x["); for (byte b : incomingBuffer.array()) { buf.append(Integer.toHexString(b) + ","); } buf.append("]"); LOG.trace("readConnectResult " + incomingBuffer.remaining() + " " + buf.toString()); } ByteBufferInputStream bbis = new ByteBufferInputStream(incomingBuffer); BinaryInputArchive bbia = BinaryInputArchive.getArchive(bbis); ConnectResponse conRsp = new ConnectResponse(); conRsp.deserialize(bbia, "connect"); // read "is read-only" flag boolean isRO = false; try { isRO = bbia.readBool("readOnly"); } catch (IOException e) { // this is ok -- just a packet from an old server which // doesn't contain readOnly field LOG.warn("Connected to an old server; r-o mode will be unavailable"); } this.sessionId = conRsp.getSessionId(); sendThread.onConnected(conRsp.getTimeOut(), this.sessionId, conRsp.getPasswd(), isRO); }
} else { LearnerInfo li = new LearnerInfo(); ByteBufferInputStream.byteBuffer2Record(ByteBuffer.wrap(learnerInfoData), li); this.sid = li.getServerid(); this.version = li.getProtocolVersion();
@Test public void testSkip2() throws Exception { for (int i = 0; i < DATA_BYTES.length / 2; i++) { in.read(); } long skipAmount = DATA_BYTES.length / 4; assertEquals(skipAmount, in.skip(skipAmount)); int idx = DATA_BYTES.length / 2 + (int) skipAmount; assertEquals(DATA_BYTES[idx++], in.read()); assertEquals(DATA_BYTES[idx++], in.read()); } @Test public void testNegativeSkip() throws Exception {