use of org.apache.servicecomb.registry.lightweight.store.MicroserviceStore in project incubator-servicecomb-java-chassis by apache.
the class StoreService method addInstance.
private CompletableFuture<InstanceStore> addInstance(RegisterRequest request) {
Endpoint endpoint = request.selectFirstEndpoint();
if (endpoint == null) {
return AsyncUtils.completeExceptionally(new RegisterException("can not select endpoint"));
}
MicroserviceStore microserviceStore = this.store.findMicroserviceStore(request.getServiceId());
if (microserviceStore == null) {
return addMicroserviceAndInstance(endpoint, request);
}
return checkSchemaSummary(request, microserviceStore).thenCompose(v -> discoveryClient.getInstanceAsync(endpoint, request.getServiceId())).thenApply(instance -> addInstance(microserviceStore, instance));
}
use of org.apache.servicecomb.registry.lightweight.store.MicroserviceStore in project incubator-servicecomb-java-chassis by apache.
the class StoreService method registerSelf.
public void registerSelf(Self self) {
MicroserviceStore microserviceStore = store.addMicroservice(self.getMicroservice(), self.getSchemasSummary());
addInstance(microserviceStore, self.getInstance());
}
use of org.apache.servicecomb.registry.lightweight.store.MicroserviceStore in project incubator-servicecomb-java-chassis by apache.
the class StoreServiceTest method should_register_and_notify_when_schema_changed_and_has_not_existing_instance.
@Test
void should_register_and_notify_when_schema_changed_and_has_not_existing_instance() {
should_register_microservice_and_instance_when_both_not_exist();
MicroserviceStore microserviceStore = store.findMicroserviceStore(self.getServiceId());
assertThat(microserviceStore.hasInstance()).isTrue();
store.deleteInstance(self.getServiceId(), self.getInstanceId());
assertThat(microserviceStore.hasInstance()).isFalse();
eventBus.register(this);
RegisterRequest request = self.buildRegisterRequest().setSchemasSummary("new summary");
InstanceStore instanceStore = service.register(request);
assertThat(microserviceStore.isSchemaChanged("new summary")).isFalse();
assertThat(instanceStore.getInstance()).isSameAs(self.getInstance());
assertThat(schemaChangedEvent.getMicroservice()).isSameAs(self.getMicroservice());
}
use of org.apache.servicecomb.registry.lightweight.store.MicroserviceStore in project java-chassis by ServiceComb.
the class StoreService method registerSelf.
public void registerSelf(Self self) {
MicroserviceStore microserviceStore = store.addMicroservice(self.getMicroservice(), self.getSchemasSummary());
addInstance(microserviceStore, self.getInstance());
}
use of org.apache.servicecomb.registry.lightweight.store.MicroserviceStore in project java-chassis by ServiceComb.
the class StoreServiceTest method should_register_and_notify_when_schema_changed_and_has_not_existing_instance.
@Test
void should_register_and_notify_when_schema_changed_and_has_not_existing_instance() {
should_register_microservice_and_instance_when_both_not_exist();
MicroserviceStore microserviceStore = store.findMicroserviceStore(self.getServiceId());
assertThat(microserviceStore.hasInstance()).isTrue();
store.deleteInstance(self.getServiceId(), self.getInstanceId());
assertThat(microserviceStore.hasInstance()).isFalse();
eventBus.register(this);
RegisterRequest request = self.buildRegisterRequest().setSchemasSummary("new summary");
InstanceStore instanceStore = service.register(request);
assertThat(microserviceStore.isSchemaChanged("new summary")).isFalse();
assertThat(instanceStore.getInstance()).isSameAs(self.getInstance());
assertThat(schemaChangedEvent.getMicroservice()).isSameAs(self.getMicroservice());
}
Aggregations