本文整理汇总了Java中net.opentsdb.utils.Config类的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Config类属于net.opentsdb.utils包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
import net.opentsdb.utils.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void before() throws Exception {
config = new ESPluginConfig(new Config(false));
client = mock(CloseableHttpAsyncClient.class);
es = mock(ElasticSearch.class);
meta = new UIDMeta(UniqueIdType.METRIC, new byte[] { 1 }, "sys.cpu.user");
index = config.getString("tsd.search.elasticsearch.index");
doc_type = config.getString("tsd.search.elasticsearch.uidmeta_type");
when(es.httpClient()).thenReturn(client);
when(es.host()).thenReturn(HOST);
when(es.index()).thenReturn(index);
when(es.config()).thenReturn(config);
when(client.execute(any(HttpUriRequest.class),
any(FutureCallback.class)))
.thenAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
request = (HttpUriRequest) invocation.getArguments()[0];
cb = (FutureCallback<HttpResponse>) invocation.getArguments()[1];
return null;
}
});
}
示例2: initialize
import net.opentsdb.utils.Config; //导入依赖的package包/类
@Override
public Config initialize(final Config config) {
try {
visibleHost = getConfigPropertyString(config, "tsd.discovery.visble_host", "localhost");
visiblePort = getConfigPropertyInt(config, "tsd.discovery.visble_port", 4242);
serviceName = getConfigPropertyString(config, "tsd.discovery.service_name", "OpenTSDB");
serviceId = getConfigPropertyString(config, "tsd.discovery.service_id", "opentsdb");
tsdMode = getConfigPropertyString(config, "tsd.mode", "ro");
String consulUrl = getConfigPropertyString(config, "tsd.discovery.consul_url", "http://localhost:8500");
LOGGER.debug("Finished with config");
consul = Consul.builder().withUrl(consulUrl).build();
LOGGER.info("Consul ServiceDiscovery Plugin Initialized");
updateZookeeperQuorum(config);
} catch (Exception e) {
LOGGER.error("Could not register this instance with Consul", e);
}
return config;
}
示例3: start
import net.opentsdb.utils.Config; //导入依赖的package包/类
@Override
public synchronized void start() {
logger.info(String.format("Starting: %s:%s series:%s uids:%s batchSize:%d",
zkquorum, zkpath, seriesTable, uidsTable, batchSize));
hbaseClient = new HBaseClient(zkquorum, zkpath);
try {
Config config = new Config(false);
config.overrideConfig("tsd.storage.hbase.data_table", "tsdb");
config.overrideConfig("tsd.storage.hbase.uid_table", "tsdb-uid");
config.overrideConfig("tsd.core.auto_create_metrics", "true");
config.overrideConfig("tsd.storage.enable_compaction", "false");
tsdb = new TSDB(hbaseClient, config);
} catch (IOException e) {
logger.error("tsdb initialization fail: ", e);
}
channelCounter.start();
sinkCounter.start();
super.start();
}
示例4: getConfig
import net.opentsdb.utils.Config; //导入依赖的package包/类
/**
* Loads the named TSDB config
* @param name The name of the config file
* @return The named config
* @throws Exception thrown on any error
*/
public static Config getConfig(String name) throws Exception {
File tmpFile = null;
try {
if(name==null || name.trim().isEmpty()) throw new Exception("File was null or empty");
name = String.format("configs/%s.cfg", name);
log("Loading config [%s]", name);
final URL resourceURL = BaseTest.class.getClassLoader().getResource(name);
if(resourceURL==null) throw new Exception("Cannot read from the resource [" + name + "]");
final byte[] content = URLHelper.getBytesFromURL(resourceURL);
tmpFile = File.createTempFile("config-" + name.replace("/", "").replace("\\", ""), ".cfg");
URLHelper.writeToURL(URLHelper.toURL(tmpFile), content, false);
if(!tmpFile.canRead()) throw new Exception("Cannot read from the file [" + tmpFile + "]");
log("Loading [%s]", tmpFile.getAbsolutePath());
return new Config(tmpFile.getAbsolutePath());
} finally {
if(tmpFile!=null) tmpFile.deleteOnExit();
}
}
示例5: newTSDB
import net.opentsdb.utils.Config; //导入依赖的package包/类
/**
* Creates a new test TSDB
* @param configName The config name to configure with
* @return the created test TSDB
*/
public static TSDB newTSDB(String configName) {
try {
tsdb = new TSDB(getConfig(configName));
tsdb.getConfig().overrideConfig("helios.config.name", configName);
Config config = tsdb.getConfig();
StringBuilder b = new StringBuilder("\n\t=============================================\n\tTSDB Config\n\t=============================================");
for(Map.Entry<String, String> entry: config.getMap().entrySet()) {
b.append("\n\t").append(entry.getKey()).append("\t:[").append(entry.getValue()).append("]");
}
b.append("\n\t=============================================\n");
// log(b.toString());
tsdb.initializePlugins(true);
final UniqueIdRegistry reg = UniqueIdRegistry.getInstance(tsdb);
tagKunik = reg.getTagKUniqueId();
tagVunik = reg.getTagVUniqueId();
tagMunik = reg.getMetricsUniqueId();
return tsdb;
} catch (Exception e) {
throw new RuntimeException("Failed to get test TSDB [" + configName + "]", e);
}
}
示例6: before
import net.opentsdb.utils.Config; //导入依赖的package包/类
@Before
public void before() throws Exception {
tsdb = PowerMockito.mock(TSDB.class);
config = new Config(false);
connection_manager = mock(PoolingNHttpClientConnectionManager.class);
client_builder = mock(HttpAsyncClientBuilder.class);
client = mock(CloseableHttpAsyncClient.class);
ts_meta_schema = mock(TSMetaSchema.class);
uid_meta_schema = mock(UIDMetaSchema.class);
annotation_schema = mock(AnnotationSchema.class);
config.overrideConfig("tsd.search.elasticsearch.host", "localhost:9200");
when(tsdb.getConfig()).thenReturn(config);
PowerMockito.mockStatic(HttpAsyncClients.class);
when(HttpAsyncClients.custom()).thenReturn(client_builder);
PowerMockito.whenNew(PoolingNHttpClientConnectionManager.class)
.withAnyArguments().thenReturn(connection_manager);
when(client_builder.build()).thenReturn(client);
}
示例7: loadTsdbConfig
import net.opentsdb.utils.Config; //导入依赖的package包/类
private TsdbConfigPropertySource loadTsdbConfig(final ResourcePatternResolver resolver) throws IOException {
Resource configResource = null;
for (final String location : OVERRIDE_SEARCH_LOCATIONS) {
final String fullLoc = String.format("%s%s", location, CONFIG_FILENAME);
log.debug("Searching for TSDB config in {}", fullLoc);
final Resource res = resolver.getResource(fullLoc);
if (res != null && res.exists()) {
configResource = res;
log.info("Found TSDB config file using {} ", fullLoc);
break;
}
}
if (configResource == null) {
return new TsdbConfigPropertySource(PROPERTY_SOURCE_NAME, new Config(true));
} else if (configResource.isReadable()) {
return new TsdbConfigPropertySource(PROPERTY_SOURCE_NAME, new Config(configResource.getFile().getAbsolutePath()));
} else {
throw new IllegalStateException("Unable to locate any TSDB config files!");
}
}
示例8: defaults
import net.opentsdb.utils.Config; //导入依赖的package包/类
@Test
public void defaults() throws Exception {
final KafkaRpcPluginConfig config =
new KafkaRpcPluginConfig(new Config(false));
assertEquals(KafkaRpcPluginConfig.AUTO_COMMIT_INTERVAL_DEFAULT,
config.getInt(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.AUTO_COMMIT_INTERVAL_MS));
assertTrue(config.getBoolean(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.AUTO_COMMIT_ENABLE));
assertEquals(KafkaRpcPluginConfig.AUTO_OFFSET_RESET_DEFAULT,
config.getString(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.AUTO_OFFSET_RESET));
assertEquals(KafkaRpcPluginConfig.REBALANCE_BACKOFF_MS_DEFAULT,
config.getInt(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.REBALANCE_BACKOFF_MS));
assertEquals(KafkaRpcPluginConfig.REBALANCE_RETRIES_DEFAULT,
config.getInt(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.REBALANCE_RETRIES));
assertEquals(KafkaRpcPluginConfig.ZK_SESSION_TIMEOUT_DEFAULT,
config.getInt(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.ZOOKEEPER_SESSION_TIMEOUT_MS));
assertEquals(KafkaRpcPluginConfig.ZK_CONNECTION_TIMEOUT_DEFAULT,
config.getInt(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX +
KafkaRpcPluginConfig.ZOOKEEPER_CONNECTION_TIMEOUT_MS));
assertEquals(0, config.getInt(KafkaRpcPluginConfig.REQUIRED_ACKS));
assertEquals(10000, config.getInt(KafkaRpcPluginConfig.REQUEST_TIMEOUT));
assertEquals(1000, config.getInt(KafkaRpcPluginConfig.MAX_RETRIES));
assertEquals("async", config.getString(KafkaRpcPluginConfig.PRODUCER_TYPE));
assertEquals("kafka.serializer.StringEncoder",
config.getString(KafkaRpcPluginConfig.KEY_SERIALIZER));
assertEquals("net.opentsdb.tsd.KafkaSimplePartitioner",
config.getString(KafkaRpcPluginConfig.PARTITIONER_CLASS));
}
示例9: updateZookeeperQuorum
import net.opentsdb.utils.Config; //导入依赖的package包/类
private static void updateZookeeperQuorum(final Config config) {
String zkQuorum;
List<CatalogService> zookeeperService = null;
zookeeperService = getServiceNodes("zookeeper-2181");
if (zookeeperService.size() > 0) {
zkQuorum = buildConnectionString(zookeeperService);
LOGGER.info("Updated Zookeeper Quorum to " + zkQuorum);
config.overrideConfig("tsd.storage.hbase.zk_quorum", zkQuorum);
} else {
LOGGER.info("Unable to locate zookeeper-2181 in Consul");
}
}
示例10: initialize
import net.opentsdb.utils.Config; //导入依赖的package包/类
public void initialize(final TSDB tsdb) {
LOG.info("init RollupPublisher");
this.tsdb = tsdb;
this.dataPointsMap = new HashMap<String, DataPoints>();
Config config = tsdb.getConfig();
if (config.hasProperty(rollupKey)) {
this.minutes = tsdb.getConfig().getInt(rollupKey);
}
LOG.info("Using window of:" + this.minutes + " minutes");
}
示例11: getConfigPropertyString
import net.opentsdb.utils.Config; //导入依赖的package包/类
public static String getConfigPropertyString(Config config, String propertyName, String defaultValue) {
String retVal = defaultValue;
if (config.hasProperty(propertyName)) {
retVal = config.getString(propertyName);
}
return retVal;
}
示例12: getConfigPropertyInt
import net.opentsdb.utils.Config; //导入依赖的package包/类
public static Integer getConfigPropertyInt(Config config, String propertyName, Integer defaultValue) {
Integer retVal = defaultValue;
if (config.hasProperty(propertyName)) {
retVal = config.getInt(propertyName);
}
return retVal;
}
示例13: loadStartupPlugin
import net.opentsdb.utils.Config; //导入依赖的package包/类
public static StartupPlugin loadStartupPlugin(Config config) {
LOG.debug("Loading Startup Plugin");
// load the startup plugin if enabled
StartupPlugin startup;
if (config.getBoolean("tsd.startup.enable")) {
LOG.debug("startup plugin enabled");
String startupPluginClass = config.getString("tsd.startup.plugin");
LOG.debug(String.format("Will attempt to load: %s", startupPluginClass));
startup = PluginLoader.loadSpecificPlugin(startupPluginClass
, StartupPlugin.class);
if (startup == null) {
LOG.debug(String.format("2nd attempt will attempt to load: %s", startupPluginClass));
startup = loadSpecificPlugin(config.getString("tsd.startup.plugin"), StartupPlugin.class);
if (startup == null) {
throw new IllegalArgumentException("Unable to locate startup plugin: " +
config.getString("tsd.startup.plugin"));
}
}
try {
startup.initialize(config);
} catch (Exception e) {
throw new RuntimeException("Failed to initialize startup plugin", e);
}
LOG.info("initialized startup plugin [" +
startup.getClass().getCanonicalName() + "] version: "
+ startup.version());
} else {
startup = null;
}
return startup;
}
示例14: initialize
import net.opentsdb.utils.Config; //导入依赖的package包/类
/**
* {@inheritDoc}
* @see net.opentsdb.tsd.HttpRpcPlugin#initialize(net.opentsdb.core.TSDB)
*/
@Override
public void initialize(final TSDB tsdb) {
log.info(">>>>> Initializing WebSocketRPC service....");
this.tsdb = tsdb;
webSockHandler = new WebSocketServiceHandler(tsdb);
final Properties properties = new Properties();
final Config cfg = tsdb.getConfig();
properties.putAll(cfg.getMap());
path = metricManager.getAndSetConfig(CONFIG_RPC_PATH, DEFAULT_RPC_PATH, properties, cfg);
JSONRequestRouter.getInstance().registerJSONService(new SystemJSONServices());
//JSONRequestRouter.getInstance().registerJSONService(new TSDBJSONService(tsdb));
log.info("<<<<< WebSocketRPC service Initialized.");
}
示例15: main
import net.opentsdb.utils.Config; //导入依赖的package包/类
public static void main(String[] args) {
try {
JMXHelper.fireUpJMXMPServer(3259);
final Config cfg = new Config(true);
final TSDB tsdb = new TSDB(cfg);
final TSDBChronicleEventPublisher pub = new TSDBChronicleEventPublisher(true);
final int sampleSize = 128000;
final int loops = 1;
final long sleep = 0; //10000;
final int sleepFreq = 1;
final boolean text = false;
final RandomDataPointGenerator r = new RandomDataPointGenerator(pub, "Test", sampleSize, loops, sleep, sleepFreq, text);
pub.setTestLookup(r.metricMetas);
pub.initialize(tsdb);
pub.clearLookupCache();
r.start();
StdInCommandHandler.getInstance().registerCommand("stop", new Runnable(){
public void run() {
r.stop();
pub.shutdown();
System.exit(0);
}
}).run();
} catch (Exception ex) {
ex.printStackTrace(System.err);
System.exit(-1);
}
}