Package org.hibernate.stat

Examples of org.hibernate.stat.SecondLevelCacheStatistics


        }

        // check the version value in the cache...
        final String regionName = HibernateCacheUtil.getRegionName(sessionFactory(),
                                                                   VersionedItem.class);
        SecondLevelCacheStatistics slcs =
                sessionFactory()
                        .getStatistics()
                        .getSecondLevelCacheStatistics(regionName);

//        Map cacheEntries = slcs.getEntries();
View Full Code Here


        sessionFactory.getCache().evictEntityRegion(Item.class);
        Statistics stats = sessionFactory.getStatistics();
        stats.clear();

        final String regionName = HibernateCacheUtil.getRegionName(sessionFactory, Item.class);
        SecondLevelCacheStatistics statistics = getSecondLevelCacheStatistics(Item.class);

        log.info("SecondLevel Cache Region=[{}], ElementInMemory=[{}], HitCount=[{}]",
                 regionName, statistics.getElementCountInMemory(), statistics.getHitCount());
    }
View Full Code Here

      logger.info( "" );
      logger.info( "Cache regions statistics :" );
      logger.info( "" );
      String[] cacheRegions = stats.getSecondLevelCacheRegionNames();
      for (String region : cacheRegions) {
        SecondLevelCacheStatistics cacheStats = stats.getSecondLevelCacheStatistics( region );
        logger.info( "Cache region:" + cacheStats.getCategoryName() );
        logger.info( "Elements in memory:" + cacheStats.getElementCountInMemory() );
        logger.info( "Hits count:" + cacheStats.getHitCount() );
        logger.info( "Miss count:" + cacheStats.getMissCount() );
        logger.info( "Put count:" + cacheStats.getPutCount() );
        logger.info( "" );
      }

      logger.info( "Entites statistics :" );
      logger.info( "" );
View Full Code Here

      logger.info( "" );
      logger.info( "Cache regions statistics :" );
      logger.info( "" );
      String[] cacheRegions = stats.getSecondLevelCacheRegionNames();
      for (String region : cacheRegions) {
        SecondLevelCacheStatistics cacheStats = stats.getSecondLevelCacheStatistics( region );
        logger.info( "Cache region:" + cacheStats.getCategoryName() );
        logger.info( "Elements in memory:" + cacheStats.getElementCountInMemory() );
        logger.info( "Hits count:" + cacheStats.getHitCount() );
        logger.info( "Miss count:" + cacheStats.getMissCount() );
        logger.info( "Put count:" + cacheStats.getPutCount() );
        logger.info( "" );
      }

      logger.info( "Entites statistics :" );
      logger.info( "" );
View Full Code Here

    i.setDescription("A really top-quality, full-featured widget.");
    s.persist(i);
    t.commit();
    s.close();

    SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics()
        .getSecondLevelCacheStatistics( Item.class.getName() );

    assertEquals( slcs.getPutCount(), 1 );
    assertEquals( slcs.getElementCountInMemory(), 1 );
    assertEquals( slcs.getEntries().size(), 1 );

    s = openSession();
    t = s.beginTransaction();
    i = (Item) s.get( Item.class, i.getId() );

    assertEquals( slcs.getHitCount(), 1 );
    assertEquals( slcs.getMissCount(), 0 );

    i.setDescription("A bog standard item");

    t.commit();
    s.close();

    assertEquals( slcs.getPutCount(), 2 );

    Object entry = slcs.getEntries().get( i.getId() );
    Map map;
    if ( entry instanceof ReadWriteCache.Item ) {
      map = (Map) ( (ReadWriteCache.Item) entry ).getValue();
    }
    else {
View Full Code Here

  public void testEmptySecondLevelCacheEntry() throws Exception {
    getSessions().evictEntity( Item.class.getName() );
    Statistics stats = getSessions().getStatistics();
    stats.clear();
    SecondLevelCacheStatistics statistics = stats.getSecondLevelCacheStatistics( Item.class.getName() );
        Map cacheEntries = statistics.getEntries();
    assertEquals( 0, cacheEntries.size() );
  }
View Full Code Here

        }
      }
    }

    // check the version value in the cache...
    SecondLevelCacheStatistics slcs = sfi().getStatistics()
        .getSecondLevelCacheStatistics( VersionedItem.class.getName() );

    Object entry = slcs.getEntries().get( item.getId() );
    Long cachedVersionValue;
    if ( entry instanceof ReadWriteCache.Lock ) {
      //FIXME don't know what to test here
      cachedVersionValue = new Long( ( (ReadWriteCache.Lock) entry).getUnlockTimestamp() );
    }
View Full Code Here

    getCustomerIDs().add( customerId );

    assertNull( "contact exists despite not being added", getFirstContact( customerId ) );

    // check that cache was hit
    SecondLevelCacheStatistics customerSlcs = sessionFactory()
        .getStatistics()
        .getSecondLevelCacheStatistics( Customer.class.getName() );
    assertEquals( customerSlcs.getPutCount(), 1 );
    assertEquals( customerSlcs.getElementCountInMemory(), 1 );
    assertEquals( customerSlcs.getEntries().size(), 1 );

    log.infof( "Add contact to customer {0}", customerId );
    SecondLevelCacheStatistics contactsCollectionSlcs = sessionFactory()
        .getStatistics()
        .getSecondLevelCacheStatistics( Customer.class.getName() + ".contacts" );
    assertEquals( 1, contactsCollectionSlcs.getPutCount() );
    assertEquals( 1, contactsCollectionSlcs.getElementCountInMemory() );
    assertEquals( 1, contactsCollectionSlcs.getEntries().size() );

    final Contact contact = addContact( customerId );
    assertNotNull( "contact returned by addContact is null", contact );
    assertEquals(
        "Customer.contacts cache was not invalidated after addContact", 0,
        contactsCollectionSlcs.getElementCountInMemory()
    );

    assertNotNull( "Contact missing after successful add call", getFirstContact( customerId ) );

    // read everyone's contacts
View Full Code Here

      withTx(tm, new Callable<Void>() {
         @Override
         public Void call() throws Exception {
            Session s = openSession();
            SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics( Item.class.getName() + ".items" );
            Item loadedWithCachedCollection = (Item) s.load( Item.class, item.getId() );
            stats.logSummary();
            assertEquals( item.getName(), loadedWithCachedCollection.getName() );
            assertEquals( item.getItems().size(), loadedWithCachedCollection.getItems().size() );
            assertEquals( 1, cStats.getHitCount() );
            Map cacheEntries = cStats.getEntries();
            assertEquals( 1, cacheEntries.size() );
            s.close();
            return null;
         }
      });
View Full Code Here

        }
      }
    }

    // check the version value in the cache...
    SecondLevelCacheStatistics slcs = stats.getSecondLevelCacheStatistics( VersionedItem.class.getName() );

    Object entry = slcs.getEntries().get( item.getId() );
    Long cachedVersionValue;
    cachedVersionValue = (Long) ((CacheEntry) entry).getVersion();
    assertEquals(initialVersion.longValue(), cachedVersionValue.longValue());

    beginTx();
View Full Code Here

TOP

Related Classes of org.hibernate.stat.SecondLevelCacheStatistics

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.