use of org.apache.servicecomb.service.center.client.DiscoveryEvents.InstanceChangedEvent in project java-chassis by ServiceComb.
the class ServiceCenterDiscovery method pullInstance.
private void pullInstance(SubscriptionKey k, SubscriptionValue v) {
if (myselfServiceId == null) {
// registration not ready
return;
}
try {
FindMicroserviceInstancesResponse instancesResponse = serviceCenterClient.findMicroserviceInstance(myselfServiceId, k.appId, k.serviceName, ALL_VERSION, v.revision);
if (instancesResponse.isModified()) {
List<MicroserviceInstance> instances = instancesResponse.getMicroserviceInstancesResponse().getInstances() == null ? Collections.emptyList() : instancesResponse.getMicroserviceInstancesResponse().getInstances();
setMicroserviceInfo(instances);
LOGGER.info("Instance changed event, " + "current: revision={}, instances={}; " + "origin: revision={}, instances={}; " + "appId={}, serviceName={}", instancesResponse.getRevision(), instanceToString(instances), v.revision, instanceToString(v.instancesCache), k.appId, k.serviceName);
v.instancesCache = instances;
v.revision = instancesResponse.getRevision();
eventBus.post(new InstanceChangedEvent(k.appId, k.serviceName, v.instancesCache));
}
} catch (Exception e) {
LOGGER.error("find service {}#{} instance failed.", k.appId, k.serviceName, e);
failedInstances.add(k);
}
}
Aggregations