Package com.asakusafw.windgate.core.session

Examples of com.asakusafw.windgate.core.session.SessionMirror


     * Check the session ID.
     * @throws Exception if failed
     */
    @Test
    public void getId() throws Exception {
        SessionMirror session = provider.create("testing");
        try {
            assertThat(session.getId(), is("testing"));
        } finally {
            session.close();
        }
    }
View Full Code Here


     * Completes the session.
     * @throws Exception if failed
     */
    @Test
    public void complete() throws Exception {
        SessionMirror session = provider.create("testing");
        session.complete();
        SessionMirror reopen = provider.create("testing");
        reopen.close();
    }
View Full Code Here

     * Aborts the session.
     * @throws Exception if failed
     */
    @Test
    public void abort() throws Exception {
        SessionMirror session = provider.create("testing");
        session.abort();
        SessionMirror reopen = provider.create("testing");
        reopen.close();
    }
View Full Code Here

    @Override
    public void delete(String id) throws IOException {
        assert id != null;
        LOG.debug("Deleting session: {}", id);
        SessionMirror session = attach(id, false, true);
        session.abort();
    }
View Full Code Here

        }
    }

    private boolean doAbortSingle(String targetSessionId) throws IOException {
        assert targetSessionId != null;
        SessionMirror session;
        try {
            WGLOG.info("I01001",
                    targetSessionId,
                    profile.getName());
            if (RuntimeContext.get().canExecute(sessionProvider)) {
                session = sessionProvider.open(targetSessionId);
            } else {
                session = new SessionMirror.Null(targetSessionId);
            }
        } catch (SessionException e) {
            if (e.getReason() == Reason.NOT_EXIST) {
                WGLOG.info("I01002",
                        targetSessionId,
                        profile.getName());
                return false;
            }
            throw e;
        }
        try {
            WGLOG.info("I01003",
                    targetSessionId,
                    profile.getName());
            int failureCount = 0;
            for (Map.Entry<String, ResourceProvider> entry : resourceProviders.entrySet()) {
                String name = entry.getKey();
                ResourceProvider provider = entry.getValue();
                LOG.debug("Attempting to abort resource {} (session={})",
                        name,
                        targetSessionId);
                try {
                    if (RuntimeContext.get().isSimulation() == false) {
                        provider.abort(session.getId());
                    }
                } catch (IOException e) {
                    failureCount++;
                    WGLOG.warn(e, "W01002",
                            targetSessionId,
                            profile.getName(),
                            name);
                }
            }
            if (failureCount > 0) {
                throw new IOException(MessageFormat.format(
                        "Failed to abort some resources for the session \"{0}\"",
                        targetSessionId));
            }
            WGLOG.info("I01004",
                    targetSessionId,
                    profile.getName());
            session.abort();
            return true;
        } finally {
            try {
                session.close();
            } catch (IOException e) {
                WGLOG.warn(e, "W01003",
                        targetSessionId,
                        profile.getName());
            }
View Full Code Here

        try {
            WGLOG.info("I00001",
                    sessionId,
                    profile.getName(),
                    script.getName());
            SessionMirror session = attachSession(createSession);
            try {
                WGLOG.info("I00002",
                        sessionId,
                        profile.getName(),
                        script.getName());
                List<ResourceMirror> resources = createResources();
                if (createSession) {
                    WGLOG.info("I00003",
                            sessionId,
                            profile.getName(),
                            script.getName());
                    fireSessionCreated(resources);
                }
                WGLOG.info("I00004",
                        sessionId,
                        profile.getName(),
                        script.getName());
                prepareResources(resources);
                WGLOG.info("I00005",
                        sessionId,
                        profile.getName(),
                        script.getName());
                runGateProcesses(resources);
                if (completeSession) {
                    WGLOG.info("I00006",
                            sessionId,
                            profile.getName(),
                            script.getName());
                    fireSessionCompleted(resources);
                    WGLOG.info("I00007",
                            sessionId,
                            profile.getName(),
                            script.getName());
                    session.complete();
                }
            } finally {
                try {
                    session.close();
                } catch (IOException e) {
                    WGLOG.warn(e, "W00001",
                            sessionId,
                            profile.getName(),
                            script.getName());
View Full Code Here

TOP

Related Classes of com.asakusafw.windgate.core.session.SessionMirror

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.