Search in sources :

Example 1 with HttpTransport

use of org.apache.servicecomb.http.client.common.HttpTransport in project java-chassis by ServiceComb.

the class KieConfigurationSourceImpl method init.

@Override
public void init(Configuration localConfiguration) {
    configConverter = new ConfigConverter(KieConfig.INSTANCE.getFileSources());
    KieAddressManager kieAddressManager = configKieAddressManager();
    RequestConfig.Builder requestBuilder = HttpTransportFactory.defaultRequestConfig();
    if (KieConfig.INSTANCE.enableLongPolling() && KieConfig.INSTANCE.getPollingWaitTime() >= 0) {
        requestBuilder.setConnectionRequestTimeout(KieConfig.INSTANCE.getPollingWaitTime() * 2 * 1000);
        requestBuilder.setSocketTimeout(KieConfig.INSTANCE.getPollingWaitTime() * 2 * 1000);
    }
    HttpTransport httpTransport = createHttpTransport(kieAddressManager, requestBuilder.build(), localConfiguration);
    KieConfiguration kieConfiguration = createKieConfiguration();
    KieClient kieClient = new KieClient(kieAddressManager, httpTransport, kieConfiguration);
    EventManager.register(this);
    kieConfigManager = new KieConfigManager(kieClient, EventManager.getEventBus(), kieConfiguration, configConverter);
    kieConfigManager.firstPull();
    kieConfigManager.startConfigKieManager();
    updateConfiguration(WatchedUpdateResult.createIncremental(configConverter.getCurrentData(), null, null));
}
Also used : ConfigConverter(org.apache.servicecomb.config.common.ConfigConverter) RequestConfig(org.apache.http.client.config.RequestConfig) HttpTransport(org.apache.servicecomb.http.client.common.HttpTransport) KieConfiguration(org.apache.servicecomb.config.kie.client.model.KieConfiguration) KieAddressManager(org.apache.servicecomb.config.kie.client.model.KieAddressManager) KieConfigManager(org.apache.servicecomb.config.kie.client.KieConfigManager) KieClient(org.apache.servicecomb.config.kie.client.KieClient)

Example 2 with HttpTransport

use of org.apache.servicecomb.http.client.common.HttpTransport in project incubator-servicecomb-java-chassis by apache.

the class KieConfigurationSourceImpl method init.

@Override
public void init(Configuration localConfiguration) {
    configConverter = new ConfigConverter(KieConfig.INSTANCE.getFileSources());
    KieAddressManager kieAddressManager = configKieAddressManager();
    RequestConfig.Builder requestBuilder = HttpTransportFactory.defaultRequestConfig();
    if (KieConfig.INSTANCE.enableLongPolling() && KieConfig.INSTANCE.getPollingWaitTime() >= 0) {
        requestBuilder.setConnectionRequestTimeout(KieConfig.INSTANCE.getPollingWaitTime() * 2 * 1000);
        requestBuilder.setSocketTimeout(KieConfig.INSTANCE.getPollingWaitTime() * 2 * 1000);
    }
    HttpTransport httpTransport = createHttpTransport(kieAddressManager, requestBuilder.build(), localConfiguration);
    KieConfiguration kieConfiguration = createKieConfiguration();
    KieClient kieClient = new KieClient(kieAddressManager, httpTransport, kieConfiguration);
    EventManager.register(this);
    kieConfigManager = new KieConfigManager(kieClient, EventManager.getEventBus(), kieConfiguration, configConverter);
    kieConfigManager.firstPull();
    kieConfigManager.startConfigKieManager();
    updateConfiguration(WatchedUpdateResult.createIncremental(configConverter.getCurrentData(), null, null));
}
Also used : ConfigConverter(org.apache.servicecomb.config.common.ConfigConverter) RequestConfig(org.apache.http.client.config.RequestConfig) HttpTransport(org.apache.servicecomb.http.client.common.HttpTransport) KieConfiguration(org.apache.servicecomb.config.kie.client.model.KieConfiguration) KieAddressManager(org.apache.servicecomb.config.kie.client.model.KieAddressManager) KieConfigManager(org.apache.servicecomb.config.kie.client.KieConfigManager) KieClient(org.apache.servicecomb.config.kie.client.KieClient)

Example 3 with HttpTransport

use of org.apache.servicecomb.http.client.common.HttpTransport 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 4 with HttpTransport

use of org.apache.servicecomb.http.client.common.HttpTransport in project java-chassis by ServiceComb.

the class ServiceCenterRawClientTest method TestDefaultParameter.

@Test
public void TestDefaultParameter() throws IOException {
    HttpTransport httpTransport = Mockito.mock(HttpTransport.class);
    AddressManager addressManager = new AddressManager(PROJECT_NAME, Arrays.asList("http://127.0.0.1:30100"), new EventBus());
    ServiceCenterRawClient client = new ServiceCenterRawClient.Builder().setHttpTransport(httpTransport).setAddressManager(addressManager).setTenantName(TENANT_NAME).build();
    HttpResponse httpResponse = new HttpResponse();
    httpResponse.setStatusCode(200);
    httpResponse.setContent("ok");
    Mockito.when(httpTransport.doRequest(Mockito.any())).thenReturn(httpResponse);
    HttpResponse actualGetResponse = client.getHttpRequest(null, null, null);
    HttpResponse actualPostResponse = client.postHttpRequest(null, null, null);
    HttpResponse actualPutResponse = client.putHttpRequest(null, null, null);
    HttpResponse actualDeleteResponse = client.putHttpRequest(null, null, null);
    Assert.assertNotNull(actualGetResponse);
    Assert.assertEquals("ok", actualGetResponse.getContent());
    Assert.assertNotNull(actualPostResponse);
    Assert.assertEquals("ok", actualPostResponse.getContent());
    Assert.assertNotNull(actualPutResponse);
    Assert.assertEquals("ok", actualPutResponse.getContent());
    Assert.assertNotNull(actualDeleteResponse);
    Assert.assertEquals("ok", actualDeleteResponse.getContent());
}
Also used : HttpTransport(org.apache.servicecomb.http.client.common.HttpTransport) HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) EventBus(com.google.common.eventbus.EventBus) Test(org.junit.Test)

Example 5 with HttpTransport

use of org.apache.servicecomb.http.client.common.HttpTransport 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

HttpTransport (org.apache.servicecomb.http.client.common.HttpTransport)6 ConfigConverter (org.apache.servicecomb.config.common.ConfigConverter)4 EventBus (com.google.common.eventbus.EventBus)2 RequestConfig (org.apache.http.client.config.RequestConfig)2 AddressManager (org.apache.servicecomb.config.center.client.AddressManager)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 KieClient (org.apache.servicecomb.config.kie.client.KieClient)2 KieConfigManager (org.apache.servicecomb.config.kie.client.KieConfigManager)2 KieAddressManager (org.apache.servicecomb.config.kie.client.model.KieAddressManager)2 KieConfiguration (org.apache.servicecomb.config.kie.client.model.KieConfiguration)2 HttpResponse (org.apache.servicecomb.http.client.common.HttpResponse)2 Test (org.junit.Test)2