@ Override public boolean isCompleteRequest ( final ByteBuffer buffer ) throws VoldemortException { DataInputStream inputStream = new DataInputStream ( new ByteBufferBackedInputStream ( buffer ) ) ; try { byte opCode = inputStream . readByte ( ) ; // Store Name inputStream . readUTF ( ) ; // Store routing type getRoutingType ( inputStream ) ; switch ( opCode ) { case VoldemortOpCode . GET_VERSION_OP_CODE : if ( ! GetVersionRequestHandler . isCompleteRequest ( inputStream , buffer ) ) return false ; break ; case VoldemortOpCode . GET_OP_CODE : if ( ! GetRequestHandler . isCompleteRequest ( inputStream , buffer , protocolVersion ) ) return false ; break ; case VoldemortOpCode . GET_ALL_OP_CODE : if ( ! GetAllRequestHandler . isCompleteRequest ( inputStream , buffer , protocolVersion ) ) return false ; break ; case VoldemortOpCode . PUT_OP_CODE : { if ( ! PutRequestHandler . isCompleteRequest ( inputStream , buffer , protocolVersion ) ) return false ; break ; } case VoldemortOpCode . DELETE_OP_CODE : { if ( ! DeleteRequestHandler . isCompleteRequest ( inputStream , buffer ) ) return false ; break ; } default : throw new VoldemortException ( " Unrecognized Voldemort OpCode " + opCode ) ; } // This should not happen, if we reach here and if buffer has more // data, there is something wrong. if ( buffer . hasRemaining ( ) ) { logger . info ( "Probably a client bug, Discarding additional bytes in isCompleteRequest. Opcode: " + opCode + ", remaining bytes: " + buffer . remaining ( ) ) ; } return true ; } catch ( IOException e ) { // This could also occur if the various methods we call into // re-throw a corrupted value error as some other type of exception. // For example, updating the position on a buffer past its limit // throws an InvalidArgumentException. if ( logger . isDebugEnabled ( ) ) logger . debug ( "Probable partial read occurred causing exception" , e ) ; return false ; } }
This is pretty ugly . We end up mimicking the request logic here so this needs to stay in sync with handleRequest .