Skip to content

Commit

Permalink
Fix zookeeper instance update (apache#11212)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Dec 29, 2022
1 parent 1ecc00a commit e86e6e3
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
import static org.apache.dubbo.common.function.ThrowableFunction.execute;
import static org.apache.dubbo.metadata.RevisionResolver.EMPTY_REVISION;
import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getExportedServicesRevision;
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.build;
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildCuratorFramework;
import static org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildServiceDiscovery;
Expand Down Expand Up @@ -106,6 +108,19 @@ public void doUnregister(ServiceInstance serviceInstance) throws RuntimeExceptio
}
}

@Override
protected void doUpdate(ServiceInstance serviceInstance) throws RuntimeException {
if (!EMPTY_REVISION.equals(getExportedServicesRevision(serviceInstance))) {
reportMetadata(serviceInstance.getServiceMetadata());
}

try {
serviceDiscovery.updateService(build(serviceInstance));
} catch (Exception e) {
throw new RpcException(REGISTRY_EXCEPTION, "Failed register instance " + serviceInstance.toString(), e);
}
}

@Override
public Set<String> getServices() {
return doInServiceDiscovery(s -> new LinkedHashSet<>(s.queryForNames()));
Expand Down

0 comments on commit e86e6e3

Please sign in to comment.