private void terminate(){
        int workerId;
        Message tmntCommand = new Message(Message.msgType.COMMAND);
        tmntCommand.setCommandId(CommandType.SHUTDOWN);
        Set<Integer> workerIdSet = processServerMap.keySet();
        Iterator<Integer> workerIterator= workerIdSet.iterator();
        /*shut down the worker node*/
        while(workerIterator.hasNext()){
            workerId = workerIterator.next();
            try{
                processServerMap.get(workerId).sendToWorker(tmntCommand);
                processServerMap.get(workerId).stop();
            }catch (IOException e) {
                processServerMap.get(workerId).stop();
                //e.printStackTrace();
                System.out.println("shutdown Command sent failed, remove worker "+workerId);
                removeNode(workerId);
            }
            
        }
        /*shut down the console and connection server*/
        try{
            console.close();
        }catch(IOException e){
            
        }
        connServer.stop();
        
    }