use of org.apache.servicecomb.registry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImpl method updateInstanceProperties.
@Override
public boolean updateInstanceProperties(String microserviceId, String microserviceInstanceId, Map<String, String> instanceProperties) {
Map<String, MicroserviceInstance> instanceMap = microserviceInstanceMap.get(microserviceId);
if (instanceMap == null) {
throw new IllegalArgumentException("Invalid serviceId, serviceId=" + microserviceId);
}
MicroserviceInstance microserviceInstance = instanceMap.get(microserviceInstanceId);
if (microserviceInstance == null) {
throw new IllegalArgumentException(String.format("Invalid argument. microserviceId=%s, microserviceInstanceId=%s.", microserviceId, microserviceInstanceId));
}
if (instanceProperties != null) {
microserviceInstance.getProperties().putAll(instanceProperties);
}
return true;
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestPropertiesLoader method testInstancePropertiesLoader.
@Test
public void testInstancePropertiesLoader() {
Microservice microservice = LocalServiceRegistryFactory.createLocal().getMicroservice();
MicroserviceInstance instance = microservice.getInstance();
Map<String, String> expectedMap = new HashMap<>();
expectedMap.put("key0", "value0");
expectedMap.put("ek0", "ev0");
Assert.assertEquals(expectedMap, instance.getProperties());
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestSimpleMicroserviceInstancePing method testPing_more_endpoin.
@Test
public void testPing_more_endpoin() throws IOException {
SimpleMicroserviceInstancePing ping = new SimpleMicroserviceInstancePing();
MicroserviceInstance instance = new MicroserviceInstance();
List<String> endpoints = new ArrayList<>();
ServerSocket ss = new ServerSocket(35677);
endpoints.add("http://localhost:35676");
endpoints.add("http://localhost:35677");
instance.setEndpoints(endpoints);
Assert.assertTrue(ping.ping(instance));
ss.close();
Assert.assertFalse(ping.ping(instance));
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceInstance in project incubator-servicecomb-java-chassis by apache.
the class TestConsumers method registryMicroserviceMapping.
@Test
public void registryMicroserviceMapping() {
MicroserviceInstance microserviceInstance = new MicroserviceInstance();
RegistrationManager.INSTANCE.registerMicroserviceMapping("3rd", "1.0.0", Arrays.asList(microserviceInstance), Hello.class);
MicroserviceVersionRule microserviceVersionRule = appManager.getOrCreateMicroserviceVersionRule(appId, "3rd", "0+");
Assert.assertThat(microserviceVersionRule.getInstances().values(), Matchers.contains(microserviceInstance));
}
use of org.apache.servicecomb.registry.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);
}
Aggregations