/** Prints usage */ public static void usage() { System.out.println("Tribes MapDemo."); System.out.println( "Usage:\n\t" + "java MapDemo [channel options] mapName\n\t" + "\tChannel options:" + ChannelCreator.usage()); }
public FutureDone<Void> close() { // cc is not null if we opened the connection if (cc != null) { FutureDone<Void> future = cc.shutdown(); // Maybe done on arrival? Set close future in any case future.addListener( new BaseFutureAdapter<FutureDone<Void>>() { @Override public void operationComplete(FutureDone<Void> future) throws Exception { closeFuture.setDone(); } }); } else { // cc is null if its an incoming connection. We can close it here, or it will be closed when // the dispatcher // is shutdown channelFuture.channel().close(); } return closeFuture; }
/** * 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); }