当前位置: 首页>>代码示例>>Java>>正文


Java AbstractConfiguration类代码示例

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


AbstractConfiguration类属于org.apache.commons.configuration包,在下文中一共展示了AbstractConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config, String brokerId, BrokerListenerFactory factory) {
    init(config);

    BROKER_TOPIC = BROKER_TOPIC_PREFIX + "." + brokerId;

    logger.trace("Initializing Kafka consumer ...");

    // consumer config
    Properties props = new Properties();
    props.put("bootstrap.servers", config.getString("bootstrap.servers"));
    props.put("group.id", UUIDs.shortUuid());
    props.put("enable.auto.commit", "true");
    props.put("key.serializer", StringSerializer.class.getName());
    props.put("value.serializer", InternalMessageSerializer.class.getName());

    // consumer
    this.consumer = new KafkaConsumer<>(props);

    // consumer worker
    this.worker = new KafkaBrokerWorker(this.consumer, BROKER_TOPIC, factory.newListener());
    this.executor.submit(this.worker);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:24,代码来源:KafkaBrokerCommunicator.java

示例2: init

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("master_slave")) {
        throw new IllegalStateException("RedisSyncSingleStorageImpl class can only be used with master slave redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuceMasterSlave = RedisClient.create(lettuceURI);
    this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
    this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));

    // params
    initParams(config);
}
 
开发者ID:longkerdandy,项目名称:mithqtt,代码行数:20,代码来源:RedisSyncMasterSlaveStorageImpl.java

示例3: createDynamicConfig

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
public static AbstractConfiguration createDynamicConfig() {
  LOGGER.info("create dynamic config:");
  ConcurrentCompositeConfiguration config = ConfigUtil.createLocalConfig();
  DynamicWatchedConfiguration configFromConfigCenter = createConfigFromConfigCenter(config);
  if (configFromConfigCenter != null) {
    ConcurrentMapConfiguration injectConfig = new ConcurrentMapConfiguration();
    config.addConfigurationAtFront(injectConfig, "extraInjectConfig");

    duplicateServiceCombConfigToCse(configFromConfigCenter);
    config.addConfigurationAtFront(configFromConfigCenter, "configCenterConfig");

    configFromConfigCenter.getSource().addUpdateListener(new ServiceCombPropertyUpdateListener(injectConfig));
  }

  return config;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:ConfigUtil.java

示例4: testCreateDynamicConfigNoConfigCenterSPI

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
  new Expectations(SPIServiceUtils.class) {
    {
      SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class);
      result = null;
    }
  };

  AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
  MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig);
  List<ConfigModel> list = loader.getConfigModels();
  Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig));
  Assert.assertEquals(1, list.size());
  Assert.assertNotEquals(DynamicWatchedConfiguration.class,
      ((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:TestConfigUtil.java

示例5: beforeCls

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@BeforeClass
public static void beforeCls() {
  ConfigUtil.installDynamicConfig();
  AbstractConfiguration configuration =
      (AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource();
  configuration.addProperty("cse.loadbalance.test.transactionControl.policy",
      "org.apache.servicecomb.loadbalance.filter.SimpleTransactionControlFilter");
  configuration.addProperty("cse.loadbalance.test.transactionControl.options.tag0", "value0");
  configuration.addProperty("cse.loadbalance.test.isolation.enabled", "true");
  configuration.addProperty("cse.loadbalance.serverListFilters", "a");
  configuration.addProperty("cse.loadbalance.serverListFilter.a.className",
      "org.apache.servicecomb.loadbalance.MyServerListFilterExt");
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:14,代码来源:TestLoadbalanceHandler.java

示例6: setUp

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  IsolationServerListFilter = new IsolationServerListFilter();
  loadBalancerStats = new LoadBalancerStats("loadBalancer");

  AbstractConfiguration configuration =
      (AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource();
  configuration.clearProperty("cse.loadbalance.isolation.enabled");
  configuration.addProperty("cse.loadbalance.isolation.enabled",
      "true");
  configuration.clearProperty("cse.loadbalance.isolation.enableRequestThreshold");
  configuration.addProperty("cse.loadbalance.isolation.enableRequestThreshold",
      "3");
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:TestIsolationServerListFilter.java

示例7: tearDown

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
  IsolationServerListFilter = null;
  loadBalancerStats = null;

  AbstractConfiguration configuration =
      (AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource();
  configuration.clearProperty("cse.loadbalance.isolation.continuousFailureThreshold");
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:TestIsolationServerListFilter.java

示例8: testGetFilteredListOfServersOnContinuousFailureReachesThreshold

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Test
public void testGetFilteredListOfServersOnContinuousFailureReachesThreshold() {
  ((AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource())
      .addProperty("cse.loadbalance.isolation.continuousFailureThreshold",
          "3");
  Invocation invocation = Mockito.mock(Invocation.class);
  CseServer testServer = Mockito.mock(CseServer.class);
  Mockito.when(invocation.getMicroserviceName()).thenReturn("microserviceName");
  Mockito.when(testServer.getCountinuousFailureCount()).thenReturn(3);
  Mockito.when(testServer.getLastVisitTime()).thenReturn(System.currentTimeMillis());

  for (int i = 0; i < 3; ++i) {
    loadBalancerStats.incrementNumRequests(testServer);
  }

  List<Server> serverList = new ArrayList<>();
  serverList.add(testServer);
  IsolationServerListFilter.setLoadBalancerStats(loadBalancerStats);
  IsolationServerListFilter.setInvocation(invocation);
  List<Server> returnedServerList = IsolationServerListFilter.getFilteredListOfServers(serverList);
  Assert.assertEquals(0, returnedServerList.size());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:TestIsolationServerListFilter.java

示例9: testGetFilteredListOfServersOnContinuousFailureIsBelowThreshold

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Test
public void testGetFilteredListOfServersOnContinuousFailureIsBelowThreshold() {
  ((AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource())
      .addProperty("cse.loadbalance.isolation.continuousFailureThreshold",
          "3");
  Invocation invocation = Mockito.mock(Invocation.class);
  CseServer testServer = Mockito.mock(CseServer.class);
  Mockito.when(invocation.getMicroserviceName()).thenReturn("microserviceName");
  Mockito.when(testServer.getCountinuousFailureCount()).thenReturn(2);
  Mockito.when(testServer.getLastVisitTime()).thenReturn(System.currentTimeMillis());

  for (int i = 0; i < 3; ++i) {
    loadBalancerStats.incrementNumRequests(testServer);
  }

  List<Server> serverList = new ArrayList<>();
  serverList.add(testServer);
  IsolationServerListFilter.setLoadBalancerStats(loadBalancerStats);
  IsolationServerListFilter.setInvocation(invocation);
  List<Server> returnedServerList = IsolationServerListFilter.getFilteredListOfServers(serverList);
  Assert.assertEquals(1, returnedServerList.size());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:TestIsolationServerListFilter.java

示例10: beforeCls

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@BeforeClass
public static void beforeCls() {
  ConfigUtil.installDynamicConfig();
  AbstractConfiguration configuration =
      (AbstractConfiguration) DynamicPropertyFactory.getBackingConfigurationSource();
  configuration.addProperty(REQUEST_TIMEOUT_KEY, 2000);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:TestHighwayClient.java

示例11: init

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config, ApplicationListenerFactory factory) {
    init(config);

    logger.trace("Initializing Kafka consumer ...");

    // consumer config
    Properties props = new Properties();
    props.put("bootstrap.servers", config.getString("bootstrap.servers"));
    props.put("group.id", config.getString("group.id"));
    props.put("enable.auto.commit", "true");
    props.put("key.serializer", StringSerializer.class.getName());
    props.put("value.serializer", InternalMessageSerializer.class.getName());

    // consumer
    this.consumer = new KafkaConsumer<>(props);

    // consumer worker
    this.worker = new KafkaApplicationWorker(this.consumer, APPLICATION_TOPIC, factory.newListener());
    this.executor.submit(this.worker);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:22,代码来源:KafkaApplicationCommunicator.java

示例12: init

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
protected void init(AbstractConfiguration config) {
    BROKER_TOPIC_PREFIX = config.getString("communicator.broker.topic");
    APPLICATION_TOPIC = config.getString("communicator.application.topic");

    logger.trace("Initializing Kafka producer ...");

    // producer config
    Properties props = new Properties();
    props.put("bootstrap.servers", config.getString("bootstrap.servers"));
    props.put("acks", config.getString("acks"));
    props.put("key.serializer", StringSerializer.class.getName());
    props.put("value.serializer", InternalMessageSerializer.class.getName());

    // producer
    this.producer = new KafkaProducer<>(props);

    // consumer executor
    this.executor = Executors.newSingleThreadExecutor();
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:20,代码来源:KafkaCommunicator.java

示例13: init

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("single")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuce = RedisClient.create(lettuceURI);
    this.lettuceConn = this.lettuce.connect();

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useSingleServer()
            .setAddress(address.get(0))
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:27,代码来源:RedisSyncSingleStorage.java

示例14: init

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config, String serverId) {
    try {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setUsername(config.getString("rabbitmq.userName", ConnectionFactory.DEFAULT_USER));
        cf.setPassword(config.getString("rabbitmq.password", ConnectionFactory.DEFAULT_PASS));
        cf.setVirtualHost(config.getString("rabbitmq.virtualHost", ConnectionFactory.DEFAULT_VHOST));
        cf.setAutomaticRecoveryEnabled(true);
        cf.setExceptionHandler(new RabbitMQExceptionHandler());
        this.conn = cf.newConnection(Address.parseAddresses(config.getString("rabbitmq.addresses")));
        this.channel = conn.createChannel();

        logger.trace("Initializing RabbitMQ broker resources ...");

        BROKER_TOPIC_PREFIX = config.getString("communicator.broker.topic");

        logger.trace("Initializing RabbitMQ application resources ...");

        APPLICATION_TOPIC = config.getString("communicator.application.topic");
        this.channel.exchangeDeclare(APPLICATION_TOPIC, "topic", true);

    } catch (IOException | TimeoutException e) {
        logger.error("Failed to connect to RabbitMQ servers", e);
        throw new IllegalStateException("Init RabbitMQ communicator failed");
    }
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:27,代码来源:RabbitMQHttpCommunicator.java

示例15: resolve

import org.apache.commons.configuration.AbstractConfiguration; //导入依赖的package包/类
/**
 * Attempts to acquire the Vault URL from Archaius.
 *
 * @return Vault URL
 */
@Nullable
@Override
public  String resolve() {
    final AbstractConfiguration configuration = ConfigurationManager.getConfigInstance();
    final String envUrl = configuration.getString(CERBERUS_ADDR_ENV_PROPERTY);
    final String sysUrl = configuration.getString(CERBERUS_ADDR_SYS_PROPERTY);

    if (StringUtils.isNotBlank(envUrl) && HttpUrl.parse(envUrl) != null) {
        return envUrl;
    } else if (StringUtils.isNotBlank(sysUrl) && HttpUrl.parse(sysUrl) != null) {
        return sysUrl;
    }

    logger.warn("Unable to resolve the Cerberus URL.");

    return null;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-archaius-client,代码行数:23,代码来源:ArchaiusCerberusUrlResolver.java


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