JCS jcs = JCSCacheFactory.getCacheInstance(regionName); IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler(handler); jcs.setDefaultElementAttributes(attributes);
JCS jcs = JCSCacheFactory.getCacheInstance(regionName); IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler(handler); jcs.setDefaultElementAttributes(attributes);
delegate.getElementAttributes().addElementEventHandler(new EvictionListener(statistics));
delegate.getElementAttributes().addElementEventHandler(new EvictionListener(statistics));
attrp.addElementEventHandler( hand ); cache_control.put( "key" + n, "data" + n + " put from ta = junk", attrp );
attrp.addElementEventHandler( hand ); cache_control.put( "key" + n, "data" + n + " put from ta = junk", attrp );
/** * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event. * @throws Exception */ public void testSpoolNotAllowedEvent() throws Exception { MyEventHandler meh = new MyEventHandler(); CacheAccess<String, String> jcs = JCS.getInstance( "DiskButNotAllowed" ); // this should add the event handler to all items as they are created. IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes ); // put them in for ( int i = 0; i <= items; i++ ) { jcs.put( i + ":key", "data" + i ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" + meh.getSpoolNotAllowedCount() + "] does not equal the number expected.", meh.getSpoolNotAllowedCount() >= items ); }
/** * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event. * @throws Exception */ public void testSpoolNotAllowedEventOnItem() throws Exception { MyEventHandler meh = new MyEventHandler(); CacheAccess<String, String> jcs = JCS.getInstance( "DiskButNotAllowed" ); // this should add the event handler to all items as they are created. //IElementAttributes attributes = jcs.getDefaultElementAttributes(); //attributes.addElementEventHandler( meh ); //jcs.setDefaultElementAttributes( attributes ); // put them in for ( int i = 0; i <= items; i++ ) { IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.put( i + ":key", "data" + i, attributes ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" + meh.getSpoolNotAllowedCount() + "] does not equal the number expected.", meh.getSpoolNotAllowedCount() >= items ); }
/** * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event. * @throws Exception */ public void testSpoolNotAllowedEventOnItem() throws Exception { MyEventHandler meh = new MyEventHandler(); CacheAccess<String, String> jcs = JCS.getInstance( "DiskButNotAllowed" ); // this should add the event handler to all items as they are created. //IElementAttributes attributes = jcs.getDefaultElementAttributes(); //attributes.addElementEventHandler( meh ); //jcs.setDefaultElementAttributes( attributes ); // put them in for ( int i = 0; i <= items; i++ ) { IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.put( i + ":key", "data" + i, attributes ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" + meh.getSpoolNotAllowedCount() + "] does not equal the number expected.", meh.getSpoolNotAllowedCount() >= items ); }
/** * Test overflow with no disk configured for the region. * <p> * @throws Exception */ public void testSpoolNoDiskEvent() throws Exception { CacheAccess<String, String> jcs = JCS.getInstance( "NoDisk" ); MyEventHandler meh = new MyEventHandler(); // this should add the event handler to all items as they are created. IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes ); // put them in for ( int i = 0; i <= items; i++ ) { jcs.put( i + ":key", "data" + i ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE events [" + meh.getSpoolNoDiskCount() + "] does not equal the number expected.", meh.getSpoolNoDiskCount() >= items ); }
/** * Verify that the spooled event is called as expected. * <p> * @throws Exception Description of the Exception */ public void testSpoolEvent() throws Exception { // SETUP MyEventHandler meh = new MyEventHandler(); CacheAccess<String, String> jcs = JCS.getInstance( "WithDisk" ); // this should add the event handler to all items as they are created. IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes ); // DO WORK // put them in for ( int i = 0; i <= items; i++ ) { jcs.put( i + ":key", "data" + i ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // VERIFY // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE events [" + meh.getSpoolCount() + "] does not equal the number expected [" + items + "]", meh.getSpoolCount() >= items ); }
/** * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event. * @throws Exception */ public void testSpoolNotAllowedEvent() throws Exception { MyEventHandler meh = new MyEventHandler(); CacheAccess<String, String> jcs = JCS.getInstance( "DiskButNotAllowed" ); // this should add the event handler to all items as they are created. IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes ); // put them in for ( int i = 0; i <= items; i++ ) { jcs.put( i + ":key", "data" + i ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" + meh.getSpoolNotAllowedCount() + "] does not equal the number expected.", meh.getSpoolNotAllowedCount() >= items ); }
attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes );
/** * Test overflow with no disk configured for the region. * <p> * @throws Exception */ public void testSpoolNoDiskEvent() throws Exception { CacheAccess<String, String> jcs = JCS.getInstance( "NoDisk" ); MyEventHandler meh = new MyEventHandler(); // this should add the event handler to all items as they are created. IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes ); // put them in for ( int i = 0; i <= items; i++ ) { jcs.put( i + ":key", "data" + i ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE events [" + meh.getSpoolNoDiskCount() + "] does not equal the number expected.", meh.getSpoolNoDiskCount() >= items ); }
/** * Verify that the spooled event is called as expected. * <p> * @throws Exception Description of the Exception */ public void testSpoolEvent() throws Exception { // SETUP MyEventHandler meh = new MyEventHandler(); CacheAccess<String, String> jcs = JCS.getInstance( "WithDisk" ); // this should add the event handler to all items as they are created. IElementAttributes attributes = jcs.getDefaultElementAttributes(); attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes ); // DO WORK // put them in for ( int i = 0; i <= items; i++ ) { jcs.put( i + ":key", "data" + i ); } // wait a bit for it to finish Thread.sleep( items / 20 ); // VERIFY // test to see if the count is right assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE events [" + meh.getSpoolCount() + "] does not equal the number expected [" + items + "]", meh.getSpoolCount() >= items ); }
attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes );
attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes );
attributes.addElementEventHandler( meh ); jcs.setDefaultElementAttributes( attributes );