Search in sources :

Example 6 with ServiceCenterInfo

use of org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo in project incubator-servicecomb-java-chassis by apache.

the class LocalServiceRegistryClientImpl method getServiceCenterInfo.

@Override
public ServiceCenterInfo getServiceCenterInfo() {
    ServiceCenterInfo info = new ServiceCenterInfo();
    info.setVersion("1.0.0");
    info.setBuildTag("20180312");
    info.setRunMode("dev");
    info.setApiVersion("4.0.0");
    info.setConfig(new ServiceCenterConfig());
    return info;
}
Also used : ServiceCenterConfig(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterConfig) ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo)

Example 7 with ServiceCenterInfo

use of org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo in project java-chassis by ServiceComb.

the class TestServiceRegistryClientImpl method testGetServiceCenterInfoSuccess.

@Test
public void testGetServiceCenterInfoSuccess() {
    ServiceCenterInfo serviceCenterInfo = new ServiceCenterInfo();
    serviceCenterInfo.setVersion("x.x.x");
    serviceCenterInfo.setBuildTag("xxx");
    serviceCenterInfo.setRunMode("dev");
    serviceCenterInfo.setApiVersion("x.x.x");
    serviceCenterInfo.setConfig(new ServiceCenterConfig());
    new MockUp<RestClientUtil>() {

        @Mock
        void httpDo(RequestContext requestContext, Handler<RestResponse> responseHandler) {
            Holder<ServiceCenterInfo> holder = Deencapsulation.getField(responseHandler, "arg$4");
            holder.value = serviceCenterInfo;
        }
    };
    ServiceCenterInfo info = oClient.getServiceCenterInfo();
    Assert.assertEquals("x.x.x", info.getVersion());
    Assert.assertEquals("xxx", info.getBuildTag());
    Assert.assertEquals("dev", info.getRunMode());
    Assert.assertNotNull(info.getConfig());
}
Also used : ServiceCenterConfig(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterConfig) ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) Handler(io.vertx.core.Handler) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 8 with ServiceCenterInfo

use of org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo in project java-chassis by ServiceComb.

the class ServiceCenterDeploy method ensureReady.

public void ensureReady() throws Throwable {
    // {"version":"1.0.0","buildTag":"20180608145515.1.0.0.b913a2d","runMode":"dev","apiVersion":"3.0.0"}
    try {
        String address = "http://localhost:30100/version";
        ServiceCenterInfo serviceCenterInfo = new RestTemplate().getForObject(address, ServiceCenterInfo.class);
        if (serviceCenterInfo != null && serviceCenterInfo.getVersion() != null) {
            LOGGER.info("{} already started, {}.", deployDefinition.getDisplayName(), Json.pretty(serviceCenterInfo));
            return;
        }
    } catch (Throwable e) {
        LOGGER.info("failed to get ServiceCenter version, message={}", e.getMessage());
    }
    initServiceCenterCmd();
    LOGGER.info("definition of {} is: {}", deployDefinition.getDeployName(), deployDefinition);
    deploy();
    waitStartComplete();
}
Also used : ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) RestTemplate(org.springframework.web.client.RestTemplate)

Example 9 with ServiceCenterInfo

use of org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method getServiceCenterInfo.

@Override
public ServiceCenterInfo getServiceCenterInfo() {
    Holder<ServiceCenterInfo> holder = new Holder<>();
    IpPort ipPort = ipPortManager.getAvailableAddress();
    CountDownLatch countDownLatch = new CountDownLatch(1);
    restClientUtil.get(ipPort, Const.REGISTRY_API.SERVICECENTER_VERSION, new RequestParam(), syncHandler(countDownLatch, ServiceCenterInfo.class, holder));
    try {
        countDownLatch.await();
        if (holder.value != null) {
            return holder.value;
        }
    } catch (Exception e) {
        LOGGER.error("query servicecenter version info failed.", e);
    }
    return null;
}
Also used : ServiceCenterInfo(org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo) IpPort(org.apache.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) ClientException(org.apache.servicecomb.serviceregistry.client.ClientException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ServiceCenterInfo (org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo)9 ServiceCenterConfig (org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterConfig)4 Test (org.junit.Test)4 Handler (io.vertx.core.Handler)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 MockUp (mockit.MockUp)2 IpPort (org.apache.servicecomb.foundation.common.net.IpPort)2 ClientException (org.apache.servicecomb.serviceregistry.client.ClientException)2 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Holder (javax.xml.ws.Holder)1 RestTemplate (org.springframework.web.client.RestTemplate)1