Skip to content

Commit

Permalink
#9, shutdown method
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrinot committed Jul 2, 2013
1 parent be23149 commit 09d0be0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public void bootStrap() {
if (myLogger.isLoggable(Level.INFO))
myLogger.info("Bootstrapped Memcached server on port " + myPort + " backed by named cache " + myNamedCache);
}

public void shutdown() {
channelFactory.releaseExternalResources();
CacheFactory.shutdown();
}

public NamedCache getCache() {
return myCache;
Expand All @@ -98,16 +103,18 @@ void bootStrapCache() {
void bootStrapSocketServer() {
OperationFactory operationFactory = new OperationFactory(myCache);

ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool());
ServerBootstrap bootstrap = new ServerBootstrap(factory);
channelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool());
ServerBootstrap bootstrap = new ServerBootstrap(channelFactory);
bootstrap.setPipelineFactory(new MemcachedPipelineFactory(operationFactory));
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.bind(new InetSocketAddress(myPort));
}

private Logger myLogger = Logger.getLogger(this.getClass().getName());
private int myPort;
private String myNamedCache;
private NamedCache myCache;

private ChannelFactory channelFactory;
}

0 comments on commit 09d0be0

Please sign in to comment.