Package org.jboss.as.clustering.web

Examples of org.jboss.as.clustering.web.IncomingDistributableSessionData


    }

    @SuppressWarnings("unchecked")
    private void getSessionDataNoOwner(boolean includeAttributes) throws Exception {
        String sessionId = "abc";
        IncomingDistributableSessionData data = mock(IncomingDistributableSessionData.class);

        @SuppressWarnings("rawtypes")
        ArgumentCaptor<CacheInvoker.Operation> capturedOperation = ArgumentCaptor.forClass(CacheInvoker.Operation.class);

        when(this.invoker.invoke(same(this.cache), capturedOperation.capture())).thenReturn(data);

        IncomingDistributableSessionData result = this.manager.getSessionData(sessionId, null, includeAttributes);

        assertSame(data, result);

        Map<Object, Object> map = mock(Map.class);
        Map<String, Object> attributes = Collections.emptyMap();
        Integer version = Integer.valueOf(10);
        Long timestamp = Long.valueOf(System.currentTimeMillis());
        DistributableSessionMetadata metadata = new DistributableSessionMetadata();
        CacheInvoker.Operation<String, Map<Object, Object>, IncomingDistributableSessionData> operation = capturedOperation.getValue();

        when(this.cache.get(sessionId)).thenReturn(map);
        when(map.get(Byte.valueOf((byte) SessionMapEntry.VERSION.ordinal()))).thenReturn(version);
        when(map.get(Byte.valueOf((byte) SessionMapEntry.TIMESTAMP.ordinal()))).thenReturn(timestamp);
        when(map.get(Byte.valueOf((byte) SessionMapEntry.METADATA.ordinal()))).thenReturn(metadata);

        if (includeAttributes) {
            when(this.storage.load(map)).thenReturn(attributes);
        }

        result = operation.invoke(this.cache);

        assertNotNull(result);
        assertEquals(version.intValue(), result.getVersion());
        assertEquals(timestamp.longValue(), result.getTimestamp());
        assertSame(metadata, result.getMetadata());

        if (includeAttributes) {
            assertSame(attributes, result.getSessionAttributes());
        } else {
            IllegalStateException exception = null;
            Map<String, Object> sessionAttributes = null;

            try {
                sessionAttributes = result.getSessionAttributes();
            } catch (IllegalStateException e) {
                exception = e;
            }

            assertNull(sessionAttributes);
View Full Code Here


        this.getMissingSessionDataNoOwner(false);
    }

    @SuppressWarnings("unchecked")
    private void getMissingSessionDataNoOwner(boolean includeAttributes) {
        IncomingDistributableSessionData expected = mock(IncomingDistributableSessionData.class);
        @SuppressWarnings("rawtypes")
        ArgumentCaptor<CacheInvoker.Operation> capturedOperation = ArgumentCaptor.forClass(CacheInvoker.Operation.class);
        String sessionId = "abc";

        when(this.invoker.invoke(same(this.cache), capturedOperation.capture())).thenReturn(expected);

        IncomingDistributableSessionData result = this.manager.getSessionData(sessionId, null, includeAttributes);

        assertSame(expected, result);

        CacheInvoker.Operation<String, Map<Object, Object>, IncomingDistributableSessionData> operation = capturedOperation.getValue();
View Full Code Here

        this.getSessionDataWithOwner(false);
    }

    private void getSessionDataWithOwner(boolean includeAttributes) {
        IncomingDistributableSessionData result = this.manager.getSessionData("abc", "owner1", includeAttributes);

        verifyZeroInteractions(this.cache);

        assertNull(result);
    }
View Full Code Here

                String owner = entry.getValue();

                long ts = -1;
                DistributableSessionMetadata md = null;
                try {
                    IncomingDistributableSessionData sessionData = this.distributedCacheManager.getSessionData(realId, owner, false);
                    if (sessionData == null) {
                        log.debugf("Metadata unavailable for unloaded session %s", realId);
                        continue;
                    }
                    ts = sessionData.getTimestamp();
                    md = sessionData.getMetadata();
                } catch (Exception e) {
                    // most likely a lock conflict if the session is being updated remotely;
                    // ignore it and use default values for timestamp and maxInactive
                    log.debug("Problem reading metadata for session " + realId + " -- " + e.toString(), e);
                }
View Full Code Here

                        if (initialLoad && session.isOutdated() == false) {
                            // some one else loaded this
                            return session;
                        }

                        IncomingDistributableSessionData data = this.distributedCacheManager.getSessionData(realId, initialLoad);
                        if (data != null) {
                            session.update(data);
                        } else {
                            // Clunky; we set the session variable to null to indicate
                            // no data so move on
View Full Code Here

            try {
                this.ownershipLock.lockInterruptibly();

                try {
                    if (support.acquireSessionOwnership(this.realId, needNewLock()) == SessionOwnershipSupport.LockResult.ACQUIRED_FROM_CLUSTER) {
                        IncomingDistributableSessionData data = this.distributedCacheManager.getSessionData(this.realId, false);
                        if (data != null) {
                            // We may be out of date re: the distributed cache
                            update(data);
                        }
                    }
View Full Code Here

                String owner = entry.getValue();

                long ts = -1;
                DistributableSessionMetadata md = null;
                try {
                    IncomingDistributableSessionData sessionData = this.distributedCacheManager.getSessionData(realId, owner, false);
                    if (sessionData == null) {
                        log.debug("Metadata unavailable for unloaded session " + realId);
                        continue;
                    }
                    ts = sessionData.getTimestamp();
                    md = sessionData.getMetadata();
                } catch (Exception e) {
                    // most likely a lock conflict if the session is being updated remotely;
                    // ignore it and use default values for timstamp and maxInactive
                    log.debug("Problem reading metadata for session " + realId + " -- " + e.toString(), e);
                }
View Full Code Here

                        if (initialLoad && session.isOutdated() == false) {
                            // some one else loaded this
                            return session;
                        }

                        IncomingDistributableSessionData data = this.distributedCacheManager.getSessionData(realId, initialLoad);
                        if (data != null) {
                            session.update(data);
                        } else {
                            // Clunky; we set the session variable to null to indicate
                            // no data so move on
View Full Code Here

            try {
                this.ownershipLock.lockInterruptibly();

                try {
                    if (support.acquireSessionOwnership(this.realId, needNewLock()) == SessionOwnershipSupport.LockResult.ACQUIRED_FROM_CLUSTER) {
                        IncomingDistributableSessionData data = this.distributedCacheManager.getSessionData(this.realId, false);
                        if (data != null) {
                            // We may be out of date re: the distributed cache
                            update(data);
                        }
                    }
View Full Code Here

                String owner = entry.getValue();

                long ts = -1;
                DistributableSessionMetadata md = null;
                try {
                    IncomingDistributableSessionData sessionData = this.distributedCacheManager.getSessionData(realId, owner, false);
                    if (sessionData == null) {
                        log.debug("Metadata unavailable for unloaded session " + realId);
                        continue;
                    }
                    ts = sessionData.getTimestamp();
                    md = sessionData.getMetadata();
                } catch (Exception e) {
                    // most likely a lock conflict if the session is being updated remotely;
                    // ignore it and use default values for timstamp and maxInactive
                    log.debug("Problem reading metadata for session " + realId + " -- " + e.toString(), e);
                }
View Full Code Here

TOP

Related Classes of org.jboss.as.clustering.web.IncomingDistributableSessionData

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.