Пример #1
0
    @Override
    public IndexResponse getIndexByName(RpcController controller, IndexNameProto request)
        throws ServiceException {

      String databaseName = request.getDatabaseName();
      String indexName = request.getIndexName();

      rlock.lock();
      try {

        if (!store.existIndexByName(databaseName, indexName)) {
          return IndexResponse.newBuilder().setState(errUndefinedIndexName(indexName)).build();
        }

        return IndexResponse.newBuilder()
            .setState(OK)
            .setIndexDesc(store.getIndexByName(databaseName, indexName))
            .build();

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

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

      } finally {
        rlock.unlock();
      }
    }
Пример #2
0
    @Override
    public ReturnState existIndexByName(RpcController controller, IndexNameProto request) {

      String dbName = request.getDatabaseName();
      String indexName = request.getIndexName();

      try {
        // linked meta data do not support index. The request will be failed.
        if (linkedMetadataManager.existsDatabase(dbName)) {
          return errUndefinedIndexName(indexName);
        }
      } catch (Throwable t) {
        printStackTraceIfError(LOG, t);
        return returnError(t);
      }

      rlock.lock();
      try {
        return store.existIndexByName(dbName, indexName) ? OK : errUndefinedIndexName(indexName);

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

      } finally {
        rlock.unlock();
      }
    }
Пример #3
0
    @Override
    public ReturnState dropIndex(RpcController controller, IndexNameProto request) {

      String dbName = request.getDatabaseName();
      String indexName = request.getIndexName();

      wlock.lock();
      try {
        store.dropIndex(dbName, indexName);
        return OK;

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

      } finally {
        wlock.unlock();
      }
    }