boolean changed = false;
synchronized(hostsList)
{
for (Host host : hostsList.values())
{
AsyncServiceManagerServer proxy = null;
synchronized(proxies)
{
proxy = proxies.get(host.getName());
}
boolean connected = false;
if (proxy != null)
{
try
{
connected = ((Boolean)proxy.isServiceManager()).booleanValue();
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
ClientBootstrap bootstrap = new ClientBootstrap(
new NioClientSocketChannelFactory(
executor,
executor));
HessianProxyFactory factory = new HessianProxyFactory(executor, host.getName()+":"+host.getPort());
bootstrap.setPipelineFactory(
new RPCClientPipelineFactory(executor, factory));
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host.getName(), host.getPort()));
try
{
future.await(10000);
connected = future.isSuccess();
if (connected)
{
Map options = new HashMap();
options.put("sync", true);
options.put("timeout", new Long(10000));
proxy = (AsyncServiceManagerServer) factory.create(AsyncServiceManagerServer.class, HubMain.class.getClassLoader(), options);
connected = ((Boolean)proxy.isServiceManager()).booleanValue();
if (connected)
{
synchronized(proxies)
{
proxies.put(host.getName(), proxy);