View Javadoc

1   /**
2    *  Copyright 2003-2006 Greg Luck
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.ehcache.distribution;
18  
19  import net.sf.ehcache.Cache;
20  import net.sf.ehcache.CacheManager;
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  
24  /**
25   * A distributed testing tool for manual distributed testing of ehcache on cluster nodes.
26   * <p/>
27   * It is passed the ehcache configuration to use and cache to monitor
28   *
29   *
30   * @author Greg Luck
31   * @version $Id: Main.java 48 2006-04-23 00:37:13Z gregluck $
32   */
33  public final class Main {
34      private static final int TWO_SECONDS = 2000;
35  
36      private static final Log LOG = LogFactory.getLog(Main.class.getName());
37  
38      /**
39       * Utility class. No constructor
40       */
41      private Main() {
42          //noop
43      }
44  
45  
46      /**
47       * Distributed
48       * @param args
49       */
50      public static void main(String[] args) throws InterruptedException {
51  
52          if (args.length != 1) {
53              LOG.info("Usage: java -jar ehcache-test.jar path_to_ehcache.xml cacheToMonitor");
54          }
55  
56          CacheManager manager = new CacheManager(args[0]);
57  
58          Cache cache = manager.getCache(args[1]);
59          LOG.info(args[1] + " " + cache);
60  
61          while (true) {
62  
63              Thread.sleep(TWO_SECONDS);
64              LOG.info("Cache size: " + cache.getSize());
65  
66          }
67      }
68  }