mirror of
https://github.com/SWG-Source/src.git
synced 2026-01-17 00:04:25 -05:00
Added config option to TaskManager to allow node0 to be the preferred node and run tasks that are declared as "any" in taskmanager.rc
This commit is contained in:
@@ -82,6 +82,7 @@ void ConfigTaskManager::install(void)
|
||||
KEY_INT (maximumClockDriftToleranceSeconds, 10); // seconds
|
||||
KEY_INT (systemTimeCheckIntervalSeconds, 60); // seconds
|
||||
KEY_INT (clockDriftFatalIntervalSeconds, 1*60*60); // seconds
|
||||
KEY_BOOL (allowPreferredServerOnMasterNode, false);
|
||||
|
||||
int index = 0;
|
||||
char const * result = 0;
|
||||
|
||||
@@ -39,6 +39,7 @@ class ConfigTaskManager
|
||||
int maximumClockDriftToleranceSeconds;
|
||||
int systemTimeCheckIntervalSeconds;
|
||||
int clockDriftFatalIntervalSeconds;
|
||||
bool allowPreferredServerOnMasterNode;
|
||||
};
|
||||
|
||||
static const bool getAutoStart ();
|
||||
@@ -68,7 +69,7 @@ class ConfigTaskManager
|
||||
static int getMaximumClockDriftToleranceSeconds();
|
||||
static int getSystemTimeCheckIntervalSeconds();
|
||||
static int getClockDriftFatalIntervalSeconds();
|
||||
|
||||
static const bool getAllowPreferredServerOnMasterNode();
|
||||
static void install ();
|
||||
static void remove ();
|
||||
|
||||
@@ -270,4 +271,11 @@ inline int ConfigTaskManager::getClockDriftFatalIntervalSeconds()
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigTaskManager::getAllowPreferredServerOnMasterNode()
|
||||
{
|
||||
return data->allowPreferredServerOnMasterNode;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
#endif // _ConfigTaskManager_H
|
||||
|
||||
@@ -146,19 +146,33 @@ ManagerConnection *LocatorNamespace::getPreferredServer(std::string const &proce
|
||||
{
|
||||
ServerEntry &e = *i;
|
||||
if ((e.m_label != s_masterNodeLabel) && (e.hasAvailableLoad(cost)))
|
||||
{
|
||||
{
|
||||
for (std::vector<PreferredNode>::const_iterator j = s_preferredNodes.begin(); j != s_preferredNodes.end(); ++j)
|
||||
if ((*j).m_nodeLabel == e.m_label && (*j).match(processName, options))
|
||||
return e.m_connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ManagerConnection *LocatorNamespace::getUnpreferredServer(float cost)
|
||||
bool Locator::isMasterNodePreferred(std::string const &processName, std::string const &options, float cost)
|
||||
{
|
||||
if(!ConfigTaskManager::getAllowPreferredServerOnMasterNode())
|
||||
return false;
|
||||
|
||||
for (std::vector<PreferredNode>::const_iterator j = s_preferredNodes.begin(); j != s_preferredNodes.end(); ++j)
|
||||
if ((*j).m_nodeLabel == s_masterNodeLabel && (*j).match(processName, options))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ManagerConnection *LocatorNamespace::getUnpreferredServer(float cost)
|
||||
{
|
||||
// Find a node other than the master node that can afford to run the process
|
||||
// and is a not marked as a preferred node for anything; if more than one
|
||||
// node qualifies, return the node with the lowest load
|
||||
@@ -190,8 +204,8 @@ ManagerConnection *LocatorNamespace::getUnpreferredServer(float cost)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
ManagerConnection *Locator::getBestServer(std::string const &processName, std::string const &options, float cost)
|
||||
{
|
||||
if (s_serverList.empty())
|
||||
{
|
||||
if (s_serverList.empty())
|
||||
return 0;
|
||||
|
||||
// first, look for a preferred node for this process
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
static void install();
|
||||
static void closed(std::string const &label, ManagerConnection const *oldConnection);
|
||||
static ManagerConnection *getBestServer(std::string const &processName, std::string const &options, float cost);
|
||||
static bool isMasterNodePreferred(std::string const &processName, std::string const &options, float cost);
|
||||
static float getMyLoad();
|
||||
static float getMyMaximumLoad();
|
||||
static float getServerLoad(std::string const &label);
|
||||
|
||||
@@ -84,7 +84,7 @@ void ManagerConnection::onConnectionClosed()
|
||||
|
||||
void ManagerConnection::onConnectionOpened()
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, ("Manager connection opened\n"));
|
||||
DEBUG_REPORT_LOG(true, ("Manager connection opened for %s \n", getRemoteAddress().c_str()));
|
||||
TaskConnectionIdMessage id(TaskConnectionIdMessage::TaskManager, TaskManager::getNodeLabel(), ConfigTaskManager::getClusterName());
|
||||
send(id);
|
||||
s_managerConnectionCount++;
|
||||
|
||||
@@ -613,7 +613,6 @@ unsigned long TaskManager::startServer(const std::string & processName, const st
|
||||
}
|
||||
|
||||
const ProcessEntry pe = (*f).second;
|
||||
|
||||
// does the process run on this box?
|
||||
if(pe.targetHost == "local" || pe.targetHost == getNodeLabel() || nodeLabel == getNodeLabel() || nodeLabel == "local")
|
||||
{
|
||||
@@ -646,10 +645,14 @@ unsigned long TaskManager::startServer(const std::string & processName, const st
|
||||
// select a task manager on which to spawn the server
|
||||
// find the best target
|
||||
float cost = getLoadForProcess(pe.processName);
|
||||
ManagerConnection * conn = Locator::getBestServer(pe.processName, options, cost);
|
||||
if(!conn)
|
||||
if(Locator::isMasterNodePreferred(pe.processName, options, cost))
|
||||
{
|
||||
|
||||
pid = startServerLocal(pe, options);
|
||||
}
|
||||
ManagerConnection * conn = Locator::getBestServer(pe.processName, options, cost);
|
||||
if(!conn && !pid)
|
||||
{
|
||||
|
||||
if(ManagerConnection::getConnectionCount() < 1)
|
||||
pid = startServerLocal(pe, options);
|
||||
else
|
||||
@@ -666,7 +669,7 @@ unsigned long TaskManager::startServer(const std::string & processName, const st
|
||||
s_queuedSpawnRequests.push_back(r);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(!pid)
|
||||
{
|
||||
std::string label = "uninitialized label";
|
||||
if(conn->getNodeLabel())
|
||||
|
||||
Reference in New Issue
Block a user