Search in sources :

Example 1 with AddressManager

use of org.apache.servicecomb.config.center.client.AddressManager in project incubator-servicecomb-java-chassis by apache.

the class ConfigCenterConfigurationSourceImpl method init.

@Override
public void init(Configuration localConfiguration) {
    configConverter = new ConfigConverter(ConfigCenterConfig.INSTANCE.getFileSources());
    AddressManager kieAddressManager = configKieAddressManager();
    HttpTransport httpTransport = createHttpTransport(kieAddressManager, HttpTransportFactory.defaultRequestConfig().build(), localConfiguration);
    ConfigCenterClient configCenterClient = new ConfigCenterClient(kieAddressManager, httpTransport);
    EventManager.register(this);
    QueryConfigurationsRequest queryConfigurationsRequest = firstPull(configCenterClient);
    configCenterManager = new ConfigCenterManager(configCenterClient, EventManager.getEventBus(), configConverter);
    configCenterManager.setQueryConfigurationsRequest(queryConfigurationsRequest);
    configCenterManager.startConfigCenterManager();
}
Also used : ConfigConverter(org.apache.servicecomb.config.common.ConfigConverter) HttpTransport(org.apache.servicecomb.http.client.common.HttpTransport) AddressManager(org.apache.servicecomb.config.center.client.AddressManager) ConfigCenterManager(org.apache.servicecomb.config.center.client.ConfigCenterManager) QueryConfigurationsRequest(org.apache.servicecomb.config.center.client.model.QueryConfigurationsRequest) ConfigCenterClient(org.apache.servicecomb.config.center.client.ConfigCenterClient)

Example 2 with AddressManager

use of org.apache.servicecomb.config.center.client.AddressManager in project incubator-servicecomb-java-chassis by apache.

the class ConfigCenterConfigurationSourceImplTest method configAddressManagerTest.

@Test
void configAddressManagerTest() {
    List<String> addresses = new ArrayList<>();
    addresses.add("http://127.0.0.1:30103");
    addresses.add("http://127.0.0.2:30103");
    AddressManager addressManager = new AddressManager("test", addresses, EventManager.getEventBus());
    Assert.assertNotNull(addressManager);
    String address = addressManager.address();
    Assert.assertEquals("http://127.0.0.2:30103/v3/test", address);
    address = addressManager.address();
    Assert.assertEquals("http://127.0.0.1:30103/v3/test", address);
    addressManager = new AddressManager(null, addresses, EventManager.getEventBus());
    address = addressManager.address();
    Assert.assertEquals("http://127.0.0.2:30103/v3/default", address);
}
Also used : AddressManager(org.apache.servicecomb.config.center.client.AddressManager) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 3 with AddressManager

use of org.apache.servicecomb.config.center.client.AddressManager in project java-chassis by ServiceComb.

the class ConfigCenterConfigurationSourceImplTest method onRefreshEndpointEventTest.

@Test
void onRefreshEndpointEventTest() {
    List<String> addresses = new ArrayList<>();
    addresses.add("http://127.0.0.1:30103");
    List<String> addressAZ = new ArrayList<>();
    addressAZ.add("rest://127.0.0.1:30100?sslEnabled=true");
    Map<String, List<String>> zoneAndRegion = new HashMap<>();
    zoneAndRegion.put("sameZone", addressAZ);
    zoneAndRegion.put("sameRegion", new ArrayList<>());
    RefreshEndpointEvent event = new RefreshEndpointEvent(zoneAndRegion, "CseConfigCenter");
    AddressManager addressManager = new AddressManager("test", addresses, EventManager.getEventBus());
    addressManager.onRefreshEndpointEvent(event);
    List<String> availableAZ = Deencapsulation.getField(addressManager, "availableZone");
    Assert.assertEquals("https://127.0.0.1:30100/v3/test", availableAZ.get(0));
}
Also used : AddressManager(org.apache.servicecomb.config.center.client.AddressManager) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RefreshEndpointEvent(org.apache.servicecomb.http.client.event.RefreshEndpointEvent) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 4 with AddressManager

use of org.apache.servicecomb.config.center.client.AddressManager in project java-chassis by ServiceComb.

the class ConfigCenterConfigurationSourceImplTest method configAddressManagerTest.

@Test
void configAddressManagerTest() {
    List<String> addresses = new ArrayList<>();
    addresses.add("http://127.0.0.1:30103");
    addresses.add("http://127.0.0.2:30103");
    AddressManager addressManager = new AddressManager("test", addresses, EventManager.getEventBus());
    Assert.assertNotNull(addressManager);
    String address = addressManager.address();
    Assert.assertEquals("http://127.0.0.2:30103/v3/test", address);
    address = addressManager.address();
    Assert.assertEquals("http://127.0.0.1:30103/v3/test", address);
    addressManager = new AddressManager(null, addresses, EventManager.getEventBus());
    address = addressManager.address();
    Assert.assertEquals("http://127.0.0.2:30103/v3/default", address);
}
Also used : AddressManager(org.apache.servicecomb.config.center.client.AddressManager) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 5 with AddressManager

use of org.apache.servicecomb.config.center.client.AddressManager in project java-chassis by ServiceComb.

the class ConfigCenterConfigurationSourceImpl method init.

@Override
public void init(Configuration localConfiguration) {
    configConverter = new ConfigConverter(ConfigCenterConfig.INSTANCE.getFileSources());
    AddressManager kieAddressManager = configKieAddressManager();
    HttpTransport httpTransport = createHttpTransport(kieAddressManager, HttpTransportFactory.defaultRequestConfig().build(), localConfiguration);
    ConfigCenterClient configCenterClient = new ConfigCenterClient(kieAddressManager, httpTransport);
    EventManager.register(this);
    QueryConfigurationsRequest queryConfigurationsRequest = firstPull(configCenterClient);
    configCenterManager = new ConfigCenterManager(configCenterClient, EventManager.getEventBus(), configConverter);
    configCenterManager.setQueryConfigurationsRequest(queryConfigurationsRequest);
    configCenterManager.startConfigCenterManager();
}
Also used : ConfigConverter(org.apache.servicecomb.config.common.ConfigConverter) HttpTransport(org.apache.servicecomb.http.client.common.HttpTransport) AddressManager(org.apache.servicecomb.config.center.client.AddressManager) ConfigCenterManager(org.apache.servicecomb.config.center.client.ConfigCenterManager) QueryConfigurationsRequest(org.apache.servicecomb.config.center.client.model.QueryConfigurationsRequest) ConfigCenterClient(org.apache.servicecomb.config.center.client.ConfigCenterClient)

Aggregations

AddressManager (org.apache.servicecomb.config.center.client.AddressManager)6 ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 HashMap (java.util.HashMap)2 List (java.util.List)2 ConfigCenterClient (org.apache.servicecomb.config.center.client.ConfigCenterClient)2 ConfigCenterManager (org.apache.servicecomb.config.center.client.ConfigCenterManager)2 QueryConfigurationsRequest (org.apache.servicecomb.config.center.client.model.QueryConfigurationsRequest)2 ConfigConverter (org.apache.servicecomb.config.common.ConfigConverter)2 HttpTransport (org.apache.servicecomb.http.client.common.HttpTransport)2 RefreshEndpointEvent (org.apache.servicecomb.http.client.event.RefreshEndpointEvent)2