Author: karthick
Date: Wed Mar 4 21:39:12 2009
New Revision: 750166
URL: http://svn.apache.org/viewvc?rev=750166&view=rev
Log:
If the server is running low on memory, suggest sensible next steps to the user.
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=750166&r1=750165&r2=750166&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
Wed Mar 4 21:39:12 2009
@@ -561,6 +561,7 @@
_server.setDehydrationPolicy(dehy);
}
_server.setHydrationLazy(_odeConfig.isHydrationLazy());
+
_server.setLowFreeMemoryThreshold(_odeConfig.getLowFreeMemoryThreshold());
_server.setConfigProperties(_odeConfig.getProperties());
_server.init();
}
Modified:
ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java?rev=750166&r1=750165&r2=750166&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java
Wed Mar 4 21:39:12 2009
@@ -86,6 +86,8 @@
public static final String PROP_PROCESS_HYDRATION = "process.hydration";
+ public static final String PROP_LOW_FREE_MEMORY_THRESHOLD =
"low.free.memory.threshold";
+
public static final String PROP_DAOCF = "dao.factory";
private File _cfgFile;
@@ -263,6 +265,10 @@
public boolean isDbLoggingEnabled() {
return
Boolean.valueOf(getProperty(OdeConfigProperties.PROP_DB_LOGGING, "false"));
}
+
+ public int getLowFreeMemoryThreshold() {
+ return Integer.valueOf(getProperty(PROP_LOW_FREE_MEMORY_THRESHOLD,
"10"));
+ }
public String getProperty(String pname) {
Modified:
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?rev=750166&r1=750165&r2=750166&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
(original)
+++
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
Wed Mar 4 21:39:12 2009
@@ -90,6 +90,7 @@
private Contexts _contexts = new Contexts();
private DehydrationPolicy _dehydrationPolicy;
private boolean _hydrationLazy;
+ private int _lowFreeMemoryThreshold;
private Properties _configProperties;
BpelEngineImpl _engine;
@@ -141,6 +142,7 @@
_state = State.RUNNING;
__log.info(__msgs.msgServerStarted());
if (_dehydrationPolicy != null) new Thread(new
ProcessDefReaper()).start();
+ if (_lowFreeMemoryThreshold != 0) new Thread(new
FreeMemoryChecker()).start();
} finally {
_mngmtLock.writeLock().unlock();
}
@@ -391,6 +393,37 @@
getEngine().onScheduledJob(jobInfo);
}
+ private class FreeMemoryChecker implements Runnable {
+ Runtime runtime = Runtime.getRuntime();
+ public void run() {
+ __log.debug("Starting free memory checker thread.");
+ long pollingTime = 60000;
+ try {
+ while (true) {
+ Thread.sleep(pollingTime);
+ double freeMemory = (double) runtime.freeMemory();
+ double maxMemory = (double) runtime.maxMemory();
+ if ((freeMemory / maxMemory) < (_lowFreeMemoryThreshold /
100)) {
+ __log.info("You are running out of free
memory!");
+ __log.info("Please try to restart the server
with a higher maximum Java heap size");
+ __log.info("If you cannot increase the heap
size, then please reduce your workload by:");
+ __log.info("a) Waiting for active instances to
complete before starting new ones");
+ __log.info("b) Retiring low-priority processes
that you don't plan on using");
+ if (_dehydrationPolicy == null) {
+ __log.info("Process dehydration is currently
turned off");
+ __log.info("Restarting the server with process
hydration turned on may help");
+ } else {
+ __log.info("Process dehydration is currently
turned on");
+ __log.info("Configuring process hydration with
a lower maximum age and count may help");
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ __log.info(e);
+ }
+ }
+ }
+
private class ProcessDefReaper implements Runnable {
public void run() {
__log.debug("Starting process definition reaper thread.");
@@ -477,7 +510,11 @@
}
public void setHydrationLazy(boolean hydrationLazy) {
- this._hydrationLazy = hydrationLazy;
+ _hydrationLazy = hydrationLazy;
+ }
+
+ public void setLowFreeMemoryThreshold(int lowFreeMemoryThreshold) {
+ _lowFreeMemoryThreshold = lowFreeMemoryThreshold;
}
}