CodedInputStream cis = CodedInputStream.newInstance(is); int headerSize = cis.readRawVarint32(); Message.Builder builder = RequestHeader.newBuilder(); ProtobufUtil.mergeFrom(builder, cis, headerSize); RequestHeader header = (RequestHeader) builder.build(); SimpleServerCall reqTooBig = new SimpleServerCall(header.getCallId(), this.service, null, null, null, null, this, 0, this.addr, System.currentTimeMillis(), 0, this.rpcServer.reservoir, this.rpcServer.cellBlockBuilder, null, responder);
if (header.hasPriority()) { return header.getPriority();
int headerSize = cis.readRawVarint32(); offset = cis.getTotalBytesRead(); Message.Builder builder = RequestHeader.newBuilder(); ProtobufUtil.mergeFrom(builder, cis, headerSize); RequestHeader header = (RequestHeader) builder.build(); offset += headerSize; int id = header.getCallId(); if (RpcServer.LOG.isTraceEnabled()) { RpcServer.LOG.trace("RequestHeader " + TextFormat.shortDebugString(header) CellScanner cellScanner = null; try { if (header.hasRequestParam() && header.getRequestParam()) { md = this.service.getDescriptorForType().findMethodByName( header.getMethodName()); if (md == null) throw new UnsupportedOperationException(header.getMethodName()); builder = this.service.getRequestPrototype(md).newBuilderForType(); cis.resetSizeCounter(); if (header.hasCellBlockMeta()) { buf.position(offset); ByteBuff dup = buf.duplicate(); dup.limit(offset + header.getCellBlockMeta().getLength()); cellScanner = this.rpcServer.cellBlockBuilder.createCellScannerReusingBuffers( this.codec, this.compressionCodec, dup); if (header.hasTimeout() && header.getTimeout() > 0) { timeout = Math.max(this.rpcServer.minClientRequestTimeout, header.getTimeout());
RequestHeader smallHead = RequestHeader.newBuilder().setCallId(1).build(); when(smallCallTask.getRpcCall()).thenReturn(smallCall); when(smallCall.getHeader()).thenReturn(smallHead); RequestHeader largeHead = RequestHeader.newBuilder().setCallId(50).build(); when(largeCallTask.getRpcCall()).thenReturn(largeCall); when(largeCall.getHeader()).thenReturn(largeHead); RequestHeader hugeHead = RequestHeader.newBuilder().setCallId(100).build(); when(hugeCallTask.getRpcCall()).thenReturn(hugeCall); when(hugeCall.getHeader()).thenReturn(hugeHead);
putCall.param = RequestConverter.buildMutateRequest( Bytes.toBytes("abc"), new Put(Bytes.toBytes("row"))); RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build(); when(putCallTask.getRpcCall()).thenReturn(putCall); when(putCall.getHeader()).thenReturn(putHead); RequestHeader getHead = RequestHeader.newBuilder().setMethodName("get").build(); when(getCallTask.getRpcCall()).thenReturn(getCall); when(getCall.getHeader()).thenReturn(getHead); ServerCall scanCall = mock(ServerCall.class); scanCall.param = ScanRequest.newBuilder().setScannerId(1).build(); RequestHeader scanHead = RequestHeader.newBuilder().setMethodName("scan").build(); when(scanCallTask.getRpcCall()).thenReturn(scanCall); when(scanCall.getHeader()).thenReturn(scanHead);
@Test public void testQosFunctionForScanMethod() throws IOException { RequestHeader.Builder headerBuilder = RequestHeader.newBuilder(); headerBuilder.setMethodName("Scan"); RequestHeader header = headerBuilder.build();
.computeMessageSize(2, getTraceInfo()); .computeMessageSize(5, getCellBlockMeta());
result = result && (hasCallId() == other.hasCallId()); if (hasCallId()) { result = result && (getCallId() == other.getCallId()); result = result && (hasTraceInfo() == other.hasTraceInfo()); if (hasTraceInfo()) { result = result && getTraceInfo() .equals(other.getTraceInfo()); result = result && (hasMethodName() == other.hasMethodName()); if (hasMethodName()) { result = result && getMethodName() .equals(other.getMethodName()); result = result && (hasRequestParam() == other.hasRequestParam()); if (hasRequestParam()) { result = result && (getRequestParam() == other.getRequestParam()); result = result && (hasCellBlockMeta() == other.hasCellBlockMeta()); if (hasCellBlockMeta()) { result = result && getCellBlockMeta() .equals(other.getCellBlockMeta()); result = result && (hasPriority() == other.hasPriority()); if (hasPriority()) { result = result && (getPriority() == other.getPriority());
RequestHeader requestHeader = IPCUtil.buildRequestHeader(call, null); dos.writeInt(IPCUtil.getTotalSizeWhenWrittenDelimited(requestHeader, call.param)); requestHeader.writeDelimitedTo(dos); call.param.writeDelimitedTo(dos); dos.flush();
buf.writeInt(totalSize); try (ByteBufOutputStream bbos = new ByteBufOutputStream(buf)) { requestHeader.writeDelimitedTo(bbos); if (call.param != null) { call.param.writeDelimitedTo(bbos);
@Test public void testQosFunctionForMeta() throws IOException { priority = regionServer.rpcServices.getPriority(); RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
hash = (19 * hash) + getDescriptor().hashCode(); if (hasCallId()) { hash = (37 * hash) + CALL_ID_FIELD_NUMBER; hash = (53 * hash) + getCallId(); if (hasTraceInfo()) { hash = (37 * hash) + TRACE_INFO_FIELD_NUMBER; hash = (53 * hash) + getTraceInfo().hashCode(); if (hasMethodName()) { hash = (37 * hash) + METHOD_NAME_FIELD_NUMBER; hash = (53 * hash) + getMethodName().hashCode(); if (hasRequestParam()) { hash = (37 * hash) + REQUEST_PARAM_FIELD_NUMBER; hash = (53 * hash) + org.apache.hbase.thirdparty.com.google.protobuf.Internal.hashBoolean( getRequestParam()); if (hasCellBlockMeta()) { hash = (37 * hash) + CELL_BLOCK_META_FIELD_NUMBER; hash = (53 * hash) + getCellBlockMeta().hashCode(); if (hasPriority()) { hash = (37 * hash) + PRIORITY_FIELD_NUMBER; hash = (53 * hash) + getPriority(); if (hasTimeout()) { hash = (37 * hash) + TIMEOUT_FIELD_NUMBER; hash = (53 * hash) + getTimeout();
putCall.param = RequestConverter.buildMutateRequest( Bytes.toBytes("abc"), new Put(Bytes.toBytes("row"))); RequestHeader putHead = RequestHeader.newBuilder().setMethodName("mutate").build(); when(putCallTask.getRpcCall()).thenReturn(putCall); when(putCall.getHeader()).thenReturn(putHead);
private CallRunner getMockedCallRunner(long timestamp, final long sleepTime) throws IOException { ServerCall putCall = new ServerCall(1, null, null, RPCProtos.RequestHeader.newBuilder().setMethodName("mutate").build(), RequestConverter.buildMutateRequest(Bytes.toBytes("abc"), new Put(Bytes.toBytes("row"))), null, null, 9, null, timestamp, 0, null, null, null) {
public void writeTo(org.apache.hbase.thirdparty.com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeUInt32(1, callId_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeMessage(2, getTraceInfo()); } if (((bitField0_ & 0x00000004) == 0x00000004)) { org.apache.hbase.thirdparty.com.google.protobuf.GeneratedMessageV3.writeString(output, 3, methodName_); } if (((bitField0_ & 0x00000008) == 0x00000008)) { output.writeBool(4, requestParam_); } if (((bitField0_ & 0x00000010) == 0x00000010)) { output.writeMessage(5, getCellBlockMeta()); } if (((bitField0_ & 0x00000020) == 0x00000020)) { output.writeUInt32(6, priority_); } if (((bitField0_ & 0x00000040) == 0x00000040)) { output.writeUInt32(7, timeout_); } unknownFields.writeTo(output); }
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader.getDefaultInstance()) return this; if (other.hasCallId()) { setCallId(other.getCallId()); } if (other.hasTraceInfo()) { mergeTraceInfo(other.getTraceInfo()); } if (other.hasMethodName()) { bitField0_ |= 0x00000004; methodName_ = other.methodName_; onChanged(); } if (other.hasRequestParam()) { setRequestParam(other.getRequestParam()); } if (other.hasCellBlockMeta()) { mergeCellBlockMeta(other.getCellBlockMeta()); } if (other.hasPriority()) { setPriority(other.getPriority()); } if (other.hasTimeout()) { setTimeout(other.getTimeout()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
static RequestHeader buildRequestHeader(Call call, CellBlockMeta cellBlockMeta) { RequestHeader.Builder builder = RequestHeader.newBuilder(); builder.setCallId(call.id); //TODO handle htrace API change, see HBASE-18895 /*if (call.span != null) { builder.setTraceInfo(RPCTInfo.newBuilder().setParentId(call.span.getSpanId()) .setTraceId(call.span.getTracerId())); }*/ builder.setMethodName(call.md.getName()); builder.setRequestParam(call.param != null); if (cellBlockMeta != null) { builder.setCellBlockMeta(cellBlockMeta); } // Only pass priority if there is one set. if (call.priority != HConstants.PRIORITY_UNSET) { builder.setPriority(call.priority); } builder.setTimeout(call.timeout); return builder.build(); }
private CallRunner createMockTask(AtomicInteger callExecutionCount, boolean isRegionServerReportTask) { CallRunner task = mock(CallRunner.class); ServerCall call = mock(ServerCall.class); when(task.getRpcCall()).thenReturn(call); when(call.getHeader()).thenReturn(RPCProtos.RequestHeader.newBuilder() .setMethodName(isRegionServerReportTask ? REGION_SERVER_REPORT : OTHER).build()); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { callExecutionCount.incrementAndGet(); Thread.sleep(1000); return null; } }).when(task).run(); return task; }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
@Override public boolean dispatch(CallRunner callTask) throws InterruptedException, IOException { ServerCall call = callTask.getCall(); int priority = call.getHeader().getPriority(); if (indexPriority == priority) { return indexCallExecutor.dispatch(callTask); } else if (metadataPriority == priority) { return metadataCallExecutor.dispatch(callTask); } else { return delegate.dispatch(callTask); } }