public void stop(boolean now) throws Exception { log.info("Stopping Gravity (now=%s)...", now); synchronized (this) { if (adapterFactory != null) { try { adapterFactory.stopAll(); } catch (Exception e) { log.error(e, "Error while stopping adapter factory"); } adapterFactory = null; } if (serverChannel != null) { try { removeChannel(serverChannel.getId(), false); } catch (Exception e) { log.error(e, "Error while removing server channel: %s", serverChannel); } serverChannel = null; } if (channelsTimer != null) { try { channelsTimer.cancel(); } catch (Exception e) { log.error(e, "Error while cancelling channels timer"); } channelsTimer = null; } if (gravityPool != null) { try { if (now) gravityPool.shutdownNow(); else gravityPool.shutdown(); } catch (Exception e) { log.error(e, "Error while stopping thread pool"); } gravityPool = null; } if (udpReceiverFactory != null) { try { udpReceiverFactory.stop(); } catch (Exception e) { log.error(e, "Error while stopping udp receiver factory"); } udpReceiverFactory = null; } started = false; } log.info("Gravity sucessfully stopped."); }
public boolean cancel(AsyncChannelRunner runner) { if (gravityPool == null) { runner.reset(); throw new NullPointerException("Gravity not started or pool disabled"); } return gravityPool.remove(runner); }
public void execute(AsyncChannelRunner runner) { if (gravityPool == null) { runner.reset(); throw new NullPointerException("Gravity not started or pool disabled"); } gravityPool.execute(runner); }
public int getQueueSize() { if (gravityPool != null) return gravityPool.getQueueSize(); return 0; }
public int getQueueRemainingCapacity() { if (gravityPool != null) return gravityPool.getQueueRemainingCapacity(); return gravityConfig.getQueueCapacity(); }
public void setMaximumPoolSize(int maximumPoolSize) { gravityConfig.setMaximumPoolSize(maximumPoolSize); if (gravityPool != null) gravityPool.setMaximumPoolSize(maximumPoolSize); }
public int getMaximumPoolSize() { if (gravityPool != null) return gravityPool.getMaximumPoolSize(); return gravityConfig.getMaximumPoolSize(); }
public void setKeepAliveTimeMillis(long keepAliveTimeMillis) { gravityConfig.setKeepAliveTimeMillis(keepAliveTimeMillis); if (gravityPool != null) gravityPool.setKeepAliveTimeMillis(keepAliveTimeMillis); }
public long getKeepAliveTimeMillis() { if (gravityPool != null) return gravityPool.getKeepAliveTimeMillis(); return gravityConfig.getKeepAliveTimeMillis(); }
public void setCorePoolSize(int corePoolSize) { gravityConfig.setCorePoolSize(corePoolSize); if (gravityPool != null) gravityPool.setCorePoolSize(corePoolSize); }
public void reconfigure(GravityConfig gravityConfig, GraniteConfig graniteConfig) { this.gravityConfig = gravityConfig; this.graniteConfig = graniteConfig; if (gravityPool != null) gravityPool.reconfigure(gravityConfig); }