Java 类org.apache.hadoop.hbase.protobuf.generated.TracingProtos.RPCTInfo 实例源码

项目:HIndex    文件:RpcClient.java   
/**
 * Initiates a call by sending the parameter to the remote server.
 * Note: this is not called from the Connection thread, but by other
 * threads.
 * @param call
 * @param priority
 * @see #readResponse()
 */
protected void writeRequest(Call call, final int priority) {
  if (shouldCloseConnection.get()) return;
  try {
    RequestHeader.Builder builder = RequestHeader.newBuilder();
    builder.setCallId(call.id);
    if (Trace.isTracing()) {
      Span s = Trace.currentSpan();
      builder.setTraceInfo(RPCTInfo.newBuilder().
        setParentId(s.getSpanId()).setTraceId(s.getTraceId()));
    }
    builder.setMethodName(call.md.getName());
    builder.setRequestParam(call.param != null);
    ByteBuffer cellBlock = ipcUtil.buildCellBlock(this.codec, this.compressor, call.cells);
    if (cellBlock != null) {
      CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
      cellBlockBuilder.setLength(cellBlock.limit());
      builder.setCellBlockMeta(cellBlockBuilder.build());
    }
    // Only pass priority if there one.  Let zero be same as no priority.
    if (priority != 0) builder.setPriority(priority);
    //noinspection SynchronizeOnNonFinalField
    RequestHeader header = builder.build();
    synchronized (this.out) { // FindBugs IS2_INCONSISTENT_SYNC
      IPCUtil.write(this.out, header, call.param, cellBlock);
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(getName() + ": wrote request header " + TextFormat.shortDebugString(header));
    }
  } catch(IOException e) {
    markClosed(e);
  }
}
项目:c5    文件:RpcClient.java   
/**
 * Initiates a call by sending the parameter to the remote server.
 * Note: this is not called from the Connection thread, but by other
 * threads.
 * @param call
 * @param priority
 * @see #readResponse()
 */
protected void writeRequest(Call call, final int priority) {
  if (shouldCloseConnection.get()) return;
  try {
    RequestHeader.Builder builder = RequestHeader.newBuilder();
    builder.setCallId(call.id);
    if (Trace.isTracing()) {
      Span s = Trace.currentSpan();
      builder.setTraceInfo(RPCTInfo.newBuilder().
        setParentId(s.getSpanId()).setTraceId(s.getTraceId()));
    }
    builder.setMethodName(call.md.getName());
    builder.setRequestParam(call.param != null);
    ByteBuffer cellBlock = ipcUtil.buildCellBlock(this.codec, this.compressor, call.cells);
    if (cellBlock != null) {
      CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
      cellBlockBuilder.setLength(cellBlock.limit());
      builder.setCellBlockMeta(cellBlockBuilder.build());
    }
    // Only pass priority if there one.  Let zero be same as no priority.
    if (priority != 0) builder.setPriority(priority);
    //noinspection SynchronizeOnNonFinalField
    RequestHeader header = builder.build();
    synchronized (this.out) { // FindBugs IS2_INCONSISTENT_SYNC
      IPCUtil.write(this.out, header, call.param, cellBlock);
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug(getName() + ": wrote request header " + TextFormat.shortDebugString(header));
    }
  } catch(IOException e) {
    markClosed(e);
  }
}
项目:ditb    文件:RpcClientImpl.java   
/**
 * Initiates a call by sending the parameter to the remote server.
 * Note: this is not called from the Connection thread, but by other
 * threads.
 * @see #readResponse()
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="IS2_INCONSISTENT_SYNC",
    justification="Findbugs is misinterpreting locking missing fact that this.outLock is held")
private void writeRequest(Call call, final int priority, Span span) throws IOException {
  RequestHeader.Builder builder = RequestHeader.newBuilder();
  builder.setCallId(call.id);
  if (span != null) {
    builder.setTraceInfo(
        RPCTInfo.newBuilder().setParentId(span.getSpanId()).setTraceId(span.getTraceId()));
  }
  builder.setMethodName(call.md.getName());
  builder.setRequestParam(call.param != null);
  ByteBuffer cellBlock = ipcUtil.buildCellBlock(this.codec, this.compressor, call.cells);
  if (cellBlock != null) {
    CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
    cellBlockBuilder.setLength(cellBlock.limit());
    builder.setCellBlockMeta(cellBlockBuilder.build());
  }
  // Only pass priority if there one.  Let zero be same as no priority.
  if (priority != 0) builder.setPriority(priority);
  RequestHeader header = builder.build();

  setupIOstreams();

  // Now we're going to write the call. We take the lock, then check that the connection
  //  is still valid, and, if so we do the write to the socket. If the write fails, we don't
  //  know where we stand, we have to close the connection.
  checkIsOpen();
  IOException writeException = null;
  synchronized (this.outLock) {
    if (Thread.interrupted()) throw new InterruptedIOException();

    calls.put(call.id, call); // We put first as we don't want the connection to become idle.
    checkIsOpen(); // Now we're checking that it didn't became idle in between.

    try {
      call.callStats.setRequestSizeBytes(IPCUtil.write(this.out, header, call.param,
          cellBlock));
    } catch (IOException e) {
      // We set the value inside the synchronized block, this way the next in line
      //  won't even try to write. Otherwise we might miss a call in the calls map?
      shouldCloseConnection.set(true);
      writeException = e;
      interrupt();
    }
  }

  // call close outside of the synchronized (outLock) to prevent deadlock - HBASE-14474
  if (writeException != null) {
    markClosed(writeException);
    close();
  }

  // We added a call, and may be started the connection close. In both cases, we
  //  need to notify the reader.
  doNotify();

  // Now that we notified, we can rethrow the exception if any. Otherwise we're good.
  if (writeException != null) throw writeException;
}
项目:pbase    文件:RpcClientImpl.java   
/**
 * Initiates a call by sending the parameter to the remote server.
 * Note: this is not called from the Connection thread, but by other
 * threads.
 * @see #readResponse()
 */
private void writeRequest(Call call, final int priority, Span span) throws IOException {
  RequestHeader.Builder builder = RequestHeader.newBuilder();
  builder.setCallId(call.id);
  if (span != null) {
    builder.setTraceInfo(
        RPCTInfo.newBuilder().setParentId(span.getSpanId()).setTraceId(span.getTraceId()));
  }
  builder.setMethodName(call.md.getName());
  builder.setRequestParam(call.param != null);
  ByteBuffer cellBlock = ipcUtil.buildCellBlock(this.codec, this.compressor, call.cells);
  if (cellBlock != null) {
    CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
    cellBlockBuilder.setLength(cellBlock.limit());
    builder.setCellBlockMeta(cellBlockBuilder.build());
  }
  // Only pass priority if there one.  Let zero be same as no priority.
  if (priority != 0) builder.setPriority(priority);
  RequestHeader header = builder.build();

  setupIOstreams();

  // Now we're going to write the call. We take the lock, then check that the connection
  //  is still valid, and, if so we do the write to the socket. If the write fails, we don't
  //  know where we stand, we have to close the connection.
  checkIsOpen();
  IOException writeException = null;
  synchronized (this.outLock) {
    if (Thread.interrupted()) throw new InterruptedIOException();

    calls.put(call.id, call); // We put first as we don't want the connection to become idle.
    checkIsOpen(); // Now we're checking that it didn't became idle in between.

    try {
      IPCUtil.write(this.out, header, call.param, cellBlock);
    } catch (IOException e) {
      // We set the value inside the synchronized block, this way the next in line
      //  won't even try to write
      shouldCloseConnection.set(true);
      writeException = e;
      interrupt();
    }
  }

  // We added a call, and may be started the connection close. In both cases, we
  //  need to notify the reader.
  synchronized (this) {
    notifyAll();
  }

  // Now that we notified, we can rethrow the exception if any. Otherwise we're good.
  if (writeException != null) throw writeException;
}
项目:PyroDB    文件:RpcClient.java   
/**
 * Initiates a call by sending the parameter to the remote server.
 * Note: this is not called from the Connection thread, but by other
 * threads.
 * @see #readResponse()
 */
private void writeRequest(Call call, final int priority, Span span) throws IOException {
  RequestHeader.Builder builder = RequestHeader.newBuilder();
  builder.setCallId(call.id);
  if (span != null) {
    builder.setTraceInfo(
        RPCTInfo.newBuilder().setParentId(span.getSpanId()).setTraceId(span.getTraceId()));
  }
  builder.setMethodName(call.md.getName());
  builder.setRequestParam(call.param != null);
  ByteBuffer cellBlock = ipcUtil.buildCellBlock(this.codec, this.compressor, call.cells);
  if (cellBlock != null) {
    CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
    cellBlockBuilder.setLength(cellBlock.limit());
    builder.setCellBlockMeta(cellBlockBuilder.build());
  }
  // Only pass priority if there one.  Let zero be same as no priority.
  if (priority != 0) builder.setPriority(priority);
  RequestHeader header = builder.build();

  setupIOstreams();

  // Now we're going to write the call. We take the lock, then check that the connection
  //  is still valid, and, if so we do the write to the socket. If the write fails, we don't
  //  know where we stand, we have to close the connection.
  checkIsOpen();
  IOException writeException = null;
  synchronized (this.out) {
    if (Thread.interrupted()) throw new InterruptedIOException();

    calls.put(call.id, call); // We put first as we don't want the connection to become idle.
    checkIsOpen(); // Now we're checking that it didn't became idle in between.

    try {
      IPCUtil.write(this.out, header, call.param, cellBlock);
    } catch (IOException e) {
      // We set the value inside the synchronized block, this way the next in line
      //  won't even try to write
      shouldCloseConnection.set(true);
      writeException = e;
    }
  }

  // We added a call, and may be started the connection close. In both cases, we
  //  need to notify the reader.
  synchronized (this) {
    notifyAll();
  }

  // Now that we notified, we can rethrow the exception if any. Otherwise we're good.
  if (writeException != null) throw writeException;

  if (LOG.isDebugEnabled()) {
    LOG.debug(getName() + ": wrote request header " + TextFormat.shortDebugString(header));
  }
}