com.netflix.servo.monitor.Monitors Java Examples

The following examples show how to use com.netflix.servo.monitor.Monitors. 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: Exhibitor.java    From exhibitor with Apache License 2.0 6 votes vote down vote up
private static RepeatingActivity initServo(Exhibitor exhibitor, ActivityLog log, ActivityQueue activityQueue, ExhibitorArguments arguments, AtomicReference<CompositeMonitor<?>> theMonitor)
{
    theMonitor.set(null);

    RepeatingActivity localServoMonitoring = null;
    if ( arguments.servoRegistration != null )
    {
        ZookeeperMonitoredData  zookeeperMonitoredData = new ZookeeperMonitoredData();
        CompositeMonitor<?>     compositeMonitor = Monitors.newObjectMonitor(zookeeperMonitoredData);

        GetMonitorData          getMonitorData = new GetMonitorData(exhibitor, zookeeperMonitoredData);
        localServoMonitoring = new RepeatingActivityImpl(log, activityQueue, QueueGroups.IO, getMonitorData, arguments.servoRegistration.getZookeeperPollMs());
        arguments.servoRegistration.getMonitorRegistry().register(compositeMonitor);

        theMonitor.set(compositeMonitor);
    }
    return localServoMonitoring;
}
 
Example #2
Source File: LoadBalancerContext.java    From ribbon with Apache License 2.0 6 votes vote down vote up
/**
 * Set necessary parameters from client configuration and register with Servo monitors.
 */
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    if (clientConfig == null) {
        return;    
    }
    clientName = clientConfig.getClientName();
    if (StringUtils.isEmpty(clientName)) {
        clientName = "default";
    }
    vipAddresses = clientConfig.resolveDeploymentContextbasedVipAddresses();
    maxAutoRetries = clientConfig.getOrDefault(CommonClientConfigKey.MaxAutoRetries);
    maxAutoRetriesNextServer = clientConfig.getOrDefault(CommonClientConfigKey.MaxAutoRetriesNextServer);
    okToRetryOnAllOperations = clientConfig.getOrDefault(CommonClientConfigKey.OkToRetryOnAllOperations);
    defaultRetryHandler = new DefaultLoadBalancerRetryHandler(clientConfig);
    
    tracer = getExecuteTracer();

    Monitors.registerObject("Client_" + clientName, this);
}
 
Example #3
Source File: RemoteFileSink.java    From suro with Apache License 2.0 6 votes vote down vote up
public RemoteFileSink(
        LocalFileSink localFileSink,
        RemotePrefixFormatter prefixFormatter,
        int concurrentUpload,
        boolean batchUpload) {
    this.localFileSink = localFileSink;
    this.prefixFormatter = prefixFormatter == null ? new DynamicRemotePrefixFormatter("date(yyyyMMdd)") : prefixFormatter;
    this.batchUpload = batchUpload;

    Preconditions.checkNotNull(localFileSink, "localFileSink is needed");

    uploader = Executors.newFixedThreadPool(concurrentUpload == 0 ? 5 : concurrentUpload);
    localFilePoller = Executors.newSingleThreadExecutor();

    if (!batchUpload) {
        localFileSink.cleanUp(false);
    }

    Monitors.registerObject(
            this.getClass().getSimpleName() + '-' + localFileSink.getOutputDir().replace('/', '_'),
            this);
}
 
Example #4
Source File: ConnectionPool.java    From suro with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param config Client configuration
 * @param lb LoadBalancer implementation
 */
@Inject
public ConnectionPool(ClientConfig config, ILoadBalancer lb) {
    this.config = config;
    this.lb = lb;

    connectionSweeper = Executors.newScheduledThreadPool(1);
    newConnectionBuilder = Executors.newFixedThreadPool(1);

    Monitors.registerObject(this);

    populationLatch = new CountDownLatch(Math.min(lb.getServerList(true).size(), config.getAsyncSenderThreads()));
    Executors.newSingleThreadExecutor().submit(new Runnable() {
        @Override
        public void run() {
            populateClients();
        }
    });
    try {
        populationLatch.await(populationLatch.getCount() * config.getConnectionTimeout(), TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        logger.error("Exception on CountDownLatch awaiting: " + e.getMessage(), e);
    }
    logger.info("ConnectionPool population finished with the size: " + getPoolSize()
            + ", will continue up to: " + lb.getServerList(true).size());
}
 
Example #5
Source File: MetricAnnotationManualTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenAnnotatedMonitor_whenUpdated_thenDataCollected() throws Exception {
    Monitors.registerObject("testObject", this);
    assertTrue(Monitors.isObjectRegistered("testObject", this));

    updateCount.incrementAndGet();
    updateCount.incrementAndGet();
    SECONDS.sleep(1);

    List<List<Metric>> metrics = observer.getObservations();
    System.out.println(metrics);
    assertThat(metrics, hasSize(greaterThanOrEqualTo(1)));

    Iterator<List<Metric>> metricIterator = metrics.iterator();
    //skip first empty observation
    metricIterator.next();
    while (metricIterator.hasNext()) {
        assertThat(metricIterator.next(), hasItem(hasProperty("config", hasProperty("name", is("integerCounter")))));
    }

}
 
Example #6
Source File: PrimeConnections.java    From ribbon with Apache License 2.0 6 votes vote down vote up
private void setUp(String name, int maxRetries, 
        long maxTotalTimeToPrimeConnections, String primeConnectionsURI, float primeRatio) {        
    this.name = name;
    this.maxRetries = maxRetries;
    this.maxTotalTimeToPrimeConnections = maxTotalTimeToPrimeConnections;
    this.primeConnectionsURIPath = primeConnectionsURI;        
    this.primeRatio = primeRatio;
    executorService = new ThreadPoolExecutor(1 /* minimum */,
            maxExecutorThreads /* max threads */,
            executorThreadTimeout /*
                                   * timeout - same property as create
                                   * timeout
                                   */, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>()
            /* Bounded queue with FIFO- bounded to max tasks */,
            new ASyncPrimeConnectionsThreadFactory(name) /*
                                                          * So we can give
                                                          * our Thread a
                                                          * name
                                                          */
    );        
    totalCounter = Monitors.newCounter(name + "_PrimeConnection_TotalCounter");
    successCounter = Monitors.newCounter(name + "_PrimeConnection_SuccessCounter");
    initialPrimeTimer = Monitors.newTimer(name + "_initialPrimeConnectionsTimer", TimeUnit.MILLISECONDS);
    Monitors.registerObject(name + "_PrimeConnection", this);
}
 
Example #7
Source File: ZoneAffinityServerListFilter.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig niwsClientConfig) {
    zoneAffinity = niwsClientConfig.getOrDefault(CommonClientConfigKey.EnableZoneAffinity);
    zoneExclusive = niwsClientConfig.getOrDefault(CommonClientConfigKey.EnableZoneExclusivity);
    zone = niwsClientConfig.getGlobalProperty(ZONE).getOrDefault();
    zoneAffinityPredicate = new ZoneAffinityPredicate(zone);

    activeReqeustsPerServerThreshold = niwsClientConfig.getDynamicProperty(MAX_LOAD_PER_SERVER);
    blackOutServerPercentageThreshold = niwsClientConfig.getDynamicProperty(MAX_BLACKOUT_SERVER_PERCENTAGE);
    availableServersThreshold = niwsClientConfig.getDynamicProperty(MIN_AVAILABLE_SERVERS);

    overrideCounter = Monitors.newCounter("ZoneAffinity_OverrideCounter");

    Monitors.registerObject("NIWSServerListFilter_" + niwsClientConfig.getClientName());
}
 
Example #8
Source File: LoadBalancerContext.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public Timer getExecuteTracer() {
    if (tracer == null) {
        synchronized(this) {
            if (tracer == null) {
                tracer = Monitors.newTimer(clientName + "_LoadBalancerExecutionTimer", TimeUnit.MILLISECONDS);                    
            }
        }
    } 
    return tracer;        
}
 
Example #9
Source File: ZoneStats.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public ZoneStats(String name, String zone, LoadBalancerStats loadBalancerStats) {
    this.zone = zone;
    this.loadBalancerStats = loadBalancerStats;
    monitorId = name + ":" + zone;  
    counter = Monitors.newCounter(PREFIX + name + "_" + zone + "_Counter");
    Monitors.registerObject(monitorId, this);
}
 
Example #10
Source File: BaseLoadBalancer.java    From ribbon with Apache License 2.0 5 votes vote down vote up
/**
 * Register with monitors and start priming connections if it is set.
 */
protected void init() {
    Monitors.registerObject("LoadBalancer_" + name, this);
    // register the rule as it contains metric for available servers count
    Monitors.registerObject("Rule_" + name, this.getRule());
    if (enablePrimingConnections && primeConnections != null) {
        primeConnections.primeConnections(getReachableServers());
    }
}
 
Example #11
Source File: BaseLoadBalancer.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public void shutdown() {
    cancelPingTask();
    if (primeConnections != null) {
        primeConnections.shutdown();
    }
    Monitors.unregisterObject("LoadBalancer_" + name, this);
    Monitors.unregisterObject("Rule_" + name, this.getRule());
}
 
Example #12
Source File: ClientFactory.java    From ribbon with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to create client and load balancer (if enabled in client config) given the name and client config.
 * Instances are created using reflection (see {@link #instantiateInstanceWithClientConfig(String, IClientConfig)}
 *
 * @param restClientName
 * @param clientConfig
 * @throws ClientException if any errors occurs in the process, or if the client with the same name already exists
 */
public static synchronized IClient<?, ?> registerClientFromProperties(String restClientName, IClientConfig clientConfig) throws ClientException { 
	IClient<?, ?> client = null;
	ILoadBalancer loadBalancer = null;
	if (simpleClientMap.get(restClientName) != null) {
		throw new ClientException(
				ClientException.ErrorType.GENERAL,
				"A Rest Client with this name is already registered. Please use a different name");
	}
	try {
		String clientClassName = clientConfig.getOrDefault(CommonClientConfigKey.ClientClassName);
		client = (IClient<?, ?>) instantiateInstanceWithClientConfig(clientClassName, clientConfig);
		boolean initializeNFLoadBalancer = clientConfig.getOrDefault(CommonClientConfigKey.InitializeNFLoadBalancer);
		if (initializeNFLoadBalancer) {
			loadBalancer = registerNamedLoadBalancerFromclientConfig(restClientName, clientConfig);
		}
		if (client instanceof AbstractLoadBalancerAwareClient) {
			((AbstractLoadBalancerAwareClient) client).setLoadBalancer(loadBalancer);
		}
	} catch (Throwable e) {
		String message = "Unable to InitializeAndAssociateNFLoadBalancer set for RestClient:"
				+ restClientName;
		logger.warn(message, e);
		throw new ClientException(ClientException.ErrorType.CONFIGURATION, 
				message, e);
	}
	simpleClientMap.put(restClientName, client);

	Monitors.registerObject("Client_" + restClientName, client);

	logger.info("Client Registered:" + client.toString());
	return client;
}
 
Example #13
Source File: MetricTypeManualTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenDefaultCounter_whenManipulate_thenCountValid() {
    Counter counter = Monitors.newCounter("test");
    assertEquals("counter should start with 0", 0, counter
      .getValue()
      .intValue());
    counter.increment();
    assertEquals("counter should have increased by 1", 1, counter
      .getValue()
      .intValue());
    counter.increment(-1);
    assertEquals("counter should have decreased by 1", 0, counter
      .getValue()
      .intValue());
}
 
Example #14
Source File: LocalFileSink.java    From suro with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public LocalFileSink(
        @JsonProperty("outputDir") String outputDir,
        @JsonProperty("writer") FileWriter writer,
        @JsonProperty("notice") Notice notice,
        @JsonProperty("maxFileSize") long maxFileSize,
        @JsonProperty("rotationPeriod") String rotationPeriod,
        @JsonProperty("minPercentFreeDisk") int minPercentFreeDisk,
        @JsonProperty("queue4Sink") MessageQueue4Sink queue4Sink,
        @JsonProperty("batchSize") int batchSize,
        @JsonProperty("batchTimeout") int batchTimeout,
        @JsonProperty("pauseOnLongQueue") boolean pauseOnLongQueue,
        @JacksonInject SpaceChecker spaceChecker) {
    if (!outputDir.endsWith("/")) {
        outputDir += "/";
    }
    Preconditions.checkNotNull(outputDir, "outputDir is needed");

    this.outputDir = outputDir;
    this.writer = writer == null ? new TextFileWriter(null) : writer;
    this.maxFileSize = maxFileSize == 0 ? 200 * 1024 * 1024 : maxFileSize;
    this.rotationPeriod = new Period(rotationPeriod == null ? "PT2m" : rotationPeriod);
    this.minPercentFreeDisk = minPercentFreeDisk == 0 ? 15 : minPercentFreeDisk;
    this.notice = notice == null ? new QueueNotice<String>() : notice;
    this.spaceChecker = spaceChecker;

    Monitors.registerObject(outputDir.replace('/', '_'), this);
    initialize("localfile_" + outputDir.replace('/', '_'),
            queue4Sink == null ? new MemoryQueue4Sink(10000) : queue4Sink,
            batchSize,
            batchTimeout,
            pauseOnLongQueue);
}
 
Example #15
Source File: SyncSuroClient.java    From suro with Apache License 2.0 5 votes vote down vote up
@Inject
public SyncSuroClient(ClientConfig config, ConnectionPool connectionPool) {
    this.config = config;
    this.connectionPool = connectionPool;
    this.compression = Compression.create(config.getCompression());

    Monitors.registerObject(this);
}
 
Example #16
Source File: JsonLog4jFormatter.java    From suro with Apache License 2.0 5 votes vote down vote up
@Inject
public JsonLog4jFormatter(ClientConfig config, ObjectMapper jsonMapper) {
    this.config     = config;
    if (jsonMapper == null)
        this.jsonMapper = new DefaultObjectMapper();
    else
        this.jsonMapper = jsonMapper;
    fmt = DateTimeFormat.forPattern(config.getLog4jDateTimeFormat());
    stringFormatter = new StringLog4jFormatter(config);

    Monitors.registerObject(this);
}
 
Example #17
Source File: SQSNotice.java    From suro with Apache License 2.0 5 votes vote down vote up
@JsonCreator
public SQSNotice(
        @JsonProperty("queues") List<String> queues,
        @JsonProperty("region") @JacksonInject("region") String region,
        @JsonProperty("connectionTimeout") int connectionTimeout,
        @JsonProperty("maxConnections") int maxConnections,
        @JsonProperty("socketTimeout") int socketTimeout,
        @JsonProperty("maxRetries") int maxRetries,
        @JsonProperty("enableBase64Encoding") boolean enableBase64Encoding,
        @JacksonInject AmazonSQSClient sqsClient,
        @JacksonInject AWSCredentialsProvider credentialsProvider) {
    this.queues = queues;
    this.region = region;

    this.enableBase64Encoding = enableBase64Encoding;
    this.sqsClient = sqsClient;
    this.credentialsProvider = credentialsProvider;

    Preconditions.checkArgument(queues.size() > 0);
    Preconditions.checkNotNull(region);

    clientConfig = new ClientConfiguration();
    if (connectionTimeout > 0) {
        clientConfig = clientConfig.withConnectionTimeout(connectionTimeout);
    }
    if (maxConnections > 0) {
        clientConfig = clientConfig.withMaxConnections(maxConnections);
    }
    if (socketTimeout > 0) {
        clientConfig = clientConfig.withSocketTimeout(socketTimeout);
    }
    if (maxRetries > 0) {
        clientConfig = clientConfig.withMaxErrorRetry(maxRetries);
    }

    Monitors.registerObject(Joiner.on('_').join(queues), this);
}
 
Example #18
Source File: MessageSetProcessor.java    From suro with Apache License 2.0 5 votes vote down vote up
@Inject
public MessageSetProcessor(
    Queue4Server queue,
    MessageRouter router,
    ServerConfig config,
    ObjectMapper jsonMapper) throws Exception {
    this.queue = queue;
    this.router = router;
    this.config = config;
    this.jsonMapper = jsonMapper;

    isRunning = true;

    Monitors.registerObject(this);
}
 
Example #19
Source File: MessageRouter.java    From suro with Apache License 2.0 5 votes vote down vote up
@Inject
public MessageRouter(
        RoutingMap routingMap,
        SinkManager sinkManager,
        ObjectMapper jsonMapper) {
    this.routingMap = routingMap;
    this.sinkManager = sinkManager;
    this.jsonMapper = jsonMapper;

    Monitors.registerObject(this);
}
 
Example #20
Source File: NamedConnectionPool.java    From ribbon with Apache License 2.0 5 votes vote down vote up
void initMonitors(String name) {
    Preconditions.checkNotNull(name);
    freeEntryCounter = Monitors.newCounter(name + "_Reuse");
    createEntryCounter = Monitors.newCounter(name + "_CreateNew");
    requestCounter = Monitors.newCounter(name + "_Request");
    releaseCounter = Monitors.newCounter(name + "_Release");
    deleteCounter = Monitors.newCounter(name + "_Delete");
    requestTimer = Monitors.newTimer(name + "_RequestConnectionTimer", TimeUnit.MILLISECONDS);
    creationTimer = Monitors.newTimer(name + "_CreateConnectionTimer", TimeUnit.MILLISECONDS);
    this.name = name;
    Monitors.registerObject(name, this);
}
 
Example #21
Source File: DynoCPMonitor.java    From dyno with Apache License 2.0 5 votes vote down vote up
public DynoCPMonitor(String namePrefix) {

        try {
            DefaultMonitorRegistry.getInstance().register(Monitors.newObjectMonitor(namePrefix, this));
        } catch (Exception e) {
            Logger.warn("Failed to register metrics with monitor registry", e);
        }
    }
 
Example #22
Source File: NFHttpClient.java    From ribbon with Apache License 2.0 5 votes vote down vote up
void init(IClientConfig config, boolean registerMonitor) {
	HttpParams params = getParams();

	HttpProtocolParams.setContentCharset(params, "UTF-8");  
	params.setParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME, 
			ThreadSafeClientConnManager.class.getName());
	HttpClientParams.setRedirecting(params, config.get(CommonClientConfigKey.FollowRedirects, true));
	// set up default headers
	List<Header> defaultHeaders = new ArrayList<Header>();
	defaultHeaders.add(new BasicHeader("Netflix.NFHttpClient.Version", "1.0"));
	defaultHeaders.add(new BasicHeader("X-netflix-httpclientname", name));
	params.setParameter(ClientPNames.DEFAULT_HEADERS, defaultHeaders);

	connPoolCleaner = new ConnectionPoolCleaner(name, this.getConnectionManager(), connectionPoolCleanUpScheduler);

	this.retriesProperty = config.getGlobalProperty(RETRIES.format(name));

	this.sleepTimeFactorMsProperty = config.getGlobalProperty(SLEEP_TIME_FACTOR_MS.format(name));
	setHttpRequestRetryHandler(
			new NFHttpMethodRetryHandler(this.name, this.retriesProperty.getOrDefault(), false,
					this.sleepTimeFactorMsProperty.getOrDefault()));
    tracer = Monitors.newTimer(EXECUTE_TRACER + "-" + name, TimeUnit.MILLISECONDS);
    if (registerMonitor) {
           Monitors.registerObject(name, this);
    }
    maxTotalConnectionProperty = config.getDynamicProperty(CommonClientConfigKey.MaxTotalHttpConnections);
    maxTotalConnectionProperty.onChange(newValue ->
    	((ThreadSafeClientConnManager) getConnectionManager()).setMaxTotal(newValue)
    );

    maxConnectionPerHostProperty = config.getDynamicProperty(CommonClientConfigKey.MaxHttpConnectionsPerHost);
    maxConnectionPerHostProperty.onChange(newValue ->
		((ThreadSafeClientConnManager) getConnectionManager()).setDefaultMaxPerRoute(newValue)
       );

	connIdleEvictTimeMilliSeconds = config.getGlobalProperty(CONN_IDLE_EVICT_TIME_MILLIS.format(name));
}
 
Example #23
Source File: NFHttpClientFactory.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static void shutdownNFHttpClient(String name) {
    NFHttpClient c = namedClientMap.get(name);
    if (c != null) {
        c.shutdown();
        namedClientMap.remove(name);
        Monitors.unregisterObject(name, c);
    }
}
 
Example #24
Source File: HealthMonitor.java    From Raigad with Apache License 2.0 5 votes vote down vote up
@Inject
public HealthMonitor(IConfiguration config, InstanceManager instanceManager, HttpModule httpModule) {
    super(config);
    this.instanceManager = instanceManager;
    this.httpModule = httpModule;
    healthReporter = new Elasticsearch_HealthReporter();
    discoveryClient = DiscoveryManager.getInstance().getDiscoveryClient();
    Monitors.registerObject(healthReporter);
}
 
Example #25
Source File: SnapshotBackupMonitor.java    From Raigad with Apache License 2.0 5 votes vote down vote up
@Inject
public SnapshotBackupMonitor(IConfiguration config, SnapshotBackupManager snapshotBackupManager) {
    super(config);
    snapshotBackupReporter = new Elasticsearch_SnapshotBackupReporter();
    this.snapshotBackupManager = snapshotBackupManager;
    Monitors.registerObject(snapshotBackupReporter);
}
 
Example #26
Source File: NodeHealthMonitor.java    From Raigad with Apache License 2.0 4 votes vote down vote up
@Inject
public NodeHealthMonitor(IConfiguration config) {
    super(config);
    healthReporter = new ElasticsearchNodeHealthReporter();
    Monitors.registerObject(healthReporter);
}
 
Example #27
Source File: QueueNotice.java    From suro with Apache License 2.0 4 votes vote down vote up
public QueueNotice() {
    queue = new LinkedBlockingQueue<E>(DEFAULT_LENGTH);
    timeout = DEFAULT_TIMEOUT;

    Monitors.registerObject(this);
}
 
Example #28
Source File: JvmStatsMonitor.java    From Raigad with Apache License 2.0 4 votes vote down vote up
@Inject
public JvmStatsMonitor(IConfiguration config) {
    super(config);
    jvmStatsReporter = new Elasticsearch_JvmStatsReporter();
    Monitors.registerObject(jvmStatsReporter);
}
 
Example #29
Source File: KafkaSinkV2.java    From suro with Apache License 2.0 4 votes vote down vote up
@JsonCreator
public KafkaSinkV2(
        @JsonProperty("queue4Sink") MessageQueue4Sink queue4Sink,
        @JsonProperty("client.id") String clientId,
        @JsonProperty("metadata.broker.list") String bootstrapServers,
        @JsonProperty("compression.codec") String codec,
        @JsonProperty("send.buffer.bytes") int sendBufferBytes,
        @JsonProperty("batchSize") int batchSize,
        @JsonProperty("batchTimeout") int batchTimeout,
        @JsonProperty("request.timeout.ms") int requestTimeout,
        @JsonProperty("kafka.etc") Properties etcProps,
        @JsonProperty("keyTopicMap") Map<String, String> keyTopicMap,
        @JsonProperty("jobQueueSize") int jobQueueSize,
        @JsonProperty("corePoolSize") int corePoolSize,
        @JsonProperty("maxPoolSize") int maxPoolSize,
        @JsonProperty("jobTimeout") long jobTimeout,
        @JsonProperty("pauseOnLongQueue") boolean pauseOnLongQueue
) {
    super(jobQueueSize, corePoolSize, maxPoolSize, jobTimeout,
            KafkaSink.class.getSimpleName() + "-" + clientId);

    Preconditions.checkNotNull(bootstrapServers);
    Preconditions.checkNotNull(clientId);

    this.clientId = clientId;
    initialize(
            "kafka_" + clientId,
            queue4Sink == null ? new MemoryQueue4Sink(10000) : queue4Sink,
            batchSize,
            batchTimeout,
            pauseOnLongQueue);

    Properties props = new Properties();
    props.put("client.id", clientId);
    // metadata.broker.list was renamed to bootstrap.servers in the new kafka producer
    props.put("bootstrap.servers", bootstrapServers);
    if (codec != null) {
        props.put("compression.codec", codec);
    }
    if (sendBufferBytes > 0) {
        props.put("send.buffer.bytes", Integer.toString(sendBufferBytes));
    }
    if (requestTimeout > 0) {
        props.put("request.timeout.ms", Integer.toString(requestTimeout));
    }

    if (etcProps != null) {
        props.putAll(etcProps);
    }

    this.keyTopicMap = keyTopicMap != null ? keyTopicMap : Maps.<String, String>newHashMap();

    producer = new KafkaProducer<>(props, new ByteArraySerializer(), new ByteArraySerializer());

    Monitors.registerObject(clientId, this);
}
 
Example #30
Source File: ProcessStatsMonitor.java    From Raigad with Apache License 2.0 4 votes vote down vote up
@Inject
public ProcessStatsMonitor(IConfiguration config) {
    super(config);
    processStatsReporter = new Elasticsearch_ProcessStatsReporter();
    Monitors.registerObject(processStatsReporter);
}