/** * No protobuf encoding of raw sasl messages */ private void doRawSaslReply(SaslStatus status, Writable rv, String errorClass, String error) throws IOException { //In my testing, have noticed that sasl messages are usually //in the ballpark of 100-200. That's why the initialcapacity is 256. ByteBufferOutputStream saslResponse = new ByteBufferOutputStream(256); DataOutputStream out = new DataOutputStream(saslResponse); out.writeInt(status.state); // write status if (status == SaslStatus.SUCCESS) { rv.write(out); } else { WritableUtils.writeString(out, errorClass); WritableUtils.writeString(out, error); } saslCall.setSaslTokenResponse(saslResponse.getByteBuffer()); saslCall.responder = responder; saslCall.sendResponseIfReady(); }
private static void readStatus(DataInputStream inStream) throws IOException { int id = inStream.readInt(); // read and discard dummy id int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
private void doSaslReply(SaslStatus status, Writable rv, String errorClass, String error) throws IOException { saslCall.setResponse(rv, status == SaslStatus.SUCCESS ? Status.SUCCESS : Status.ERROR, errorClass, error); saslCall.responder = responder; saslCall.sendResponseIfReady(); }
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }