• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.opentsdb.utils.Config的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Config类属于net.opentsdb.utils包,在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
      }
    });
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-elasticsearch,代码行数:26,代码来源:TestDefaultUIDMetaSchema.java


示例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;
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:24,代码来源:ConsulPlugin.java


示例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();
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:21,代码来源:OpenTSDBSink.java


示例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();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:25,代码来源:BaseTest.java


示例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);
		}		
	}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:27,代码来源:BaseTest.java


示例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);
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-elasticsearch,代码行数:23,代码来源:TestElasticSearch.java


示例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!");
    }
}
 
开发者ID:Conductor,项目名称:tsquare,代码行数:24,代码来源:TsWebApplicationContextInitializer.java


示例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));
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-rpc-kafka,代码行数:36,代码来源:TestKafkaRpcPluginConfig.java


示例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");
    }
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:14,代码来源:ConsulPlugin.java


示例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");
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:11,代码来源:RollupPublisher.java


示例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;
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:8,代码来源:Utils.java


示例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;
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:8,代码来源:Utils.java


示例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;
}
 
开发者ID:inst-tech,项目名称:opentsdb-plugins,代码行数:39,代码来源:Utils.java


示例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.");
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:19,代码来源:WebSocketRPC.java


示例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);
	}

	
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:31,代码来源:RandomDataPointGenerator.java


示例16: 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);
  note = new Annotation();
  note.setTSUID("010101");
  note.setDescription("Unit testing Dragonstone!");
  note.setStartTime(1483228800);
  
  index = config.getString("tsd.search.elasticsearch.index");
  doc_type = config.getString("tsd.search.elasticsearch.annotation_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;
      }
    });
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-elasticsearch,代码行数:30,代码来源:TestDefaultAnnotationSchema.java


示例17: 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 TSMeta("010101");
  meta.setDisplayName("Testing");
  final UIDMeta metric = new UIDMeta(UniqueIdType.METRIC, new byte[] { 1 }, 
      "sys.cpu.user");
  Whitebox.setInternalState(meta, "metric", metric);
  final UIDMeta tagk = new UIDMeta(UniqueIdType.TAGK, new byte[] { 1 },
      "host");
  final UIDMeta tagv = new UIDMeta(UniqueIdType.TAGV, new byte[] { 1 },
      "web01");
  Whitebox.setInternalState(meta, "tags", Lists.newArrayList(tagk, tagv));
  index = config.getString("tsd.search.elasticsearch.index");
  doc_type = config.getString("tsd.search.elasticsearch.tsmeta_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;
      }
    });
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-elasticsearch,代码行数:35,代码来源:TestAnalyzedAndMappedTSMetaSchema.java


示例18: defaults

import net.opentsdb.utils.Config; //导入依赖的package包/类
@Test
public void defaults() throws Exception {
  final ESPluginConfig config = new ESPluginConfig(new Config(false));
  
  assertEquals("", config.getString("tsd.search.elasticsearch.hosts"));
  assertEquals(1, config.getInt("tsd.search.elasticsearch.index_threads"));
  assertEquals("opentsdb", config.getString("tsd.search.elasticsearch.index"));
  assertEquals("tsmeta", config.getString("tsd.search.elasticsearch.tsmeta_type"));
  assertEquals("uidmeta", config.getString("tsd.search.elasticsearch.uidmeta_type"));
  assertEquals("annotation", config.getString("tsd.search.elasticsearch.annotation_type"));
  assertEquals(25, config.getInt("tsd.search.elasticsearch.pool.max_per_route"));
  assertEquals(50, config.getInt("tsd.search.elasticsearch.pool.max_total"));
  
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-elasticsearch,代码行数:15,代码来源:TestESPluginConfig.java


示例19: KafkaRpcPluginConfig

import net.opentsdb.utils.Config; //导入依赖的package包/类
/**
 * Default ctor
 * @param parent The configuration we're basing this config on
 */
public KafkaRpcPluginConfig(final Config parent) {
  super(parent);
  setLocalDefaults();
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-rpc-kafka,代码行数:9,代码来源:KafkaRpcPluginConfig.java


示例20: before

import net.opentsdb.utils.Config; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void before() throws Exception {
  tsdb = PowerMockito.mock(TSDB.class);
  config = new KafkaRpcPluginConfig(new Config(false));
  group = mock(KafkaRpcPluginGroup.class);
  message = mock(MessageAndMetadata.class);
  rate_limiter = mock(RateLimiter.class);
  requeue = mock(KafkaStorageExceptionHandler.class);
  counters = new ConcurrentHashMap<String, Map<String, AtomicLong>>();
  deserializer = new JSONDeserializer();
  
  consumer_connector = mock(ConsumerConnector.class);

  mockStatic(Consumer.class);
  when(Consumer.createJavaConsumerConnector((ConsumerConfig) any()))
          .thenReturn(consumer_connector);
  
  when(tsdb.getConfig()).thenReturn(config);
  when(tsdb.getStorageExceptionHandler()).thenReturn(requeue);
  
  parent = mock(KafkaRpcPlugin.class);
  when(parent.getHost()).thenReturn(LOCALHOST);
  when(parent.getTSDB()).thenReturn(tsdb);
  when(parent.getConfig()).thenReturn(config);
  when(parent.getNamespaceCounters()).thenReturn(counters);
  when(parent.trackMetricPrefix()).thenReturn(true);
  
  when(group.getParent()).thenReturn(parent);
  when(group.getRateLimiter()).thenReturn(rate_limiter);
  when(group.getGroupID()).thenReturn(GROUPID);
  when(group.getConsumerType()).thenReturn(TsdbConsumerType.RAW);
  when(group.getDeserializer()).thenReturn(deserializer);
  
  config.overrideConfig(KafkaRpcPluginConfig.KAFKA_CONFIG_PREFIX 
      + "zookeeper.connect", ZKS);
  
  stream_list = mock(List.class);
  when(consumer_connector.createMessageStreamsByFilter(
      (TopicFilter) any(), anyInt())).thenReturn(stream_list);

  final KafkaStream<byte[], byte[]> stream = mock(KafkaStream.class);
  when(stream_list.get(0)).thenReturn(stream);

  iterator = mock(ConsumerIterator.class);
  when(stream.iterator()).thenReturn(iterator);

  when(iterator.hasNext()).thenReturn(true).thenReturn(false);
  when(iterator.next()).thenReturn(message);
  
  PowerMockito.mockStatic(ConsumerConfig.class);
  PowerMockito.whenNew(ConsumerConfig.class).withAnyArguments()
    .thenReturn(mock(ConsumerConfig.class));
  
  PowerMockito.mockStatic(Consumer.class);
  when(Consumer.createJavaConsumerConnector(any(ConsumerConfig.class)))
    .thenReturn(consumer_connector);
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-rpc-kafka,代码行数:59,代码来源:TestKafkaRpcPluginThread.java



注:本文中的net.opentsdb.utils.Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NameReference类代码示例发布时间:2022-05-23
下一篇:
Java MessageListenerContainer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap