/** * This method returns semi-structured data on this queue. * <p> * @see org.apache.commons.jcs.engine.behavior.ICacheEventQueue#getStatistics() * @return information on the status and history of the queue */ @Override public IStats getStatistics() { IStats stats = new Stats(); stats.setTypeName( "Cache Event Queue" ); ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>(); elems.add(new StatElement<Boolean>( "Working", Boolean.valueOf(this.isWorking()) ) ); elems.add(new StatElement<Boolean>( "Alive", Boolean.valueOf(this.isAlive()) ) ); elems.add(new StatElement<Boolean>( "Empty", Boolean.valueOf(this.isEmpty()) ) ); elems.add(new StatElement<Integer>( "Size", Integer.valueOf(this.size()) ) ); stats.setStatElements( elems ); return stats; }
elems.add(new StatElement<Boolean>( "Empty", Boolean.valueOf(this.isEmpty()) ) );
/** * Adds put events to the queue. * @param end * @param expectedPutCount * @throws Exception */ public void runPutTest( int end, int expectedPutCount ) throws Exception { for ( int i = 0; i <= end; i++ ) { CacheElement<String, String> elem = new CacheElement<String, String>( "testCache1", i + ":key", i + "data" ); queue.addPutEvent( elem ); } while ( !queue.isEmpty() ) { synchronized ( this ) { System.out.println( "queue is still busy, waiting 250 millis" ); this.wait( 250 ); } } System.out.println( "queue is empty, comparing putCount" ); // this becomes less accurate with each test. It should never fail. If // it does things are very off. assertTrue( "The put count [" + listen.putCount + "] is below the expected minimum threshold [" + expectedPutCount + "]", listen.putCount >= ( expectedPutCount - 1 ) ); }
/** * Adds put events to the queue. * @param end * @param expectedPutCount * @throws Exception */ public void runPutTest( int end, int expectedPutCount ) throws Exception { for ( int i = 0; i <= end; i++ ) { CacheElement<String, String> elem = new CacheElement<String, String>( "testCache1", i + ":key", i + "data" ); queue.addPutEvent( elem ); } while ( !queue.isEmpty() ) { synchronized ( this ) { System.out.println( "queue is still busy, waiting 250 millis" ); this.wait( 250 ); } } System.out.println( "queue is empty, comparing putCount" ); // this becomes less accurate with each test. It should never fail. If // it does things are very off. assertTrue( "The put count [" + listen.putCount + "] is below the expected minimum threshold [" + expectedPutCount + "]", listen.putCount >= ( expectedPutCount - 1 ) ); }