@Override
public ListenableFuture<Duration> announce(Set<ServiceAnnouncement> services)
{
checkNotNull(services, "services is null");
Builder builder;
final boolean servicesEmpty = services.isEmpty();
if (servicesEmpty) {
builder = prepareDelete();
}
else {
Announcement announcement = new Announcement(nodeInfo.getEnvironment(), nodeInfo.getNodeId(), nodeInfo.getPool(), nodeInfo.getLocation(), services);
builder = preparePut()
.setHeader("Content-Type", MEDIA_TYPE_JSON.toString())
.setBodyGenerator(jsonBodyGenerator(announcementCodec, announcement));
}
Request request = builder
.setUri(URI.create("v1/announcement/" + nodeInfo.getNodeId()))
.setHeader("User-Agent", nodeInfo.getNodeId())
.build();
return httpClient.executeAsync(request, new DiscoveryResponseHandler<Duration>("Announcement")