Search in sources :

Example 16 with MicroserviceInstance

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

the class TestMicroserviceInstanceResponse method testMicroserviceInstanceResponse.

@Test
public void testMicroserviceInstanceResponse() {
    MicroserviceInstance microserviceInstance = new MicroserviceInstance();
    MicroserviceInstanceResponse microserviceInstanceResponse = new MicroserviceInstanceResponse();
    microserviceInstanceResponse.setInstance(microserviceInstance);
    Assert.assertNotNull(microserviceInstanceResponse.getInstance());
}
Also used : MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Test(org.junit.Test)

Example 17 with MicroserviceInstance

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

the class TestInstanceCache method beforeClass.

@BeforeClass
public static void beforeClass() {
    MicroserviceInstance instance = new MicroserviceInstance();
    instance.setStatus(MicroserviceInstanceStatus.UP);
    List<String> endpoints = new ArrayList<>();
    endpoints.add("rest://127.0.0.1:8080");
    instance.setEndpoints(endpoints);
    instance.setInstanceId("1");
    instMap.put(instance.getInstanceId(), instance);
    instanceCache = new InstanceCache("testAppID", "testMicroServiceName", "1.0", instMap);
}
Also used : ArrayList(java.util.ArrayList) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) BeforeClass(org.junit.BeforeClass)

Example 18 with MicroserviceInstance

use of org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance 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 19 with MicroserviceInstance

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

the class AbstractEndpointDiscoveryFilter method createDiscoveryTreeNode.

@SuppressWarnings("unchecked")
protected DiscoveryTreeNode createDiscoveryTreeNode(String expectTransportName, DiscoveryContext context, DiscoveryTreeNode parent) {
    List<Object> endpoints = new ArrayList<>();
    for (MicroserviceInstance instance : ((Map<String, MicroserviceInstance>) parent.data()).values()) {
        for (String endpoint : instance.getEndpoints()) {
            try {
                URI uri = URI.create(endpoint);
                String transportName = uri.getScheme();
                if (!isTransportNameMatch(transportName, expectTransportName)) {
                    continue;
                }
                Object objEndpoint = createEndpoint(transportName, endpoint, instance);
                if (objEndpoint == null) {
                    continue;
                }
                endpoints.add(objEndpoint);
            } catch (Exception e) {
                LOGGER.warn("unrecognized address find, ignore {}.", endpoint);
            }
        }
    }
    return new DiscoveryTreeNode().subName(parent, expectTransportName).data(endpoints);
}
Also used : ArrayList(java.util.ArrayList) MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance) Map(java.util.Map) URI(java.net.URI)

Example 20 with MicroserviceInstance

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

the class AbstractServiceRegistry method updateInstanceProperties.

public boolean updateInstanceProperties(Map<String, String> instanceProperties) {
    MicroserviceInstance microserviceInstance = microservice.getInstance();
    boolean success = srClient.updateInstanceProperties(microserviceInstance.getServiceId(), microserviceInstance.getInstanceId(), instanceProperties);
    if (success) {
        microserviceInstance.setProperties(instanceProperties);
    }
    return success;
}
Also used : MicroserviceInstance(org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)

Aggregations

MicroserviceInstance (org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance)56 Test (org.junit.Test)30 Expectations (mockit.Expectations)16 ArrayList (java.util.ArrayList)15 Microservice (org.apache.servicecomb.serviceregistry.api.registry.Microservice)15 HashMap (java.util.HashMap)11 MicroserviceInstances (org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances)7 Before (org.junit.Before)5 EventBus (com.google.common.eventbus.EventBus)4 Server (com.netflix.loadbalancer.Server)4 BootEvent (org.apache.servicecomb.core.BootListener.BootEvent)4 CseServer (org.apache.servicecomb.loadbalance.CseServer)4 Subscribe (com.google.common.eventbus.Subscribe)3 Map (java.util.Map)3 VersionedCache (org.apache.servicecomb.foundation.common.cache.VersionedCache)3 MicroserviceInstanceRegisterTask (org.apache.servicecomb.serviceregistry.task.MicroserviceInstanceRegisterTask)3 URI (java.net.URI)2 List (java.util.List)2 RSAProviderTokenManager (org.apache.servicecomb.authentication.provider.RSAProviderTokenManager)2 SchemaListenerManager (org.apache.servicecomb.core.definition.loader.SchemaListenerManager)2