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());
}
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);
}
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());
}
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);
}
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;
}
Aggregations