strategy = new RoundRobinStrategy<byte[]>();
break;
}
}
CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);
@SuppressWarnings("unchecked")
ServiceDiscovery<byte[]> serviceDiscovery = CuratorEntry.mustGetThing(entry, discoveryProjection.id, ServiceDiscovery.class);
final ServiceProvider<byte[]> serviceProvider = serviceDiscovery
.serviceProviderBuilder()
.downInstancePolicy(new DownInstancePolicy(downTimeoutMs, TimeUnit.MILLISECONDS, downErrorThreshold))
.providerStrategy(strategy)
.serviceName(serviceName)
.build();
try
{
serviceProvider.start();
Closer closer = new Closer()
{
@Override
public void close()
{
try
{
serviceProvider.close();
}
catch ( IOException e )
{
log.error("Could not close ServiceProvider with serviceName: " + serviceName, e);
}
}
};
String id = entry.addThing(serviceProvider, closer);
return new DiscoveryProviderProjection(id);
}
catch ( Exception e )
{
throw new RpcException(e);