IDEMPIERE-3382 Schedule process shouldn't allow concurrent execution

This commit is contained in:
Heng Sin Low 2017-05-31 11:09:05 +08:00
parent f01e4cac14
commit d12e72aec3
2 changed files with 34 additions and 3 deletions

View File

@ -501,8 +501,13 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
@Override @Override
public void run() { public void run() {
if (server.isSleeping()) {
server.run(); server.run();
scheduleFuture = Adempiere.getThreadPoolExecutor().schedule(this, server.getSleepMS(), TimeUnit.MILLISECONDS); scheduleFuture = Adempiere.getThreadPoolExecutor().schedule(this, server.getSleepMS(), TimeUnit.MILLISECONDS);
} else {
//server busy, try again after one minute
scheduleFuture = Adempiere.getThreadPoolExecutor().schedule(this, 60 * 1000, TimeUnit.MILLISECONDS);
}
} }
public AdempiereServer getServer() { public AdempiereServer getServer() {

View File

@ -69,6 +69,7 @@ import org.compiere.model.MStore;
import org.compiere.model.MSysConfig; import org.compiere.model.MSysConfig;
import org.compiere.model.MSystem; import org.compiere.model.MSystem;
import org.compiere.model.Query; import org.compiere.model.Query;
import org.compiere.server.AdempiereServer;
import org.compiere.server.AdempiereServerGroup; import org.compiere.server.AdempiereServerGroup;
import org.compiere.server.AdempiereServerMgr; import org.compiere.server.AdempiereServerMgr;
import org.compiere.server.AdempiereServerMgr.ServerWrapper; import org.compiere.server.AdempiereServerMgr.ServerWrapper;
@ -268,7 +269,32 @@ public class AdempiereMonitor extends HttpServlet
return false; return false;
} }
// //
server.getServer().runNow(); AdempiereServer serverInstance = server.getServer();
if (serverInstance.isSleeping())
{
serverInstance.runNow();
}
else
{
int count = 0;
while(!serverInstance.isSleeping() && count < 5)
{
count++;
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
Thread.interrupted();
}
}
if (serverInstance.isSleeping())
serverInstance.runNow();
else
{
m_message = new p();
m_message.addElement(new strong("Timeout waiting for server process to be available for execution."));
m_message.addElement(serverID);
}
}
// //
return true; return true;
} // processRunParameter } // processRunParameter