Java Code Examples for org.apache.hadoop.metrics2.lib.DefaultMetricsSystem#setMiniClusterMode()

The following examples show how to use org.apache.hadoop.metrics2.lib.DefaultMetricsSystem#setMiniClusterMode() . 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: MiniOzoneChaosCluster.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Override
public MiniOzoneChaosCluster build() throws IOException {

  DefaultMetricsSystem.setMiniClusterMode(true);
  initializeConfiguration();
  if (numOfOMs > 1) {
    initOMRatisConf();
  }

  StorageContainerManager scm;
  List<OzoneManager> omList;
  try {
    scm = createSCM();
    scm.start();
    if (numOfOMs > 1) {
      omList = createOMService();
    } else {
      OzoneManager om = createOM();
      om.start();
      omList = Arrays.asList(om);
    }
  } catch (AuthenticationException ex) {
    throw new IOException("Unable to build MiniOzoneCluster. ", ex);
  }

  final List<HddsDatanodeService> hddsDatanodes = createHddsDatanodes(
      scm, null);

  MiniOzoneChaosCluster cluster =
      new MiniOzoneChaosCluster(conf, omList, scm, hddsDatanodes,
          omServiceId, clazzes);

  if (startDataNodes) {
    cluster.startHddsDatanodes();
  }
  return cluster;
}
 
Example 2
Source File: TestSecureOzoneCluster.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Before
  public void init() {
    try {
      conf = new OzoneConfiguration();
      conf.set(OZONE_SCM_CLIENT_ADDRESS_KEY, "localhost");

      conf.setInt(OZONE_SCM_CLIENT_PORT_KEY,
          getPort(OZONE_SCM_CLIENT_PORT_DEFAULT, 100));
      conf.setInt(OZONE_SCM_DATANODE_PORT_KEY,
          getPort(OZONE_SCM_DATANODE_PORT_DEFAULT, 100));
      conf.setInt(OZONE_SCM_BLOCK_CLIENT_PORT_KEY,
          getPort(OZONE_SCM_BLOCK_CLIENT_PORT_DEFAULT, 100));
      conf.setInt(OZONE_SCM_SECURITY_SERVICE_PORT_KEY,
          getPort(OZONE_SCM_SECURITY_SERVICE_PORT_DEFAULT, 100));

      DefaultMetricsSystem.setMiniClusterMode(true);
      final String path = folder.newFolder().toString();
      Path metaDirPath = Paths.get(path, "om-meta");
      conf.set(OZONE_METADATA_DIRS, metaDirPath.toString());
      conf.setBoolean(OZONE_SECURITY_ENABLED_KEY, true);
      conf.set(HADOOP_SECURITY_AUTHENTICATION, KERBEROS.name());

      workDir = GenericTestUtils.getTestDir(getClass().getSimpleName());

      startMiniKdc();
      setSecureConfig();
      createCredentialsInKDC();
      generateKeyPair();
//      OzoneManager.setTestSecureOmFlag(true);
    } catch (Exception e) {
      LOG.error("Failed to initialize TestSecureOzoneCluster", e);
    }
  }
 
Example 3
Source File: TestDelegationToken.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
  try {
    conf = new OzoneConfiguration();
    conf.set(OZONE_SCM_CLIENT_ADDRESS_KEY, "localhost");

    conf.setInt(OZONE_SCM_CLIENT_PORT_KEY,
        getPort(OZONE_SCM_CLIENT_PORT_DEFAULT, 100));
    conf.setInt(OZONE_SCM_DATANODE_PORT_KEY,
        getPort(OZONE_SCM_DATANODE_PORT_DEFAULT, 100));
    conf.setInt(OZONE_SCM_BLOCK_CLIENT_PORT_KEY,
        getPort(OZONE_SCM_BLOCK_CLIENT_PORT_DEFAULT, 100));
    conf.setInt(OZONE_SCM_SECURITY_SERVICE_PORT_KEY,
        getPort(OZONE_SCM_SECURITY_SERVICE_PORT_DEFAULT, 100));

    DefaultMetricsSystem.setMiniClusterMode(true);
    final String path = folder.newFolder().toString();
    Path metaDirPath = Paths.get(path, "om-meta");
    conf.set(OZONE_METADATA_DIRS, metaDirPath.toString());
    conf.setBoolean(OZONE_SECURITY_ENABLED_KEY, true);
    conf.set(HADOOP_SECURITY_AUTHENTICATION, KERBEROS.name());

    workDir = GenericTestUtils.getTestDir(getClass().getSimpleName());

    startMiniKdc();
    setSecureConfig();
    createCredentialsInKDC();
    generateKeyPair();
    //      OzoneManager.setTestSecureOmFlag(true);
  } catch (Exception e) {
    LOG.error("Failed to initialize TestSecureOzoneCluster", e);
  }
}
 
Example 4
Source File: TestSecureOzoneContainer.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
  DefaultMetricsSystem.setMiniClusterMode(true);
  conf = new OzoneConfiguration();
  String ozoneMetaPath =
      GenericTestUtils.getTempPath("ozoneMeta");
  conf.set(OZONE_METADATA_DIRS, ozoneMetaPath);
  secConfig = new SecurityConfig(conf);
  caClient = new CertificateClientTestImpl(conf);
  secretManager = new OzoneBlockTokenSecretManager(new SecurityConfig(conf),
      60 * 60 * 24, caClient.getCertificate().
      getSerialNumber().toString());
}
 
Example 5
Source File: TestSecureContainerServer.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
@BeforeClass
static public void setup() throws Exception {
  DefaultMetricsSystem.setMiniClusterMode(true);
  CONF.set(HddsConfigKeys.HDDS_METADATA_DIR_NAME, TEST_DIR);
  CONF.setBoolean(OZONE_SECURITY_ENABLED_KEY, true);
  CONF.setBoolean(HDDS_BLOCK_TOKEN_ENABLED, true);
  caClient = new CertificateClientTestImpl(CONF);
}
 
Example 6
Source File: TestWorkPreservingRMRestart.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws UnknownHostException {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  conf = getConf();
  UserGroupInformation.setConfiguration(conf);
  conf.set(YarnConfiguration.RECOVERY_ENABLED, "true");
  conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
  conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, true);
  conf.setLong(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS, 0);
  DefaultMetricsSystem.setMiniClusterMode(true);
}
 
Example 7
Source File: TestMRAppMaster.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws AccessControlException,
    FileNotFoundException, IllegalArgumentException, IOException {
  //Do not error out if metrics are inited multiple times
  DefaultMetricsSystem.setMiniClusterMode(true);
  File dir = new File(stagingDir);
  stagingDir = dir.getAbsolutePath();
  localFS = FileContext.getLocalFSFileContext();
  localFS.delete(new Path(testDir.getAbsolutePath()), true);
  testDir.mkdir();
}
 
Example 8
Source File: TestWorkPreservingRMRestart.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws UnknownHostException {
  Logger rootLogger = LogManager.getRootLogger();
  rootLogger.setLevel(Level.DEBUG);
  conf = getConf();
  UserGroupInformation.setConfiguration(conf);
  conf.set(YarnConfiguration.RECOVERY_ENABLED, "true");
  conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
  conf.setBoolean(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_ENABLED, true);
  conf.setLong(YarnConfiguration.RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS, 0);
  DefaultMetricsSystem.setMiniClusterMode(true);
}
 
Example 9
Source File: TestMRAppMaster.java    From big-c with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws AccessControlException,
    FileNotFoundException, IllegalArgumentException, IOException {
  //Do not error out if metrics are inited multiple times
  DefaultMetricsSystem.setMiniClusterMode(true);
  File dir = new File(stagingDir);
  stagingDir = dir.getAbsolutePath();
  localFS = FileContext.getLocalFSFileContext();
  localFS.delete(new Path(testDir.getAbsolutePath()), true);
  testDir.mkdir();
}
 
Example 10
Source File: TestMasterNoCluster.java    From hbase with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  Configuration c = TESTUTIL.getConfiguration();
  // We use local filesystem.  Set it so it writes into the testdir.
  CommonFSUtils.setRootDir(c, TESTUTIL.getDataTestDir());
  DefaultMetricsSystem.setMiniClusterMode(true);
  // Startup a mini zk cluster.
  TESTUTIL.startMiniZKCluster();
}
 
Example 11
Source File: MiniOzoneClusterImpl.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Override
public MiniOzoneCluster build() throws IOException {
  DefaultMetricsSystem.setMiniClusterMode(true);
  initializeConfiguration();
  StorageContainerManager scm = null;
  OzoneManager om = null;
  ReconServer reconServer = null;
  List<HddsDatanodeService> hddsDatanodes = Collections.emptyList();
  try {
    scm = createSCM();
    scm.start();
    om = createOM();
    if (certClient != null) {
      om.setCertClient(certClient);
    }
    om.start();

    if (includeRecon) {
      configureRecon();
      reconServer = new ReconServer();
      reconServer.execute(new String[] {});
    }

    hddsDatanodes = createHddsDatanodes(scm, reconServer);

    MiniOzoneClusterImpl cluster = new MiniOzoneClusterImpl(conf, om, scm,
        hddsDatanodes, reconServer);

    cluster.setCAClient(certClient);
    if (startDataNodes) {
      cluster.startHddsDatanodes();
    }
    return cluster;
  } catch (Exception ex) {
    stopOM(om);
    if (includeRecon) {
      stopRecon(reconServer);
    }
    if (startDataNodes) {
      stopDatanodes(hddsDatanodes);
    }
    stopSCM(scm);
    removeConfiguration();

    if (ex instanceof IOException) {
      throw (IOException) ex;
    }
    if (ex instanceof RuntimeException) {
      throw (RuntimeException) ex;
    }
    throw new IOException("Unable to build MiniOzoneCluster. ", ex);
  }
}
 
Example 12
Source File: MiniOzoneHAClusterImpl.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Override
public MiniOzoneCluster build() throws IOException {
  if (numOfActiveOMs > numOfOMs) {
    throw new IllegalArgumentException("Number of active OMs cannot be " +
        "more than the total number of OMs");
  }

  // If num of ActiveOMs is not set, set it to numOfOMs.
  if (numOfActiveOMs == ACTIVE_OMS_NOT_SET) {
    numOfActiveOMs = numOfOMs;
  }

  DefaultMetricsSystem.setMiniClusterMode(true);
  initializeConfiguration();
  initOMRatisConf();
  StorageContainerManager scm;
  ReconServer reconServer = null;
  try {
    scm = createSCM();
    scm.start();
    createOMService();
    if (includeRecon) {
      configureRecon();
      reconServer = new ReconServer();
      reconServer.execute(new String[] {});
    }
  } catch (AuthenticationException ex) {
    throw new IOException("Unable to build MiniOzoneCluster. ", ex);
  }

  final List<HddsDatanodeService> hddsDatanodes = createHddsDatanodes(
      scm, reconServer);

  MiniOzoneHAClusterImpl cluster = new MiniOzoneHAClusterImpl(conf,
      activeOMs, inactiveOMs, scm, hddsDatanodes, omServiceId, reconServer);

  if (startDataNodes) {
    cluster.startHddsDatanodes();
  }
  return cluster;
}
 
Example 13
Source File: TraceMetricsSourceTest.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() throws Exception{
  DefaultMetricsSystem.setMiniClusterMode(true);
}
 
Example 14
Source File: MetricsAssertHelperImpl.java    From hbase with Apache License 2.0 4 votes vote down vote up
@Override
public void init() {
  // Make sure that the metrics system doesn't throw an exception when
  // registering a source with the same name
  DefaultMetricsSystem.setMiniClusterMode(true);
}