com.opsdatastore.collector.Collector Maven / Gradle / Ivy
package com.opsdatastore.collector;
/*-
* #%L
* OpsDataStore SDK
* %%
* Copyright (C) 2017 OpsDataStore
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import com.codahale.metrics.health.HealthCheck;
import com.typesafe.config.Config;
import java.util.Properties;
import org.apache.log4j.Logger;
/**
* Interface that defines all the features a collector needs to provide
* @author kguthrie
*/
public interface Collector {
/**
* Set the logger for this Collector. This is guaranteed to be called
* before any other method
* @param logger logger that should be stored locally within the collector
*/
void setLogger(Logger logger);
/**
* @return an indication of the health of the plugin and the system it
* collections information from
* @throws Exception only on errors while checking health
*/
HealthCheck.Result checkHealth() throws Exception;
/**
* Configure this instance of the collector with the common settings from
* the settings section of application.conf
* @param config
* @throws java.lang.Exception on
*/
void configure(Config config) throws Exception;
/**
* Start this instance of the collector with the given instance specific
* properties. This is where background threads or network connections
* should be created and started
* @param instanceId id of the monitored instance from application.conf
* @param instanceProperties key-value pairs taken directly from one of the
* monitored instance sections of the application.conf file
* @throws java.lang.Exception on any error starting the collector
*/
void start(String instanceId, Properties instanceProperties)
throws Exception;
/**
* Stop this instance of the collector as well as any and all background
* threads of network connections
* @throws java.lang.Exception on any errors when stopping the collector
*/
void stop() throws Exception;
/**
* This method is called on a scheduled basis based on the configured
* collection interval to tell the collector which object have been updated
* or deleted
* @param sink interface into the underlying collector system
* @throws java.lang.Exception on any errors during collection
*/
void collect(CollectorSink sink) throws Exception;
}