• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ExceptionResponse类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse的典型用法代码示例。如果您正苦于以下问题:Java ExceptionResponse类的具体用法?Java ExceptionResponse怎么用?Java ExceptionResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ExceptionResponse类属于org.apache.hadoop.hbase.protobuf.generated.RPCProtos包,在下文中一共展示了ExceptionResponse类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createRemoteException

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
/**
 * @param e exception to be wrapped
 * @return RemoteException made from passed <code>e</code>
 */
private RemoteException createRemoteException(final ExceptionResponse e) {
  String innerExceptionClassName = e.getExceptionClassName();
  boolean doNotRetry = e.getDoNotRetry();
  return e.hasHostname()?
    // If a hostname then add it to the RemoteWithExtrasException
    new RemoteWithExtrasException(innerExceptionClassName,
      e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry):
    new RemoteWithExtrasException(innerExceptionClassName,
      e.getStackTrace(), doNotRetry);
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:15,
代码来源:RpcClientImpl.java

示例2: createRemoteException

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
/**
 * @param e
 * @return RemoteException made from passed <code>e</code>
 */
private RemoteException createRemoteException(final ExceptionResponse e) {
  String innerExceptionClassName = e.getExceptionClassName();
  boolean doNotRetry = e.getDoNotRetry();
  return e.hasHostname()?
    // If a hostname then add it to the RemoteWithExtrasException
    new RemoteWithExtrasException(innerExceptionClassName,
      e.getStackTrace(), e.getHostname(), e.getPort(), doNotRetry):
    new RemoteWithExtrasException(innerExceptionClassName,
      e.getStackTrace(), doNotRetry);
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:15,
代码来源:RpcClient.java

示例3: setResponse

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
protected synchronized void setResponse(Object m, final CellScanner cells,
    Throwable t, String errorMsg) {
  if (this.isError) return;
  if (t != null) this.isError = true;
  BufferChain bc = null;
  try {
    ResponseHeader.Builder headerBuilder = ResponseHeader.newBuilder();
    // Presume it a pb Message.  Could be null.
    Message result = (Message)m;
    // Call id.
    headerBuilder.setCallId(this.id);
    if (t != null) {
      ExceptionResponse.Builder exceptionBuilder = ExceptionResponse.newBuilder();
      exceptionBuilder.setExceptionClassName(t.getClass().getName());
      exceptionBuilder.setStackTrace(errorMsg);
      exceptionBuilder.setDoNotRetry(t instanceof DoNotRetryIOException ||
        t instanceof NeedUnmanagedConnectionException);
      if (t instanceof RegionMovedException) {
        // Special casing for this exception.  This is only one carrying a payload.
        // Do this instead of build a generic system for allowing exceptions carry
        // any kind of payload.
        RegionMovedException rme = (RegionMovedException)t;
        exceptionBuilder.setHostname(rme.getHostname());
        exceptionBuilder.setPort(rme.getPort());
      }
      // Set the exception as the result of the method invocation.
      headerBuilder.setException(exceptionBuilder.build());
    }
    // Pass reservoir to buildCellBlock. Keep reference to returne so can add it back to the
    // reservoir when finished. This is hacky and the hack is not contained but benefits are
    // high when we can avoid a big buffer allocation on each rpc.
    this.cellBlock = ipcUtil.buildCellBlock(this.connection.codec,
      this.connection.compressionCodec, cells, reservoir);
    if (this.cellBlock != null) {
      CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
      // Presumes the cellBlock bytebuffer has been flipped so limit has total size in it.
      cellBlockBuilder.setLength(this.cellBlock.limit());
      headerBuilder.setCellBlockMeta(cellBlockBuilder.build());
    }
    Message header = headerBuilder.build();

    // Organize the response as a set of bytebuffers rather than collect it all together inside
    // one big byte array; save on allocations.
    ByteBuffer bbHeader = IPCUtil.getDelimitedMessageAsByteBuffer(header);
    ByteBuffer bbResult = IPCUtil.getDelimitedMessageAsByteBuffer(result);
    int totalSize = bbHeader.capacity() + (bbResult == null? 0: bbResult.limit()) +
      (this.cellBlock == null? 0: this.cellBlock.limit());
    ByteBuffer bbTotalSize = ByteBuffer.wrap(Bytes.toBytes(totalSize));
    bc = new BufferChain(bbTotalSize, bbHeader, bbResult, this.cellBlock);
    if (connection.useWrap) {
      bc = wrapWithSasl(bc);
    }
  } catch (IOException e) {
    LOG.warn("Exception while creating response " + e);
  }
  this.response = bc;
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:58,
代码来源:RpcServer.java

示例4: readResponse

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
protected void readResponse() {
  if (shouldCloseConnection.get()) return;
  Call call = null;
  boolean expectedCall = false;
  try {
    // See HBaseServer.Call.setResponse for where we write out the response.
    // Total size of the response.  Unused.  But have to read it in anyways.
    int totalSize = in.readInt();

    // Read the header
    ResponseHeader responseHeader = ResponseHeader.parseDelimitedFrom(in);
    int id = responseHeader.getCallId();
    call = calls.remove(id); // call.done have to be set before leaving this method
    expectedCall = (call != null && !call.done);
    if (!expectedCall) {
      // So we got a response for which we have no corresponding 'call' here on the client-side.
      // We probably timed out waiting, cleaned up all references, and now the server decides
      // to return a response.  There is nothing we can do w/ the response at this stage. Clean
      // out the wire of the response so its out of the way and we can get other responses on
      // this connection.
      int readSoFar = IPCUtil.getTotalSizeWhenWrittenDelimited(responseHeader);
      int whatIsLeftToRead = totalSize - readSoFar;
      IOUtils.skipFully(in, whatIsLeftToRead);
      if (call != null) {
        call.callStats.setResponseSizeBytes(totalSize);
        call.callStats.setCallTimeMs(
            EnvironmentEdgeManager.currentTime() - call.callStats.getStartTime());
      }
      return;
    }
    if (responseHeader.hasException()) {
      ExceptionResponse exceptionResponse = responseHeader.getException();
      RemoteException re = createRemoteException(exceptionResponse);
      call.setException(re);
      call.callStats.setResponseSizeBytes(totalSize);
      call.callStats.setCallTimeMs(
          EnvironmentEdgeManager.currentTime() - call.callStats.getStartTime());
      if (isFatalConnectionException(exceptionResponse)) {
        markClosed(re);
      }
    } else {
      Message value = null;
      if (call.responseDefaultType != null) {
        Builder builder = call.responseDefaultType.newBuilderForType();
        ProtobufUtil.mergeDelimitedFrom(builder, in);
        value = builder.build();
      }
      CellScanner cellBlockScanner = null;
      if (responseHeader.hasCellBlockMeta()) {
        int size = responseHeader.getCellBlockMeta().getLength();
        byte [] cellBlock = new byte[size];
        IOUtils.readFully(this.in, cellBlock, 0, cellBlock.length);
        cellBlockScanner = ipcUtil.createCellScanner(this.codec, this.compressor, cellBlock);
      }
      call.setResponse(value, cellBlockScanner);
      call.callStats.setResponseSizeBytes(totalSize);
      call.callStats.setCallTimeMs(
          EnvironmentEdgeManager.currentTime() - call.callStats.getStartTime());
    }
  } catch (IOException e) {
    if (expectedCall) call.setException(e);
    if (e instanceof SocketTimeoutException) {
      // Clean up open calls but don't treat this as a fatal condition,
      // since we expect certain responses to not make it by the specified
      // {@link ConnectionId#rpcTimeout}.
      if (LOG.isTraceEnabled()) LOG.trace("ignored", e);
    } else {
      // Treat this as a fatal condition and close this connection
      markClosed(e);
    }
  } finally {
    cleanupCalls(false);
  }
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:75,
代码来源:RpcClientImpl.java

示例5: isFatalConnectionException

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
/**
 * @return True if the exception is a fatal connection exception.
 */
private boolean isFatalConnectionException(final ExceptionResponse e) {
  return e.getExceptionClassName().
    equals(FatalConnectionException.class.getName());
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:8,
代码来源:RpcClientImpl.java

示例6: setResponse

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
protected synchronized void setResponse(Object m, final CellScanner cells,
    Throwable t, String errorMsg) {
  if (this.isError) return;
  if (t != null) this.isError = true;
  BufferChain bc = null;
  try {
    ResponseHeader.Builder headerBuilder = ResponseHeader.newBuilder();
    // Presume it a pb Message.  Could be null.
    Message result = (Message)m;
    // Call id.
    headerBuilder.setCallId(this.id);
    if (t != null) {
      ExceptionResponse.Builder exceptionBuilder = ExceptionResponse.newBuilder();
      exceptionBuilder.setExceptionClassName(t.getClass().getName());
      exceptionBuilder.setStackTrace(errorMsg);
      exceptionBuilder.setDoNotRetry(t instanceof DoNotRetryIOException);
      if (t instanceof RegionMovedException) {
        // Special casing for this exception.  This is only one carrying a payload.
        // Do this instead of build a generic system for allowing exceptions carry
        // any kind of payload.
        RegionMovedException rme = (RegionMovedException)t;
        exceptionBuilder.setHostname(rme.getHostname());
        exceptionBuilder.setPort(rme.getPort());
      }
      // Set the exception as the result of the method invocation.
      headerBuilder.setException(exceptionBuilder.build());
    }
    ByteBuffer cellBlock =
      ipcUtil.buildCellBlock(this.connection.codec, this.connection.compressionCodec, cells);
    if (cellBlock != null) {
      CellBlockMeta.Builder cellBlockBuilder = CellBlockMeta.newBuilder();
      // Presumes the cellBlock bytebuffer has been flipped so limit has total size in it.
      cellBlockBuilder.setLength(cellBlock.limit());
      headerBuilder.setCellBlockMeta(cellBlockBuilder.build());
    }
    Message header = headerBuilder.build();

    // Organize the response as a set of bytebuffers rather than collect it all together inside
    // one big byte array; save on allocations.
    ByteBuffer bbHeader = IPCUtil.getDelimitedMessageAsByteBuffer(header);
    ByteBuffer bbResult = IPCUtil.getDelimitedMessageAsByteBuffer(result);
    int totalSize = bbHeader.capacity() + (bbResult == null? 0: bbResult.limit()) +
      (cellBlock == null? 0: cellBlock.limit());
    ByteBuffer bbTotalSize = ByteBuffer.wrap(Bytes.toBytes(totalSize));
    bc = new BufferChain(bbTotalSize, bbHeader, bbResult, cellBlock);
    if (connection.useWrap) {
      bc = wrapWithSasl(bc);
    }
  } catch (IOException e) {
    LOG.warn("Exception while creating response " + e);
  }
  this.response = bc;
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:54,
代码来源:RpcServer.java

示例7: readResponse

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
protected void readResponse() {
  if (shouldCloseConnection.get()) return;
  Call call = null;
  boolean expectedCall = false;
  try {
    // See HBaseServer.Call.setResponse for where we write out the response.
    // Total size of the response.  Unused.  But have to read it in anyways.
    int totalSize = in.readInt();

    // Read the header
    ResponseHeader responseHeader = ResponseHeader.parseDelimitedFrom(in);
    int id = responseHeader.getCallId();
    call = calls.remove(id); // call.done have to be set before leaving this method
    expectedCall = (call != null && !call.done);
    if (!expectedCall) {
      // So we got a response for which we have no corresponding 'call' here on the client-side.
      // We probably timed out waiting, cleaned up all references, and now the server decides
      // to return a response.  There is nothing we can do w/ the response at this stage. Clean
      // out the wire of the response so its out of the way and we can get other responses on
      // this connection.
      int readSoFar = IPCUtil.getTotalSizeWhenWrittenDelimited(responseHeader);
      int whatIsLeftToRead = totalSize - readSoFar;
      IOUtils.skipFully(in, whatIsLeftToRead);
      return;
    }
    if (responseHeader.hasException()) {
      ExceptionResponse exceptionResponse = responseHeader.getException();
      RemoteException re = createRemoteException(exceptionResponse);
      call.setException(re);
      if (isFatalConnectionException(exceptionResponse)) {
        markClosed(re);
      }
    } else {
      Message value = null;
      if (call.responseDefaultType != null) {
        Builder builder = call.responseDefaultType.newBuilderForType();
        builder.mergeDelimitedFrom(in);
        value = builder.build();
      }
      CellScanner cellBlockScanner = null;
      if (responseHeader.hasCellBlockMeta()) {
        int size = responseHeader.getCellBlockMeta().getLength();
        byte [] cellBlock = new byte[size];
        IOUtils.readFully(this.in, cellBlock, 0, cellBlock.length);
        cellBlockScanner = ipcUtil.createCellScanner(this.codec, this.compressor, cellBlock);
      }
      call.setResponse(value, cellBlockScanner);
    }
  } catch (IOException e) {
    if (expectedCall) call.setException(e);
    if (e instanceof SocketTimeoutException) {
      // Clean up open calls but don't treat this as a fatal condition,
      // since we expect certain responses to not make it by the specified
      // {@link ConnectionId#rpcTimeout}.
      if (LOG.isTraceEnabled()) LOG.trace("ignored", e);
    } else {
      // Treat this as a fatal condition and close this connection
      markClosed(e);
    }
  } finally {
    cleanupCalls(false);
  }
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:64,
代码来源:RpcClientImpl.java

示例8: readResponse

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
protected void readResponse() {
  if (shouldCloseConnection.get()) return;
  touch();
  int totalSize = -1;
  try {
    // See HBaseServer.Call.setResponse for where we write out the response.
    // Total size of the response.  Unused.  But have to read it in anyways.
    totalSize = in.readInt();

    // Read the header
    ResponseHeader responseHeader = ResponseHeader.parseDelimitedFrom(in);
    int id = responseHeader.getCallId();
    if (LOG.isDebugEnabled()) {
      LOG.debug(getName() + ": got response header " +
        TextFormat.shortDebugString(responseHeader) + ", totalSize: " + totalSize + " bytes");
    }
    Call call = calls.get(id);
    if (call == null) {
      // So we got a response for which we have no corresponding 'call' here on the client-side.
      // We probably timed out waiting, cleaned up all references, and now the server decides
      // to return a response.  There is nothing we can do w/ the response at this stage. Clean
      // out the wire of the response so its out of the way and we can get other responses on
      // this connection.
      int readSoFar = IPCUtil.getTotalSizeWhenWrittenDelimited(responseHeader);
      int whatIsLeftToRead = totalSize - readSoFar;
      LOG.debug("Unknown callId: " + id + ", skipping over this response of " +
        whatIsLeftToRead + " bytes");
      IOUtils.skipFully(in, whatIsLeftToRead);
    }
    if (responseHeader.hasException()) {
      ExceptionResponse exceptionResponse = responseHeader.getException();
      RemoteException re = createRemoteException(exceptionResponse);
      if (isFatalConnectionException(exceptionResponse)) {
        markClosed(re);
      } else {
        if (call != null) call.setException(re);
      }
    } else {
      Message value = null;
      // Call may be null because it may have timedout and been cleaned up on this side already
      if (call != null && call.responseDefaultType != null) {
        Builder builder = call.responseDefaultType.newBuilderForType();
        builder.mergeDelimitedFrom(in);
        value = builder.build();
      }
      CellScanner cellBlockScanner = null;
      if (responseHeader.hasCellBlockMeta()) {
        int size = responseHeader.getCellBlockMeta().getLength();
        byte [] cellBlock = new byte[size];
        IOUtils.readFully(this.in, cellBlock, 0, cellBlock.length);
        cellBlockScanner = ipcUtil.createCellScanner(this.codec, this.compressor, cellBlock);
      }
      // it's possible that this call may have been cleaned up due to a RPC
      // timeout, so check if it still exists before setting the value.
      if (call != null) call.setResponse(value, cellBlockScanner);
    }
    if (call != null) calls.remove(id);
  } catch (IOException e) {
    if (e instanceof SocketTimeoutException && remoteId.rpcTimeout > 0) {
      // Clean up open calls but don't treat this as a fatal condition,
      // since we expect certain responses to not make it by the specified
      // {@link ConnectionId#rpcTimeout}.
      closeException = e;
    } else {
      // Treat this as a fatal condition and close this connection
      markClosed(e);
    }
  } finally {
    if (remoteId.rpcTimeout > 0) {
      cleanupCalls(remoteId.rpcTimeout);
    }
  }
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:74,
代码来源:RpcClient.java

示例9: isFatalConnectionException

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
/**
 * @param e
 * @return True if the exception is a fatal connection exception.
 */
private boolean isFatalConnectionException(final ExceptionResponse e) {
  return e.getExceptionClassName().
    equals(FatalConnectionException.class.getName());
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:9,
代码来源:RpcClient.java

示例10: readResponse

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ExceptionResponse; //导入依赖的package包/类
protected void readResponse() {
  if (shouldCloseConnection.get()) return;
  Call call = null;
  boolean expectedCall = false;
  try {
    // See HBaseServer.Call.setResponse for where we write out the response.
    // Total size of the response.  Unused.  But have to read it in anyways.
    int totalSize = in.readInt();

    // Read the header
    ResponseHeader responseHeader = ResponseHeader.parseDelimitedFrom(in);
    int id = responseHeader.getCallId();
    if (LOG.isDebugEnabled()) {
      LOG.debug(getName() + ": got response header " +
        TextFormat.shortDebugString(responseHeader) + ", totalSize: " + totalSize + " bytes");
    }
    call = calls.remove(id); // call.done have to be set before leaving this method
    expectedCall = (call != null && !call.done);
    if (!expectedCall) {
      // So we got a response for which we have no corresponding 'call' here on the client-side.
      // We probably timed out waiting, cleaned up all references, and now the server decides
      // to return a response.  There is nothing we can do w/ the response at this stage. Clean
      // out the wire of the response so its out of the way and we can get other responses on
      // this connection.
      int readSoFar = IPCUtil.getTotalSizeWhenWrittenDelimited(responseHeader);
      int whatIsLeftToRead = totalSize - readSoFar;
      LOG.debug("Unknown callId: " + id + ", skipping over this response of " +
          whatIsLeftToRead + " bytes");
      IOUtils.skipFully(in, whatIsLeftToRead);
    }
    if (responseHeader.hasException()) {
      ExceptionResponse exceptionResponse = responseHeader.getException();
      RemoteException re = createRemoteException(exceptionResponse);
      if (expectedCall) call.setException(re);
      if (isFatalConnectionException(exceptionResponse)) {
        markClosed(re);
      }
    } else {
      Message value = null;
      // Call may be null because it may have timeout and been cleaned up on this side already
      if (expectedCall && call.responseDefaultType != null) {
        Builder builder = call.responseDefaultType.newBuilderForType();
        builder.mergeDelimitedFrom(in);
        value = builder.build();
      }
      CellScanner cellBlockScanner = null;
      if (responseHeader.hasCellBlockMeta()) {
        int size = responseHeader.getCellBlockMeta().getLength();
        byte [] cellBlock = new byte[size];
        IOUtils.readFully(this.in, cellBlock, 0, cellBlock.length);
        cellBlockScanner = ipcUtil.createCellScanner(this.codec, this.compressor, cellBlock);
      }
      // it's possible that this call may have been cleaned up due to a RPC
      // timeout, so check if it still exists before setting the value.
      if (expectedCall) call.setResponse(value, cellBlockScanner);
    }
  } catch (IOException e) {
    if (expectedCall) call.setException(e);
    if (e instanceof SocketTimeoutException) {
      // Clean up open calls but don't treat this as a fatal condition,
      // since we expect certain responses to not make it by the specified
      // {@link ConnectionId#rpcTimeout}.
    } else {
      // Treat this as a fatal condition and close this connection
      markClosed(e);
    }
  } finally {
    cleanupCalls(false);
    if (expectedCall && !call.done) {
      LOG.warn("Coding error: code should be true for callId=" + call.id +
          ", server=" + getRemoteAddress() +
          ", shouldCloseConnection=" + shouldCloseConnection.get());
    }
  }
}
 

开发者ID:shenli-uiuc,
项目名称:PyroDB,
代码行数:76,
代码来源:RpcClient.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)