HHH-17347 Support for JDK which do not support JFR events
This commit is contained in:
parent
1b2be49045
commit
8492d1c4b8
|
@ -16,9 +16,16 @@ dependencies {
|
||||||
testImplementation testLibs.jfrUnit
|
testImplementation testLibs.jfrUnit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileTestJava {
|
||||||
|
//Testing JFR events require JDK > 16
|
||||||
|
javaCompiler = javaToolchains.compilerFor {
|
||||||
|
languageVersion = JavaLanguageVersion.of( 17 )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
//Testing JFR events require JDK > 16
|
//Testing JFR events require JDK > 16
|
||||||
javaLauncher = javaToolchains.launcherFor {
|
javaLauncher = javaToolchains.launcherFor {
|
||||||
languageVersion = JavaLanguageVersion.of(17)
|
languageVersion = JavaLanguageVersion.of( 17 )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class FlushEvent extends Event implements HibernateEvent {
|
||||||
@Label("Number Of Processed Entities")
|
@Label("Number Of Processed Entities")
|
||||||
public int numberOfEntitiesProcessed;
|
public int numberOfEntitiesProcessed;
|
||||||
|
|
||||||
@Label("Number Of Processed Collectionc")
|
@Label("Number Of Processed Collections")
|
||||||
public int numberOfCollectionsProcessed;
|
public int numberOfCollectionsProcessed;
|
||||||
|
|
||||||
@Label("Flush time")
|
@Label("Flush time")
|
||||||
|
|
|
@ -10,10 +10,10 @@ import org.hibernate.cache.spi.Region;
|
||||||
import org.hibernate.cache.spi.access.CachedDomainDataAccess;
|
import org.hibernate.cache.spi.access.CachedDomainDataAccess;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.event.spi.EventManager;
|
|
||||||
import org.hibernate.event.spi.HibernateEvent;
|
|
||||||
import org.hibernate.event.spi.AutoFlushEvent;
|
import org.hibernate.event.spi.AutoFlushEvent;
|
||||||
|
import org.hibernate.event.spi.EventManager;
|
||||||
import org.hibernate.event.spi.EventSource;
|
import org.hibernate.event.spi.EventSource;
|
||||||
|
import org.hibernate.event.spi.HibernateEvent;
|
||||||
import org.hibernate.internal.build.AllowNonPortable;
|
import org.hibernate.internal.build.AllowNonPortable;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
@ -27,11 +27,26 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||||
@AllowNonPortable
|
@AllowNonPortable
|
||||||
public class JfrEventManager implements EventManager {
|
public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
private static final EventType eventType = EventType.getEventType( SessionOpenEvent.class );
|
private static final EventType sessionOpenEventType = EventType.getEventType( SessionOpenEvent.class );
|
||||||
|
private static final EventType sessionClosedEventType = EventType.getEventType( SessionClosedEvent.class );
|
||||||
|
private static final EventType jdbcConnectionAcquisitionEventType = EventType
|
||||||
|
.getEventType( JdbcConnectionAcquisitionEvent.class );
|
||||||
|
private static final EventType jdbcConnectionReleaseEventType = EventType
|
||||||
|
.getEventType( JdbcConnectionReleaseEvent.class );
|
||||||
|
private static final EventType jdbcPreparedStatementCreationEventType = EventType
|
||||||
|
.getEventType( JdbcPreparedStatementCreationEvent.class );
|
||||||
|
private static final EventType jdbcPreparedStatementExecutionEventType = EventType.getEventType(
|
||||||
|
JdbcPreparedStatementExecutionEvent.class );
|
||||||
|
private static final EventType jdbcBatchExecutionEventType = EventType.getEventType( JdbcBatchExecutionEvent.class );
|
||||||
|
private static final EventType cachePutEventType = EventType.getEventType( CachePutEvent.class );
|
||||||
|
private static final EventType cacheGetEventType = EventType.getEventType( CacheGetEvent.class );
|
||||||
|
private static final EventType flushEventType = EventType.getEventType( FlushEvent.class );
|
||||||
|
private static final EventType partialFlushEventType = EventType.getEventType( PartialFlushEvent.class );
|
||||||
|
private static final EventType dirtyCalculationEventType = EventType.getEventType( DirtyCalculationEvent.class );
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionOpenEvent beginSessionOpenEvent() {
|
public SessionOpenEvent beginSessionOpenEvent() {
|
||||||
if ( eventType.isEnabled() ) {
|
if ( sessionOpenEventType.isEnabled() ) {
|
||||||
final SessionOpenEvent sessionOpenEvent = new SessionOpenEvent();
|
final SessionOpenEvent sessionOpenEvent = new SessionOpenEvent();
|
||||||
sessionOpenEvent.begin();
|
sessionOpenEvent.begin();
|
||||||
return sessionOpenEvent;
|
return sessionOpenEvent;
|
||||||
|
@ -57,19 +72,22 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionClosedEvent beginSessionClosedEvent() {
|
public SessionClosedEvent beginSessionClosedEvent() {
|
||||||
|
if ( sessionClosedEventType.isEnabled() ) {
|
||||||
final SessionClosedEvent sessionClosedEvent = new SessionClosedEvent();
|
final SessionClosedEvent sessionClosedEvent = new SessionClosedEvent();
|
||||||
if ( sessionClosedEvent.isEnabled() ) {
|
|
||||||
sessionClosedEvent.begin();
|
sessionClosedEvent.begin();
|
||||||
}
|
|
||||||
return sessionClosedEvent;
|
return sessionClosedEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeSessionClosedEvent(
|
public void completeSessionClosedEvent(
|
||||||
HibernateEvent event,
|
HibernateEvent event,
|
||||||
SharedSessionContractImplementor session) {
|
SharedSessionContractImplementor session) {
|
||||||
|
if ( event != null ) {
|
||||||
final SessionClosedEvent sessionClosedEvent = (SessionClosedEvent) event;
|
final SessionClosedEvent sessionClosedEvent = (SessionClosedEvent) event;
|
||||||
if ( sessionClosedEvent.isEnabled() ) {
|
|
||||||
sessionClosedEvent.end();
|
sessionClosedEvent.end();
|
||||||
if ( sessionClosedEvent.shouldCommit() ) {
|
if ( sessionClosedEvent.shouldCommit() ) {
|
||||||
sessionClosedEvent.sessionIdentifier = getSessionIdentifier( session );
|
sessionClosedEvent.sessionIdentifier = getSessionIdentifier( session );
|
||||||
|
@ -80,21 +98,24 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcConnectionAcquisitionEvent beginJdbcConnectionAcquisitionEvent() {
|
public JdbcConnectionAcquisitionEvent beginJdbcConnectionAcquisitionEvent() {
|
||||||
|
if ( jdbcConnectionAcquisitionEventType.isEnabled() ) {
|
||||||
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = new JdbcConnectionAcquisitionEvent();
|
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = new JdbcConnectionAcquisitionEvent();
|
||||||
if ( jdbcConnectionAcquisitionEvent.isEnabled() ) {
|
|
||||||
jdbcConnectionAcquisitionEvent.begin();
|
jdbcConnectionAcquisitionEvent.begin();
|
||||||
jdbcConnectionAcquisitionEvent.startedAt = System.nanoTime();
|
jdbcConnectionAcquisitionEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return jdbcConnectionAcquisitionEvent;
|
return jdbcConnectionAcquisitionEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeJdbcConnectionAcquisitionEvent(
|
public void completeJdbcConnectionAcquisitionEvent(
|
||||||
HibernateEvent event,
|
HibernateEvent event,
|
||||||
SharedSessionContractImplementor session,
|
SharedSessionContractImplementor session,
|
||||||
Object tenantId) {
|
Object tenantId) {
|
||||||
|
if ( event != null ) {
|
||||||
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = (JdbcConnectionAcquisitionEvent) event;
|
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = (JdbcConnectionAcquisitionEvent) event;
|
||||||
if ( jdbcConnectionAcquisitionEvent.isEnabled() ) {
|
|
||||||
jdbcConnectionAcquisitionEvent.end();
|
jdbcConnectionAcquisitionEvent.end();
|
||||||
if ( jdbcConnectionAcquisitionEvent.shouldCommit() ) {
|
if ( jdbcConnectionAcquisitionEvent.shouldCommit() ) {
|
||||||
jdbcConnectionAcquisitionEvent.executionTime = getExecutionTime( jdbcConnectionAcquisitionEvent.startedAt );
|
jdbcConnectionAcquisitionEvent.executionTime = getExecutionTime( jdbcConnectionAcquisitionEvent.startedAt );
|
||||||
|
@ -109,21 +130,24 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcConnectionReleaseEvent beginJdbcConnectionReleaseEvent() {
|
public JdbcConnectionReleaseEvent beginJdbcConnectionReleaseEvent() {
|
||||||
|
if ( jdbcConnectionReleaseEventType.isEnabled() ) {
|
||||||
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = new JdbcConnectionReleaseEvent();
|
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = new JdbcConnectionReleaseEvent();
|
||||||
if ( jdbcConnectionReleaseEvent.isEnabled() ) {
|
|
||||||
jdbcConnectionReleaseEvent.begin();
|
jdbcConnectionReleaseEvent.begin();
|
||||||
jdbcConnectionReleaseEvent.startedAt = System.nanoTime();
|
jdbcConnectionReleaseEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return jdbcConnectionReleaseEvent;
|
return jdbcConnectionReleaseEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeJdbcConnectionReleaseEvent(
|
public void completeJdbcConnectionReleaseEvent(
|
||||||
HibernateEvent event,
|
HibernateEvent event,
|
||||||
SharedSessionContractImplementor session,
|
SharedSessionContractImplementor session,
|
||||||
Object tenantId) {
|
Object tenantId) {
|
||||||
|
if ( event != null ) {
|
||||||
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = (JdbcConnectionReleaseEvent) event;
|
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = (JdbcConnectionReleaseEvent) event;
|
||||||
if ( jdbcConnectionReleaseEvent.isEnabled() ) {
|
|
||||||
jdbcConnectionReleaseEvent.end();
|
jdbcConnectionReleaseEvent.end();
|
||||||
if ( jdbcConnectionReleaseEvent.shouldCommit() ) {
|
if ( jdbcConnectionReleaseEvent.shouldCommit() ) {
|
||||||
jdbcConnectionReleaseEvent.executionTime = getExecutionTime( jdbcConnectionReleaseEvent.startedAt );
|
jdbcConnectionReleaseEvent.executionTime = getExecutionTime( jdbcConnectionReleaseEvent.startedAt );
|
||||||
|
@ -138,20 +162,23 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcPreparedStatementCreationEvent beginJdbcPreparedStatementCreationEvent() {
|
public JdbcPreparedStatementCreationEvent beginJdbcPreparedStatementCreationEvent() {
|
||||||
|
if ( jdbcPreparedStatementCreationEventType.isEnabled() ) {
|
||||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = new JdbcPreparedStatementCreationEvent();
|
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = new JdbcPreparedStatementCreationEvent();
|
||||||
if ( jdbcPreparedStatementCreation.isEnabled() ) {
|
|
||||||
jdbcPreparedStatementCreation.begin();
|
jdbcPreparedStatementCreation.begin();
|
||||||
jdbcPreparedStatementCreation.startedAt = System.nanoTime();
|
jdbcPreparedStatementCreation.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return jdbcPreparedStatementCreation;
|
return jdbcPreparedStatementCreation;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeJdbcPreparedStatementCreationEvent(
|
public void completeJdbcPreparedStatementCreationEvent(
|
||||||
HibernateEvent event,
|
HibernateEvent event,
|
||||||
String preparedStatementSql) {
|
String preparedStatementSql) {
|
||||||
|
if ( event != null ) {
|
||||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = (JdbcPreparedStatementCreationEvent) event;
|
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = (JdbcPreparedStatementCreationEvent) event;
|
||||||
if ( jdbcPreparedStatementCreation.isEnabled() ) {
|
|
||||||
jdbcPreparedStatementCreation.end();
|
jdbcPreparedStatementCreation.end();
|
||||||
if ( jdbcPreparedStatementCreation.shouldCommit() ) {
|
if ( jdbcPreparedStatementCreation.shouldCommit() ) {
|
||||||
jdbcPreparedStatementCreation.executionTime = getExecutionTime( jdbcPreparedStatementCreation.startedAt );
|
jdbcPreparedStatementCreation.executionTime = getExecutionTime( jdbcPreparedStatementCreation.startedAt );
|
||||||
|
@ -163,20 +190,23 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcPreparedStatementExecutionEvent beginJdbcPreparedStatementExecutionEvent() {
|
public JdbcPreparedStatementExecutionEvent beginJdbcPreparedStatementExecutionEvent() {
|
||||||
|
if ( jdbcPreparedStatementExecutionEventType.isEnabled() ) {
|
||||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = new JdbcPreparedStatementExecutionEvent();
|
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = new JdbcPreparedStatementExecutionEvent();
|
||||||
if ( jdbcPreparedStatementExecutionEvent.isEnabled() ) {
|
|
||||||
jdbcPreparedStatementExecutionEvent.begin();
|
jdbcPreparedStatementExecutionEvent.begin();
|
||||||
jdbcPreparedStatementExecutionEvent.startedAt = System.nanoTime();
|
jdbcPreparedStatementExecutionEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return jdbcPreparedStatementExecutionEvent;
|
return jdbcPreparedStatementExecutionEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeJdbcPreparedStatementExecutionEvent(
|
public void completeJdbcPreparedStatementExecutionEvent(
|
||||||
HibernateEvent event,
|
HibernateEvent event,
|
||||||
String preparedStatementSql) {
|
String preparedStatementSql) {
|
||||||
|
if ( event != null ) {
|
||||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = (JdbcPreparedStatementExecutionEvent) event;
|
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = (JdbcPreparedStatementExecutionEvent) event;
|
||||||
if ( jdbcPreparedStatementExecutionEvent.isEnabled() ) {
|
|
||||||
jdbcPreparedStatementExecutionEvent.end();
|
jdbcPreparedStatementExecutionEvent.end();
|
||||||
if ( jdbcPreparedStatementExecutionEvent.shouldCommit() ) {
|
if ( jdbcPreparedStatementExecutionEvent.shouldCommit() ) {
|
||||||
jdbcPreparedStatementExecutionEvent.executionTime = getExecutionTime(
|
jdbcPreparedStatementExecutionEvent.executionTime = getExecutionTime(
|
||||||
|
@ -189,20 +219,23 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcBatchExecutionEvent beginJdbcBatchExecutionEvent() {
|
public JdbcBatchExecutionEvent beginJdbcBatchExecutionEvent() {
|
||||||
|
if ( jdbcBatchExecutionEventType.isEnabled() ) {
|
||||||
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = new JdbcBatchExecutionEvent();
|
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = new JdbcBatchExecutionEvent();
|
||||||
if ( jdbcBatchExecutionEvent.isEnabled() ) {
|
|
||||||
jdbcBatchExecutionEvent.begin();
|
jdbcBatchExecutionEvent.begin();
|
||||||
jdbcBatchExecutionEvent.startedAt = System.nanoTime();
|
jdbcBatchExecutionEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return jdbcBatchExecutionEvent;
|
return jdbcBatchExecutionEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeJdbcBatchExecutionEvent(
|
public void completeJdbcBatchExecutionEvent(
|
||||||
HibernateEvent event,
|
HibernateEvent event,
|
||||||
String statementSql) {
|
String statementSql) {
|
||||||
|
if ( event != null ) {
|
||||||
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = (JdbcBatchExecutionEvent) event;
|
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = (JdbcBatchExecutionEvent) event;
|
||||||
if ( jdbcBatchExecutionEvent.isEnabled() ) {
|
|
||||||
jdbcBatchExecutionEvent.end();
|
jdbcBatchExecutionEvent.end();
|
||||||
if ( jdbcBatchExecutionEvent.shouldCommit() ) {
|
if ( jdbcBatchExecutionEvent.shouldCommit() ) {
|
||||||
jdbcBatchExecutionEvent.executionTime = getExecutionTime( jdbcBatchExecutionEvent.startedAt );
|
jdbcBatchExecutionEvent.executionTime = getExecutionTime( jdbcBatchExecutionEvent.startedAt );
|
||||||
|
@ -214,13 +247,16 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HibernateEvent beginCachePutEvent() {
|
public HibernateEvent beginCachePutEvent() {
|
||||||
|
if ( cachePutEventType.isEnabled() ) {
|
||||||
final CachePutEvent cachePutEvent = new CachePutEvent();
|
final CachePutEvent cachePutEvent = new CachePutEvent();
|
||||||
if ( cachePutEvent.isEnabled() ) {
|
|
||||||
cachePutEvent.begin();
|
cachePutEvent.begin();
|
||||||
cachePutEvent.startedAt = System.nanoTime();
|
cachePutEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return cachePutEvent;
|
return cachePutEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeCachePutEvent(
|
public void completeCachePutEvent(
|
||||||
|
@ -229,8 +265,8 @@ public class JfrEventManager implements EventManager {
|
||||||
Region region,
|
Region region,
|
||||||
boolean cacheContentChanged,
|
boolean cacheContentChanged,
|
||||||
CacheActionDescription description) {
|
CacheActionDescription description) {
|
||||||
|
if ( event != null ) {
|
||||||
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
||||||
if ( cachePutEvent.isEnabled() ) {
|
|
||||||
cachePutEvent.end();
|
cachePutEvent.end();
|
||||||
if ( cachePutEvent.shouldCommit() ) {
|
if ( cachePutEvent.shouldCommit() ) {
|
||||||
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
|
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
|
||||||
|
@ -271,8 +307,8 @@ public class JfrEventManager implements EventManager {
|
||||||
boolean cacheContentChanged,
|
boolean cacheContentChanged,
|
||||||
boolean isNatualId,
|
boolean isNatualId,
|
||||||
CacheActionDescription description) {
|
CacheActionDescription description) {
|
||||||
|
if ( event != null ) {
|
||||||
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
||||||
if ( cachePutEvent.isEnabled() ) {
|
|
||||||
cachePutEvent.end();
|
cachePutEvent.end();
|
||||||
if ( cachePutEvent.shouldCommit() ) {
|
if ( cachePutEvent.shouldCommit() ) {
|
||||||
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
|
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
|
||||||
|
@ -295,8 +331,8 @@ public class JfrEventManager implements EventManager {
|
||||||
CollectionPersister persister,
|
CollectionPersister persister,
|
||||||
boolean cacheContentChanged,
|
boolean cacheContentChanged,
|
||||||
CacheActionDescription description) {
|
CacheActionDescription description) {
|
||||||
|
if ( event != null ) {
|
||||||
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
||||||
if ( cachePutEvent.isEnabled() ) {
|
|
||||||
cachePutEvent.end();
|
cachePutEvent.end();
|
||||||
if ( cachePutEvent.shouldCommit() ) {
|
if ( cachePutEvent.shouldCommit() ) {
|
||||||
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
|
cachePutEvent.executionTime = getExecutionTime( cachePutEvent.startedAt );
|
||||||
|
@ -312,13 +348,16 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HibernateEvent beginCacheGetEvent() {
|
public HibernateEvent beginCacheGetEvent() {
|
||||||
|
if ( cacheGetEventType.isEnabled() ) {
|
||||||
final CacheGetEvent cacheGetEvent = new CacheGetEvent();
|
final CacheGetEvent cacheGetEvent = new CacheGetEvent();
|
||||||
if ( cacheGetEvent.isEnabled() ) {
|
|
||||||
cacheGetEvent.begin();
|
cacheGetEvent.begin();
|
||||||
cacheGetEvent.startedAt = System.nanoTime();
|
cacheGetEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return cacheGetEvent;
|
return cacheGetEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeCacheGetEvent(
|
public void completeCacheGetEvent(
|
||||||
|
@ -326,8 +365,8 @@ public class JfrEventManager implements EventManager {
|
||||||
SharedSessionContractImplementor session,
|
SharedSessionContractImplementor session,
|
||||||
Region region,
|
Region region,
|
||||||
boolean hit) {
|
boolean hit) {
|
||||||
|
if ( event != null ) {
|
||||||
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
||||||
if ( cacheGetEvent.isEnabled() ) {
|
|
||||||
cacheGetEvent.end();
|
cacheGetEvent.end();
|
||||||
if ( cacheGetEvent.shouldCommit() ) {
|
if ( cacheGetEvent.shouldCommit() ) {
|
||||||
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
|
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
|
||||||
|
@ -347,8 +386,8 @@ public class JfrEventManager implements EventManager {
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
boolean isNaturalKey,
|
boolean isNaturalKey,
|
||||||
boolean hit) {
|
boolean hit) {
|
||||||
|
if ( event != null ) {
|
||||||
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
||||||
if ( cacheGetEvent.isEnabled() ) {
|
|
||||||
cacheGetEvent.end();
|
cacheGetEvent.end();
|
||||||
if ( cacheGetEvent.shouldCommit() ) {
|
if ( cacheGetEvent.shouldCommit() ) {
|
||||||
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
|
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
|
||||||
|
@ -369,8 +408,8 @@ public class JfrEventManager implements EventManager {
|
||||||
Region region,
|
Region region,
|
||||||
CollectionPersister persister,
|
CollectionPersister persister,
|
||||||
boolean hit) {
|
boolean hit) {
|
||||||
|
if ( event != null ) {
|
||||||
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
||||||
if ( cacheGetEvent.isEnabled() ) {
|
|
||||||
cacheGetEvent.end();
|
cacheGetEvent.end();
|
||||||
if ( cacheGetEvent.shouldCommit() ) {
|
if ( cacheGetEvent.shouldCommit() ) {
|
||||||
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
|
cacheGetEvent.executionTime = getExecutionTime( cacheGetEvent.startedAt );
|
||||||
|
@ -385,13 +424,16 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FlushEvent beginFlushEvent() {
|
public FlushEvent beginFlushEvent() {
|
||||||
|
if ( flushEventType.isEnabled() ) {
|
||||||
final FlushEvent flushEvent = new FlushEvent();
|
final FlushEvent flushEvent = new FlushEvent();
|
||||||
if ( flushEvent.isEnabled() ) {
|
|
||||||
flushEvent.begin();
|
flushEvent.begin();
|
||||||
flushEvent.startedAt = System.nanoTime();
|
flushEvent.startedAt = System.nanoTime();
|
||||||
}
|
|
||||||
return flushEvent;
|
return flushEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeFlushEvent(
|
public void completeFlushEvent(
|
||||||
|
@ -405,8 +447,8 @@ public class JfrEventManager implements EventManager {
|
||||||
HibernateEvent hibernateEvent,
|
HibernateEvent hibernateEvent,
|
||||||
org.hibernate.event.spi.FlushEvent event,
|
org.hibernate.event.spi.FlushEvent event,
|
||||||
boolean autoFlush) {
|
boolean autoFlush) {
|
||||||
|
if ( hibernateEvent != null ) {
|
||||||
final FlushEvent flushEvent = (FlushEvent) hibernateEvent;
|
final FlushEvent flushEvent = (FlushEvent) hibernateEvent;
|
||||||
if ( flushEvent.isEnabled() ) {
|
|
||||||
flushEvent.end();
|
flushEvent.end();
|
||||||
if ( flushEvent.shouldCommit() ) {
|
if ( flushEvent.shouldCommit() ) {
|
||||||
flushEvent.executionTime = getExecutionTime( flushEvent.startedAt );
|
flushEvent.executionTime = getExecutionTime( flushEvent.startedAt );
|
||||||
|
@ -422,20 +464,23 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PartialFlushEvent beginPartialFlushEvent() {
|
public PartialFlushEvent beginPartialFlushEvent() {
|
||||||
|
if ( partialFlushEventType.isEnabled() ) {
|
||||||
final PartialFlushEvent partialFlushEvent = new PartialFlushEvent();
|
final PartialFlushEvent partialFlushEvent = new PartialFlushEvent();
|
||||||
if ( partialFlushEvent.isEnabled() ) {
|
|
||||||
partialFlushEvent.startedAt = System.nanoTime();
|
partialFlushEvent.startedAt = System.nanoTime();
|
||||||
partialFlushEvent.begin();
|
partialFlushEvent.begin();
|
||||||
}
|
|
||||||
return partialFlushEvent;
|
return partialFlushEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completePartialFlushEvent(
|
public void completePartialFlushEvent(
|
||||||
HibernateEvent hibernateEvent,
|
HibernateEvent hibernateEvent,
|
||||||
AutoFlushEvent event) {
|
AutoFlushEvent event) {
|
||||||
|
if ( event != null ) {
|
||||||
final PartialFlushEvent flushEvent = (PartialFlushEvent) hibernateEvent;
|
final PartialFlushEvent flushEvent = (PartialFlushEvent) hibernateEvent;
|
||||||
if ( flushEvent.isEnabled() ) {
|
|
||||||
flushEvent.end();
|
flushEvent.end();
|
||||||
if ( flushEvent.shouldCommit() ) {
|
if ( flushEvent.shouldCommit() ) {
|
||||||
flushEvent.executionTime = getExecutionTime( flushEvent.startedAt );
|
flushEvent.executionTime = getExecutionTime( flushEvent.startedAt );
|
||||||
|
@ -451,13 +496,16 @@ public class JfrEventManager implements EventManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DirtyCalculationEvent beginDirtyCalculationEvent() {
|
public DirtyCalculationEvent beginDirtyCalculationEvent() {
|
||||||
|
if ( dirtyCalculationEventType.isEnabled() ) {
|
||||||
final DirtyCalculationEvent dirtyCalculationEvent = new DirtyCalculationEvent();
|
final DirtyCalculationEvent dirtyCalculationEvent = new DirtyCalculationEvent();
|
||||||
if ( dirtyCalculationEvent.isEnabled() ) {
|
|
||||||
dirtyCalculationEvent.startedAt = System.nanoTime();
|
dirtyCalculationEvent.startedAt = System.nanoTime();
|
||||||
dirtyCalculationEvent.begin();
|
dirtyCalculationEvent.begin();
|
||||||
}
|
|
||||||
return dirtyCalculationEvent;
|
return dirtyCalculationEvent;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void completeDirtyCalculationEvent(
|
public void completeDirtyCalculationEvent(
|
||||||
|
@ -466,8 +514,8 @@ public class JfrEventManager implements EventManager {
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
EntityEntry entry,
|
EntityEntry entry,
|
||||||
int[] dirtyProperties) {
|
int[] dirtyProperties) {
|
||||||
|
if ( event != null ) {
|
||||||
final DirtyCalculationEvent dirtyCalculationEvent = (DirtyCalculationEvent) event;
|
final DirtyCalculationEvent dirtyCalculationEvent = (DirtyCalculationEvent) event;
|
||||||
if ( dirtyCalculationEvent.isEnabled() ) {
|
|
||||||
dirtyCalculationEvent.end();
|
dirtyCalculationEvent.end();
|
||||||
if ( dirtyCalculationEvent.shouldCommit() ) {
|
if ( dirtyCalculationEvent.shouldCommit() ) {
|
||||||
dirtyCalculationEvent.executionTime = getExecutionTime( dirtyCalculationEvent.startedAt );
|
dirtyCalculationEvent.executionTime = getExecutionTime( dirtyCalculationEvent.startedAt );
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class PartialFlushEvent extends Event implements HibernateEvent {
|
||||||
@Label( "Number Of Processed Entities" )
|
@Label( "Number Of Processed Entities" )
|
||||||
public int numberOfEntitiesProcessed;
|
public int numberOfEntitiesProcessed;
|
||||||
|
|
||||||
@Label( "Number Of Processed Collectionc" )
|
@Label( "Number Of Processed Collections" )
|
||||||
public int numberOfCollectionsProcessed;
|
public int numberOfCollectionsProcessed;
|
||||||
|
|
||||||
@Label( "PartialFlushEvent time" )
|
@Label( "PartialFlushEvent time" )
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class DirtyCalculationEventTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@EnableEvent(DirtyCalculationEvent.NAME)
|
@EnableEvent(DirtyCalculationEvent.NAME)
|
||||||
public void testFlushEvent(SessionFactoryScope scope) {
|
public void testDirtyCalculationEvent(SessionFactoryScope scope) {
|
||||||
jfrEvents.reset();
|
jfrEvents.reset();
|
||||||
String sessionId = scope.fromTransaction(
|
String sessionId = scope.fromTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
|
|
Loading…
Reference in New Issue