Search in sources :

Example 1 with DrillbitStartupException

use of org.apache.drill.exec.exception.DrillbitStartupException in project drill by apache.

the class ServiceEngine method start.

public DrillbitEndpoint start() throws DrillbitStartupException, UnknownHostException {
    // loopback address check
    if (isDistributedMode && InetAddress.getByName(hostName).isLoopbackAddress()) {
        throw new DrillbitStartupException("Drillbit is disallowed to bind to loopback address in distributed mode.");
    }
    final int userPort = userServer.bind(intialUserPort, allowPortHunting);
    DrillbitEndpoint partialEndpoint = DrillbitEndpoint.newBuilder().setAddress(hostName).setUserPort(userPort).setVersion(DrillVersionInfo.getVersion()).build();
    partialEndpoint = controller.start(partialEndpoint, allowPortHunting);
    return dataPool.start(partialEndpoint, allowPortHunting);
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)

Example 2 with DrillbitStartupException

use of org.apache.drill.exec.exception.DrillbitStartupException in project drill by apache.

the class BootStrapContext method login.

private void login(final DrillConfig config) throws DrillbitStartupException {
    try {
        if (config.hasPath(SERVICE_PRINCIPAL)) {
            // providing a service principal => Kerberos mechanism
            final Configuration loginConf = new Configuration();
            loginConf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION, UserGroupInformation.AuthenticationMethod.KERBEROS.toString());
            // set optional user name mapping
            if (config.hasPath(KERBEROS_NAME_MAPPING)) {
                loginConf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTH_TO_LOCAL, config.getString(KERBEROS_NAME_MAPPING));
            }
            UserGroupInformation.setConfiguration(loginConf);
            // service principal canonicalization
            final String principal = config.getString(SERVICE_PRINCIPAL);
            final String[] parts = KerberosUtil.splitPrincipalIntoParts(principal);
            if (parts.length != 3) {
                throw new DrillbitStartupException(String.format("Invalid %s, Drill service principal must be of format: primary/instance@REALM", SERVICE_PRINCIPAL));
            }
            parts[1] = KerberosUtil.canonicalizeInstanceName(parts[1], hostName);
            final String canonicalizedPrincipal = KerberosUtil.getPrincipalFromParts(parts[0], parts[1], parts[2]);
            final String keytab = config.getString(SERVICE_KEYTAB_LOCATION);
            // login to KDC (AS)
            // Note that this call must happen before any call to UserGroupInformation#getLoginUser,
            // but there is no way to enforce the order (this static init. call and parameters from
            // DrillConfig are both required).
            UserGroupInformation.loginUserFromKeytab(canonicalizedPrincipal, keytab);
            logger.info("Process user name: '{}' and logged in successfully as '{}'", processUserName, canonicalizedPrincipal);
        } else {
            // init
            UserGroupInformation.getLoginUser();
        }
    // ugi does not support logout
    } catch (final IOException e) {
        throw new DrillbitStartupException("Failed to login.", e);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) IOException(java.io.IOException)

Example 3 with DrillbitStartupException

use of org.apache.drill.exec.exception.DrillbitStartupException in project drill by apache.

the class Drillbit method start.

public static Drillbit start(final DrillConfig config, final RemoteServiceSet remoteServiceSet) throws DrillbitStartupException {
    logger.debug("Starting new Drillbit.");
    // TODO: allow passing as a parameter
    ScanResult classpathScan = ClassPathScanner.fromPrescan(config);
    Drillbit bit;
    try {
        bit = new Drillbit(config, remoteServiceSet, classpathScan);
    } catch (final Exception ex) {
        throw new DrillbitStartupException("Failure while initializing values in Drillbit.", ex);
    }
    try {
        bit.run();
    } catch (final Exception e) {
        logger.error("Failure during initial startup of Drillbit.", e);
        bit.close();
        throw new DrillbitStartupException("Failure during initial startup of Drillbit.", e);
    }
    logger.debug("Started new Drillbit.");
    return bit;
}
Also used : ScanResult(org.apache.drill.common.scanner.persistence.ScanResult) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException)

Example 4 with DrillbitStartupException

use of org.apache.drill.exec.exception.DrillbitStartupException in project drill by apache.

the class ConnectTriesPropertyTestClusterBits method testSetUp.

@BeforeClass
public static void testSetUp() throws Exception {
    remoteServiceSet = RemoteServiceSet.getLocalServiceSet();
    zkHelper = new ZookeeperHelper();
    zkHelper.startZookeeper(1);
    // Creating Drillbits
    drillConfig = zkHelper.getConfig();
    try {
        int drillBitStarted = 0;
        drillbits = new ArrayList<>();
        while (drillBitStarted < drillBitCount) {
            drillbits.add(Drillbit.start(drillConfig, remoteServiceSet));
            ++drillBitStarted;
        }
    } catch (DrillbitStartupException e) {
        throw new RuntimeException("Failed to start drillbits.", e);
    }
    bitInfo = new StringBuilder();
    for (int i = 0; i < drillBitCount; ++i) {
        final DrillbitEndpoint currentEndPoint = drillbits.get(i).getContext().getEndpoint();
        final String currentBitIp = currentEndPoint.getAddress();
        final int currentBitPort = currentEndPoint.getUserPort();
        bitInfo.append(",");
        bitInfo.append(currentBitIp);
        bitInfo.append(":");
        bitInfo.append(currentBitPort);
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) ZookeeperHelper(org.apache.drill.exec.ZookeeperHelper) DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) BeforeClass(org.junit.BeforeClass)

Example 5 with DrillbitStartupException

use of org.apache.drill.exec.exception.DrillbitStartupException in project drill by apache.

the class UserAuthenticatorFactory method createAuthenticator.

/**
   * Create a {@link UserAuthenticator} implementation based on BOOT settings in
   * given <i>drillConfig</i>.
   *
   * @param config DrillConfig containing BOOT options.
   * @return Initialized {@link UserAuthenticator} implementation instance.
   *         It is responsibility of the caller to close the authenticator when no longer needed.
   *
   * @throws DrillbitStartupException when no implementation found for given BOOT options.
   */
public static UserAuthenticator createAuthenticator(final DrillConfig config, ScanResult scan) throws DrillbitStartupException {
    if (!config.hasPath(USER_AUTHENTICATOR_IMPL)) {
        throw new DrillbitStartupException(String.format("BOOT option '%s' is missing in config.", USER_AUTHENTICATOR_IMPL));
    }
    final String authImplConfigured = config.getString(USER_AUTHENTICATOR_IMPL);
    if (Strings.isNullOrEmpty(authImplConfigured)) {
        throw new DrillbitStartupException(String.format("Invalid value '%s' for BOOT option '%s'", authImplConfigured, USER_AUTHENTICATOR_IMPL));
    }
    final Collection<Class<? extends UserAuthenticator>> authImpls = scan.getImplementations(UserAuthenticator.class);
    logger.debug("Found UserAuthenticator implementations: {}", authImpls);
    for (Class<? extends UserAuthenticator> clazz : authImpls) {
        final UserAuthenticatorTemplate template = clazz.getAnnotation(UserAuthenticatorTemplate.class);
        if (template == null) {
            logger.warn("{} doesn't have {} annotation. Skipping.", clazz.getCanonicalName(), UserAuthenticatorTemplate.class);
            continue;
        }
        if (Strings.isNullOrEmpty(template.type())) {
            logger.warn("{} annotation doesn't have valid type field for UserAuthenticator implementation {}. Skipping..", UserAuthenticatorTemplate.class, clazz.getCanonicalName());
            continue;
        }
        if (template.type().equalsIgnoreCase(authImplConfigured)) {
            Constructor<?> validConstructor = null;
            for (Constructor<?> c : clazz.getConstructors()) {
                if (c.getParameterTypes().length == 0) {
                    validConstructor = c;
                    break;
                }
            }
            if (validConstructor == null) {
                logger.warn("Skipping UserAuthenticator implementation class '{}' since it doesn't " + "implement a constructor [{}()]", clazz.getCanonicalName(), clazz.getName());
                continue;
            }
            // Instantiate authenticator and initialize it
            try {
                final UserAuthenticator authenticator = clazz.newInstance();
                authenticator.setup(config);
                return authenticator;
            } catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) {
                throw new DrillbitStartupException(String.format("Failed to create and initialize the UserAuthenticator class '%s'", clazz.getCanonicalName()), e);
            }
        }
    }
    String errMsg = String.format("Failed to find the implementation of '%s' for type '%s'", UserAuthenticator.class.getCanonicalName(), authImplConfigured);
    logger.error(errMsg);
    throw new DrillbitStartupException(errMsg);
}
Also used : DrillbitStartupException(org.apache.drill.exec.exception.DrillbitStartupException)

Aggregations

DrillbitStartupException (org.apache.drill.exec.exception.DrillbitStartupException)8 IOException (java.io.IOException)3 DrillConfig (org.apache.drill.common.config.DrillConfig)3 ZookeeperHelper (org.apache.drill.exec.ZookeeperHelper)3 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)3 Test (org.junit.Test)3 QueryContext (org.apache.drill.exec.ops.QueryContext)2 UserSession (org.apache.drill.exec.rpc.user.UserSession)2 Drillbit (org.apache.drill.exec.server.Drillbit)2 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)2 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)2 ExtendedLatch (org.apache.drill.common.concurrent.ExtendedLatch)1 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)1 FragmentSetupException (org.apache.drill.exec.exception.FragmentSetupException)1 RpcException (org.apache.drill.exec.rpc.RpcException)1 Pointer (org.apache.drill.exec.util.Pointer)1 Configuration (org.apache.hadoop.conf.Configuration)1 BeforeClass (org.junit.BeforeClass)1