/** * Change thread ownership of a connection or upgrade weight. * * @param connection : connection which has to be transfered from the main selector thread to a * new worker comm thread that has the least weight. If the connection is already managed by a * comm thread, then just update connection's weight. * @param addWeightBy : upgrade weight of connection * @param channel : SocketChannel for the passed in connection */ public void addWeight( final TCConnectionImpl connection, final int addWeightBy, final SocketChannel channel) { synchronized (managedConnectionsMap) { // this connection is already handled by a WorkerComm if (this.managedConnectionsMap.containsKey(connection)) { this.clientWeights += addWeightBy; this.managedConnectionsMap.put( connection, this.managedConnectionsMap.get(connection) + addWeightBy); return; } } // MainComm Thread if (workerCommMgr == null) { return; } readerComm.unregister(channel); final CoreNIOServices workerComm = workerCommMgr.getNextWorkerComm(); connection.setCommWorker(workerComm); workerComm.addConnection(connection, addWeightBy); workerComm.requestReadWriteInterest(connection, channel); }