Package winstone

Examples of winstone.WinstoneSession


                    sessionId, ipPort, this.controlPort);
            searchThreads.add(search);
        }

        // Wait until we get an answer
        WinstoneSession answer = null;
        String senderThread = null;
        boolean finished = false;
        while (!finished) {
            // Loop through all search threads. If finished, exit, otherwise
            // sleep
            List finishedThreads = new ArrayList();
            for (Iterator i = searchThreads.iterator(); i.hasNext();) {
                ClusterSessionSearch searchThread = (ClusterSessionSearch) i
                        .next();
                if (!searchThread.isFinished())
                    continue;
                else if (searchThread.getResult() == null)
                    finishedThreads.add(searchThread);
                else {
                    answer = searchThread.getResult();
                    senderThread = searchThread.getAddressPort();
                }
            }

            // Remove finished threads
            for (Iterator i = finishedThreads.iterator(); i.hasNext();)
                searchThreads.remove(i.next());

            if (searchThreads.isEmpty() || (answer != null))
                finished = true;
            else
                try {
                    Thread.sleep(100);
                } catch (InterruptedException err) {
                }
        }

        // Once we have an answer, terminate all search threads
        for (Iterator i = searchThreads.iterator(); i.hasNext();) {
            ClusterSessionSearch searchThread = (ClusterSessionSearch) i.next();
            searchThread.destroy();
        }
        if (answer != null) {
            answer.activate(webAppConfig);
            Logger.log(Logger.DEBUG, CLUSTER_RESOURCES,
                    "SimpleCluster.SessionTransferredFrom", senderThread);
        }
        return answer;
    }
View Full Code Here


        WebAppConfiguration webAppConfig = hostConfig.getWebAppByURI(webAppPrefix);
        ObjectOutputStream outData = new ObjectOutputStream(out);
        if (webAppConfig == null) {
            outData.writeUTF(ClusterSessionSearch.SESSION_NOT_FOUND);
        } else {
            WinstoneSession session = webAppConfig.getSessionById(sessionId, true);
            if (session != null) {
                outData.writeUTF(ClusterSessionSearch.SESSION_FOUND);
                outData.writeObject(session);
                outData.flush();
                if (inControl.readUTF().equals(
                        ClusterSessionSearch.SESSION_RECEIVED))
                    session.passivate();
                Logger.log(Logger.DEBUG, CLUSTER_RESOURCES,
                        "SimpleCluster.SessionTransferredTo", ipPortSender);
            } else {
                outData.writeUTF(ClusterSessionSearch.SESSION_NOT_FOUND);
            }
View Full Code Here

            outControl.flush();
            InputStream in = controlConnection.getInputStream();
            ObjectInputStream inSession = new ObjectInputStream(in);
            String reply = inSession.readUTF();
            if ((reply != null) && reply.equals(SESSION_FOUND)) {
                WinstoneSession session = (WinstoneSession) inSession
                        .readObject();
                outControl.writeUTF(SESSION_RECEIVED);
                this.result = session;
            }
            outControl.close();
View Full Code Here

TOP

Related Classes of winstone.WinstoneSession

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.