IDEMPIERE-3670 Schedule process: always recalculate sleep time before start and startAll. Fix context is lost error.

This commit is contained in:
Heng Sin Low 2018-04-06 13:41:13 +08:00
parent 3d675e132c
commit 77e30d8c2c
1 changed files with 7 additions and 0 deletions

View File

@ -227,6 +227,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
continue; continue;
// Do start // Do start
// replace // replace
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, server.getServer().getModel().getAD_Client_ID());
server.getServer().recalculateSleepMS(); server.getServer().recalculateSleepMS();
server.start(); server.start();
} }
@ -235,6 +236,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
log.log(Level.SEVERE, "Server: " + server, e); log.log(Level.SEVERE, "Server: " + server, e);
} }
} // for all servers } // for all servers
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0);
// Final Check // Final Check
int noRunning = 0; int noRunning = 0;
@ -281,6 +283,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
try try
{ {
// replace // replace
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, server.getServer().getModel().getAD_Client_ID());
server.getServer().recalculateSleepMS(); server.getServer().recalculateSleepMS();
server.start(); server.start();
} }
@ -289,6 +292,10 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
log.log(Level.SEVERE, "Server=" + serverID, e); log.log(Level.SEVERE, "Server=" + serverID, e);
return false; return false;
} }
finally
{
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0);
}
if (log.isLoggable(Level.INFO)) log.info(server.toString()); if (log.isLoggable(Level.INFO)) log.info(server.toString());
return (server.scheduleFuture != null && !server.scheduleFuture.isDone()); return (server.scheduleFuture != null && !server.scheduleFuture.isDone());
} // startIt } // startIt