コード例 #1
0
ファイル: CatalogServer.java プロジェクト: RonyMin/tajo
    @Override
    public IndexListResponse getAllIndexes(RpcController controller, NullProto request)
        throws ServiceException {
      rlock.lock();
      try {
        return IndexListResponse.newBuilder().addAllIndexDesc(store.getAllIndexes()).build();

      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);

        return IndexListResponse.newBuilder().setState(returnError(t)).build();

      } finally {
        rlock.unlock();
      }
    }
コード例 #2
0
ファイル: CatalogServer.java プロジェクト: RonyMin/tajo
    @Override
    public IndexListResponse getAllIndexesByTable(
        RpcController controller, TableIdentifierProto request) throws ServiceException {
      final String databaseName = request.getDatabaseName();
      final String tableName = request.getTableName();

      try {
        // linked meta data do not support index.
        // So, the request that wants to check the index in this db will get empty list.
        if (linkedMetadataManager.existsDatabase(databaseName)) {
          return IndexListResponse.newBuilder().setState(OK).build();
        }
      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);
        return IndexListResponse.newBuilder().setState(returnError(t)).build();
      }

      rlock.lock();
      try {

        if (!store.existIndexesByTable(databaseName, tableName)) {
          return IndexListResponse.newBuilder().setState(errUndefinedIndex(tableName)).build();
        }
        IndexListResponse.Builder builder = IndexListResponse.newBuilder().setState(OK);
        for (String eachIndexName : store.getAllIndexNamesByTable(databaseName, tableName)) {
          builder.addIndexDesc(store.getIndexByName(databaseName, eachIndexName));
        }
        return builder.build();
      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);

        return IndexListResponse.newBuilder().setState(returnError(t)).build();
      } finally {
        rlock.unlock();
      }
    }