public static Cache getCache(SessionFactoryImplementor sessionFactoryImplementor, String regionName) { final RegionFactory regionFactory = sessionFactoryImplementor.getCache().getRegionFactory(); final EhcacheRegionFactory ehcacheRegionFactory = (EhcacheRegionFactory) regionFactory; final CacheManager cacheManager = ehcacheRegionFactory.getCacheManager(); regionName = prefix( regionName ); return cacheManager.getCache( regionName ); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException { if ( log.isTraceEnabled() ) { log.trace( "Deserializing " + getClass().getSimpleName() ); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Step 1 :: read back non-transient state... ois.defaultReadObject(); sessionEventsManager = new SessionEventListenerManagerImpl(); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Step 2 :: read back transient state... // -- see above factory = SessionFactoryImpl.deserialize( ois ); jdbcSessionContext = new JdbcSessionContextImpl( this, (StatementInspector) ois.readObject() ); jdbcCoordinator = JdbcCoordinatorImpl.deserialize( ois, this ); cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this ); transactionCoordinator = factory.getServiceRegistry() .getService( TransactionCoordinatorBuilder.class ) .buildTransactionCoordinator( jdbcCoordinator, this ); entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor ); exceptionConverter = new ExceptionConverterImpl( this ); } }
@Override public void invalidate( String[] spaces, SharedSessionContractImplementor session) { final boolean stats = session.getFactory().getStatistics().isStatisticsEnabled(); final Long ts = session.getFactory().getCache().getRegionFactory().nextTimestamp(); for (Serializable space : spaces) { if ( DEBUG_ENABLED ) { log.debugf( "Invalidating space [%s], timestamp: %s", space, ts ); } try { session.getEventListenerManager().cachePutStart(); timestampsRegion.putIntoCache( space, ts, session ); } finally { session.getEventListenerManager().cachePutEnd(); if ( stats ) { session.getFactory().getStatistics().updateTimestampsCachePut(); } } } }
@Override public void preInvalidate( String[] spaces, SharedSessionContractImplementor session) { final SessionFactoryImplementor factory = session.getFactory(); final RegionFactory regionFactory = factory.getCache().getRegionFactory(); final boolean stats = factory.getStatistics().isStatisticsEnabled(); final Long ts = regionFactory.nextTimestamp() + regionFactory.getTimeout(); for ( Serializable space : spaces ) { if ( DEBUG_ENABLED ) { log.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts ); } try { session.getEventListenerManager().cachePutStart(); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync timestampsRegion.putIntoCache( space, ts, session ); } finally { session.getEventListenerManager().cachePutEnd(); } if ( stats ) { factory.getStatistics().updateTimestampsCachePut(); } } }
public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options) { this.factory = factory; this.cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException, SQLException { if ( log.isTraceEnabled() ) { log.trace( "Deserializing " + getClass().getSimpleName() ); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Step 1 :: read back non-transient state... ois.defaultReadObject(); sessionEventsManager = new SessionEventListenerManagerImpl(); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Step 2 :: read back transient state... // -- see above factory = SessionFactoryImpl.deserialize( ois ); jdbcSessionContext = new JdbcSessionContextImpl( this, (StatementInspector) ois.readObject() ); jdbcCoordinator = JdbcCoordinatorImpl.deserialize( ois, this ); cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this ); transactionCoordinator = factory.getServiceRegistry() .getService( TransactionCoordinatorBuilder.class ) .buildTransactionCoordinator( jdbcCoordinator, this ); entityNameResolver = new CoordinatingEntityNameResolver( factory, interceptor ); exceptionConverter = new ExceptionConverterImpl( this ); }
@Override public void preInvalidate( String[] spaces, SharedSessionContractImplementor session) { final SessionFactoryImplementor factory = session.getFactory(); final RegionFactory regionFactory = factory.getCache().getRegionFactory(); final boolean stats = factory.getStatistics().isStatisticsEnabled(); final Long ts = regionFactory.nextTimestamp() + regionFactory.getTimeout(); for ( Serializable space : spaces ) { if ( DEBUG_ENABLED ) { log.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts ); } try { session.getEventListenerManager().cachePutStart(); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync timestampsRegion.putIntoCache( space, ts, session ); } finally { session.getEventListenerManager().cachePutEnd(); } if ( stats ) { factory.getStatistics().updateTimestampsCachePut(); } } }
@Override public void invalidate( String[] spaces, SharedSessionContractImplementor session) { final boolean stats = session.getFactory().getStatistics().isStatisticsEnabled(); final Long ts = session.getFactory().getCache().getRegionFactory().nextTimestamp(); for (Serializable space : spaces) { if ( DEBUG_ENABLED ) { log.debugf( "Invalidating space [%s], timestamp: %s", space, ts ); } try { session.getEventListenerManager().cachePutStart(); timestampsRegion.putIntoCache( space, ts, session ); } finally { session.getEventListenerManager().cachePutEnd(); if ( stats ) { session.getFactory().getStatistics().updateTimestampsCachePut(); } } } }
public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options) { this.factory = factory; this.cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );