private synchronized Worker createWorker ( int i ) throws IOException { Preconditions . checkState ( mState == State . STARTED , "Must be in a started state to create workers" ) ; File confDir = new File ( mWorkDir , "conf-worker" + i ) ; File logsDir = new File ( mWorkDir , "logs-worker" + i ) ; File ramdisk = new File ( mWorkDir , "ramdisk" + i ) ; logsDir . mkdirs ( ) ; ramdisk . mkdirs ( ) ; int rpcPort = getNewPort ( ) ; int dataPort = getNewPort ( ) ; int webPort = getNewPort ( ) ; Map < PropertyKey , String > conf = new HashMap <> ( ) ; conf . put ( PropertyKey . LOGGER_TYPE , "WORKER_LOGGER" ) ; conf . put ( PropertyKey . CONF_DIR , confDir . getAbsolutePath ( ) ) ; conf . put ( PropertyKey . Template . WORKER_TIERED_STORE_LEVEL_DIRS_PATH . format ( 0 ) , ramdisk . getAbsolutePath ( ) ) ; conf . put ( PropertyKey . LOGS_DIR , logsDir . getAbsolutePath ( ) ) ; conf . put ( PropertyKey . WORKER_RPC_PORT , Integer . toString ( rpcPort ) ) ; conf . put ( PropertyKey . WORKER_WEB_PORT , Integer . toString ( webPort ) ) ; Worker worker = mCloser . register ( new Worker ( logsDir , conf ) ) ; mWorkers . add ( worker ) ; LOG . info ( "Created worker with (rpc, data, web) ports ({}, {}, {})" , rpcPort , dataPort , webPort ) ; return worker ; }
Creates the specified worker without starting it .