private void handleInitialize(ChannelHandlerContext ctx, MappingHttpRequest request) throws IOException, SocketException { InetSocketAddress addr = (InetSocketAddress) ctx.getChannel().getRemoteAddress(); LOG.info(LogUtil.subheader("Using " + addr.getHostName() + " as the database address.")); Component.db.setHostAddress(addr.getHostName()); Component.db.markEnabled(); Component.dns.setHostAddress(addr.getHostName()); Component.eucalyptus.setHostAddress(addr.getHostName()); Component.cluster.setHostAddress(addr.getHostName()); Component.jetty.setHostAddress(addr.getHostName()); HeartbeatType msg = (HeartbeatType) request.getMessage(); LOG.info(LogUtil.header("Got heartbeat event: " + LogUtil.dumpObject(msg))); for (HeartbeatComponentType component : msg.getComponents()) { LOG.info(LogUtil.subheader("Registering local component: " + LogUtil.dumpObject(component))); System.setProperty("euca." + component.getComponent() + ".name", component.getName()); Component.valueOf(component.getComponent()).markLocal(); // FIXME: this is needed because we can't dynamically change the mule config, so we need to // disable at init time and hup when a new component is loaded. initializedComponents.add(component.getComponent()); } // FIXME: this is needed because we can't dynamically change the mule config, so we need to // disable at init time and hup when a new component is loaded. if (!initializedComponents.contains(Component.storage.name())) { Component.storage.markDisabled(); } // FIXME: this is needed because we can't dynamically change the mule config, so we need to // disable at init time and hup when a new component is loaded. if (!initializedComponents.contains(Component.walrus.name())) { Component.walrus.markDisabled(); } System.setProperty("euca.db.password", Hashes.getHexSignature()); System.setProperty("euca.db.url", Component.db.getUri().toASCIIString()); boolean foundDb = false; try { foundDb = NetworkUtil.testReachability(addr.getHostName()); LOG.debug("Initializing SSL just in case: " + SslSetup.class); foundDb = true; } catch (Throwable e) { foundDb = false; } if (foundDb) { HttpResponse response = new DefaultHttpResponse(request.getProtocolVersion(), HttpResponseStatus.OK); ChannelFuture writeFuture = ctx.getChannel().write(response); writeFuture.addListener(ChannelFutureListener.CLOSE); initialized = true; if (this.channel != null) { this.channel.close(); } } else { HttpResponse response = new DefaultHttpResponse(request.getProtocolVersion(), HttpResponseStatus.NOT_ACCEPTABLE); ChannelFuture writeFuture = ctx.getChannel().write(response); writeFuture.addListener(ChannelFutureListener.CLOSE); } }