def create_sasl_header(self): rpcheader = RpcRequestHeaderProto() rpcheader.rpcKind = 2 # rpcheaderproto.RpcKindProto.Value('RPC_PROTOCOL_BUFFER') rpcheader.rpcOp = 0 # rpcheaderproto.RpcPayloadOperationProto.Value('RPC_FINAL_PACKET') rpcheader.callId = -33 rpcheader.retryCount = -1 rpcheader.clientId = self.client_id[0:16] return rpcheader
def create_rpc_request_header(self): '''Creates and serializes a delimited RpcRequestHeaderProto message.''' rpcheader = RpcRequestHeaderProto() rpcheader.rpcKind = 2 # rpcheaderproto.RpcKindProto.Value('RPC_PROTOCOL_BUFFER') rpcheader.rpcOp = 0 # rpcheaderproto.RpcPayloadOperationProto.Value('RPC_FINAL_PACKET') rpcheader.callId = self.call_id rpcheader.retryCount = -1 rpcheader.clientId = self.client_id[0:16] if self.call_id == -3: self.call_id = 0 else: self.call_id += 1 # Serialize delimited s_rpcHeader = rpcheader.SerializeToString() log_protobuf_message("RpcRequestHeaderProto (len: %d)" % (len(s_rpcHeader)), rpcheader) return s_rpcHeader
def _send_sasl_message(self, message): rpcheader = RpcRequestHeaderProto() rpcheader.rpcKind = 2 # RPC_PROTOCOL_BUFFER rpcheader.rpcOp = 0 rpcheader.callId = -33 # SASL rpcheader.retryCount = -1 rpcheader.clientId = b"" s_rpcheader = rpcheader.SerializeToString() s_message = message.SerializeToString() header_length = len(s_rpcheader) + encoder._VarintSize(len(s_rpcheader)) + len(s_message) + encoder._VarintSize(len(s_message)) self._trans.write(struct.pack('!I', header_length)) self._trans.write_delimited(s_rpcheader) self._trans.write_delimited(s_message) log_protobuf_message("Send out", message)