Package org.hypertable.AsyncComm

Examples of org.hypertable.AsyncComm.Comm


        int   workerCount;
        String configFile = null;
        String str;
        Properties props = new Properties();
        HandlerFactory handlerFactory;
        Comm comm;
        boolean verbose = false;

        if (args.length == 1 && args[0].equals("--help"))
            Usage.DumpAndExit(usage);

        for (int i=0; i<args.length; i++) {
            if (args[i].startsWith("--config="))
                configFile = args[i].substring(9);
            else if (args[i].equals("--verbose")) {
                verbose = true;
            }
            else
                Usage.DumpAndExit(usage);
        }

        ShutdownHook sh = new ShutdownHook();
        Runtime.getRuntime().addShutdownHook(sh);

        if (configFile == null)
            configFile = System.installDir + "/conf/hypertable.cfg";

        FileInputStream fis = new FileInputStream(configFile);
        props.load(fis);

        if (verbose)
            props.setProperty("verbose", "true");

        // Determine listen port
        str  = props.getProperty("HdfsBroker.Port", DEFAULT_PORT);
        port = Integer.parseInt(str);

        // Determine reactor count
        str = props.getProperty("HdfsBroker.Reactors");
        reactorCount = (str == null) ? (short)System.processorCount
                                     : Short.parseShort(str);

        // Determine worker count
        str = props.getProperty("HdfsBroker.Workers");
        workerCount = (str == null) ? (short)System.processorCount
                                    : Integer.parseInt(str);

        if (verbose) {
            java.lang.System.out.println("Num CPUs=" + System.processorCount);
            java.lang.System.out.println("HdfsBroker.Port=" + port);
            java.lang.System.out.println("HdfsBroker.Reactors=" + reactorCount);
            java.lang.System.out.println("HdfsBroker.Workers=" + workerCount);
        }

        ReactorFactory.Initialize(reactorCount);

        comm = new Comm(0);
        //Global.protocol = new Protocol();
        ms_app_queue = new ApplicationQueue(workerCount);

        ms_broker = new HdfsBroker(comm, props);
        handlerFactory = new HandlerFactory(comm, ms_app_queue, ms_broker);
        comm.Listen(port, handlerFactory, null);

        ms_app_queue.Join();
    }
View Full Code Here

TOP

Related Classes of org.hypertable.AsyncComm.Comm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.