com.yammer.metrics.reporting.ConsoleReporter Java Examples

The following examples show how to use com.yammer.metrics.reporting.ConsoleReporter. 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: ReporterSetup.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
public static void setupReporter(BlurConfiguration configuration, String reporter) {
  reporter = reporter.trim();
  try {
    TYPES type = TYPES.valueOf(reporter.trim());
    switch (type) {
    case ConsoleReporter:
      setupConsoleReporter(configuration);
      return;
    case CsvReporter:
      setupCsvReporter(configuration);
      return;
    case GangliaReporter:
      setupGangliaReporter(configuration);
      return;
    case GraphiteReporter:
      setupGraphiteReporter(configuration);
      return;
    default:
      break;
    }
  } catch (IllegalArgumentException e) {
    LOG.info("Cannot resolve reporter of type [{0}] trying to find class.", reporter);
    try {
      Class<?> reporterClazz = Class.forName(reporter);
      reflectiveSetup(reporterClazz, configuration, reporter);
    } catch (ClassNotFoundException ex) {
      LOG.error("Cannot find class [{0}]", reporter);
    }
  }
}
 
Example #2
Source File: ReporterSetup.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
private static void setupConsoleReporter(BlurConfiguration configuration) {
  long period = configuration.getLong(BLUR_SHARD_METRICS_REPORTER_PREFIX + "console." + "period", 5l);
  TimeUnit unit = TimeUnit.valueOf(configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "console." + "unit",
      "SECONDS").toUpperCase());
  ConsoleReporter.enable(period, unit);
}
 
Example #3
Source File: BcryptCommandTest.java    From usergrid with Apache License 2.0 2 votes vote down vote up
/**
 * Tests bcrypt hashing with a default number of rounds.  Note that via the console output, this test should take
 * about 5 seconds to run since we want to force 500 ms per authentication attempt with bcrypt
 */
@Test
public void testHashRoundSpeed() throws UnsupportedEncodingException {

    int cryptIterations = 2 ^ 11;
    int numberOfTests = 10;

    BcryptCommand command = new BcryptCommand();
    command.setDefaultIterations( cryptIterations );

    String baseString = "I am a test password for hashing";

    CredentialsInfo info = new CredentialsInfo();


    UUID user = UUID.randomUUID();
    UUID applicationId = UUID.randomUUID();

    byte[] result = command.hash( baseString.getBytes( "UTF-8" ), info, user, applicationId );


    String stringResults = encodeBase64URLSafeString( result );

    info.setSecret( stringResults );

    Timer timer = Metrics.newTimer( BcryptCommandTest.class, "hashtimer" );

    for ( int i = 0; i < numberOfTests; i++ ) {
        TimerContext timerCtx = timer.time();

        //now check we can auth with the same phrase
        byte[] authed = command.auth( baseString.getBytes( "UTF-8" ), info, user, applicationId );

        timerCtx.stop();


        assertArrayEquals( result, authed );
    }

    /**
     * Print out the data
     */
    ConsoleReporter reporter = new ConsoleReporter( Metrics.defaultRegistry(), System.out, MetricPredicate.ALL );

    reporter.run();
}