Search in sources :

Example 1 with ReadMessageHandler

use of com.bonree.brfs.disknode.server.handler.impl.ReadMessageHandler in project BRFS by zhangnianli.

the class Test method main.

public static void main(String[] args) throws Exception {
    int port = 8899;
    if (args.length > 0) {
        port = Integer.parseInt(args[0]);
    }
    JettyDiskNodeHttpServer s = new JettyDiskNodeHttpServer(port);
    DiskWriterManager nodeManager = new DiskWriterManager();
    nodeManager.start();
    DiskJettyHttpRequestHandler httpRequestHandler = new DiskJettyHttpRequestHandler();
    httpRequestHandler.put(DiskOperation.OP_OPEN, new OpenMessageHandler(nodeManager));
    httpRequestHandler.put(DiskOperation.OP_WRITE, new WriteMessageHandler(nodeManager));
    httpRequestHandler.put(DiskOperation.OP_READ, new ReadMessageHandler());
    httpRequestHandler.put(DiskOperation.OP_CLOSE, new CloseMessageHandler(nodeManager));
    httpRequestHandler.put(DiskOperation.OP_DELETE, new DeleteMessageHandler(nodeManager));
    ContextHandler handler = new ContextHandler("/disk");
    handler.setHandler(httpRequestHandler);
    // handler.setHandler(new AbstractHandler() {
    // 
    // @Override
    // public void handle(String target, Request baseRequest,
    // HttpServletRequest request, HttpServletResponse response)
    // throws IOException, ServletException {
    // System.out.println("length=" + request.getContentLength());
    // int contentLength = request.getContentLength();
    // System.out.println("content length############" + contentLength);
    // byte[] data = new byte[Math.max(contentLength, 0)];
    // if(request.getContentLength() > 0) {
    // InputUtils.readBytes(request.getInputStream(), data, 0, data.length);
    // 
    // System.out.println(new String(data));
    // }
    // baseRequest.setHandled(true);
    // }
    // });
    s.addContextHandler(handler);
    s.start();
    System.out.println("####################SERVER STARTED#####################");
}
Also used : ContextHandler(org.eclipse.jetty.server.handler.ContextHandler) NettyHttpContextHandler(com.bonree.brfs.disknode.server.netty.NettyHttpContextHandler) CloseMessageHandler(com.bonree.brfs.disknode.server.handler.impl.CloseMessageHandler) DiskWriterManager(com.bonree.brfs.disknode.DiskWriterManager) ReadMessageHandler(com.bonree.brfs.disknode.server.handler.impl.ReadMessageHandler) DeleteMessageHandler(com.bonree.brfs.disknode.server.handler.impl.DeleteMessageHandler) WriteMessageHandler(com.bonree.brfs.disknode.server.handler.impl.WriteMessageHandler) OpenMessageHandler(com.bonree.brfs.disknode.server.handler.impl.OpenMessageHandler)

Example 2 with ReadMessageHandler

use of com.bonree.brfs.disknode.server.handler.impl.ReadMessageHandler in project BRFS by zhangnianli.

the class Test method main.

public static void main(String[] args) throws Exception {
    int port = 8899;
    if (args.length > 0) {
        port = Integer.parseInt(args[0]);
    }
    NettyHttpServer s = new NettyHttpServer(port);
    DiskWriterManager nodeManager = new DiskWriterManager();
    nodeManager.start();
    DiskNettyHttpRequestHandler diskHttpRequestHandler = new DiskNettyHttpRequestHandler();
    diskHttpRequestHandler.put(DiskOperation.OP_OPEN, new OpenMessageHandler(nodeManager));
    diskHttpRequestHandler.put(DiskOperation.OP_WRITE, new WriteMessageHandler(nodeManager));
    diskHttpRequestHandler.put(DiskOperation.OP_READ, new ReadMessageHandler());
    diskHttpRequestHandler.put(DiskOperation.OP_CLOSE, new CloseMessageHandler(nodeManager));
    diskHttpRequestHandler.put(DiskOperation.OP_DELETE, new DeleteMessageHandler(nodeManager));
    s.addContextHandler(new NettyHttpContextHandler("/disk", diskHttpRequestHandler));
    s.start();
}
Also used : CloseMessageHandler(com.bonree.brfs.disknode.server.handler.impl.CloseMessageHandler) DiskWriterManager(com.bonree.brfs.disknode.DiskWriterManager) ReadMessageHandler(com.bonree.brfs.disknode.server.handler.impl.ReadMessageHandler) DeleteMessageHandler(com.bonree.brfs.disknode.server.handler.impl.DeleteMessageHandler) WriteMessageHandler(com.bonree.brfs.disknode.server.handler.impl.WriteMessageHandler) DiskNettyHttpRequestHandler(com.bonree.brfs.disknode.server.handler.impl.DiskNettyHttpRequestHandler) OpenMessageHandler(com.bonree.brfs.disknode.server.handler.impl.OpenMessageHandler)

Aggregations

DiskWriterManager (com.bonree.brfs.disknode.DiskWriterManager)2 CloseMessageHandler (com.bonree.brfs.disknode.server.handler.impl.CloseMessageHandler)2 DeleteMessageHandler (com.bonree.brfs.disknode.server.handler.impl.DeleteMessageHandler)2 OpenMessageHandler (com.bonree.brfs.disknode.server.handler.impl.OpenMessageHandler)2 ReadMessageHandler (com.bonree.brfs.disknode.server.handler.impl.ReadMessageHandler)2 WriteMessageHandler (com.bonree.brfs.disknode.server.handler.impl.WriteMessageHandler)2 DiskNettyHttpRequestHandler (com.bonree.brfs.disknode.server.handler.impl.DiskNettyHttpRequestHandler)1 NettyHttpContextHandler (com.bonree.brfs.disknode.server.netty.NettyHttpContextHandler)1 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)1