本文整理匯總了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);
}
示例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);
}
示例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;
}
示例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());
}
示例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");
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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");
}
}
示例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;
}