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
|
||||
protected Map 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_DOMAIN_NAME, "test");
|
||||
return properties;
|
||||
|
|
|
@ -70,21 +70,4 @@ public class BatchBuilderImpl implements BatchBuilder, Configurable, Manageable,
|
|||
? new BatchingBatch( key, jdbcCoordinator, jdbcBatchSizeToUse )
|
||||
: 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 );
|
||||
agentId = (String) configValues.get( AvailableSettings.JMX_AGENT_ID );
|
||||
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(
|
||||
AvailableSettings.JMX_SF_NAME,
|
||||
configValues,
|
||||
ConfigurationHelper.getString( Environment.SESSION_FACTORY_NAME, configValues )
|
||||
defaultSessionFactoryName
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,10 @@ public interface Manageable {
|
|||
*
|
||||
* @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
|
||||
|
@ -26,12 +29,17 @@ public interface Manageable {
|
|||
*
|
||||
* @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.
|
||||
*
|
||||
* @return The management bean.
|
||||
*/
|
||||
public Object getManagementBean();
|
||||
default Object getManagementBean() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,18 +22,6 @@ public interface OptionallyManageable extends Manageable {
|
|||
*/
|
||||
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
|
||||
default Object getManagementBean() {
|
||||
// Generally the wrapper is not Manageable itself
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.stat;
|
||||
|
||||
import javax.management.MXBean;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -13,6 +15,7 @@ package org.hibernate.stat;
|
|||
*
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@MXBean
|
||||
public interface Statistics {
|
||||
|
||||
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.persister.entity.EntityPersister;
|
||||
import org.hibernate.service.Service;
|
||||
import org.hibernate.service.spi.Manageable;
|
||||
import org.hibernate.stat.Statistics;
|
||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||
|
||||
|
@ -32,7 +33,7 @@ import static org.hibernate.internal.CoreLogging.messageLogger;
|
|||
* @author Alex Snaps
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||
public class StatisticsImpl implements StatisticsImplementor, Service, Manageable {
|
||||
private static final CoreMessageLogger LOG = messageLogger( StatisticsImpl.class );
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
|
@ -931,8 +932,6 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void logSummary() {
|
||||
LOG.loggingStatistics();
|
||||
|
|
Loading…
Reference in New Issue