public boolean unregisterGateway(AbstractGateway gateway) { synchronized (this._LOCK_) { logger.info("Unregistering Gateway: " + gateway.toShortString()); getGateways().remove(gateway.getGatewayId()); if ((getStatus() == Status.Started) || (gateway.getStatus() == AbstractGateway.Status.Started)) { logger.info("Stopping gateway: " + gateway.getGatewayId()); boolean startStatus = gateway.stop(); if (!startStatus) logger.warn(String.format("Gateway %s did not stop!", gateway.getGatewayId())); return startStatus; } return true; } }
public boolean stop() { boolean allStopped = true; synchronized (this._LOCK_) { if (getStatus() == Status.Started) { setStatus(Status.Stopping); logger.info("Service stopping..."); for (AbstractGateway gateway : this.gateways.values()) { logger.info("Stopping gateway: " + gateway.getGatewayId()); allStopped &= gateway.stop(); } this.serviceMessageDispatcher.cancel(); try { this.serviceMessageDispatcher.join(); } catch (InterruptedException e) { logger.error("Unhandled exception!", e); } setStatus(Status.Stopped); if (allStopped) logger.info("Service stopped."); else logger.warn("Service stopped, but some gateways did not stop!"); } } return allStopped; }
public boolean registerGateway(AbstractGateway gateway) { synchronized (this._LOCK_) { logger.info("Registering Gateway: " + gateway.toShortString()); getGateways().put(gateway.getGatewayId(), gateway); if (getStatus() == Status.Started) { logger.info("Starting gateway: " + gateway.getGatewayId()); boolean startStatus = gateway.start(); if (!startStatus) { logger.warn(String.format("Gateway %s did not start!", gateway.getGatewayId())); getGateways().remove(gateway.getGatewayId()); } return startStatus; } return true; } }
synchronized (this._LOCK_) if (getStatus() == Status.Stopped)
if (getStatus() == Status.Stopped)
public boolean send(OutboundMessage message) if (getStatus() == Status.Started)
p.println("<tr><td>Status</td><td>Uptime</td><td>Callback Queue</td><td>Message Queue</td><td>Received</td><td>Sent</td><td>Failed</td><td>Failures</td><td>Sending Rate</td></tr>"); p.println("<tbody>"); p.println(String.format("<tr><td>%s</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%f m/s</td></tr>", formatStatus(Service.getInstance().getStatus()), formatUpTime(Service.getInstance().getStatistics().getStartTime()), Service.getInstance().getCallbackManager().getQueueLoad(), Service.getInstance().getAllQueueLoad(), Service.getInstance().getStatistics().getTotalReceived(), Service.getInstance().getStatistics().getTotalSent(), Service.getInstance().getStatistics().getTotalFailed(), Service.getInstance().getStatistics().getTotalFailures(), getSendingRate(Service.getInstance().getStatistics().getStartTime(), Service.getInstance().getStatistics().getTotalSent()))); p.println("</table>"); p.println("<h3>Gateway information</h3>");