Search in sources :

Example 1 with MicroserviceInstances

use of org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances in project incubator-servicecomb-java-chassis by apache.

the class MicroserviceVersions method pullInstances.

public void pullInstances() {
    if (pendingPullCount.decrementAndGet() != 0) {
        return;
    }
    MicroserviceInstances microserviceInstances = RegistryUtils.findServiceInstances(appId, microserviceName, DefinitionConst.VERSION_RULE_ALL, revision);
    if (microserviceInstances == null) {
        return;
    }
    if (!microserviceInstances.isNeedRefresh()) {
        return;
    }
    List<MicroserviceInstance> pulledInstances = microserviceInstances.getInstancesResponse().getInstances();
    String rev = microserviceInstances.getRevision();
    safeSetInstances(pulledInstances, rev);
}
Also used : MicroserviceInstances(org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)

Example 2 with MicroserviceInstances

use of org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances in project incubator-servicecomb-java-chassis by apache.

the class TestMicroserviceVersions method setUp.

@Before
public void setUp() throws Exception {
    microserviceInstances = new MicroserviceInstances();
    findInstancesResponse = new FindInstancesResponse();
}
Also used : MicroserviceInstances(org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances) FindInstancesResponse(org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse) Before(org.junit.Before)

Example 3 with MicroserviceInstances

use of org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances in project incubator-servicecomb-java-chassis by apache.

the class LocalServiceRegistryClientImplTest method testLoadRegistryFile.

@Test
public void testLoadRegistryFile() {
    Assert.assertNotNull(registryClient);
    Assert.assertThat(registryClient.getAllMicroservices().size(), Is.is(1));
    List<MicroserviceInstance> m = registryClient.findServiceInstance("", "myapp", "springmvctest", DefinitionConst.VERSION_RULE_ALL);
    Assert.assertEquals(1, m.size());
    MicroserviceInstances microserviceInstances = registryClient.findServiceInstances("", "myapp", "springmvctest", DefinitionConst.VERSION_RULE_ALL, null);
    List<MicroserviceInstance> mi = microserviceInstances.getInstancesResponse().getInstances();
    Assert.assertEquals(1, mi.size());
}
Also used : MicroserviceInstances(org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 4 with MicroserviceInstances

use of org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances in project incubator-servicecomb-java-chassis by apache.

the class AbstractServiceRegistry method findServiceInstances.

public MicroserviceInstances findServiceInstances(String appId, String serviceName, String versionRule, String revision) {
    MicroserviceInstances microserviceInstances = srClient.findServiceInstances(microservice.getServiceId(), appId, serviceName, versionRule, revision);
    if (microserviceInstances == null) {
        LOGGER.error("Can not find any instances from service center due to previous errors. service={}/{}/{}", appId, serviceName, versionRule);
        return null;
    }
    if (!microserviceInstances.isNeedRefresh()) {
        LOGGER.debug("instances revision is not changed, service={}/{}/{}", appId, serviceName, versionRule);
        return microserviceInstances;
    }
    List<MicroserviceInstance> instances = microserviceInstances.getInstancesResponse().getInstances();
    LOGGER.info("find instances[{}] from service center success. service={}/{}/{}", instances.size(), appId, serviceName, versionRule);
    for (MicroserviceInstance instance : instances) {
        LOGGER.info("service id={}, instance id={}, endpoints={}", instance.getServiceId(), instance.getInstanceId(), instance.getEndpoints());
    }
    return microserviceInstances;
}
Also used : MicroserviceInstances(org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)

Example 5 with MicroserviceInstances

use of org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances in project incubator-servicecomb-java-chassis by apache.

the class TestAppManager method setUp.

@Before
public void setUp() throws Exception {
    microserviceInstances = new MicroserviceInstances();
    findInstancesResponse = new FindInstancesResponse();
    findInstancesResponse.setInstances(Collections.emptyList());
    microserviceInstances.setInstancesResponse(findInstancesResponse);
}
Also used : MicroserviceInstances(org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances) FindInstancesResponse(org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse) Before(org.junit.Before)

Aggregations

MicroserviceInstances (org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances)10 MicroserviceInstance (org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)7 FindInstancesResponse (org.apache.servicecomb.serviceregistry.api.response.FindInstancesResponse)4 Test (org.junit.Test)4 Microservice (org.apache.servicecomb.serviceregistry.api.registry.Microservice)3 Before (org.junit.Before)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Version (org.apache.servicecomb.serviceregistry.version.Version)1 VersionRule (org.apache.servicecomb.serviceregistry.version.VersionRule)1