コード例 #1
1
ファイル: JolokiaServer.java プロジェクト: rhuss/jolokia
  /**
   * Start this server. If we manage an own HttpServer, then the HttpServer will be started as well.
   */
  public void start() {
    // URL as configured takes precedence
    String configUrl =
        NetworkUtil.replaceExpression(config.getJolokiaConfig().get(ConfigKey.DISCOVERY_AGENT_URL));
    jolokiaHttpHandler.start(
        lazy, configUrl != null ? configUrl : url, config.getAuthenticator() != null);

    if (httpServer != null) {
      // Starting our own server in an own thread group with a fixed name
      // so that the cleanup thread can recognize it.
      ThreadGroup threadGroup = new ThreadGroup("jolokia");
      threadGroup.setDaemon(false);

      Thread starterThread =
          new Thread(
              threadGroup,
              new Runnable() {
                @Override
                public void run() {
                  httpServer.start();
                }
              });
      starterThread.start();
      cleaner = new CleanupThread(httpServer, threadGroup);
      cleaner.start();
    }
  }
コード例 #2
0
ファイル: Cleanser.java プロジェクト: gpmidi/BigBrother
 /**
  * Start the cleaner thread and pray to God it finishes.
  *
  * @param player Person to blame for the lag. Or null.
  */
 public static void clean(Player player) {
   if (cleanupThread != null && cleanupThread.done) {
     cleanupThread = null;
   }
   if (cleanupThread == null || !cleanupThread.isAlive()) {
     cleanupThread = new CleanupThread(player);
     cleanupThread.start();
   } else {
     if (player != null)
       player.chat(BigBrother.premessage + " Cleaner already busy.  Try again later.");
   }
 }
コード例 #3
0
ファイル: JolokiaServer.java プロジェクト: rhuss/jolokia
  /** Stop the HTTP server */
  public void stop() {
    jolokiaHttpHandler.stop();

    if (cleaner != null) {
      cleaner.stopServer();
    }
  }
コード例 #4
0
 public void destroy() {
   try {
     if (cleanupThread != null) {
       cleanupThread.stopThread();
     }
   } finally {
     isDestroyed = true;
   }
 }
コード例 #5
0
 @Override
 protected void finalize() throws Throwable {
   adapterCleanupThread.stopCleaner();
   for (ResourceSet rs : resourceSets.keySet()) {
     if (rs != null && adapter != null) {
       rs.eAdapters().remove(adapter);
     }
   }
   super.finalize();
 }
コード例 #6
0
 public ConcurrentLRUCache(
     int upperWaterMark,
     final int lowerWaterMark,
     int acceptableWatermark,
     int initialSize,
     boolean runCleanupThread,
     boolean runNewThreadForCleanup,
     EvictionListener<K, V> evictionListener) {
   if (upperWaterMark < 1) throw new IllegalArgumentException("upperWaterMark must be > 0");
   if (lowerWaterMark >= upperWaterMark)
     throw new IllegalArgumentException("lowerWaterMark must be  < upperWaterMark");
   map = new ConcurrentHashMap<Object, CacheEntry>(initialSize);
   newThreadForCleanup = runNewThreadForCleanup;
   this.upperWaterMark = upperWaterMark;
   this.lowerWaterMark = lowerWaterMark;
   this.acceptableWaterMark = acceptableWatermark;
   this.evictionListener = evictionListener;
   if (runCleanupThread) {
     cleanupThread = new CleanupThread(this);
     cleanupThread.start();
   }
 }
コード例 #7
0
  public Object put(K key, V val) {
    if (val == null) return null;
    CacheEntry e = new CacheEntry(key, val, stats.accessCounter.incrementAndGet());
    CacheEntry oldCacheEntry = map.put(key, e);
    if (oldCacheEntry == null) {
      stats.size.incrementAndGet();
    }
    if (islive) {
      stats.putCounter.incrementAndGet();
    } else {
      stats.nonLivePutCounter.incrementAndGet();
    }

    // Check if we need to clear out old entries from the cache.
    // isCleaning variable is checked instead of markAndSweepLock.isLocked()
    // for performance because every put invokation will check until
    // the size is back to an acceptable level.
    //
    // There is a race between the check and the call to markAndSweep, but
    // it's unimportant because markAndSweep actually aquires the lock or returns if it can't.
    //
    // Thread safety note: isCleaning read is piggybacked (comes after) other volatile reads
    // in this method.
    if (stats.size.get() > upperWaterMark && !isCleaning) {
      if (newThreadForCleanup) {
        new Thread() {
          public void run() {
            markAndSweep();
          }
        }.start();
      } else if (cleanupThread != null) {
        cleanupThread.wakeThread();
      } else {
        markAndSweep();
      }
    }
    return oldCacheEntry == null ? null : oldCacheEntry.value;
  }
コード例 #8
0
 public EventManagerTableBased() {
   resourceSets = new WeakHashMap<ResourceSet, Object>();
   registrationManager = new RegistrationManagerTableBased();
   adapterCleanupThread = new CleanupThread(adaptersNoLongerStronglyReferenced, this);
   adapterCleanupThread.start();
 }