本文整理匯總了Java中io.grpc.StatusRuntimeException類的典型用法代碼示例。如果您正苦於以下問題:Java StatusRuntimeException類的具體用法?Java StatusRuntimeException怎麽用?Java StatusRuntimeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
StatusRuntimeException類屬於io.grpc包,在下文中一共展示了StatusRuntimeException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: store
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
@Override
public void store(StoreRequest request, StreamObserver<StoreResponse> responseObserver) {
try {
responseObserver.onNext(indexManger.storeDocument(request));
responseObserver.onCompleted();
}
catch (Exception e) {
log.error("Failed to store: <" + request.getUniqueId() + "> in index <" + request.getIndexName() + ">: " + e.getClass().getSimpleName() + ": ", e);
Metadata m = new Metadata();
m.put(MetaKeys.ERROR_KEY, e.getMessage());
responseObserver.onError(new StatusRuntimeException(Status.UNKNOWN, m));
if (request.hasResultDocument()) {
try {
if (request.getResultDocument().hasDocument()) {
BasicBSONObject document = (BasicBSONObject) BSON.decode(request.getResultDocument().getDocument().toByteArray());
log.error(document.toString());
}
}
catch (Exception e2) {
}
}
}
}
示例2: listDatabases
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.StringListType listDatabases()
{
MetaProto.NoneType none = MetaProto.NoneType.newBuilder().build();
MetaProto.StringListType stringList;
MetaProto.StringListType.Builder builder = MetaProto.StringListType.newBuilder();
try {
stringList = metaBlockingStub.listDatabases(none);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
stringList = MetaProto.StringListType.newBuilder().build();
return stringList;
}
logger.info("Databases list : " + stringList);
return stringList;
}
示例3: listTables
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.StringListType listTables(String dbName)
{
MetaProto.DbNameParam databaseName = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
MetaProto.StringListType stringList;
try {
stringList = metaBlockingStub.listTables(databaseName);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
stringList = MetaProto.StringListType.newBuilder().build();
return stringList;
}
logger.info("Tables list : " + stringList);
return stringList;
}
示例4: listColumns
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.StringListType listColumns(String dbName, String tblName)
{
MetaProto.DbNameParam dbNameParam = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
MetaProto.TblNameParam tblNameParam = MetaProto.TblNameParam.newBuilder()
.setTable(tblName)
.build();
MetaProto.DbTblParam dbTblParam = MetaProto.DbTblParam.newBuilder()
.setDatabase(dbNameParam)
.setTable(tblNameParam)
.build();
MetaProto.StringListType stringList;
try {
stringList = metaBlockingStub.listColumns(dbTblParam);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
stringList = MetaProto.StringListType.newBuilder().build();
return stringList;
}
logger.info("Columns list : " + stringList);
return stringList;
}
示例5: listColumnsDataType
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.StringListType listColumnsDataType(String dbName, String tblName)
{
MetaProto.DbNameParam dbNameParam = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
MetaProto.TblNameParam tblNameParam = MetaProto.TblNameParam.newBuilder()
.setTable(tblName)
.build();
MetaProto.DbTblParam dbTblParam = MetaProto.DbTblParam.newBuilder()
.setDatabase(dbNameParam)
.setTable(tblNameParam)
.build();
MetaProto.StringListType stringList;
try {
stringList = metaBlockingStub.listColumnsDataType(dbTblParam);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
stringList = MetaProto.StringListType.newBuilder().build();
return stringList;
}
logger.info("ColumnsDataType list : " + stringList);
return stringList;
}
示例6: getDatabase
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.DbParam getDatabase(String dbName)
{
MetaProto.DbNameParam databaseName = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
MetaProto.DbParam database;
try {
database = metaBlockingStub.getDatabase(databaseName);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
database = MetaProto.DbParam.newBuilder().setIsEmpty(false).build();
return database;
}
logger.info("Database is : " + database);
return database;
}
示例7: getTable
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.TblParam getTable(String dbName, String tblName)
{
MetaProto.DbNameParam databaseName = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
MetaProto.TblNameParam tableName = MetaProto.TblNameParam.newBuilder()
.setTable(tblName)
.build();
MetaProto.DbTblParam databaseTable = MetaProto.DbTblParam.newBuilder()
.setDatabase(databaseName)
.setTable(tableName)
.build();
MetaProto.TblParam table;
try {
table = metaBlockingStub.getTable(databaseTable);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
table = MetaProto.TblParam.newBuilder().build();
return table;
}
logger.info("Table is : " + table);
return table;
}
示例8: deleteTable
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public StatusProto.ResponseStatus deleteTable(String dbName, String tblName)
{
MetaProto.DbNameParam databaseName = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
MetaProto.TblNameParam tableName = MetaProto.TblNameParam.newBuilder()
.setTable(tblName)
.build();
MetaProto.DbTblParam databaseTable = MetaProto.DbTblParam.newBuilder()
.setDatabase(databaseName)
.setTable(tableName)
.build();
StatusProto.ResponseStatus status;
try {
status = metaBlockingStub.deleteTable(databaseTable);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
status = StatusProto.ResponseStatus.newBuilder().build();
return status;
}
logger.info("Delete table status is : " + status.getStatus());
return status;
}
示例9: deleteDatabase
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public StatusProto.ResponseStatus deleteDatabase(String dbName)
{
MetaProto.DbNameParam databaseName = MetaProto.DbNameParam.newBuilder()
.setDatabase(dbName)
.build();
StatusProto.ResponseStatus status;
try {
status = metaBlockingStub.deleteDatabase(databaseName);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
status = StatusProto.ResponseStatus.newBuilder().setStatus(StatusProto.ResponseStatus.State.DELETE_DATABASE_ERROR).build();
return status;
}
logger.info("Delete database status is : " + status.getStatus());
return status;
}
示例10: getStorageFormat
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.StorageFormatParam getStorageFormat(String storageFormatName)
{
MetaProto.StorageFormatParam storageFormat;
if (nameValidate(storageFormatName)) {
MetaProto.GetStorageFormatParam getStorageFormatParam =
MetaProto.GetStorageFormatParam.newBuilder()
.setStorageFormatName(storageFormatName)
.build();
try {
storageFormat = metaBlockingStub.getStorageFormat(getStorageFormatParam);
}
catch (StatusRuntimeException e) {
storageFormat = MetaProto.StorageFormatParam.newBuilder().setIsEmpty(true).build();
return storageFormat;
}
}
else {
storageFormat = MetaProto.StorageFormatParam.newBuilder().setIsEmpty(true).build();
}
logger.info("Create storage format status is : " + storageFormat);
return storageFormat;
}
示例11: createFunc
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public StatusProto.ResponseStatus createFunc(String funcName,
byte[] funcContent)
{
boolean funcNameFormat = nameValidate(funcName);
boolean funcNameLen = lengthValidate(funcName);
StatusProto.ResponseStatus status;
if (funcNameFormat & funcNameLen) {
ByteString byteString = ByteString.copyFrom(funcContent);
MetaProto.FuncParam func = MetaProto.FuncParam.newBuilder()
.setFuncName(funcName)
.setFuncContent(byteString).build();
try {
status = metaBlockingStub.createFunc(func);
}
catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
status = StatusProto.ResponseStatus.newBuilder().build();
return status;
}
}
else {
status = StatusProto.ResponseStatus.newBuilder().build();
}
logger.info("Create fiber function status is : " + status.getStatus());
return status;
}
示例12: getFunc
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
public MetaProto.FuncParam getFunc(String funcName)
{
MetaProto.FuncParam funcParam;
if (nameValidate(funcName)) {
MetaProto.GetFuncParam getFuncParam =
MetaProto.GetFuncParam.newBuilder()
.setFuncName(funcName)
.build();
try {
funcParam = metaBlockingStub.getFunc(getFuncParam);
}
catch (StatusRuntimeException e) {
funcParam = MetaProto.FuncParam.newBuilder().build();
return funcParam;
}
}
else {
funcParam = MetaProto.FuncParam.newBuilder().setIsEmpty(true).build();
}
logger.info("Create storage format status is : " + funcParam);
return funcParam;
}
示例13: invoke
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
@Override
public StreamObserver<Message> invoke(StreamObserver<Message> responseObserver) {
try {
this.remote = RpcContext.getContext().getAttachment(Constants.REMOTE_ADDRESS);
Class<?> requestType = grpcMethodType.requestType();
PoJo2ProtoStreamObserver servserResponseObserver =
PoJo2ProtoStreamObserver.newObserverWrap(responseObserver);
Object result = method.invoke(serviceToInvoke, servserResponseObserver);
return Proto2PoJoStreamObserver.newObserverWrap((StreamObserver<Object>) result, requestType);
} catch (Throwable e) {
String stackTrace = ThrowableUtil.stackTraceToString(e);
log.error(e.getMessage(), e);
StatusRuntimeException statusException =
Status.UNAVAILABLE.withDescription(stackTrace).asRuntimeException();
responseObserver.onError(statusException);
} finally {
log.debug(String.format("Service: %s Method: %s RemoteAddress: %s",
providerUrl.getServiceInterface(), method.getName(), this.remote));
}
return null;
}
示例14: streamCall
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
private void streamCall(Message request, StreamObserver<Message> responseObserver) {
try {
Class<?> requestType = grpcMethodType.requestType();
Object reqPojo = SerializerUtil.protobuf2Pojo(request, requestType);
Object[] requestParams =
new Object[] {reqPojo, PoJo2ProtoStreamObserver.newObserverWrap(responseObserver)};
method.invoke(serviceToInvoke, requestParams);
} catch (Throwable e) {
String stackTrace = ThrowableUtil.stackTraceToString(e);
log.error(e.getMessage(), e);
StatusRuntimeException statusException =
Status.UNAVAILABLE.withDescription(stackTrace).asRuntimeException();
responseObserver.onError(statusException);
} finally {
log.debug(String.format("Service: %s Method: %s RemoteAddress: %s",
providerUrl.getServiceInterface(), method.getName(), this.remote));
}
}
示例15: publish
import io.grpc.StatusRuntimeException; //導入依賴的package包/類
@Override
public void publish(@NonNull MSG_Facts request,
@NonNull StreamObserver<MSG_Empty> responseObserver) {
List<Fact> facts = request.getFactList().stream().map(converter::fromProto).collect(
Collectors.toList());
final int size = facts.size();
log.debug("publish {} fact{}", size, size > 1 ? "s" : "");
log.trace("publish {}", facts);
try {
log.trace("store publish {}", facts);
store.publish(facts);
log.trace("store publish done");
responseObserver.onNext(MSG_Empty.getDefaultInstance());
responseObserver.onCompleted();
} catch (Throwable e) {
log.error("Problem while publishing: ", e);
responseObserver.onError(new StatusRuntimeException(Status.INTERNAL.withDescription(e
.getMessage())));
}
}