IDEMPIERE 4211 (#307)
* IDEMPIERE-4211 Schedulers launched twice - problem with RunOnlyOnIP null running on load balancer add 1 to 3 minute delay to wait for hazelcast service * IDEMPIERE-4211 Schedulers launched twice - problem with RunOnlyOnIP null running on load balancer move waiting to background thread add MONITOR_INITIAL_WAIT_FOR_CLUSTER_IN_SECONDS and MONITOR_MAX_WAIT_FOR_CLUSTER_IN_SECONDS sysconfig
This commit is contained in:
parent
2b9cb9bb2e
commit
e06938cedc
|
@ -124,6 +124,8 @@ public class MSysConfig extends X_AD_SysConfig
|
||||||
public static final String MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER = "MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER";
|
public static final String MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER = "MAX_RESULTS_PER_SEARCH_IN_DOCUMENT_CONTROLLER";
|
||||||
public static final String MAX_TEXT_LENGTH_ON_GRID_VIEW = "MAX_TEXT_LENGTH_ON_GRID_VIEW";
|
public static final String MAX_TEXT_LENGTH_ON_GRID_VIEW = "MAX_TEXT_LENGTH_ON_GRID_VIEW";
|
||||||
public static final String MENU_INFOUPDATER_SLEEP_MS = "MENU_INFOUPDATER_SLEEP_MS";
|
public static final String MENU_INFOUPDATER_SLEEP_MS = "MENU_INFOUPDATER_SLEEP_MS";
|
||||||
|
public static final String MONITOR_INITIAL_WAIT_FOR_CLUSTER_IN_SECONDS = "MONITOR_INITIAL_WAIT_FOR_CLUSTER_IN_SECONDS";
|
||||||
|
public static final String MONITOR_MAX_WAIT_FOR_CLUSTER_IN_SECONDS = "MONITOR_MAX_WAIT_FOR_CLUSTER_IN_SECONDS";
|
||||||
public static final String MFG_ValidateCostsDifferenceOnCreate = "MFG_ValidateCostsDifferenceOnCreate";
|
public static final String MFG_ValidateCostsDifferenceOnCreate = "MFG_ValidateCostsDifferenceOnCreate";
|
||||||
public static final String MFG_ValidateCostsOnCreate = "MFG_ValidateCostsOnCreate";
|
public static final String MFG_ValidateCostsOnCreate = "MFG_ValidateCostsOnCreate";
|
||||||
public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT";
|
public static final String PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT = "PAYMENT_OVERWRITE_DOCUMENTNO_WITH_CHECK_ON_PAYMENT";
|
||||||
|
|
|
@ -28,6 +28,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.servlet.ServletConfig;
|
import javax.servlet.ServletConfig;
|
||||||
|
@ -115,6 +117,8 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
|
|
||||||
private volatile static ArrayList<File> m_dirAccessList = null;
|
private volatile static ArrayList<File> m_dirAccessList = null;
|
||||||
|
|
||||||
|
private ScheduledFuture<?> serverMgrFuture = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get
|
* Get
|
||||||
* @param request request
|
* @param request request
|
||||||
|
@ -201,7 +205,7 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (log.isLoggable(Level.INFO)) log.info ("ServerID=" + serverID);
|
if (log.isLoggable(Level.INFO)) log.info ("ServerID=" + serverID);
|
||||||
ServerInstance server = m_serverMgr.getServerInstance(serverID);
|
ServerInstance server = getServerManager().getServerInstance(serverID);
|
||||||
if (server == null)
|
if (server == null)
|
||||||
{
|
{
|
||||||
m_message = new p();
|
m_message = new p();
|
||||||
|
@ -272,7 +276,7 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (log.isLoggable(Level.INFO)) log.info ("ServerID=" + serverID);
|
if (log.isLoggable(Level.INFO)) log.info ("ServerID=" + serverID);
|
||||||
ServerInstance server = m_serverMgr.getServerInstance(serverID);
|
ServerInstance server = getServerManager().getServerInstance(serverID);
|
||||||
if (server == null)
|
if (server == null)
|
||||||
{
|
{
|
||||||
m_message = new p();
|
m_message = new p();
|
||||||
|
@ -281,7 +285,7 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
String error = m_serverMgr.runNow(serverID);
|
String error = getServerManager().runNow(serverID);
|
||||||
if (!Util.isEmpty(error, true))
|
if (!Util.isEmpty(error, true))
|
||||||
{
|
{
|
||||||
m_message = new p();
|
m_message = new p();
|
||||||
|
@ -317,9 +321,9 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
{
|
{
|
||||||
if (start)
|
if (start)
|
||||||
{
|
{
|
||||||
ok = m_serverMgr.startAll()==null;
|
ok = getServerManager().startAll()==null;
|
||||||
} else{
|
} else{
|
||||||
ok = m_serverMgr.stopAll()==null;
|
ok = getServerManager().stopAll()==null;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_message.addElement("All");
|
m_message.addElement("All");
|
||||||
|
@ -328,11 +332,11 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
{
|
{
|
||||||
if (reload)
|
if (reload)
|
||||||
{
|
{
|
||||||
ok=m_serverMgr.reload()==null;
|
ok=getServerManager().reload()==null;
|
||||||
this.createSummaryPage(request, response,true);
|
this.createSummaryPage(request, response,true);
|
||||||
m_dirAccessList = getDirAcessList();
|
m_dirAccessList = getDirAcessList();
|
||||||
} else {
|
} else {
|
||||||
ServerInstance server = m_serverMgr.getServerInstance(serverID);
|
ServerInstance server = getServerManager().getServerInstance(serverID);
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
m_message = new p();
|
m_message = new p();
|
||||||
m_message.addElement(new strong("Server not found: "));
|
m_message.addElement(new strong("Server not found: "));
|
||||||
|
@ -340,9 +344,9 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (start)
|
if (start)
|
||||||
ok = m_serverMgr.start(serverID)==null;
|
ok = getServerManager().start(serverID)==null;
|
||||||
else
|
else
|
||||||
ok = m_serverMgr.stop(serverID)==null;
|
ok = getServerManager().stop(serverID)==null;
|
||||||
m_message.addElement(server.getModel().getName());
|
m_message.addElement(server.getModel().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,16 +680,16 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
line = new tr();
|
line = new tr();
|
||||||
line.addElement(new th().addElement("Manager"));
|
line.addElement(new th().addElement("Manager"));
|
||||||
line.addElement(new td().addElement(WebEnv.getCellContent(m_serverMgr.getDescription())));
|
line.addElement(new td().addElement(WebEnv.getCellContent(getServerManager().getDescription())));
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
line = new tr();
|
line = new tr();
|
||||||
line.addElement(new th().addElement("Start - Elapsed"));
|
line.addElement(new th().addElement("Start - Elapsed"));
|
||||||
line.addElement(new td().addElement(WebEnv.getCellContent(m_serverMgr.getStartTime())
|
line.addElement(new td().addElement(WebEnv.getCellContent(getServerManager().getStartTime())
|
||||||
+ " - " + TimeUtil.formatElapsed(m_serverMgr.getStartTime())));
|
+ " - " + TimeUtil.formatElapsed(getServerManager().getStartTime())));
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
line = new tr();
|
line = new tr();
|
||||||
line.addElement(new th().addElement("Servers"));
|
line.addElement(new th().addElement("Servers"));
|
||||||
line.addElement(new td().addElement(WebEnv.getCellContent(createServerCountMessage(m_serverMgr.getServerCount()))));
|
line.addElement(new td().addElement(WebEnv.getCellContent(createServerCountMessage(getServerManager().getServerCount()))));
|
||||||
table.addElement(line);
|
table.addElement(line);
|
||||||
line = new tr();
|
line = new tr();
|
||||||
line.addElement(new th().addElement("Last Updated"));
|
line.addElement(new th().addElement("Last Updated"));
|
||||||
|
@ -754,7 +758,7 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
// ***** Server Links *****
|
// ***** Server Links *****
|
||||||
bb.addElement(new hr());
|
bb.addElement(new hr());
|
||||||
para = new p();
|
para = new p();
|
||||||
ServerInstance[] servers = m_serverMgr.getServerInstances();
|
ServerInstance[] servers = getServerManager().getServerInstances();
|
||||||
for (int i = 0; i < servers.length; i++)
|
for (int i = 0; i < servers.length; i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
|
@ -946,16 +950,16 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
|
|
||||||
writer.println("\t<server-manager>");
|
writer.println("\t<server-manager>");
|
||||||
writer.print("\t\t<description>");
|
writer.print("\t\t<description>");
|
||||||
writer.print(m_serverMgr.getDescription());
|
writer.print(getServerManager().getDescription());
|
||||||
writer.println("</description>");
|
writer.println("</description>");
|
||||||
writer.print("\t\t<start-time>");
|
writer.print("\t\t<start-time>");
|
||||||
writer.print(m_serverMgr.getStartTime());
|
writer.print(getServerManager().getStartTime());
|
||||||
writer.println("</start-time>");
|
writer.println("</start-time>");
|
||||||
writer.print("\t\t<server-count>");
|
writer.print("\t\t<server-count>");
|
||||||
writer.print(m_serverMgr.getServerCount());
|
writer.print(getServerManager().getServerCount());
|
||||||
writer.println("</server-count>");
|
writer.println("</server-count>");
|
||||||
|
|
||||||
ServerInstance[] servers = m_serverMgr.getServerInstances();
|
ServerInstance[] servers = getServerManager().getServerInstances();
|
||||||
for (int i = 0; i < servers.length; i++)
|
for (int i = 0; i < servers.length; i++)
|
||||||
{
|
{
|
||||||
ServerInstance server = servers[i];
|
ServerInstance server = servers[i];
|
||||||
|
@ -1276,22 +1280,62 @@ public class AdempiereMonitor extends HttpServlet
|
||||||
WebEnv.initWeb(config);
|
WebEnv.initWeb(config);
|
||||||
log.info ("");
|
log.info ("");
|
||||||
|
|
||||||
//always create the local server manager instance
|
// initial Wait (default to 10 seconds) to give cluster service time to start first
|
||||||
m_serverMgr = AdempiereServerMgr.get();
|
final int initialWaitSeconds = MSysConfig.getIntValue(MSysConfig.MONITOR_INITIAL_WAIT_FOR_CLUSTER_IN_SECONDS, 10);
|
||||||
|
serverMgrFuture = Adempiere.getThreadPoolExecutor().schedule(() -> {
|
||||||
|
int maxSecondsToWait = MSysConfig.getIntValue(MSysConfig.MONITOR_MAX_WAIT_FOR_CLUSTER_IN_SECONDS, 180);
|
||||||
|
int totalWaitSeconds = initialWaitSeconds;
|
||||||
|
//check every 5 seconds (until maxSecondsToWait)
|
||||||
|
int waitSeconds = 5;
|
||||||
|
while (ClusterServerMgr.getClusterService() == null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Thread.sleep(waitSeconds * 1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (Thread.interrupted())
|
||||||
|
break;
|
||||||
|
totalWaitSeconds += waitSeconds;
|
||||||
|
if (totalWaitSeconds >= maxSecondsToWait) {
|
||||||
|
log.warning("Cluster Service did not start after " + totalWaitSeconds + " seconds");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//switch to cluster manager if cluster service is available
|
//always create the local server manager instance
|
||||||
if (ClusterServerMgr.getClusterService() != null)
|
m_serverMgr = AdempiereServerMgr.get();
|
||||||
m_serverMgr = ClusterServerMgr.getInstance();
|
|
||||||
|
//switch to cluster manager if cluster service is available
|
||||||
|
if (ClusterServerMgr.getClusterService() != null)
|
||||||
|
m_serverMgr = ClusterServerMgr.getInstance();
|
||||||
|
}, initialWaitSeconds, TimeUnit.SECONDS);
|
||||||
|
|
||||||
m_dirAccessList = getDirAcessList();
|
m_dirAccessList = getDirAcessList();
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
|
private IServerManager getServerManager()
|
||||||
|
{
|
||||||
|
if (!serverMgrFuture.isDone() && !serverMgrFuture.isCancelled())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
serverMgrFuture.get();
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
return m_serverMgr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy
|
* Destroy
|
||||||
*/
|
*/
|
||||||
public void destroy ()
|
public void destroy ()
|
||||||
{
|
{
|
||||||
log.info ("destroy");
|
log.info ("destroy");
|
||||||
|
if (!serverMgrFuture.isDone() && !serverMgrFuture.isCancelled())
|
||||||
|
{
|
||||||
|
serverMgrFuture.cancel(true);
|
||||||
|
}
|
||||||
|
serverMgrFuture = null;
|
||||||
m_serverMgr = null;
|
m_serverMgr = null;
|
||||||
m_dirAccessList = null;
|
m_dirAccessList = null;
|
||||||
} // destroy
|
} // destroy
|
||||||
|
|
Loading…
Reference in New Issue