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

@ -31,6 +31,12 @@
<doc line=""/> <doc line=""/>
</method> </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> </module_interface>
</namespace> </namespace>

@ -97,9 +97,10 @@ public:
nlassert(m_Master == NULL); nlassert(m_Master == NULL);
// TODO: SAY HELLO
m_Master = new CModulePipelineMasterProxy(moduleProxy); m_Master = new CModulePipelineMasterProxy(moduleProxy);
// TODO: AUTHENTICATE OR GATEWAY SECURITY?
sendMasterAvailablePlugins();
} }
} }
@ -132,6 +133,7 @@ public:
if (PIPELINE::isServiceStateIdle()) if (PIPELINE::isServiceStateIdle())
{ {
m_ReloadSheetsState = REQUEST_NONE; m_ReloadSheetsState = REQUEST_NONE;
sendMasterAvailablePlugins();
m_Master->slaveReloadedSheets(this); m_Master->slaveReloadedSheets(this);
CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_SLAVE_RELOAD_SHEETS); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_SLAVE_RELOAD_SHEETS);
} }
@ -164,6 +166,13 @@ public:
else m_ReloadSheetsState = REQUEST_MADE; else m_ReloadSheetsState = REQUEST_MADE;
} }
void sendMasterAvailablePlugins()
{
std::vector<uint32> availablePlugins;
g_PipelineWorkspace->listAvailablePlugins(availablePlugins);
m_Master->setAvailablePlugins(this, availablePlugins);
}
protected: protected:
NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CModulePipelineSlave, CModuleBase) 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>") 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; NLGEORGES::UFormLoader *g_FormLoader = NULL;
CPipelineWorkspace *g_PipelineWorkspace = NULL; CPipelineWorkspace *g_PipelineWorkspace = NULL;
CDatabaseStatus *g_DatabaseStatus = NULL; CDatabaseStatus *g_DatabaseStatus = NULL;
CPipelineInterfaceImpl *g_PipelineInterfaceImpl = NULL;
std::string unMacroPath(const std::string &path) std::string unMacroPath(const std::string &path)
{ {
@ -119,7 +120,6 @@ enum EState
/// Data /// Data
CInfoFlags *s_InfoFlags = NULL; CInfoFlags *s_InfoFlags = NULL;
CTaskManager *s_TaskManager = NULL; CTaskManager *s_TaskManager = NULL;
CPipelineInterfaceImpl *s_PipelineInterfaceImpl = NULL;
CPipelineProcessImpl *s_PipelineProcessImpl = NULL; CPipelineProcessImpl *s_PipelineProcessImpl = NULL;
EState s_State = STATE_IDLE; EState s_State = STATE_IDLE;
@ -390,7 +390,7 @@ public:
g_DatabaseStatus = new CDatabaseStatus(); 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. s_PipelineProcessImpl = new CPipelineProcessImpl(NULL); // Create a singleton impl for global usage without running project for test purposes.
// Load libraries // Load libraries
@ -442,8 +442,8 @@ public:
delete s_PipelineProcessImpl; delete s_PipelineProcessImpl;
s_PipelineProcessImpl = NULL; s_PipelineProcessImpl = NULL;
delete s_PipelineInterfaceImpl; delete g_PipelineInterfaceImpl;
s_PipelineInterfaceImpl = NULL; g_PipelineInterfaceImpl = NULL;
delete g_DatabaseStatus; delete g_DatabaseStatus;
g_DatabaseStatus = NULL; g_DatabaseStatus = NULL;
@ -567,7 +567,7 @@ NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "<processName>")
switch (it->HandlerType) switch (it->HandlerType)
{ {
case PIPELINE::PLUGIN_REGISTERED_CLASS: 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"; statusHandler = "AVAILABLE";
else else
statusHandler = "NOT FOUND"; statusHandler = "NOT FOUND";
@ -579,7 +579,7 @@ NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "<processName>")
std::string statusInfo; std::string statusInfo;
switch (it->InfoType) 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"; statusInfo = "AVAILABLE";
else else
statusInfo = "NOT FOUND"; statusInfo = "NOT FOUND";

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

@ -37,6 +37,8 @@
// Project includes // Project includes
#include "pipeline_project.h" #include "pipeline_project.h"
#include "pipeline_service.h"
#include "pipeline_interface_impl.h"
using namespace std; using namespace std;
// using namespace NLMISC; // using namespace NLMISC;
@ -113,7 +115,7 @@ CPipelineWorkspace::~CPipelineWorkspace()
m_Projects.clear(); 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; uint16 pluginId = 0;
for (std::vector<NLMISC::CRefPtr<NLGEORGES::UForm> >::iterator it = m_Plugins.begin(), end = m_Plugins.end(); it != end; ++it) 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.InfoType = (TPluginType)infoType;
processPlugin.Id.Sub.Plugin = pluginId; processPlugin.Id.Sub.Plugin = pluginId;
processPlugin.Id.Sub.Handler = i; 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()); 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; 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) CPipelineProject *CPipelineWorkspace::getProject(const std::string &project)
{ {
std::map<std::string, CPipelineProject *>::const_iterator it = m_Projects.find(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); CPipelineWorkspace(NLGEORGES::UFormLoader *formLoader, const std::string &sheetName);
virtual ~CPipelineWorkspace(); 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); CPipelineProject *getProject(const std::string &project);
bool getProcessPlugin(CProcessPluginInfo &result, uint32 globalId); 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 */ }; /* class CPipelineWorkspace */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

Loading…
Cancel
Save