private synchronized HeartbeatType getMessage( Collection<ComponentConfiguration> componentConfigurations) { HeartbeatType hbmsg = new HeartbeatType(); hbmsg.getStarted().addAll(started); this.started.clear(); hbmsg.getStopped().addAll(stopped); this.stopped.clear(); for (ComponentConfiguration c : componentConfigurations) { hbmsg.getComponents().add(new HeartbeatComponentType(c.getComponent().name(), c.getName())); } return hbmsg; }
private void handleHeartbeat(MappingHttpRequest request) throws URISyntaxException { HeartbeatType hb = (HeartbeatType) request.getMessage(); // 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. List<String> registeredComponents = Lists.newArrayList(); for (HeartbeatComponentType component : hb.getComponents()) { if (!initializedComponents.contains(component.getComponent())) { System.exit(123); // HUP } registeredComponents.add(component.getComponent()); } if (!registeredComponents.containsAll(initializedComponents)) { System.exit(123); // HUP } // FIXME: end. for (ComponentType startedComponent : hb.getStarted()) { Component c = Component.valueOf(startedComponent.getComponent()); try { if (Component.walrus.equals(c)) { ComponentConfiguration config = Configuration.getWalrusConfiguration(startedComponent.getName()); Configuration.fireStartComponent(config); } if (Component.storage.equals(c)) { ComponentConfiguration config = Configuration.getStorageControllerConfiguration(startedComponent.getName()); Configuration.fireStartComponent(config); } } catch (Exception e1) { LOG.debug(e1, e1); } } for (ComponentType stoppedComponent : hb.getStopped()) { URI uri = new URI(stoppedComponent.getUri()); Component c = Component.valueOf(stoppedComponent.getComponent()); try { if (Component.walrus.equals(c)) { Configuration.fireStopComponent(new RemoteConfiguration(c, uri)); } if (Component.storage.equals(c)) { Configuration.fireStopComponent(new RemoteConfiguration(c, uri)); } } catch (Exception e1) { LOG.debug(e1, e1); } } }