Search in sources :

Example 61 with VisibleForTesting

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");
        }
    }
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AuthorizationException(org.apache.storm.generated.AuthorizationException) Principal(java.security.Principal) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 62 with VisibleForTesting

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();
        }
    }
}
Also used : EntityTable(org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityTable) FlowActivityTable(org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityTable) AppToFlowTable(org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowTable) ApplicationTable(org.apache.hadoop.yarn.server.timelineservice.storage.application.ApplicationTable) FlowRunTable(org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowRunTable) Connection(org.apache.hadoop.hbase.client.Connection) IOException(java.io.IOException) Admin(org.apache.hadoop.hbase.client.Admin) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 63 with VisibleForTesting

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;
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) InetSocketAddress(java.net.InetSocketAddress) YarnRPC(org.apache.hadoop.yarn.ipc.YarnRPC) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 64 with VisibleForTesting

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;
}
Also used : YarnUncaughtExceptionHandler(org.apache.hadoop.yarn.YarnUncaughtExceptionHandler) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 65 with VisibleForTesting

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);
    }
}
Also used : RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1955 IOException (java.io.IOException)284 ArrayList (java.util.ArrayList)214 Map (java.util.Map)156 HashMap (java.util.HashMap)147 List (java.util.List)113 File (java.io.File)94 ImmutableMap (com.google.common.collect.ImmutableMap)72 HashSet (java.util.HashSet)67 Path (org.apache.hadoop.fs.Path)63 ImmutableList (com.google.common.collect.ImmutableList)60 Path (java.nio.file.Path)60 Set (java.util.Set)52 Matcher (java.util.regex.Matcher)46 Collectors (java.util.stream.Collectors)46 Collection (java.util.Collection)39 Optional (java.util.Optional)38 NotNull (org.jetbrains.annotations.NotNull)37 ImmutableSet (com.google.common.collect.ImmutableSet)34 TreeMap (java.util.TreeMap)34