当前位置: 首页>>代码示例>>Java>>正文


Java ServerCallable类代码示例

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


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

示例1: getIndexByName

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final IndexDesc getIndexByName(final String databaseName, final String indexName) {
  try {
    return new ServerCallable<IndexDesc>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public IndexDesc call(NettyClientBase client) throws ServiceException {

        IndexNameProto.Builder builder = IndexNameProto.newBuilder();
        builder.setDatabaseName(databaseName);
        builder.setIndexName(indexName);

        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return new IndexDesc(stub.getIndexByName(null, builder.build()));
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return null;
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:20,代码来源:AbstractCatalogClient.java

示例2: getAllTableNames

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final Collection<String> getAllTableNames() {
  try {
    return new ServerCallable<Collection<String>>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Collection<String> call(NettyClientBase client) throws ServiceException {
        List<String> protos = new ArrayList<String>();
        GetAllTableNamesResponse response;
        CatalogProtocolService.BlockingInterface stub = getStub(client);
        response = stub.getAllTableNames(null, NullProto.newBuilder().build());
        int size = response.getTableNameCount();
        for (int i = 0; i < size; i++) {
          protos.add(response.getTableName(i));
        }
        return protos;
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return null;
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:22,代码来源:AbstractCatalogClient.java

示例3: existsTable

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final boolean existsTable(final String tableId) {
  try {
    return new ServerCallable<Boolean>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Boolean call(NettyClientBase client) throws ServiceException {
        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return stub
            .existsTable(null, StringProto.newBuilder().setValue(tableId).build())
            .getValue();
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return false;
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:17,代码来源:AbstractCatalogClient.java

示例4: existIndex

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public boolean existIndex(final String tableName, final String columnName) {
  try {
    return new ServerCallable<Boolean>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Boolean call(NettyClientBase client) throws ServiceException {
        GetIndexRequest.Builder builder = GetIndexRequest.newBuilder();
        builder.setTableName(tableName);
        builder.setColumnName(columnName);
        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return stub.existIndex(null, builder.build()).getValue();
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return false;
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:18,代码来源:AbstractCatalogClient.java

示例5: getIndex

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final IndexDesc getIndex(final String indexName) {
  try {
    return new ServerCallable<IndexDesc>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public IndexDesc call(NettyClientBase client) throws ServiceException {
        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return new IndexDesc(
            stub.getIndexByName(null,
                StringProto.newBuilder().setValue(indexName).build()));
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return null;
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:17,代码来源:AbstractCatalogClient.java

示例6: dropFunction

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final boolean dropFunction(final String signature) {
  try {
    return new ServerCallable<Boolean>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Boolean call(NettyClientBase client) throws ServiceException {
        UnregisterFunctionRequest.Builder builder = UnregisterFunctionRequest.newBuilder();
        builder.setSignature(signature);

        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return stub.dropFunction(null, builder.build()).getValue();
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return false;
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:18,代码来源:AbstractCatalogClient.java

示例7: containFunction

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final boolean containFunction(final String signature, FunctionType funcType, DataType... paramTypes) {
  final ContainFunctionRequest.Builder builder =
      ContainFunctionRequest.newBuilder();
  if (funcType != null) {
    builder.setFunctionType(funcType);
  }
  builder.setSignature(signature);
  for (DataType type : paramTypes) {
    builder.addParameterTypes(type);
  }

  try {
    return new ServerCallable<Boolean>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Boolean call(NettyClientBase client) throws ServiceException {
        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return stub.containFunction(null, builder.build()).getValue();
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return false;
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:25,代码来源:AbstractCatalogClient.java

示例8: executeQueryAndGetResult

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
/**
 * It submits a query statement and get a response.
 * The main difference from {@link #executeQuery(String)}
 * is a blocking method. So, this method is wait for
 * the finish of the submitted query.
 *
 * @return If failed, return null.
 */
public ResultSet executeQueryAndGetResult(final String sql)
    throws ServiceException, IOException {
  GetQueryStatusResponse response = new ServerCallable<GetQueryStatusResponse>(connPool, tajoMasterAddr,
      TajoMasterClientProtocol.class, false, true) {
    public GetQueryStatusResponse call(NettyClientBase client) throws ServiceException {
      final QueryRequest.Builder builder = QueryRequest.newBuilder();
      builder.setQuery(sql);
      TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();
      return tajoMasterService.submitQuery(null, builder.build());
    }
  }.withRetries();

  QueryId queryId = new QueryId(response.getQueryId());
  if (queryId.equals(QueryIdFactory.NULL_QUERY_ID)) {
    return this.createNullResultSet(queryId);
  } else {
    return this.getQueryResultAndWait(queryId);
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:28,代码来源:TajoClient.java

示例9: updateQuery

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
public boolean updateQuery(final String sql) throws ServiceException {
  return new ServerCallable<Boolean>(connPool, tajoMasterAddr,
      TajoMasterClientProtocol.class, false, true) {
    public Boolean call(NettyClientBase client) throws ServiceException {
      QueryRequest.Builder builder = QueryRequest.newBuilder();
      builder.setQuery(sql);

      TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();
      UpdateQueryResponse response = tajoMasterService.updateQuery(null, builder.build());
      if (response.getResultCode() == ResultCode.OK) {
        return true;
      } else {
        if (response.hasErrorMessage()) {
          LOG.error(response.getErrorMessage());
        }
        return false;
      }
    }
  }.withRetries();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:21,代码来源:TajoClient.java

示例10: createExternalTable

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
public TableDesc createExternalTable(final String name, final Schema schema, final Path path, final TableMeta meta)
    throws SQLException, ServiceException {
  return new ServerCallable<TableDesc>(connPool, tajoMasterAddr,
      TajoMasterClientProtocol.class, false, true) {
    public TableDesc call(NettyClientBase client) throws ServiceException, SQLException {
      TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();

      CreateTableRequest.Builder builder = CreateTableRequest.newBuilder();
      builder.setName(name);
      builder.setSchema(schema.getProto());
      builder.setMeta(meta.getProto());
      builder.setPath(path.toUri().toString());
      TableResponse res = tajoMasterService.createExternalTable(null, builder.build());
      if (res.getResultCode() == ResultCode.OK) {
        return CatalogUtil.newTableDesc(res.getTableDesc());
      } else {
        throw new SQLException(res.getErrorMessage(), SQLStates.ER_NO_SUCH_TABLE.getState());
      }
    }
  }.withRetries();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:22,代码来源:TajoClient.java

示例11: getTableDesc

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
public TableDesc getTableDesc(final String tableName) throws SQLException, ServiceException {
  return new ServerCallable<TableDesc>(connPool, tajoMasterAddr,
      TajoMasterClientProtocol.class, false, true) {
    public TableDesc call(NettyClientBase client) throws ServiceException, SQLException {
      TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();

      GetTableDescRequest.Builder build = GetTableDescRequest.newBuilder();
      build.setTableName(tableName);
      TableResponse res = tajoMasterService.getTableDesc(null, build.build());
      if (res.getResultCode() == ResultCode.OK) {
        return CatalogUtil.newTableDesc(res.getTableDesc());
      } else {
        throw new SQLException(res.getErrorMessage(), SQLStates.ER_NO_SUCH_TABLE.getState());
      }
    }
  }.withRetries();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:18,代码来源:TajoClient.java

示例12: getFunctions

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
public List<CatalogProtos.FunctionDescProto> getFunctions(final String functionName) throws ServiceException {
  return new ServerCallable<List<CatalogProtos.FunctionDescProto>>(connPool, tajoMasterAddr,
      TajoMasterClientProtocol.class, false, true) {
    public List<CatalogProtos.FunctionDescProto> call(NettyClientBase client) throws ServiceException, SQLException {
      TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();

      String paramFunctionName = functionName == null ? "" : functionName;

      FunctionResponse res = tajoMasterService.getFunctionList(null,
          StringProto.newBuilder().setValue(paramFunctionName).build());
      if (res.getResultCode() == ResultCode.OK) {
        return res.getFunctionsList();
      } else {
        throw new SQLException(res.getErrorMessage());
      }
    }
  }.withRetries();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:19,代码来源:TajoClient.java

示例13: createTablespace

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final Boolean createTablespace(final String tablespaceName, final String tablespaceUri) {
  try {
    return new ServerCallable<Boolean>(pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Boolean call(NettyClientBase client) throws ServiceException {
        CatalogProtocolService.BlockingInterface stub = getStub(client);

        CreateTablespaceRequest.Builder builder = CreateTablespaceRequest.newBuilder();
        builder.setTablespaceName(tablespaceName);
        builder.setTablespaceUri(tablespaceUri);
        return stub.createTablespace(null, builder.build()).getValue();
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return Boolean.FALSE;
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:19,代码来源:AbstractCatalogClient.java

示例14: createDatabase

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final Boolean createDatabase(final String databaseName, @Nullable final String tablespaceName) {
  try {
    return new ServerCallable<Boolean>(pool, catalogServerAddr, CatalogProtocol.class, false) {
      public Boolean call(NettyClientBase client) throws ServiceException {
        CatalogProtocolService.BlockingInterface stub = getStub(client);

        CreateDatabaseRequest.Builder builder = CreateDatabaseRequest.newBuilder();
        builder.setDatabaseName(databaseName);
        if (tablespaceName != null) {
          builder.setTablespaceName(tablespaceName);
        }
        return stub.createDatabase(null, builder.build()).getValue();
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return Boolean.FALSE;
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:21,代码来源:AbstractCatalogClient.java

示例15: getTableDesc

import org.apache.tajo.rpc.ServerCallable; //导入依赖的package包/类
@Override
public final TableDesc getTableDesc(final String databaseName, final String tableName) {
  try {
    return new ServerCallable<TableDesc>(this.pool, catalogServerAddr, CatalogProtocol.class, false) {
      public TableDesc call(NettyClientBase client) throws ServiceException {
        TableIdentifierProto.Builder builder = TableIdentifierProto.newBuilder();
        builder.setDatabaseName(databaseName);
        builder.setTableName(tableName);

        CatalogProtocolService.BlockingInterface stub = getStub(client);
        return CatalogUtil.newTableDesc(stub.getTableDesc(null, builder.build()));
      }
    }.withRetries();
  } catch (ServiceException e) {
    LOG.error(e.getMessage(), e);
    return null;
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:19,代码来源:AbstractCatalogClient.java


注:本文中的org.apache.tajo.rpc.ServerCallable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。