use of org.apache.servicecomb.governance.marker.TrafficMarker in project java-chassis by ServiceComb.
the class GovernancePropertiesTest method test_match_properties_changed.
@Test
public void test_match_properties_changed() {
dynamicValues.put("servicecomb.matchGroup.demo-rateLimiting", "matches:\n" + " - apiPath:\n" + " exact: \"/hello2\"\n" + " name: match0");
dynamicValues.put("servicecomb.matchGroup.demo-rateLimiting2", "matches:\n" + " - apiPath:\n" + " exact: \"/hello2\"\n" + " name: match0");
GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
Map<String, TrafficMarker> markers = matchProperties.getParsedEntity();
Assert.assertEquals(5, markers.size());
TrafficMarker demoRateLimiting = markers.get("demo-rateLimiting");
List<Matcher> matchers = demoRateLimiting.getMatches();
Assert.assertEquals(1, matchers.size());
Matcher matcher = matchers.get(0);
Assert.assertEquals("/hello2", matcher.getApiPath().get("exact"));
demoRateLimiting = markers.get("demo-rateLimiting2");
matchers = demoRateLimiting.getMatches();
Assert.assertEquals(1, matchers.size());
matcher = matchers.get(0);
Assert.assertEquals("/hello2", matcher.getApiPath().get("exact"));
}
use of org.apache.servicecomb.governance.marker.TrafficMarker in project incubator-servicecomb-java-chassis by apache.
the class GovernancePropertiesTest method test_match_properties_changed.
@Test
public void test_match_properties_changed() {
dynamicValues.put("servicecomb.matchGroup.demo-rateLimiting", "matches:\n" + " - apiPath:\n" + " exact: \"/hello2\"\n" + " name: match0");
dynamicValues.put("servicecomb.matchGroup.demo-rateLimiting2", "matches:\n" + " - apiPath:\n" + " exact: \"/hello2\"\n" + " name: match0");
GovernanceEventManager.post(new GovernanceConfigurationChangedEvent(new HashSet<>(dynamicValues.keySet())));
Map<String, TrafficMarker> markers = matchProperties.getParsedEntity();
Assert.assertEquals(5, markers.size());
TrafficMarker demoRateLimiting = markers.get("demo-rateLimiting");
List<Matcher> matchers = demoRateLimiting.getMatches();
Assert.assertEquals(1, matchers.size());
Matcher matcher = matchers.get(0);
Assert.assertEquals("/hello2", matcher.getApiPath().get("exact"));
demoRateLimiting = markers.get("demo-rateLimiting2");
matchers = demoRateLimiting.getMatches();
Assert.assertEquals(1, matchers.size());
matcher = matchers.get(0);
Assert.assertEquals("/hello2", matcher.getApiPath().get("exact"));
}
use of org.apache.servicecomb.governance.marker.TrafficMarker in project incubator-servicecomb-java-chassis by apache.
the class MatchersServiceImpl method checkMatch.
@Override
public boolean checkMatch(GovernanceRequest governanceRequest, String key) {
Map<String, TrafficMarker> parsedEntity = matchProperties.getParsedEntity();
TrafficMarker trafficMarker = parsedEntity.get(key);
if (trafficMarker == null) {
return false;
}
return trafficMarker.checkMatch(governanceRequest, requestProcessor);
}
Aggregations