use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project incubator-servicecomb-java-chassis by apache.
the class GovernancePropertiesTest method tearDown.
@After
public void tearDown() {
Set<String> keys = dynamicValues.keySet();
keys.forEach(k -> dynamicValues.put(k, null));
GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
}
use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project incubator-servicecomb-java-chassis by apache.
the class GovernancePropertiesTest method test_bulkhead_properties_bound.
@Test
public void test_bulkhead_properties_bound() {
dynamicValues.put("servicecomb.bulkhead.test-bulkhead1", "rules:\n" + "maxConcurrentCalls: 0\n" + "maxWaitDuration: 2000");
dynamicValues.put("servicecomb.bulkhead.test-bulkhead2", "rules:\n" + "maxConcurrentCalls: 1000\n" + "maxWaitDuration: 0");
dynamicValues.put("servicecomb.bulkhead.test-bulkhead3", "rules:\n" + "maxConcurrentCalls: 0\n" + "maxWaitDuration: 2S");
GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
Map<String, BulkheadPolicy> policies = bulkheadProperties.getParsedEntity();
Assert.assertEquals(4, policies.size());
BulkheadPolicy policy = policies.get("test-bulkhead1");
Assert.assertEquals(0, policy.getMaxConcurrentCalls());
Assert.assertEquals(2000, Duration.parse(policy.getMaxWaitDuration()).toMillis());
policy = policies.get("test-bulkhead2");
Assert.assertEquals(1000, policy.getMaxConcurrentCalls());
Assert.assertEquals(0, Duration.parse(policy.getMaxWaitDuration()).toMillis());
Assert.assertEquals("test-bulkhead2", policy.getName());
policy = policies.get("test-bulkhead3");
Assert.assertEquals(0, policy.getMaxConcurrentCalls());
Assert.assertEquals(2000, Duration.parse(policy.getMaxWaitDuration()).toMillis());
Assert.assertEquals("test-bulkhead3", policy.getName());
}
use of org.apache.servicecomb.governance.event.GovernanceConfigurationChangedEvent in project incubator-servicecomb-java-chassis by apache.
the class ServiceCombConfigurationEventAdapter method onConfigurationChangedEvent.
@Subscribe
public void onConfigurationChangedEvent(RefreshGovernanceConfigurationEvent event) {
Set<String> changedKeys = new HashSet<>();
addMap(changedKeys, event.getEvent().getAdded());
addMap(changedKeys, event.getEvent().getDeleted());
addMap(changedKeys, event.getEvent().getChanged());
addMap(changedKeys, event.getEvent().getComplete());
GovernanceConfigurationChangedEvent newEvent = new GovernanceConfigurationChangedEvent(changedKeys);
GovernanceEventManager.post(newEvent);
}
Aggregations