private StatsDClient createClient(String address, int port, StatsDClientErrorHandler errorHandler) { try { return new NonBlockingStatsDClient("rapture", address, port, errorHandler); } catch (StatsDClientException e1) { log.error(String.format("Error initializing statsd client with host %s - %s", address, ExceptionToString.format(e1))); return new NoOpStatsDClient(); } }
private StatsDClient createClient(String statsdHost, int port) { StatsDClientErrorHandler errorHandler = new StatsDClientErrorHandler() { @Override public void handle(Exception exception) { log.error("Error sending to statsd: " + ExceptionToString.format(exception)); } }; if (statsdHost == null) { log.fatal("Error, statsd host not set. It needs to be set in RaptureMETRICS.cfg"); return new NoOpStatsDClient(); } else { try { InetAddress address = InetAddress.getByName(statsdHost); String ip = address.getHostAddress(); log.info(String.format("statsd host=%s, ip=%s", statsdHost, ip)); return createClient(ip, port, errorHandler); } catch (UnknownHostException e) { log.error(String.format("Error resolving statsd host ip. hostname=%s - %s", statsdHost, ExceptionToString.format(e))); return createClient(statsdHost, port, errorHandler); } } }
statsDClient = new NoOpStatsDClient();
statsDClient = new NoOpStatsDClient();
private ReplicationServer createReplicationServer() { ReplicationServer replicationServer = new ReplicationServer( conf, srcCluster, destCluster, auditLogReader, dbKeyValueStore, persistedJobInfoStore, Arrays.asList(replicationFilter), new DirectoryCopier(conf, srcCluster.getTmpDir(), false), new NoOpStatsDClient(), 1, 2, Optional.of(0L)); replicationServer.setPollWaitTimeMs(TEST_POLL_TIME); return replicationServer; }
/** * Returns an initialized instance of the StatsDClient If StatsD is enabled * this is a NonBlockingStatsDClient which guarantees not to block the thread or * throw exceptions. If StatsD is not enabled it creates a NoOpStatsDClient which * contains all empty methods * * @return initialized StatsDClient */ protected StatsDClient createStatsDClient() { final boolean enabled = getOptionalBooleanConfig(STATSD_ENABLED, DEFAULT_STATSD_ENABLED); if (enabled) { final String prefix = getOptionalStringConfig(STATSD_PREFIX, DEFAULT_STATSD_PREFIX); final String host = getOptionalStringConfig(STATSD_HOST, DEFAULT_STATSD_HOST); final int port = getOptionalIntConfig(STATSD_PORT, DEFAULT_STATSD_PORT); return new NonBlockingStatsDClient(prefix, host, port); } else { return new NoOpStatsDClient(); } }