HHH-6190 - Leverage JmxService to expose management and monitoring capabilities.
This commit is contained in:
parent
36fc1ad35e
commit
180df5199e
|
@ -36,6 +36,7 @@ public class JmxTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected Map buildSettings() {
|
protected Map buildSettings() {
|
||||||
Map properties = super.buildSettings();
|
Map properties = super.buildSettings();
|
||||||
|
properties.put( AvailableSettings.GENERATE_STATISTICS, Boolean.TRUE.toString());
|
||||||
properties.put( AvailableSettings.JMX_ENABLED, Boolean.TRUE.toString());
|
properties.put( AvailableSettings.JMX_ENABLED, Boolean.TRUE.toString());
|
||||||
properties.put( AvailableSettings.JMX_DOMAIN_NAME, "test");
|
properties.put( AvailableSettings.JMX_DOMAIN_NAME, "test");
|
||||||
return properties;
|
return properties;
|
||||||
|
|
|
@ -70,21 +70,4 @@ public class BatchBuilderImpl implements BatchBuilder, Configurable, Manageable,
|
||||||
? new BatchingBatch( key, jdbcCoordinator, jdbcBatchSizeToUse )
|
? new BatchingBatch( key, jdbcCoordinator, jdbcBatchSizeToUse )
|
||||||
: new NonBatchingBatch( key, jdbcCoordinator );
|
: new NonBatchingBatch( key, jdbcCoordinator );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getManagementDomain() {
|
|
||||||
// use Hibernate default domain
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getManagementServiceType() {
|
|
||||||
// use Hibernate default scheme
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getManagementBean() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,22 @@ public class JmxServiceImpl implements JmxService, Stoppable {
|
||||||
usePlatformServer = ConfigurationHelper.getBoolean( AvailableSettings.JMX_PLATFORM_SERVER, configValues );
|
usePlatformServer = ConfigurationHelper.getBoolean( AvailableSettings.JMX_PLATFORM_SERVER, configValues );
|
||||||
agentId = (String) configValues.get( AvailableSettings.JMX_AGENT_ID );
|
agentId = (String) configValues.get( AvailableSettings.JMX_AGENT_ID );
|
||||||
defaultDomain = (String) configValues.get( AvailableSettings.JMX_DOMAIN_NAME );
|
defaultDomain = (String) configValues.get( AvailableSettings.JMX_DOMAIN_NAME );
|
||||||
|
|
||||||
|
String defaultSessionFactoryName = ConfigurationHelper.getString(
|
||||||
|
Environment.SESSION_FACTORY_NAME,
|
||||||
|
configValues
|
||||||
|
);
|
||||||
|
if ( defaultSessionFactoryName == null ) {
|
||||||
|
defaultSessionFactoryName = ConfigurationHelper.getString(
|
||||||
|
Environment.PERSISTENCE_UNIT_NAME,
|
||||||
|
configValues
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
sessionFactoryName = ConfigurationHelper.getString(
|
sessionFactoryName = ConfigurationHelper.getString(
|
||||||
AvailableSettings.JMX_SF_NAME,
|
AvailableSettings.JMX_SF_NAME,
|
||||||
configValues,
|
configValues,
|
||||||
ConfigurationHelper.getString( Environment.SESSION_FACTORY_NAME, configValues )
|
defaultSessionFactoryName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,10 @@ public interface Manageable {
|
||||||
*
|
*
|
||||||
* @return The management domain.
|
* @return The management domain.
|
||||||
*/
|
*/
|
||||||
public String getManagementDomain();
|
default String getManagementDomain() {
|
||||||
|
// use Hibernate default domain
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the service to specify a special 'serviceType' portion of the object name. {@code null} indicates
|
* Allows the service to specify a special 'serviceType' portion of the object name. {@code null} indicates
|
||||||
|
@ -26,12 +29,17 @@ public interface Manageable {
|
||||||
*
|
*
|
||||||
* @return The custom 'serviceType' name.
|
* @return The custom 'serviceType' name.
|
||||||
*/
|
*/
|
||||||
public String getManagementServiceType();
|
default String getManagementServiceType() {
|
||||||
|
// use Hibernate default domain
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The the management bean (MBean) for this service.
|
* The the management bean (MBean) for this service.
|
||||||
*
|
*
|
||||||
* @return The management bean.
|
* @return The management bean.
|
||||||
*/
|
*/
|
||||||
public Object getManagementBean();
|
default Object getManagementBean() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,18 +22,6 @@ public interface OptionallyManageable extends Manageable {
|
||||||
*/
|
*/
|
||||||
List<Manageable> getRealManageables();
|
List<Manageable> getRealManageables();
|
||||||
|
|
||||||
@Override
|
|
||||||
default String getManagementDomain() {
|
|
||||||
// Generally the wrapper is not Manageable itself
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
default String getManagementServiceType() {
|
|
||||||
// Generally the wrapper is not Manageable itself
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default Object getManagementBean() {
|
default Object getManagementBean() {
|
||||||
// Generally the wrapper is not Manageable itself
|
// Generally the wrapper is not Manageable itself
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.stat;
|
package org.hibernate.stat;
|
||||||
|
|
||||||
|
import javax.management.MXBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposes statistics for a particular {@link org.hibernate.SessionFactory}. Beware of milliseconds metrics, they
|
* Exposes statistics for a particular {@link org.hibernate.SessionFactory}. Beware of milliseconds metrics, they
|
||||||
* are dependent of the JVM precision: you may then encounter a 10 ms approximation depending on you OS platform.
|
* are dependent of the JVM precision: you may then encounter a 10 ms approximation depending on you OS platform.
|
||||||
|
@ -13,6 +15,7 @@ package org.hibernate.stat;
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
|
@MXBean
|
||||||
public interface Statistics {
|
public interface Statistics {
|
||||||
|
|
||||||
int DEFAULT_QUERY_STATISTICS_MAX_SIZE = 5000;
|
int DEFAULT_QUERY_STATISTICS_MAX_SIZE = 5000;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.internal.util.collections.BoundedConcurrentHashMap;
|
||||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
|
import org.hibernate.service.spi.Manageable;
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||||
* @author Alex Snaps
|
* @author Alex Snaps
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
public class StatisticsImpl implements StatisticsImplementor, Service {
|
public class StatisticsImpl implements StatisticsImplementor, Service, Manageable {
|
||||||
private static final CoreMessageLogger LOG = messageLogger( StatisticsImpl.class );
|
private static final CoreMessageLogger LOG = messageLogger( StatisticsImpl.class );
|
||||||
|
|
||||||
private final SessionFactoryImplementor sessionFactory;
|
private final SessionFactoryImplementor sessionFactory;
|
||||||
|
@ -931,8 +932,6 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logSummary() {
|
public void logSummary() {
|
||||||
LOG.loggingStatistics();
|
LOG.loggingStatistics();
|
||||||
|
|
Loading…
Reference in New Issue