initial add of EbeanORM server based on v2.8.1

This commit is contained in:
rbygrave committed 2012-09-14 00:40:39 +12:00
1 parent 2b74d0f9d9
commit 96ce4c0ddf
1188 files changed
+135034

No files matched your search

@@ -0,0 +1,121 @@
package com.avaje.ebeaninternal.server.jmx;
import java.util.logging.Logger;
import com.avaje.ebean.AdminAutofetch;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.config.AutofetchMode;
import com.avaje.ebeaninternal.server.autofetch.AutoFetchManager;
/**
* Implementation of the AutoFetchControl.
* <p>
* This is accessible via {@link EbeanServer#getAdminAutofetch()} or via JMX
* MBeans.
* </p>
*/
public class MAdminAutofetch implements MAdminAutofetchMBean, AdminAutofetch {
final Logger logger = Logger.getLogger(MAdminAutofetch.class.getName());
final AutoFetchManager autoFetchManager;
final String modeOptions;
public MAdminAutofetch(AutoFetchManager autoFetchListener) {
this.autoFetchManager = autoFetchListener;
this.modeOptions = AutofetchMode.DEFAULT_OFF + ", "
+ AutofetchMode.DEFAULT_ON + ", "
+ AutofetchMode.DEFAULT_ONIFEMPTY;
}
public boolean isQueryTuning() {
return autoFetchManager.isQueryTuning();
}
public void setQueryTuning(boolean enable) {
autoFetchManager.setQueryTuning(enable);
}
public boolean isProfiling() {
return autoFetchManager.isProfiling();
}
public void setProfiling(boolean enable) {
autoFetchManager.setProfiling(enable);
}
public String getModeOptions() {
return modeOptions;
}
public String getMode() {
return autoFetchManager.getMode().name();
}
public void setMode(String implicitMode) {
try {
AutofetchMode mode = AutofetchMode.valueOf(implicitMode);
autoFetchManager.setMode(mode);
} catch (Exception e) {
logger.info("Invalid implicit mode attempted "+e.getMessage());
}
}
public String collectUsageViaGC() {
return autoFetchManager.collectUsageViaGC(-1);
}
public double getProfilingRate() {
return autoFetchManager.getProfilingRate();
}
public void setProfilingRate(double rate) {
autoFetchManager.setProfilingRate(rate);
}
public int getProfilingMin() {
return autoFetchManager.getProfilingMin();
}
public int getProfilingBase() {
return autoFetchManager.getProfilingBase();
}
public void setProfilingMin(int profilingMin) {
autoFetchManager.setProfilingMin(profilingMin);
}
public void setProfilingBase(int profilingMax) {
autoFetchManager.setProfilingBase(profilingMax);
}
public String updateTunedQueryInfo() {
return autoFetchManager.updateTunedQueryInfo();
}
public int clearProfilingInfo() {
return autoFetchManager.clearProfilingInfo();
}
public int clearTunedQueryInfo() {
return autoFetchManager.clearTunedQueryInfo();
}
public void clearQueryStatistics() {
autoFetchManager.clearQueryStatistics();
}
public int getTotalProfileSize() {
return autoFetchManager.getTotalProfileSize();
}
public int getTotalTunedQueryCount() {
return autoFetchManager.getTotalTunedQueryCount();
}
public int getTotalTunedQuerySize() {
return autoFetchManager.getTotalTunedQuerySize();
}
}
@@ -0,0 +1,145 @@
package com.avaje.ebeaninternal.server.jmx;
import com.avaje.ebean.Query;
public interface MAdminAutofetchMBean {
/**
* Return true if profiling is enabled.
*/
public boolean isProfiling();
/**
* Set to true to enable profiling.
*/
public void setProfiling(boolean enable);
/**
* Return true if autoFetch is enabled.
*/
public boolean isQueryTuning();
/**
* Set to true to enable autoFetch.
*/
public void setQueryTuning(boolean enable);
/**
* This controls whether autoFetch is used when it has not
* been explicitly set on a query via {@link Query#setAutoFetch(boolean)}.
*/
public String getMode();
/**
* List of the valid implicit modes that can be used.
*/
public String getModeOptions();
/**
* Set the auto fetch mode used when a query has not had {@link Query#setAutoFetch(boolean)}.
*/
public void setMode(String mode);
/**
* Return the max number of queries profiled (per query point).
* <p>
* The number of queries profiled is collected per query point. Once a query
* point has profiled this number of queries it does not profile any more.
* </p>
*/
public int getProfilingBase();
/**
* Set a max number of queries to profile per query point.
* <p>
* This number should provide a level of confidence that no more profiling
* is required for this query point.
* </p>
*/
public void setProfilingBase(int profilingMaxThreshold);
/**
* Returns the rate which profiling is collected.
* This is an int between 0 and 100.
*/
public double getProfilingRate();
/**
* Set the rate at which profiling is collected after the base.
*
* @param rate a int between 0 and 100.
*/
public void setProfilingRate(double rate);
/**
* Return the minimum number of queries profiled before autoFetch will start
* automatically tuning the queries.
* <p>
* This could be one which means start autoFetch tuning after the first
* profiling information is collected.
* </p>
*/
public int getProfilingMin();
/**
* Set the minimum number of queries profiled per query point before
* autoFetch will automatically tune the queries.
* <p>
* Increasing this number will mean more profiling is collected before
* autoFetch starts tuning the query.
* </p>
*/
public void setProfilingMin(int autoFetchMinThreshold);
/**
* Fire a garbage collection (hint to the JVM). Assuming garbage collection
* fires this will gather the usage profiling information.
*/
public String collectUsageViaGC();
/**
* This will take the current profiling information and update the "tuned query
* detail".
* <p>
* This is done periodically and can also be manually invoked.
* </p>
*/
public String updateTunedQueryInfo();
/**
* Clear all the tuned query info.
* <p>
* Should only need do this for testing and playing around.
* </p>
* @return the amount of tuned query information cleared.
*/
public int clearTunedQueryInfo();
/**
* Clear all the profiling information.
* <p>
* This means the profiling information will need to be re-gathered.
* </p>
* <p>
* Should only need do this for testing and playing around.
* </p>
* @return the amount of profiled information cleared.
*/
public int clearProfilingInfo();
/**
* Return the number of queries tuned by AutoFetch.
*/
public int getTotalTunedQueryCount();
/**
* Return the size of the TuneQuery map.
*/
public int getTotalTunedQuerySize();
/**
* Return the size of the profile map.
*/
public int getTotalProfileSize();
}
@@ -0,0 +1,75 @@
/**
* Copyright (C) 2006 Robin Bygrave
*
* This file is part of Ebean.
*
* Ebean is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* Ebean is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Ebean; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package com.avaje.ebeaninternal.server.jmx;
import com.avaje.ebean.AdminLogging;
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.LogLevel;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebeaninternal.server.transaction.TransactionManager;
/**
* Implementation of the LogControl.
* <p>
* This is accessible via {@link EbeanServer#getAdminLogging()} or via JMX MBean.
* </p>
*/
public class MAdminLogging implements MAdminLoggingMBean, AdminLogging {
private final TransactionManager transactionManager;
private boolean debugSql;
private boolean debugLazyLoad;
/**
* Configure from serverConfig properties.
*/
public MAdminLogging(ServerConfig serverConfig, TransactionManager txManager) {
this.transactionManager = txManager;
this.debugSql = serverConfig.isDebugSql();
this.debugLazyLoad = serverConfig.isDebugLazyLoad();
}
public void setLogLevel(LogLevel logLevel){
transactionManager.setTransactionLogLevel(logLevel);
}
public LogLevel getLogLevel() {
return transactionManager.getTransactionLogLevel();
}
public boolean isDebugGeneratedSql() {
return debugSql;
}
public void setDebugGeneratedSql(boolean debugSql) {
this.debugSql = debugSql;
}
public boolean isDebugLazyLoad() {
return debugLazyLoad;
}
public void setDebugLazyLoad(boolean debugLazyLoad) {
this.debugLazyLoad = debugLazyLoad;
}
}
@@ -0,0 +1,37 @@
package com.avaje.ebeaninternal.server.jmx;
import com.avaje.ebean.LogLevel;
public interface MAdminLoggingMBean {
/**
* The current log level .
*/
public LogLevel getLogLevel();
/**
* Set the log level for native sql queries.
*/
public void setLogLevel(LogLevel logLevel);
/**
* If true Log generated sql to the console.
*/
public boolean isDebugGeneratedSql();
/**
* Set to true to Log generated sql to the console.
*/
public void setDebugGeneratedSql(boolean debugSql);
/**
* Return true if lazy loading should be debugged.
*/
public boolean isDebugLazyLoad();
/**
* Set the debugging on lazy loading.
*/
public void setDebugLazyLoad(boolean debugLazyLoad);
}
@@ -0,0 +1,4 @@
/**
* JMX MBeans.
*/
package com.avaje.ebeaninternal.server.jmx;