Beispiel #1
0
 @Override
 public void run() {
   System.out.println("Shutting down...");
   // create an exit thread that forces a shutdown if the JVM wont exit cleanly
   SystemExit exit = new SystemExit(5000);
   exit.setDaemon(true);
   exit.start();
   try {
     // stop the channel
     channel.stop(Channel.DEFAULT);
   } catch (Exception x) {
     x.printStackTrace();
   }
   System.out.println("Channel stopped.");
 }
Beispiel #2
0
  /**
   * Main method
   *
   * @param args
   * @throws Exception
   */
  @SuppressWarnings("unused")
  public static void main(String[] args) throws Exception {
    long start = System.currentTimeMillis();
    // create a channel object
    ManagedChannel channel = (ManagedChannel) ChannelCreator.createChannel(args);
    // define a map name, unless one is defined as a paramters
    String mapName = "MapDemo";
    if (args.length > 0 && (!args[args.length - 1].startsWith("-"))) {
      mapName = args[args.length - 1];
    }
    // start the channel
    channel.start(Channel.DEFAULT);
    // listen for shutdown
    Runtime.getRuntime().addShutdownHook(new Shutdown(channel));
    // create a map demo object
    new MapDemo(channel, mapName);

    // put the main thread to sleep until we are done
    System.out.println(
        "System test complete, time to start="
            + (System.currentTimeMillis() - start)
            + " ms. Sleeping to let threads finish.");
    Thread.sleep(60 * 1000 * 60);
  }