Package org.apache.jcs.engine.behavior

Examples of org.apache.jcs.engine.behavior.ICacheElement


            int bytes = random.nextInt( 20 );
            // 4-24 KB
            int size = ( bytes + 4 ) * 1024;
            DiskTestObject tile = new DiskTestObject( new Integer( i ), new byte[size] );

            ICacheElement element = new CacheElement( cacheName, tile.id, tile );
            elements[i] = element;
        }
        return elements;
    }
View Full Code Here


    {
        try
        {
            long start = System.currentTimeMillis();
            //if ( running ) {
            ICacheElement cb = new CacheElement( hashtableName, key, val );
            log.debug( "key = " + key );
            String result = sendCache( cb );
            sleep( 100 );
            running = false;
            long end = System.currentTimeMillis();
View Full Code Here

        JCS jcs = JCS.getInstance( "testCache1" );

        jcs.put( "test_key", "test_data" );

        long now = System.currentTimeMillis();
        ICacheElement elem = jcs.getCacheElement( "test_key" );
        assertEquals( "Name wasn't right", "testCache1", elem.getCacheName() );

        long diff = now - elem.getElementAttributes().getCreateTime();
        assertTrue( "Create time should have been at or after the call", diff >= 0 );

    }
View Full Code Here

    public ICacheElement get( Serializable key )
        throws IOException
    {
        CacheElement ce = new CacheElement( cacheName, key, null );

        ICacheElement ice = null;
        try
        {
            ice = ARC( ce, true );
        }
        catch ( Exception e )
View Full Code Here

        service.setListenerId( 123456 );

        int cnt = 100;
        for ( int i = 0; i < cnt; i++ )
        {
            ICacheElement element = new CacheElement( "test", "key" + i, "value1" );
            service.update( element );
        }

        SleepUtil.sleepAtLeast( 1000 );
View Full Code Here

        lattr2.setTcpServer( "localhost:1103" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        ICacheElement element = new CacheElement( "test", "key", "value1" );
        service.update( element );

        SleepUtil.sleepAtLeast( 300 );

        ICacheElement element2 = new CacheElement( "test", "key", "value2" );
        service.update( element2 );

        SleepUtil.sleepAtLeast1000 );

        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
        System.out.println( "cacheElement = " + cacheElement );
        assertEquals( "Didn't get the correct object", element2.getVal(), cacheElement.getVal() );
    }
View Full Code Here

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        String key = "key";
        ICacheElement element = new CacheElement( "test", key, "value1" );
        service.update( element );

        SleepUtil.sleepAtLeast( 300 );

        ICacheElement element2 = new CacheElement( "test", key, "value2" );
        service.update( element2 );

        SleepUtil.sleepAtLeast( 1000 );

        ICacheElement cacheElement = cacheMgr.getCache().get( "key" );
        System.out.println( "cacheElement = " + cacheElement );
        assertEquals( "Didn't get the correct object", element2.getVal(), cacheElement.getVal() );
    }
View Full Code Here

        // give it our mock cache manager
        //LateralTCPListener listener = (LateralTCPListener)
        LateralTCPListener.getInstance( lattr, cacheMgr );

        // add the item to the listeners cache
        ICacheElement element = new CacheElement( "test", "key", "value1" );
        cacheMgr.getCache().update( element );

        // setup a service to talk to the listener started above.
        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
        lattr2.setTcpListenerPort( 1108 );
        lattr2.setTcpServer( "localhost:1107" );

        LateralTCPService service = new LateralTCPService( lattr2 );
        service.setListenerId( 123456 );

        SleepUtil.sleepAtLeast300 );

        // DO WORK
        ICacheElement result = service.get( "test", "key" );

        System.out.println( "testSendAndReceived, result = " + result );
        assertNotNull( "Result should not be null.", result );
        assertEquals( "Didn't get the correct object", element.getVal(), result.getVal() );
    }
View Full Code Here

        watch = (ICacheObserver) obj;

        p( "subscribing to the server" );

        watch.addCacheListener( "testCache", this );
        ICacheElement cb = new CacheElement( "testCache", "testKey", "testVal" );

        for ( int i = 0; i < count; i++ )
        {
            cb = new CacheElement( "testCache", "" + i, "" + i );

            if ( delete )
            {
                p( "deleting a cache item from the server " + i );

                cache.remove( cb.getCacheName(), cb.getKey() );
            }
            if ( write )
            {
                p( "putting a cache bean to the server " + i );

                try
                {
                    cache.update( cb );
                }
                catch ( ObjectExistsException oee )
                {
                    p( oee.toString() );
                }
            }
            if ( read )
            {
                try
                {
                    Object val = cache.get( cb.getCacheName(), cb.getKey() );
                    p( "get " + cb.getKey() + " returns " + val );
                }
                catch ( CacheException onfe )
                {
                    // nothing
                }
View Full Code Here

        // get removed.";
        //p( "dataToPassHashCodeCompare hashcode = " + +
        // dataToPassHashCodeCompare.hashCode() );

        cache.put( keyToBeRemovedOnPut, "this should get removed." );
        ICacheElement element1 = new CacheElement( region, keyToBeRemovedOnPut, region
            + ":data-this shouldn't get there" );
        service.update( element1 );

        cache.put( keyToNotBeRemovedOnPut, dataToPassHashCodeCompare );
        ICacheElement element2 = new CacheElement( region, keyToNotBeRemovedOnPut, dataToPassHashCodeCompare );
        service.update( element2 );

        /*
         * try { for ( int i = 1; i < numOps; i++ ) { Random ran = new Random( i );
         * int n = ran.nextInt( 4 ); int kn = ran.nextInt( range ); String key =
View Full Code Here

TOP

Related Classes of org.apache.jcs.engine.behavior.ICacheElement

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.