use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project storm by apache.
the class DRPC method checkAuthorization.
@VisibleForTesting
static void checkAuthorization(ReqContext reqContext, IAuthorizer auth, String operation, String function) throws AuthorizationException {
if (reqContext != null) {
ThriftAccessLogger.logAccessFunction(reqContext.requestID(), reqContext.remoteAddress(), reqContext.principal(), operation, function);
}
if (auth != null) {
Map<String, String> map = new HashMap<>();
map.put(DRPCAuthorizerBase.FUNCTION_NAME, function);
if (!auth.permit(reqContext, operation, map)) {
Principal principal = reqContext.principal();
String user = (principal != null) ? principal.getName() : "unknown";
throw new AuthorizationException("DRPC request '" + operation + "' for '" + user + "' user is not authorized");
}
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.
the class TimelineSchemaCreator method createAllTables.
@VisibleForTesting
public static void createAllTables(Configuration hbaseConf, boolean skipExisting) throws IOException {
Connection conn = null;
try {
conn = ConnectionFactory.createConnection(hbaseConf);
Admin admin = conn.getAdmin();
if (admin == null) {
throw new IOException("Cannot create table since admin is null");
}
try {
new EntityTable().createTable(admin, hbaseConf);
} catch (IOException e) {
if (skipExisting) {
LOG.warn("Skip and continue on: " + e.getMessage());
} else {
throw e;
}
}
try {
new AppToFlowTable().createTable(admin, hbaseConf);
} catch (IOException e) {
if (skipExisting) {
LOG.warn("Skip and continue on: " + e.getMessage());
} else {
throw e;
}
}
try {
new ApplicationTable().createTable(admin, hbaseConf);
} catch (IOException e) {
if (skipExisting) {
LOG.warn("Skip and continue on: " + e.getMessage());
} else {
throw e;
}
}
try {
new FlowRunTable().createTable(admin, hbaseConf);
} catch (IOException e) {
if (skipExisting) {
LOG.warn("Skip and continue on: " + e.getMessage());
} else {
throw e;
}
}
try {
new FlowActivityTable().createTable(admin, hbaseConf);
} catch (IOException e) {
if (skipExisting) {
LOG.warn("Skip and continue on: " + e.getMessage());
} else {
throw e;
}
}
} finally {
if (conn != null) {
conn.close();
}
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.
the class NodeTimelineCollectorManager method getNMCollectorService.
@VisibleForTesting
protected CollectorNodemanagerProtocol getNMCollectorService() {
if (nmCollectorService == null) {
synchronized (this) {
if (nmCollectorService == null) {
Configuration conf = getConfig();
InetSocketAddress nmCollectorServiceAddress = conf.getSocketAddr(YarnConfiguration.NM_BIND_HOST, YarnConfiguration.NM_COLLECTOR_SERVICE_ADDRESS, YarnConfiguration.DEFAULT_NM_COLLECTOR_SERVICE_ADDRESS, YarnConfiguration.DEFAULT_NM_COLLECTOR_SERVICE_PORT);
LOG.info("nmCollectorServiceAddress: " + nmCollectorServiceAddress);
final YarnRPC rpc = YarnRPC.create(conf);
// TODO Security settings.
nmCollectorService = (CollectorNodemanagerProtocol) rpc.getProxy(CollectorNodemanagerProtocol.class, nmCollectorServiceAddress, conf);
}
}
}
return nmCollectorService;
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hadoop by apache.
the class PerNodeTimelineCollectorsAuxService method launchServer.
@VisibleForTesting
public static PerNodeTimelineCollectorsAuxService launchServer(String[] args, NodeTimelineCollectorManager collectorManager, Configuration conf) {
Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
StringUtils.startupShutdownMessage(PerNodeTimelineCollectorsAuxService.class, args, LOG);
PerNodeTimelineCollectorsAuxService auxService = null;
try {
auxService = collectorManager == null ? new PerNodeTimelineCollectorsAuxService() : new PerNodeTimelineCollectorsAuxService(collectorManager);
ShutdownHookManager.get().addShutdownHook(new ShutdownHook(auxService), SHUTDOWN_HOOK_PRIORITY);
auxService.init(conf);
auxService.start();
} catch (Throwable t) {
LOG.fatal("Error starting PerNodeTimelineCollectorServer", t);
ExitUtil.terminate(-1, "Error starting PerNodeTimelineCollectorServer");
}
return auxService;
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hbase by apache.
the class RSRpcServices method getRegion.
/**
* Find the HRegion based on a region specifier
*
* @param regionSpecifier the region specifier
* @return the corresponding region
* @throws IOException if the specifier is not null,
* but failed to find the region
*/
@VisibleForTesting
public Region getRegion(final RegionSpecifier regionSpecifier) throws IOException {
ByteString value = regionSpecifier.getValue();
RegionSpecifierType type = regionSpecifier.getType();
switch(type) {
case REGION_NAME:
byte[] regionName = value.toByteArray();
String encodedRegionName = HRegionInfo.encodeRegionName(regionName);
return regionServer.getRegionByEncodedName(regionName, encodedRegionName);
case ENCODED_REGION_NAME:
return regionServer.getRegionByEncodedName(value.toStringUtf8());
default:
throw new DoNotRetryIOException("Unsupported region specifier type: " + type);
}
}
Aggregations