/** * Start collecting stats for the {@link org.apache.mina.common.IoSession} of the service. * New sessions or destroyed will be automaticly added or removed. */ public void start() { synchronized (this) { if ( worker != null && worker.isAlive() ) throw new RuntimeException( "Stat collecting already started" ); // add all current sessions polledSessions = new ConcurrentLinkedQueue<>(); Map<Long, IoSession> sessions = service.getManagedSessions(); if (sessions != null) { for (IoSession ioSession : sessions.values()) { addSession(ioSession); } } // listen for new ones service.addListener( serviceListener ); // start polling worker = new Worker(); worker.start(); } }
/** * Start collecting stats for the {@link org.apache.mina.common.IoSession} of the service. * New sessions or destroyed will be automaticly added or removed. */ public void start() { synchronized (this) { if ( worker != null && worker.isAlive() ) throw new RuntimeException( "Stat collecting already started" ); // add all current sessions polledSessions = new ConcurrentLinkedQueue<>(); Map<Long, IoSession> sessions = service.getManagedSessions(); if (sessions != null) { for (IoSession ioSession : sessions.values()) { addSession(ioSession); } } // listen for new ones service.addListener( serviceListener ); // start polling worker = new Worker(); worker.start(); } }