use of com.bonree.brfs.disknode.server.handler.FileLengthMessageHandler in project BRFS by zhangnianli.
the class EmptyMain method start.
@Override
public void start() throws Exception {
LOG.info("Empty Main--port[{}]", httpConfig.getPort());
createRootDirIfNeeded(diskContext.getRootDir());
RecordCollectionManager recorderManager = new RecordCollectionManager();
writerManager = new FileWriterManager(recorderManager);
writerManager.start();
writerManager.rebuildFileWriterbyDir(diskContext.getRootDir());
server = new NettyHttpServer(httpConfig);
requestHandlerExecutor = Executors.newFixedThreadPool(Configs.getConfiguration().GetConfig(DataNodeConfigs.CONFIG_REQUEST_HANDLER_NUM), new PooledThreadFactory("request_handler"));
FileFormater fileFormater = new SimpleFileFormater(Configs.getConfiguration().GetConfig(DataNodeConfigs.CONFIG_FILE_MAX_CAPACITY));
NettyHttpRequestHandler requestHandler = new NettyHttpRequestHandler(requestHandlerExecutor);
requestHandler.addMessageHandler("PUT", new OpenMessageHandler(diskContext, writerManager));
requestHandler.addMessageHandler("POST", new WriteMessageHandler(diskContext, writerManager, fileFormater));
requestHandler.addMessageHandler("GET", new ReadMessageHandler(diskContext, fileFormater));
requestHandler.addMessageHandler("CLOSE", new CloseMessageHandler(diskContext, writerManager, fileFormater));
requestHandler.addMessageHandler("DELETE", new DeleteMessageHandler(diskContext, writerManager));
server.addContextHandler(DiskContext.URI_DISK_NODE_ROOT, requestHandler);
NettyHttpRequestHandler flushRequestHandler = new NettyHttpRequestHandler(requestHandlerExecutor);
flushRequestHandler.addMessageHandler("POST", new FlushMessageHandler(diskContext, writerManager));
server.addContextHandler(DiskContext.URI_FLUSH_NODE_ROOT, flushRequestHandler);
NettyHttpRequestHandler sequenceRequestHandler = new NettyHttpRequestHandler(requestHandlerExecutor);
sequenceRequestHandler.addMessageHandler("GET", new FileLengthMessageHandler(diskContext, writerManager, fileFormater));
server.addContextHandler(DiskContext.URI_LENGTH_NODE_ROOT, sequenceRequestHandler);
NettyHttpRequestHandler listRequestHandler = new NettyHttpRequestHandler(requestHandlerExecutor);
listRequestHandler.addMessageHandler("GET", new ListMessageHandler(diskContext));
server.addContextHandler(DiskContext.URI_LIST_NODE_ROOT, listRequestHandler);
NettyHttpRequestHandler recoverRequestHandler = new NettyHttpRequestHandler(requestHandlerExecutor);
recoverRequestHandler.addMessageHandler("POST", new RecoveryMessageHandler(diskContext, serviceManager, writerManager, fileFormater));
server.addContextHandler(DiskContext.URI_RECOVER_NODE_ROOT, recoverRequestHandler);
NettyHttpRequestHandler pingRequestHandler = new NettyHttpRequestHandler(requestHandlerExecutor);
pingRequestHandler.addMessageHandler("GET", new PingPongRequestHandler());
server.addContextHandler(DiskContext.URI_PING_PONG_ROOT, pingRequestHandler);
server.start();
}
Aggregations