Example #1
0
  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.");
  }
Example #2
0
 public boolean cancel(AsyncChannelRunner runner) {
   if (gravityPool == null) {
     runner.reset();
     throw new NullPointerException("Gravity not started or pool disabled");
   }
   return gravityPool.remove(runner);
 }
Example #3
0
 public void execute(AsyncChannelRunner runner) {
   if (gravityPool == null) {
     runner.reset();
     throw new NullPointerException("Gravity not started or pool disabled");
   }
   gravityPool.execute(runner);
 }
Example #4
0
 public int getQueueSize() {
   if (gravityPool != null) return gravityPool.getQueueSize();
   return 0;
 }
Example #5
0
 public int getQueueRemainingCapacity() {
   if (gravityPool != null) return gravityPool.getQueueRemainingCapacity();
   return gravityConfig.getQueueCapacity();
 }
Example #6
0
 public void setMaximumPoolSize(int maximumPoolSize) {
   gravityConfig.setMaximumPoolSize(maximumPoolSize);
   if (gravityPool != null) gravityPool.setMaximumPoolSize(maximumPoolSize);
 }
Example #7
0
 public int getMaximumPoolSize() {
   if (gravityPool != null) return gravityPool.getMaximumPoolSize();
   return gravityConfig.getMaximumPoolSize();
 }
Example #8
0
 public void setKeepAliveTimeMillis(long keepAliveTimeMillis) {
   gravityConfig.setKeepAliveTimeMillis(keepAliveTimeMillis);
   if (gravityPool != null) gravityPool.setKeepAliveTimeMillis(keepAliveTimeMillis);
 }
Example #9
0
 public long getKeepAliveTimeMillis() {
   if (gravityPool != null) return gravityPool.getKeepAliveTimeMillis();
   return gravityConfig.getKeepAliveTimeMillis();
 }
Example #10
0
 public void setCorePoolSize(int corePoolSize) {
   gravityConfig.setCorePoolSize(corePoolSize);
   if (gravityPool != null) gravityPool.setCorePoolSize(corePoolSize);
 }
Example #11
0
 public void reconfigure(GravityConfig gravityConfig, GraniteConfig graniteConfig) {
   this.gravityConfig = gravityConfig;
   this.graniteConfig = graniteConfig;
   if (gravityPool != null) gravityPool.reconfigure(gravityConfig);
 }