use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project java-chassis by ServiceComb.
the class StoreServiceTest method should_register_instance_when_microservice_exist.
@Test
void should_register_instance_when_microservice_exist() {
Microservice microservice = Json.decodeValue(Json.encode(self.getMicroservice()), Microservice.class);
store.addMicroservice(microservice, self.getSchemasSummary());
RegisterRequest request = self.buildRegisterRequest();
InstanceStore instanceStore = service.register(request);
assertThat(microservice).isNotSameAs(self.getMicroservice());
assertThat(store.findMicroserviceStore(self.getServiceId()).getMicroservice()).isSameAs(microservice);
assertThat(instanceStore.getInstance()).isSameAs(self.getInstance());
}
use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project java-chassis by ServiceComb.
the class StoreServiceTest method should_process_as_heartbeat_when_nothing_changed.
@Test
void should_process_as_heartbeat_when_nothing_changed() {
should_register_microservice_and_instance_when_both_not_exist();
InstanceStore instanceStore = store.findInstanceStore(self.getInstanceId());
assertThat(instanceStore.getLastHeartBeat()).isEqualTo(0);
ticker.setValues(1L);
should_register_microservice_and_instance_when_both_not_exist();
assertThat(instanceStore.getLastHeartBeat()).isEqualTo(1);
}
use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project incubator-servicecomb-java-chassis by apache.
the class StoreService method addMicroserviceAndInstance.
private CompletableFuture<InstanceStore> addMicroserviceAndInstance(Endpoint endpoint, RegisterRequest request) {
return discoveryClient.getInfoAsync(endpoint, request.getServiceId()).thenApply(info -> {
info.getMicroservice().getSchemaMap().putAll(info.getSchemasById());
MicroserviceStore microserviceStore = store.addMicroservice(info.getMicroservice(), request.getSchemasSummary());
InstanceStore instanceStore = doAddInstance(microserviceStore, info.getInstance());
LOGGER.info("add microservice and instance, serviceId={}, instanceId={}, endpoints={}", request.getServiceId(), request.getInstanceId(), request.getEndpoints());
return instanceStore;
});
}
use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project incubator-servicecomb-java-chassis by apache.
the class StoreService method deleteInstance.
public void deleteInstance(String action, String serviceId, String instanceId) {
InstanceStore instanceStore = store.deleteInstance(serviceId, instanceId);
if (instanceStore == null) {
return;
}
LOGGER.info("{} instance, serviceId={}, instanceId={}, endpoints={}", action, instanceStore.getServiceId(), instanceStore.getInstanceId(), instanceStore.getEndpoints());
}
use of org.apache.servicecomb.registry.lightweight.store.InstanceStore in project incubator-servicecomb-java-chassis by apache.
the class StoreService method doAddInstance.
private InstanceStore doAddInstance(MicroserviceStore microserviceStore, MicroserviceInstance instance) {
InstanceStore instanceStore = store.addInstance(microserviceStore, instance);
eventBus.post(new RegisterInstanceEvent(microserviceStore.getMicroservice(), instance));
return instanceStore;
}
Aggregations