use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project java-chassis by ServiceComb.
the class AddressManagerTest method onRefreshEndpointEvent.
@Test
public void onRefreshEndpointEvent() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("http://127.0.0.3:30100");
List<String> addressRG = new ArrayList<>();
addressRG.add("http://127.0.0.4:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", addressRG);
addressManager1 = new AddressManager(addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "CseMonitoring");
addressManager1.refreshEndpoint(event, "CseMonitoring");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("http://127.0.0.3:30100", availableZone.get(0));
List<String> availableRegion = Deencapsulation.getField(addressManager1, "availableRegion");
Assert.assertEquals("http://127.0.0.4:30100", availableRegion.get(0));
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project java-chassis by ServiceComb.
the class ClassificationAddress method refreshEndPoints.
private void refreshEndPoints(MicroserviceCache microserviceCache, String name) {
Map<String, List<String>> zoneAndRegion = refreshEndPoint(microserviceCache);
EventManager.post(new RefreshEndpointEvent(zoneAndRegion, name));
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project java-chassis by ServiceComb.
the class ClassificationAddress method initEndPoint.
public void initEndPoint(String typeName) {
Map<String, List<String>> zoneAndRegion = generateZoneAndRegionAddress(typeName);
if (zoneAndRegion == null) {
return;
}
EventManager.post(new RefreshEndpointEvent(zoneAndRegion, typeName));
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project java-chassis by ServiceComb.
the class AddressManagerTest method onRefreshEndpointEvent.
@Test
public void onRefreshEndpointEvent() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("http://127.0.0.3:30100");
List<String> addressRG = new ArrayList<>();
addressRG.add("http://127.0.0.4:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", addressRG);
addressManager1 = new AddressManager("project", addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "CseConfigCenter");
addressManager1.refreshEndpoint(event, "CseConfigCenter");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("http://127.0.0.3:30100/v3/project", availableZone.get(0));
List<String> availableRegion = Deencapsulation.getField(addressManager1, "availableRegion");
Assert.assertEquals("http://127.0.0.4:30100/v3/project", availableRegion.get(0));
Assert.assertEquals("http://127.0.0.3:30100/v3/project", addressManager1.address());
}
use of org.apache.servicecomb.http.client.event.RefreshEndpointEvent in project java-chassis by ServiceComb.
the class AddressManagerTest method onRefreshEndpointEvent.
@Test
public void onRefreshEndpointEvent() {
List<String> addressAZ = new ArrayList<>();
addressAZ.add("http://127.0.0.3:30100");
List<String> addressRG = new ArrayList<>();
addressRG.add("https://127.0.0.4:30100");
Map<String, List<String>> zoneAndRegion = new HashMap<>();
zoneAndRegion.put("sameZone", addressAZ);
zoneAndRegion.put("sameRegion", addressRG);
addressManager1 = new AddressManager(addresses, new EventBus());
RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "SERVICECENTER");
addressManager1.refreshEndpoint(event, "SERVICECENTER");
List<String> availableZone = Deencapsulation.getField(addressManager1, "availableZone");
Assert.assertEquals("127.0.0.3:30100", availableZone.get(0));
List<String> availableRegion = Deencapsulation.getField(addressManager1, "availableRegion");
Assert.assertEquals("127.0.0.4:30100", availableRegion.get(0));
}
Aggregations