Package org.apache.http.nio.reactor

Examples of org.apache.http.nio.reactor.IOSession


            }
            if (key.isWritable()) {
                writable(key);
            }
        } catch (CancelledKeyException ex) {
            IOSession session = keyCancelled(key);
            if (session != null) {
                this.closedSessions.push(session);
            }
            key.attach(null);
        }
View Full Code Here


            } catch (IOException ex) {
                throw new IOReactorException("Failure registering channel " +
                        "with the selector", ex);
            }

            IOSession session = new IOSessionImpl(key, new SessionClosedCallback() {

                public void sessionClosed(IOSession session) {
                    closedSessions.push(session);
                }
               
            });
           
            int timeout = 0;
            try {
                timeout = channel.socket().getSoTimeout();
            } catch (IOException ex) {
                // Very unlikely to happen and is not fatal
                // as the protocol layer is expected to overwrite
                // this value anyways
            }
           
            session.setAttribute(IOSession.ATTACHMENT_KEY, entry.getAttachment());
            session.setSocketTimeout(timeout);
            this.sessions.add(session);
            keyCreated(key, session);

            try {
                this.eventDispatch.connected(session);
View Full Code Here

            }
        }
    }

    private void processClosedSessions() {
        IOSession session;
        while ((session = this.closedSessions.pop()) != null) {
            if (this.sessions.remove(session)) {
                this.eventDispatch.disconnected(session);
            }
        }
View Full Code Here

        }
    }

    private void closeSessions() {
        for (Iterator it = this.sessions.iterator(); it.hasNext(); ) {
            IOSession session = (IOSession) it.next();
            if (!session.isClosed()) {   

                session.close();
                this.eventDispatch.disconnected(session);
            }
        }
        this.sessions.clear();
    }
View Full Code Here

        return callback;
    }

    public E completed(final SessionRequest request) {
        PoolEntryCallback<T, E> callback = removeRequest(request);
        IOSession iosession = request.getSession();
        E entry = this.factory.createEntry(this.route, iosession);
        this.leasedSessions.add(entry);
        callback.completed(entry);
        return entry;
    }
View Full Code Here

                RouteSpecificPool<T, E> pool = getPool(entry.getRoute());
                pool.freeEntry(entry, reusable);
                if (reusable) {
                    this.availableSessions.add(entry);
                } else {
                    IOSession iosession = entry.getIOSession();
                    iosession.close();
                }
                processPendingRequests();
            }
        } finally {
            this.lock.unlock();
View Full Code Here

            for (;;) {
                entry = pool.getFreeEntry(state);
                if (entry == null) {
                    break;
                }
                IOSession iosession = entry.getIOSession();
                if (entry.isExpired(System.currentTimeMillis())) {
                    iosession.close();
                }
                if (iosession.isClosed()) {
                    this.availableSessions.remove(entry);
                    pool.freeEntry(entry, false);
                } else {
                    break;
                }
View Full Code Here

    }

    private void dropLastUsed() {
        if (!this.availableSessions.isEmpty()) {
            E entry = this.availableSessions.removeFirst();
            IOSession iosession = entry.getIOSession();
            iosession.close();
            RouteSpecificPool<T, E> pool = getPool(entry.getRoute());
            pool.remove(entry);
        }
    }
View Full Code Here

        try {
            Iterator<E> it = this.availableSessions.iterator();
            while (it.hasNext()) {
                E entry = it.next();
                if (entry.getUpdated() <= deadline) {
                    IOSession iosession = entry.getIOSession();
                    iosession.close();
                    RouteSpecificPool<T, E> pool = getPool(entry.getRoute());
                    pool.remove(entry);
                    it.remove();
                }
            }
View Full Code Here

        try {
            Iterator<E> it = this.availableSessions.iterator();
            while (it.hasNext()) {
                E entry = it.next();
                if (entry.isExpired(now)) {
                    IOSession iosession = entry.getIOSession();
                    iosession.close();
                    RouteSpecificPool<T, E> pool = getPool(entry.getRoute());
                    pool.remove(entry);
                    it.remove();
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.http.nio.reactor.IOSession

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.