Search in sources :

Example 31 with MetricsSystem

use of org.apache.hadoop.metrics2.MetricsSystem in project hadoop by apache.

the class TestMetricsSystemImpl method testRegisterDupError.

@Test(expected = MetricsException.class)
public void testRegisterDupError() {
    MetricsSystem ms = new MetricsSystemImpl("test");
    TestSource ts = new TestSource("ts");
    ms.register(ts);
    ms.register(ts);
}
Also used : DefaultMetricsSystem(org.apache.hadoop.metrics2.lib.DefaultMetricsSystem) MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) Test(org.junit.Test)

Example 32 with MetricsSystem

use of org.apache.hadoop.metrics2.MetricsSystem in project hadoop by apache.

the class TestMetricsSystemImpl method testRegisterDups.

@Test
public void testRegisterDups() {
    MetricsSystem ms = new MetricsSystemImpl();
    TestSource ts1 = new TestSource("ts1");
    TestSource ts2 = new TestSource("ts2");
    ms.register("ts1", "", ts1);
    MetricsSource s1 = ms.getSource("ts1");
    assertNotNull(s1);
    // should work when metrics system is not started
    ms.register("ts1", "", ts2);
    MetricsSource s2 = ms.getSource("ts1");
    assertNotNull(s2);
    assertNotSame(s1, s2);
    ms.shutdown();
}
Also used : MetricsSource(org.apache.hadoop.metrics2.MetricsSource) DefaultMetricsSystem(org.apache.hadoop.metrics2.lib.DefaultMetricsSystem) MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) Test(org.junit.Test)

Example 33 with MetricsSystem

use of org.apache.hadoop.metrics2.MetricsSystem in project hadoop by apache.

the class Nfs3Metrics method create.

public static Nfs3Metrics create(Configuration conf, String gatewayName) {
    String sessionId = conf.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY);
    MetricsSystem ms = DefaultMetricsSystem.instance();
    JvmMetrics jm = JvmMetrics.create(gatewayName, sessionId, ms);
    // Percentile measurement is [50th,75th,90th,95th,99th] currently 
    int[] intervals = conf.getInts(NfsConfigKeys.NFS_METRICS_PERCENTILES_INTERVALS_KEY);
    return ms.register(new Nfs3Metrics(gatewayName, sessionId, intervals, jm));
}
Also used : JvmMetrics(org.apache.hadoop.metrics2.source.JvmMetrics) MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) DefaultMetricsSystem(org.apache.hadoop.metrics2.lib.DefaultMetricsSystem)

Example 34 with MetricsSystem

use of org.apache.hadoop.metrics2.MetricsSystem in project hadoop by apache.

the class RollingFileSystemSinkTestBase method initMetricsSystem.

/**
   * Set up the metrics system, start it, and return it.
   * @param path the base path for the sink
   * @param ignoreErrors whether the sink should ignore errors
   * @param allowAppend whether the sink is allowed to append to existing files
   * @param useSecureParams whether to set the principal and keytab properties
   * @return the org.apache.hadoop.metrics2.MetricsSystem
   */
protected MetricsSystem initMetricsSystem(String path, boolean ignoreErrors, boolean allowAppend, boolean useSecureParams) {
    // If the prefix is not lower case, the metrics system won't be able to
    // read any of the properties.
    String prefix = methodName.getMethodName().toLowerCase();
    ConfigBuilder builder = new ConfigBuilder().add("*.period", 10000).add(prefix + ".sink.mysink0.class", MockSink.class.getName()).add(prefix + ".sink.mysink0.basepath", path).add(prefix + ".sink.mysink0.source", "testsrc").add(prefix + ".sink.mysink0.context", "test1").add(prefix + ".sink.mysink0.ignore-error", ignoreErrors).add(prefix + ".sink.mysink0.allow-append", allowAppend).add(prefix + ".sink.mysink0.roll-offset-interval-millis", 0).add(prefix + ".sink.mysink0.roll-interval", "1h");
    if (useSecureParams) {
        builder.add(prefix + ".sink.mysink0.keytab-key", SINK_KEYTAB_FILE_KEY).add(prefix + ".sink.mysink0.principal-key", SINK_PRINCIPAL_KEY);
    }
    builder.save(TestMetricsConfig.getTestFilename("hadoop-metrics2-" + prefix));
    MetricsSystemImpl ms = new MetricsSystemImpl(prefix);
    ms.start();
    return ms;
}
Also used : ConfigBuilder(org.apache.hadoop.metrics2.impl.ConfigBuilder) MetricsSystemImpl(org.apache.hadoop.metrics2.impl.MetricsSystemImpl)

Example 35 with MetricsSystem

use of org.apache.hadoop.metrics2.MetricsSystem in project hadoop by apache.

the class TestRollingFileSystemSinkWithLocal method testWrite.

/**
   * Test writing logs to the local file system.
   * @throws Exception when things break
   */
@Test
public void testWrite() throws Exception {
    String path = methodDir.getAbsolutePath();
    MetricsSystem ms = initMetricsSystem(path, false, false);
    assertMetricsContents(doWriteTest(ms, path, 1));
}
Also used : MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) Test(org.junit.Test)

Aggregations

MetricsSystem (org.apache.hadoop.metrics2.MetricsSystem)36 DefaultMetricsSystem (org.apache.hadoop.metrics2.lib.DefaultMetricsSystem)19 Test (org.junit.Test)19 MyMetrics1 (org.apache.hadoop.metrics2.sink.RollingFileSystemSinkTestBase.MyMetrics1)5 MetricsSource (org.apache.hadoop.metrics2.MetricsSource)4 MetricsSystemImpl (org.apache.hadoop.metrics2.impl.MetricsSystemImpl)3 JvmMetrics (org.apache.hadoop.metrics2.source.JvmMetrics)3 JvmMetrics (org.apache.hadoop.hive.common.JvmMetrics)2 After (org.junit.After)2 URI (java.net.URI)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 Calendar (java.util.Calendar)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 LlapMetricsSystem (org.apache.hadoop.hive.llap.metrics.LlapMetricsSystem)1 MetricsException (org.apache.hadoop.metrics2.MetricsException)1 MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)1 ConfigBuilder (org.apache.hadoop.metrics2.impl.ConfigBuilder)1