Added: #1440 Send available plugin handlers on slave to master

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent f32f82a385
commit eeae925a05

@ -73,6 +73,7 @@ class CModulePipelineMaster :
std::vector<std::string> Vector;
uint32 ActiveTaskId;
bool SheetsOk;
std::vector<uint32> PluginsAvailable;
~CSlave()
{
@ -204,6 +205,12 @@ public:
slave->Vector.clear();
}
void setAvailablePlugins(NLNET::IModuleProxy *sender, const std::vector<uint32> &pluginsAvailable)
{
CSlave *slave = m_Slaves[sender];
slave->PluginsAvailable = pluginsAvailable;
}
protected:
NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CModulePipelineMaster, CModuleBase)
NLMISC_COMMAND_HANDLER_ADD(CModulePipelineMaster, reloadSheets, "Reload sheets across all services", "")
@ -221,6 +228,7 @@ protected:
{
CSlave *slave = it->second;
slave->SheetsOk = false;
slave->PluginsAvailable.clear();
slave->Proxy.reloadSheets(this);
CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_MASTER_RELOAD_SHEETS);
}

@ -31,6 +31,12 @@
<doc line=""/>
</method>
<method name="setAvailablePlugins" msg="SET_A_PLG">
<doc line=""/>
<param type="std::vector&lt;uint32&gt;" name="pluginsAvailable" byref="true" serial="Cont" />
</method>
</module_interface>
</namespace>

@ -97,9 +97,10 @@ public:
nlassert(m_Master == NULL);
// TODO: SAY HELLO
m_Master = new CModulePipelineMasterProxy(moduleProxy);
// TODO: AUTHENTICATE OR GATEWAY SECURITY?
sendMasterAvailablePlugins();
}
}
@ -132,6 +133,7 @@ public:
if (PIPELINE::isServiceStateIdle())
{
m_ReloadSheetsState = REQUEST_NONE;
sendMasterAvailablePlugins();
m_Master->slaveReloadedSheets(this);
CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_SLAVE_RELOAD_SHEETS);
}
@ -164,6 +166,13 @@ public:
else m_ReloadSheetsState = REQUEST_MADE;
}
void sendMasterAvailablePlugins()
{
std::vector<uint32> availablePlugins;
g_PipelineWorkspace->listAvailablePlugins(availablePlugins);
m_Master->setAvailablePlugins(this, availablePlugins);
}
protected:
NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CModulePipelineSlave, CModuleBase)
NLMISC_COMMAND_HANDLER_ADD(CModulePipelineSlave, testUpdateDatabaseStatus, "Test master request for database status update on dependencies", "<projectName> <processName>")

@ -72,6 +72,7 @@ bool g_IsMaster = false;
NLGEORGES::UFormLoader *g_FormLoader = NULL;
CPipelineWorkspace *g_PipelineWorkspace = NULL;
CDatabaseStatus *g_DatabaseStatus = NULL;
CPipelineInterfaceImpl *g_PipelineInterfaceImpl = NULL;
std::string unMacroPath(const std::string &path)
{
@ -119,7 +120,6 @@ enum EState
/// Data
CInfoFlags *s_InfoFlags = NULL;
CTaskManager *s_TaskManager = NULL;
CPipelineInterfaceImpl *s_PipelineInterfaceImpl = NULL;
CPipelineProcessImpl *s_PipelineProcessImpl = NULL;
EState s_State = STATE_IDLE;
@ -390,7 +390,7 @@ public:
g_DatabaseStatus = new CDatabaseStatus();
s_PipelineInterfaceImpl = new CPipelineInterfaceImpl();
g_PipelineInterfaceImpl = new CPipelineInterfaceImpl();
s_PipelineProcessImpl = new CPipelineProcessImpl(NULL); // Create a singleton impl for global usage without running project for test purposes.
// Load libraries
@ -442,8 +442,8 @@ public:
delete s_PipelineProcessImpl;
s_PipelineProcessImpl = NULL;
delete s_PipelineInterfaceImpl;
s_PipelineInterfaceImpl = NULL;
delete g_PipelineInterfaceImpl;
g_PipelineInterfaceImpl = NULL;
delete g_DatabaseStatus;
g_DatabaseStatus = NULL;
@ -567,7 +567,7 @@ NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "<processName>")
switch (it->HandlerType)
{
case PIPELINE::PLUGIN_REGISTERED_CLASS:
if (std::find(PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end(), it->Handler) != PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end())
if (std::find(PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end(), it->Handler) != PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end())
statusHandler = "AVAILABLE";
else
statusHandler = "NOT FOUND";
@ -579,7 +579,7 @@ NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "<processName>")
std::string statusInfo;
switch (it->InfoType)
{
case PIPELINE::PLUGIN_REGISTERED_CLASS:if (std::find(PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end(), it->Info) != PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end())
case PIPELINE::PLUGIN_REGISTERED_CLASS:if (std::find(PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end(), it->Info) != PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end())
statusInfo = "AVAILABLE";
else
statusInfo = "NOT FOUND";

@ -47,6 +47,7 @@ namespace NLGEORGES {
namespace PIPELINE {
class CPipelineWorkspace;
class CDatabaseStatus;
class CPipelineInterfaceImpl;
#define PIPELINE_MASTER
@ -81,6 +82,7 @@ bool reloadSheets();
extern NLGEORGES::UFormLoader *g_FormLoader;
extern CPipelineWorkspace *g_PipelineWorkspace;
extern CDatabaseStatus *g_DatabaseStatus;
extern CPipelineInterfaceImpl *g_PipelineInterfaceImpl;
} /* namespace PIPELINE */

@ -37,6 +37,8 @@
// Project includes
#include "pipeline_project.h"
#include "pipeline_service.h"
#include "pipeline_interface_impl.h"
using namespace std;
// using namespace NLMISC;
@ -113,7 +115,7 @@ CPipelineWorkspace::~CPipelineWorkspace()
m_Projects.clear();
}
void CPipelineWorkspace::getProcessPlugins(std::vector<CProcessPluginInfo> &result, const std::string &process)
void CPipelineWorkspace::getProcessPlugins(std::vector<CProcessPluginInfo> &resultAppend, const std::string &process)
{
uint16 pluginId = 0;
for (std::vector<NLMISC::CRefPtr<NLGEORGES::UForm> >::iterator it = m_Plugins.begin(), end = m_Plugins.end(); it != end; ++it)
@ -145,7 +147,7 @@ void CPipelineWorkspace::getProcessPlugins(std::vector<CProcessPluginInfo> &resu
processPlugin.InfoType = (TPluginType)infoType;
processPlugin.Id.Sub.Plugin = pluginId;
processPlugin.Id.Sub.Handler = i;
result.push_back(processPlugin);
resultAppend.push_back(processPlugin);
nldebug("Found '%s': '%s', '%s'", process.c_str(), processPlugin.Handler.c_str(), processPlugin.Info.c_str());
}
@ -203,6 +205,93 @@ bool CPipelineWorkspace::getProcessPlugin(CProcessPluginInfo &result, uint32 glo
else return false;
}
void CPipelineWorkspace::listAvailablePlugins(std::vector<uint32> &result)
{
result.clear();
uint16 pluginId = 0;
for (std::vector<NLMISC::CRefPtr<NLGEORGES::UForm> >::iterator it = m_Plugins.begin(), end = m_Plugins.end(); it != end; ++it)
{
UFormElm *processHandlers;
if ((*it)->getRootNode().getNodeByName(&processHandlers, "ProcessHandlers"))
{
uint nb;
processHandlers->getArraySize(nb);
for (uint i = 0; i < nb; ++i)
{
UFormElm *handler;
if (processHandlers->getArrayNode(&handler, i))
{
std::string handlerProcess;
if (handler->getValueByName(handlerProcess, "Process"))
{
CProcessPluginInfo processPlugin;
uint32 handlerType;
uint32 infoType;
if (handler->getValueByName(handlerType, "HandlerType")
&& handler->getValueByName(processPlugin.Handler, "Handler")
&& handler->getValueByName(infoType, "InfoType")
&& handler->getValueByName(processPlugin.Info, "Info"))
{
processPlugin.HandlerType = (TPluginType)handlerType;
processPlugin.InfoType = (TPluginType)infoType;
processPlugin.Id.Sub.Plugin = pluginId;
processPlugin.Id.Sub.Handler = i;
bool handlerAvailable = false;
switch (processPlugin.HandlerType)
{
case PLUGIN_REGISTERED_CLASS:
handlerAvailable = (find(g_PipelineInterfaceImpl->RegisteredClasses.begin(), g_PipelineInterfaceImpl->RegisteredClasses.end(), processPlugin.Handler) != g_PipelineInterfaceImpl->RegisteredClasses.end());
break;
default:
nlwarning("Not implemented");
break;
}
if (handlerAvailable)
{
bool infoAvailable = false;
switch (processPlugin.InfoType)
{
case PLUGIN_REGISTERED_CLASS:
infoAvailable = (find(g_PipelineInterfaceImpl->RegisteredClasses.begin(), g_PipelineInterfaceImpl->RegisteredClasses.end(), processPlugin.Info) != g_PipelineInterfaceImpl->RegisteredClasses.end());
break;
default:
nlwarning("Not implemented");
break;
}
if (infoAvailable)
{
nldebug("Available '%s', '%s'", processPlugin.Handler.c_str(), processPlugin.Info.c_str());
result.push_back(processPlugin.Id.Global);
}
}
}
else
{
nlwarning("Missing value in '%s' at 'ProcessHandlers' at '%i'", (*it)->getFilename().c_str(), i);
}
}
else
{
nlwarning("Missing 'Process' in '%s' at 'ProcessHandlers' at '%i'", (*it)->getFilename().c_str(), i);
}
}
else
{
nlwarning("Array error in '%s'", (*it)->getFilename().c_str());
}
}
}
else
{
nlwarning("Missing 'ProcessHandlers' in '%s'", (*it)->getFilename().c_str());
}
++pluginId;
}
}
CPipelineProject *CPipelineWorkspace::getProject(const std::string &project)
{
std::map<std::string, CPipelineProject *>::const_iterator it = m_Projects.find(project);

@ -90,10 +90,13 @@ public:
CPipelineWorkspace(NLGEORGES::UFormLoader *formLoader, const std::string &sheetName);
virtual ~CPipelineWorkspace();
void getProcessPlugins(std::vector<CProcessPluginInfo> &result, const std::string &process);
void getProcessPlugins(std::vector<CProcessPluginInfo> &resultAppend, const std::string &process);
CPipelineProject *getProject(const std::string &project);
bool getProcessPlugin(CProcessPluginInfo &result, uint32 globalId);
/// Makes a list of the global id of all available plugins to this service
void listAvailablePlugins(std::vector<uint32> &result);
}; /* class CPipelineWorkspace */
} /* namespace PIPELINE */

Loading…
Cancel
Save