类org.apache.hadoop.hbase.coprocessor.CoprocessorException源码实例Demo

下面列出了怎么用org.apache.hadoop.hbase.coprocessor.CoprocessorException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hbase   文件: MasterQuotasObserver.java
@Override
public void start(CoprocessorEnvironment ctx) throws IOException {
  this.conf = ctx.getConfiguration();
  this.quotasEnabled = QuotaUtil.isQuotaEnabled(conf);

  if (!(ctx instanceof MasterCoprocessorEnvironment)) {
    throw new CoprocessorException("Must be loaded on master.");
  }
  // if running on master
  MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) ctx;
  if (mEnv instanceof HasMasterServices) {
    this.masterServices = ((HasMasterServices) mEnv).getMasterServices();
  } else {
    throw new CoprocessorException("Must be loaded on a master having master services.");
  }
}
 
源代码2 项目: kylin-on-parquet-v2   文件: CubeVisitService.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    // 需要检查当前环境是否在region上
    if (env instanceof RegionCoprocessorEnvironment) {
        this.envi = (RegionCoprocessorEnvironment) env;

    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }

}
 
源代码4 项目: Eagle   文件: AggregateProtocolEndPoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment)env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
源代码5 项目: Eagle   文件: AggregateResultCallbackImpl.java
@Override
public void update(byte[] region, byte[] row, AggregateProtos.AggregateResult result) {
    try {
        if(result == null) throw new IllegalStateException(new CoprocessorException("result is null"));
        this.update(region,row, ProtoBufConverter.fromPBResult(result));
    } catch (IOException e) {
        LOG.error("Failed to convert PB-Based message",e);
    }
}
 
源代码6 项目: eagle   文件: AggregateProtocolEndPoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
源代码7 项目: eagle   文件: AggregateResultCallbackImpl.java
@Override
public void update(byte[] region, byte[] row, AggregateProtos.AggregateResult result) {
    try {
        if (result == null) {
            throw new IllegalStateException(new CoprocessorException("result is null"));
        }
        this.update(region, row, ProtoBufConverter.fromPBResult(result));
    } catch (IOException e) {
        LOG.error("Failed to convert PB-Based message", e);
    }
}
 
源代码8 项目: phoenix   文件: MetaDataEndpointImpl.java
/**
 * Stores a reference to the coprocessor environment provided by the
 * {@link org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost} from the region where this
 * coprocessor is loaded. Since this is a coprocessor endpoint, it always expects to be loaded
 * on a table region, so always expects this to be an instance of
 * {@link RegionCoprocessorEnvironment}.
 * @param env the environment provided by the coprocessor host
 * @throws IOException if the provided environment is not an instance of
 *             {@code RegionCoprocessorEnvironment}
 */
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
    logger.info("Starting Tracing-Metrics Systems");
    // Start the phoenix trace collection
    Tracing.addTraceMetricsSource();
    Metrics.ensureConfigured();
}
 
源代码9 项目: phoenix   文件: ServerCachingEndpointImpl.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
源代码10 项目: metron   文件: EnrichmentCoprocessor.java
@Override
public void start(CoprocessorEnvironment ce) throws IOException {
  LOG.info("Starting enrichment coprocessor");
  if (ce instanceof RegionCoprocessorEnvironment) {
    this.coprocessorEnv = (RegionCoprocessorEnvironment) ce;
  } else {
    throw new CoprocessorException("Enrichment coprocessor must be loaded on a table region.");
  }
  LOG.info("Checking if internal cache initialized");
  if (null == this.cache) {
    LOG.info("Cache null, initializing");
    LOG.info("Getting global config from Zookeeper");
    String zkUrl = getZookeeperUrl(this.coprocessorEnv.getConfiguration());
    if (null == globalConfigService) {
      globalConfigService = getGlobalConfigService(zkUrl);
    }
    globalConfig = globalConfigService.get();
    Configuration config = this.coprocessorEnv.getConfiguration();
    CacheWriter<String, String> cacheWriter = null;
    try {
      String hbaseTableProviderName = (String) globalConfig
          .get(EnrichmentConfigurations.TABLE_PROVIDER);
      String tableName = (String) globalConfig.get(EnrichmentConfigurations.TABLE_NAME);
      String columnFamily = (String) globalConfig.get(EnrichmentConfigurations.COLUMN_FAMILY);
      cacheWriter = new HBaseCacheWriter(config, TableProvider
          .create(hbaseTableProviderName, HTableProvider::new), tableName, columnFamily,
          COLUMN_QUALIFIER);
    } catch (ClassNotFoundException | InstantiationException | InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
      throw new IOException("Unable to instantiate cache writer", e);
    }
    this.cache = Caffeine.newBuilder().writer(cacheWriter).build();
    LOG.info("Finished initializing cache");
  }
  LOG.info("Finished starting enrichment coprocessor");
}
 
源代码11 项目: kylin   文件: CubeVisitService.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
源代码12 项目: yuzhouwan   文件: QueryEndpoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
源代码13 项目: hbase   文件: TestServerCustomProtocol.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    return;
  }
  throw new CoprocessorException("Must be loaded on a table region!");
}
 
源代码14 项目: hbase   文件: AccessController.java
/**
 * @deprecated since 2.2.0 and will be removed in 4.0.0. Use
 *   {@link Admin#grant(UserPermission, boolean)} instead.
 * @see Admin#grant(UserPermission, boolean)
 * @see <a href="https://issues.apache.org/jira/browse/HBASE-21739">HBASE-21739</a>
 */
@Deprecated
@Override
public void grant(RpcController controller,
    AccessControlProtos.GrantRequest request,
    RpcCallback<AccessControlProtos.GrantResponse> done) {
  final UserPermission perm = AccessControlUtil.toUserPermission(request.getUserPermission());
  AccessControlProtos.GrantResponse response = null;
  try {
    // verify it's only running at .acl.
    if (aclRegion) {
      if (!initialized) {
        throw new CoprocessorException("AccessController not yet initialized");
      }
      User caller = RpcServer.getRequestUser().orElse(null);
      if (LOG.isDebugEnabled()) {
        LOG.debug("Received request from {} to grant access permission {}",
          caller.getName(), perm.toString());
      }
      preGrantOrRevoke(caller, "grant", perm);

      // regionEnv is set at #start. Hopefully not null at this point.
      regionEnv.getConnection().getAdmin().grant(
        new UserPermission(perm.getUser(), perm.getPermission()),
        request.getMergeExistingPermissions());
      if (AUDITLOG.isTraceEnabled()) {
        // audit log should store permission changes in addition to auth results
        AUDITLOG.trace("Granted permission " + perm.toString());
      }
    } else {
      throw new CoprocessorException(AccessController.class, "This method "
          + "can only execute at " + PermissionStorage.ACL_TABLE_NAME + " table.");
    }
    response = AccessControlProtos.GrantResponse.getDefaultInstance();
  } catch (IOException ioe) {
    // pass exception back up
    CoprocessorRpcUtils.setControllerException(controller, ioe);
  }
  done.run(response);
}
 
源代码15 项目: hbase   文件: AccessController.java
/**
 * @deprecated since 2.2.0 and will be removed in 4.0.0. Use {@link Admin#revoke(UserPermission)}
 *   instead.
 * @see Admin#revoke(UserPermission)
 * @see <a href="https://issues.apache.org/jira/browse/HBASE-21739">HBASE-21739</a>
 */
@Deprecated
@Override
public void revoke(RpcController controller, AccessControlProtos.RevokeRequest request,
    RpcCallback<AccessControlProtos.RevokeResponse> done) {
  final UserPermission perm = AccessControlUtil.toUserPermission(request.getUserPermission());
  AccessControlProtos.RevokeResponse response = null;
  try {
    // only allowed to be called on _acl_ region
    if (aclRegion) {
      if (!initialized) {
        throw new CoprocessorException("AccessController not yet initialized");
      }
      User caller = RpcServer.getRequestUser().orElse(null);
      if (LOG.isDebugEnabled()) {
        LOG.debug("Received request from {} to revoke access permission {}",
          caller.getShortName(), perm.toString());
      }
      preGrantOrRevoke(caller, "revoke", perm);
      // regionEnv is set at #start. Hopefully not null here.
      regionEnv.getConnection().getAdmin()
          .revoke(new UserPermission(perm.getUser(), perm.getPermission()));
      if (AUDITLOG.isTraceEnabled()) {
        // audit log should record all permission changes
        AUDITLOG.trace("Revoked permission " + perm.toString());
      }
    } else {
      throw new CoprocessorException(AccessController.class, "This method "
          + "can only execute at " + PermissionStorage.ACL_TABLE_NAME + " table.");
    }
    response = AccessControlProtos.RevokeResponse.getDefaultInstance();
  } catch (IOException ioe) {
    // pass exception back up
    CoprocessorRpcUtils.setControllerException(controller, ioe);
  }
  done.run(response);
}
 
源代码16 项目: hbase   文件: MemStoreCompactorSegmentsIterator.java
/**
 * Creates the scanner for compacting the pipeline.
 * @return the scanner
 */
private InternalScanner createScanner(HStore store, List<KeyValueScanner> scanners)
    throws IOException {
  InternalScanner scanner = null;
  boolean success = false;
  try {
    RegionCoprocessorHost cpHost = store.getCoprocessorHost();
    ScanInfo scanInfo;
    if (cpHost != null) {
      scanInfo = cpHost.preMemStoreCompactionCompactScannerOpen(store);
    } else {
      scanInfo = store.getScanInfo();
    }
    scanner = new StoreScanner(store, scanInfo, scanners, ScanType.COMPACT_RETAIN_DELETES,
        store.getSmallestReadPoint(), HConstants.OLDEST_TIMESTAMP);
    if (cpHost != null) {
      InternalScanner scannerFromCp = cpHost.preMemStoreCompactionCompact(store, scanner);
      if (scannerFromCp == null) {
        throw new CoprocessorException("Got a null InternalScanner when calling" +
            " preMemStoreCompactionCompact which is not acceptable");
      }
      success = true;
      return scannerFromCp;
    } else {
      success = true;
      return scanner;
    }
  } finally {
    if (!success) {
      Closeables.close(scanner, true);
      scanners.forEach(KeyValueScanner::close);
    }
  }
}
 
源代码17 项目: hbase   文件: BulkDeleteEndpoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
源代码18 项目: hbase   文件: RefreshHFilesEndpoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
源代码19 项目: Kylin   文件: IIEndpoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
}
 
源代码20 项目: phoenix   文件: ChildLinkMetaDataEndpoint.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionCoprocessorEnvironment) {
        this.env = (RegionCoprocessorEnvironment) env;
    } else {
        throw new CoprocessorException("Must be loaded on a table region!");
    }
    this.phoenixAccessCoprocessorHost = new PhoenixMetaDataCoprocessorHost(this.env);
    this.accessCheckEnabled = env.getConfiguration().getBoolean(QueryServices.PHOENIX_ACLS_ENABLED,
        QueryServicesOptions.DEFAULT_PHOENIX_ACLS_ENABLED);
}
 
源代码21 项目: phoenix   文件: ServerCachingEndpointImpl.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
源代码22 项目: geowave   文件: HBaseBulkDeleteEndpoint.java
@Override
public void start(final CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
源代码23 项目: geowave   文件: AggregationEndpoint.java
@Override
public void start(final CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment) env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
源代码24 项目: spliceengine   文件: SpliceRSRpcServices.java
@Override
public void start(CoprocessorEnvironment env) throws IOException {
    if (env instanceof RegionServerCoprocessorEnvironment) {
        this.regionServerServices = (RegionServerServices) ((RegionServerCoprocessorEnvironment) env).getOnlineRegions();
        SpliceLogUtils.info(LOG,"Started SpliceRSRpcServices");
    } else {
        throw new CoprocessorException("Must be loaded on a RegionServer!");
    }
}
 
源代码25 项目: kylin-on-parquet-v2   文件: CubeVisitServiceTest.java
@Test(expected = CoprocessorException.class)
public void testStart() throws IOException {
    CoprocessorEnvironment env = PowerMockito.mock(RegionServerCoprocessorEnvironment.class);
    CubeVisitService service = new CubeVisitService();
    service.start(env);
}
 
源代码26 项目: kylin   文件: CubeVisitServiceTest.java
@Test(expected = CoprocessorException.class)
public void testStart() throws IOException {
    CoprocessorEnvironment env = PowerMockito.mock(RegionServerCoprocessorEnvironment.class);
    CubeVisitService service = new CubeVisitService();
    service.start(env);
}
 
源代码27 项目: hbase   文件: AccessController.java
/**
 * @deprecated since 2.2.0 and will be removed in 4.0.0. Use
 *   {@link Admin#getUserPermissions(GetUserPermissionsRequest)} instead.
 * @see Admin#getUserPermissions(GetUserPermissionsRequest)
 * @see <a href="https://issues.apache.org/jira/browse/HBASE-21911">HBASE-21911</a>
 */
@Deprecated
@Override
public void getUserPermissions(RpcController controller,
    AccessControlProtos.GetUserPermissionsRequest request,
    RpcCallback<AccessControlProtos.GetUserPermissionsResponse> done) {
  AccessControlProtos.GetUserPermissionsResponse response = null;
  try {
    // only allowed to be called on _acl_ region
    if (aclRegion) {
      if (!initialized) {
        throw new CoprocessorException("AccessController not yet initialized");
      }
      User caller = RpcServer.getRequestUser().orElse(null);
      final String userName = request.hasUserName() ? request.getUserName().toStringUtf8() : null;
      final String namespace =
          request.hasNamespaceName() ? request.getNamespaceName().toStringUtf8() : null;
      final TableName table =
          request.hasTableName() ? ProtobufUtil.toTableName(request.getTableName()) : null;
      final byte[] cf =
          request.hasColumnFamily() ? request.getColumnFamily().toByteArray() : null;
      final byte[] cq =
          request.hasColumnQualifier() ? request.getColumnQualifier().toByteArray() : null;
      preGetUserPermissions(caller, userName, namespace, table, cf, cq);
      GetUserPermissionsRequest getUserPermissionsRequest = null;
      if (request.getType() == AccessControlProtos.Permission.Type.Table) {
        getUserPermissionsRequest = GetUserPermissionsRequest.newBuilder(table).withFamily(cf)
            .withQualifier(cq).withUserName(userName).build();
      } else if (request.getType() == AccessControlProtos.Permission.Type.Namespace) {
        getUserPermissionsRequest =
            GetUserPermissionsRequest.newBuilder(namespace).withUserName(userName).build();
      } else {
        getUserPermissionsRequest =
            GetUserPermissionsRequest.newBuilder().withUserName(userName).build();
      }
      List<UserPermission> perms =
          regionEnv.getConnection().getAdmin().getUserPermissions(getUserPermissionsRequest);
      response = AccessControlUtil.buildGetUserPermissionsResponse(perms);
    } else {
      throw new CoprocessorException(AccessController.class, "This method "
          + "can only execute at " + PermissionStorage.ACL_TABLE_NAME + " table.");
    }
  } catch (IOException ioe) {
    // pass exception back up
    CoprocessorRpcUtils.setControllerException(controller, ioe);
  }
  done.run(response);
}
 
源代码28 项目: hbase   文件: RowCountEndpoint.java
/**
 * Stores a reference to the coprocessor environment provided by the
 * {@link org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost} from the region where this
 * coprocessor is loaded.  Since this is a coprocessor endpoint, it always expects to be loaded
 * on a table region, so always expects this to be an instance of
 * {@link RegionCoprocessorEnvironment}.
 * @param env the environment provided by the coprocessor host
 * @throws IOException if the provided environment is not an instance of
 * {@code RegionCoprocessorEnvironment}
 */
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  if (env instanceof RegionCoprocessorEnvironment) {
    this.env = (RegionCoprocessorEnvironment)env;
  } else {
    throw new CoprocessorException("Must be loaded on a table region!");
  }
}
 
 类所在包
 同包方法