Java Code Examples for org.apache.hadoop.hbase.LocalHBaseCluster#startup()

The following examples show how to use org.apache.hadoop.hbase.LocalHBaseCluster#startup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecureTestCluster.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Setup and start kerberos, hbase
 */
@BeforeClass
public static void setUp() throws Exception {
  // Can take a long time for the mini kdc to come up on loaded test cluster. Tolerate this in
  // test by upping the skew time allowed from 30s to 90s.
  TEST_UTIL.getConfiguration().setLong(ServerManager.MAX_CLOCK_SKEW_MS, 90000);
  KDC = TEST_UTIL.setupMiniKdc(KEYTAB_FILE);
  USERNAME = UserGroupInformation.getLoginUser().getShortUserName();
  PRINCIPAL = USERNAME + "/" + HOST;
  HTTP_PRINCIPAL = "HTTP/" + HOST;
  KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL, HTTP_PRINCIPAL);
  TEST_UTIL.startMiniZKCluster();

  HBaseKerberosUtils.setSecuredConfiguration(TEST_UTIL.getConfiguration(),
      PRINCIPAL + "@" + KDC.getRealm(), HTTP_PRINCIPAL + "@" + KDC.getRealm());
  HBaseKerberosUtils.setSSLConfiguration(TEST_UTIL, testRunnerClass);

  TEST_UTIL.getConfiguration().setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      TokenProvider.class.getName());
  TEST_UTIL.startMiniDFSCluster(1);
  Path rootdir = TEST_UTIL.getDataTestDirOnTestFS("TestGenerateDelegationToken");
  CommonFSUtils.setRootDir(TEST_UTIL.getConfiguration(), rootdir);
  CLUSTER = new LocalHBaseCluster(TEST_UTIL.getConfiguration(), 1);
  CLUSTER.startup();
}
 
Example 2
Source File: CustomSaslAuthenticationProviderTestBase.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected static void startCluster(String rpcServerImpl) throws Exception {
  KEYTAB_FILE = new File(UTIL.getDataTestDir("keytab").toUri().getPath());
  final MiniKdc kdc = UTIL.setupMiniKdc(KEYTAB_FILE);

  // Adds our test impls instead of creating service loader entries which
  // might inadvertently get them loaded on a real cluster.
  CONF.setStrings(SaslClientAuthenticationProviders.EXTRA_PROVIDERS_KEY,
    InMemoryClientProvider.class.getName());
  CONF.setStrings(SaslServerAuthenticationProviders.EXTRA_PROVIDERS_KEY,
    InMemoryServerProvider.class.getName());
  CONF.set(SaslClientAuthenticationProviders.SELECTOR_KEY,
    InMemoryProviderSelector.class.getName());
  createBaseCluster(UTIL, KEYTAB_FILE, kdc);
  CONF.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl);
  CLUSTER = new LocalHBaseCluster(CONF, 1);
  CLUSTER.startup();
}
 
Example 3
Source File: HBaseTestUtils.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public static void startCluster() throws Exception {
    Configuration hbaseConf =
            HBaseBasedAuditRepository.getHBaseConfiguration(ApplicationProperties.get());
    hbaseTestUtility = HBaseTestingUtility.createLocalHTU(hbaseConf);
    int zkPort = hbaseConf.getInt("hbase.zookeeper.property.clientPort", 19026);
    hbaseTestUtility.startMiniZKCluster(1, zkPort);

    hbaseCluster = new LocalHBaseCluster(hbaseTestUtility.getConfiguration());
    hbaseCluster.startup();
}
 
Example 4
Source File: HBaseTestHelper.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
public static void startLocalCluster() throws IOException, InterruptedException
{
  startZooKeeperServer();
  //Configuration conf = HBaseConfiguration.create();
  Configuration conf = getConfiguration();
  LocalHBaseCluster lc = new LocalHBaseCluster(conf);
  lc.startup();
}
 
Example 5
Source File: HBaseServerTestInstance.java    From Halyard with Apache License 2.0 4 votes vote down vote up
public static synchronized Configuration getInstanceConfig() throws Exception {
    if (conf == null) {
        File zooRoot = File.createTempFile("hbase-zookeeper", "");
        zooRoot.delete();
        ZooKeeperServer zookeper = new ZooKeeperServer(zooRoot, zooRoot, 2000);
        ServerCnxnFactory factory = ServerCnxnFactory.createFactory(new InetSocketAddress("localhost", 0), 5000);
        factory.startup(zookeper);

        YarnConfiguration yconf = new YarnConfiguration();
        String argLine = System.getProperty("argLine");
        if (argLine != null) {
            yconf.set("yarn.app.mapreduce.am.command-opts", argLine.replace("jacoco.exec", "jacocoMR.exec"));
        }
        yconf.setBoolean(MRConfig.MAPREDUCE_MINICLUSTER_CONTROL_RESOURCE_MONITORING, false);
        yconf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class, ResourceScheduler.class);
        MiniMRYarnCluster miniCluster = new MiniMRYarnCluster("testCluster");
        miniCluster.init(yconf);
        String resourceManagerLink = yconf.get(YarnConfiguration.RM_ADDRESS);
        yconf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, true);
        miniCluster.start();
        miniCluster.waitForNodeManagersToConnect(10000);
        // following condition set in MiniYarnCluster:273
        while (resourceManagerLink.endsWith(":0")) {
            Thread.sleep(100);
            resourceManagerLink = yconf.get(YarnConfiguration.RM_ADDRESS);
        }

        File hbaseRoot = File.createTempFile("hbase-root", "");
        hbaseRoot.delete();
        conf = HBaseConfiguration.create(miniCluster.getConfig());
        conf.set(HConstants.HBASE_DIR, hbaseRoot.toURI().toURL().toString());
        conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, factory.getLocalPort());
        conf.set("hbase.master.hostname", "localhost");
        conf.set("hbase.regionserver.hostname", "localhost");
        conf.setInt("hbase.master.info.port", -1);
        conf.set("hbase.fs.tmp.dir", new File(System.getProperty("java.io.tmpdir")).toURI().toURL().toString());
        LocalHBaseCluster cluster = new LocalHBaseCluster(conf);
        cluster.startup();
    }
    return new Configuration(conf);
}
 
Example 6
Source File: TestInfoServersACL.java    From hbase with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  conf = UTIL.getConfiguration();
  KDC = UTIL.setupMiniKdc(KEYTAB_FILE);
  USERNAME = UserGroupInformation.getLoginUser().getShortUserName();
  PRINCIPAL = USERNAME + "/" + HOST;
  HTTP_PRINCIPAL = "HTTP/" + HOST;
  // Create principals for services and the test users
  KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL, HTTP_PRINCIPAL, USER_ADMIN_STR, USER_NONE_STR);
  UTIL.startMiniZKCluster();

  HBaseKerberosUtils.setSecuredConfiguration(conf,
      PRINCIPAL + "@" + KDC.getRealm(), HTTP_PRINCIPAL + "@" + KDC.getRealm());
  HBaseKerberosUtils.setSSLConfiguration(UTIL, TestInfoServersACL.class);

  conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      TokenProvider.class.getName());
  UTIL.startMiniDFSCluster(1);
  Path rootdir = UTIL.getDataTestDirOnTestFS("TestInfoServersACL");
  CommonFSUtils.setRootDir(conf, rootdir);

  // The info servers do not run in tests by default.
  // Set them to ephemeral ports so they will start
  // setup configuration
  conf.setInt(HConstants.MASTER_INFO_PORT, 0);
  conf.setInt(HConstants.REGIONSERVER_INFO_PORT, 0);

  conf.set(HttpServer.HTTP_UI_AUTHENTICATION, "kerberos");
  conf.set(HttpServer.HTTP_SPNEGO_AUTHENTICATION_PRINCIPAL_KEY, HTTP_PRINCIPAL);
  conf.set(HttpServer.HTTP_SPNEGO_AUTHENTICATION_KEYTAB_KEY, KEYTAB_FILE.getAbsolutePath());

  // ACL lists work only when "hadoop.security.authorization" is set to true
  conf.setBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, true);
  // only user admin will have acl access
  conf.set(HttpServer.HTTP_SPNEGO_AUTHENTICATION_ADMIN_USERS_KEY, USER_ADMIN_STR);
  //conf.set(HttpServer.FILTER_INITIALIZERS_PROPERTY, "");

  CLUSTER = new LocalHBaseCluster(conf, 1);
  CLUSTER.startup();
  CLUSTER.getActiveMaster().waitForMetaOnline();
}