Package de.javakaffee.web.msm

Examples of de.javakaffee.web.msm.MemcachedBackupSession


        assertDeepEquals( deserialized, session.getAttributesInternal() );
    }

    @Test( enabled = true )
    public void testCyclicDependencies() throws Exception {
        final MemcachedBackupSession session = _manager.createEmptySession();
        session.setValid( true );
        session.setCreationTime( System.currentTimeMillis() );
        getField( StandardSession.class, "lastAccessedTime" ).set( session, System.currentTimeMillis() + 100 );
        session.setMaxInactiveInterval( 600 );

        final Person p1 = createPerson( "foo bar", Gender.MALE, 42, "foo.bar@example.org", "foo.bar@example.com" );
        final Person p2 = createPerson( "bar baz", Gender.FEMALE, 42, "bar.baz@example.org", "bar.baz@example.com" );
        p1.addFriend( p2 );
        p2.addFriend( p1 );

        session.setAttribute( "person1", p1 );
        session.setAttribute( "person2", p2 );

        final byte[] bytes = _transcoder.serializeAttributes( session, session.getAttributesInternal() );
        assertDeepEquals( session.getAttributesInternal(), _transcoder.deserializeAttributes( bytes ) );

    }
View Full Code Here


        final SessionIdFormat format = new SessionIdFormat();

        final String sessionId1 = get( _httpClient, TC_PORT_1, null ).getSessionId();
        assertEquals( format.extractJvmRoute( sessionId1 ), JVM_ROUTE_1 );

        final MemcachedBackupSession session = (MemcachedBackupSession) manager1.findSession( sessionId1 );
        session.setAttribute( "listener", new RecordingSessionActivationListener() );

        get( _httpClient, TC_PORT_1, sessionId1 );

        final String sessionId2 = get( _httpClient, TC_PORT_2, sessionId1 ).getSessionId();
        assertEquals( format.stripJvmRoute( sessionId2 ), format.stripJvmRoute( sessionId1 ) );
        assertEquals( format.extractJvmRoute( sessionId2 ), JVM_ROUTE_2 );

        final MemcachedBackupSession loaded = (MemcachedBackupSession) manager2.findSession( sessionId2 );
        assertNotNull( loaded );
        final RecordingSessionActivationListener listener = (RecordingSessionActivationListener) loaded.getAttribute( "listener" );
        assertNotNull( listener );

        final String notifiedSessionId = listener.getSessionDidActivate();
        assertEquals( notifiedSessionId, sessionId2 );
    }
View Full Code Here

        final SessionIdFormat format = new SessionIdFormat();

        final String sessionId1 = get( _httpClient, TC_PORT_1, null ).getSessionId();
        assertNull( format.extractJvmRoute( sessionId1 ) );

        final MemcachedBackupSession session = (MemcachedBackupSession) manager1.findSession( sessionId1 );
        session.setAttribute( "listener", new RecordingSessionActivationListener() );

        get( _httpClient, TC_PORT_1, sessionId1 );

        final String sessionId2 = get( _httpClient, TC_PORT_2, sessionId1 ).getSessionId();
        assertEquals( sessionId2, sessionId1 );

        final MemcachedBackupSession loaded = (MemcachedBackupSession) manager2.findSession( sessionId2 );
        assertNotNull( loaded );
        final RecordingSessionActivationListener listener = (RecordingSessionActivationListener) loaded.getAttribute( "listener" );
        assertNotNull( listener );

        final String notifiedSessionId = listener.getSessionDidActivate();
        assertEquals( notifiedSessionId, sessionId2 );
    }
View Full Code Here

        System.out.println( "Running benchmark for " + transcoder.getClass().getSimpleName() + "..." +
            " (rounds: "+ rounds +", persons: "+ countPersons +", nodes: "+ ((int)Math.pow( nodesPerEdge, nodesPerEdge ) + nodesPerEdge + 1 ) +")" );
       
        final TranscoderService transcoderService = new TranscoderService( transcoder );
       
        final MemcachedBackupSession session = createSession( manager, "123456789abcdefghijk987654321", countPersons, nodesPerEdge );
        final byte[] data = transcoderService.serialize( session );
        final int size = data.length;
       
        for( int r = 0; r < rounds; r++ ) {
            final long start = System.currentTimeMillis();
View Full Code Here

    private static void warmup( final MemcachedBackupSessionManager manager, final SessionAttributesTranscoder transcoder,
            final int loops, final int countPersons, final int nodesPerEdge )
        throws InterruptedException {
       
        final TranscoderService transcoderService = new TranscoderService( transcoder );
        final MemcachedBackupSession session = createSession( manager, "123456789abcdefghijk987654321", countPersons, nodesPerEdge );
       
        System.out.print("Performing warmup for serialization using "+ transcoder.getClass().getSimpleName() +"...");
        final long serWarmupStart = System.currentTimeMillis();
        for( int i = 0; i < loops; i++ ) transcoderService.serialize( session );
        System.out.println(" (" + (System.currentTimeMillis() - serWarmupStart) + " ms)");
View Full Code Here

    }

    private static MemcachedBackupSession createSession( final MemcachedBackupSessionManager manager, final String id,
            final int countPersons, final int countNodesPerEdge ) {
        final MemcachedBackupSession session = manager.createEmptySession();
        session.setId( id );
        session.setValid( true );

        session.setAttribute( "stringbuffer", new StringBuffer( "<string\n&buffer/>" ) );
        session.setAttribute( "stringbuilder", new StringBuilder( "<string\n&buffer/>" ) );
       
        session.setAttribute( "persons", createPersons( countPersons ) );
        session.setAttribute( "mycontainer", new TestClasses.MyContainer() );
       
        session.setAttribute( "component", createComponents( countNodesPerEdge ) );
       
        return session;
    }
View Full Code Here

    public void testReadValueIntoObject() throws Exception {
    final MemcachedBackupSessionManager manager = new MemcachedBackupSessionManager();
    manager.setContainer( new StandardContext() );
    final JSONTranscoder transcoder = new JSONTranscoder(manager);

    final MemcachedBackupSession session = manager.createEmptySession();
    session.setValid( true );
    session.setCreationTime( System.currentTimeMillis() );
    getField( StandardSession.class, "lastAccessedTime" ).set( session, System.currentTimeMillis() + 100 );
    session.setMaxInactiveInterval( 600 );

    session.setId( "foo" );
    session.setAttribute( "person1", createPerson( "foo bar", Gender.MALE, "foo.bar@example.org", "foo.bar@example.com" ) );
    session.setAttribute( "person2", createPerson( "bar baz", Gender.FEMALE, "bar.baz@example.org", "bar.baz@example.com" ) );

    final long start = System.nanoTime();
    final byte[] json = transcoder.serializeAttributes( session, session.getAttributesInternal() );
    final Map<String, Object> readValue = transcoder.deserializeAttributes( json );
    System.out.println("json-round took " + (System.nanoTime() - start)/1000);

    assertEquals( readValue, new HashMap<String, Object>(session.getAttributesInternal()) );

  }
View Full Code Here

        final Object value = makeValueInstance( loaderForCustomClassInVersion1 );

        final SessionAttributesTranscoder transcoder = new KryoTranscoderFactory().createTranscoder( loaderForCustomClassInVersion1 );

        // serialize one instance
        final MemcachedBackupSession memcachedBackupSession = new MemcachedBackupSession();
        final Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put( "test", value );

        byte[] data = transcoder.serializeAttributes( memcachedBackupSession, attributes );
        final Map<String, Object> deserializeAttributes = transcoder.deserializeAttributes( data );
View Full Code Here

TOP

Related Classes of de.javakaffee.web.msm.MemcachedBackupSession

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.