Skip to content

Commit

Permalink
ConfigMgr 2.0 - The Configurator
Browse files Browse the repository at this point in the history
- Prototype

Signed-off-by: Gleb Aronsky <gleb.aronsky@lexisnexis.com>
  • Loading branch information
Gleb Aronsky committed Sep 28, 2016
1 parent 348378a commit c8b73e1
Show file tree
Hide file tree
Showing 108 changed files with 15,413 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ if(TOP_LEVEL_PROJECT)
endif(PLATFORM OR PLUGIN)
endif(TOP_LEVEL_PROJECT)

if (MAKE_CONFIGURATOR)
MESSAGE( "Configurator app build ON" )
HPCC_ADD_SUBDIRECTORY (configuration)
endif()

###
## Below are the non-compile based install scripts required for
## the hpcc platform.
Expand Down
96 changes: 96 additions & 0 deletions cmake_modules/commonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,102 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
endif()
endif()

option(MAKE_CONFIGURATOR "Build Configurator" ON)
option(CONFIGURATOR_LIB "Build Configurator static library (.a)" OFF)

if ( CONFIGURATOR_LIB )
set( MAKE_CONFIGURATOR ON )
endif()

if (APPLE OR WIN32)
option(USE_TBB "Enable Threading Building Block support" OFF)
else()
option(USE_TBB "Enable Threading Building Block support" ON)
option(USE_TBBMALLOC "Enable Threading Building Block scalable allocator proxy support" ON)
endif()

option(LOGGING_SERVICE "Configure use of logging service" ON)


if(REMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable rembed, already declared ${pluginname}")
else()
set(pluginname "rembed")
endif()
endif()
if(V8EMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable v8embed, already declared ${pluginname}")
else()
set(pluginname "v8embed")
endif()
endif()
if(MEMCACHED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable memcached, already declared ${pluginname}")
else()
set(pluginname "memcached")
endif()
endif()
if(PYEMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable pyembed, already declared ${pluginname}")
else()
set(pluginname "pyembed")
endif()
endif()
if(REDIS)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable redis, already declared ${pluginname}")
else()
set(pluginname "redis")
endif()
endif()
if(JAVAEMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable javaembed, already declared ${pluginname}")
else()
set(pluginname "javaembed")
endif()
endif()
if(MYSQLEMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable mysqlembed, already declared ${pluginname}")
else()
set(pluginname "mysqlembed")
endif()
endif()
if(SQLITE3EMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable sqlite3embed, already declared ${pluginname}")
else()
set(pluginname "sqlite3embed")
endif()
endif()
if(KAFKA)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable kafka, already declared ${pluginname}")
else()
set(pluginname "kafka")
endif()
endif()
if(EXAMPLEPLUGIN)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable exampleplugin, already declared ${pluginname}")
else()
set(pluginname "exampleplugin")
endif()
endif()
if(COUCHBASEEMBED)
if(DEFINED pluginname)
message(FATAL_ERROR "Cannot enable couchbaseembed, already declared ${pluginname}")
else()
set(pluginname "couchbaseembed")
endif()
endif()

>>>>>>> ConfigMgr 2.0 - The Configurator
if ( USE_XALAN AND USE_LIBXSLT )
set(USE_LIBXSLT OFF)
endif()
Expand Down
17 changes: 17 additions & 0 deletions configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
################################################################################
# HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

HPCC_ADD_SUBDIRECTORY (configurator)
246 changes: 246 additions & 0 deletions configuration/configurator/BuildSet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

#include "jptree.hpp"
#include "XMLTags.h"
#include "BuildSet.hpp"
#include "SchemaCommon.hpp"

using namespace CONFIGURATOR;

#define LOOP_THRU_BUILD_SET for (int idx = 0; idx < m_buildSetArray.length(); idx++)

static CBuildSetManager *s_pBuildSetManager = NULL;

CBuildSetManager* CBuildSetManager::getInstance(const char* pBuildSetFile, const char* pBuildSetDirectory)
{
if (s_pBuildSetManager == NULL)
{
s_pBuildSetManager = new CBuildSetManager();

if (pBuildSetFile != NULL)
s_pBuildSetManager->m_buildSetFile.set(pBuildSetFile);
else
s_pBuildSetManager->m_buildSetFile.set(DEFAULT_BUILD_SET_XML_FILE);

if (pBuildSetDirectory != NULL)
s_pBuildSetManager->m_buildSetDir.set(pBuildSetDirectory);
else
s_pBuildSetManager->m_buildSetDir.set(DEFAULT_BUILD_SET_DIRECTORY);

pBuildSetFile = s_pBuildSetManager->m_buildSetFile;
pBuildSetDirectory = s_pBuildSetManager->m_buildSetDir;

s_pBuildSetManager->m_buildSetPath.clear().appendf("%s%s%s", pBuildSetDirectory, pBuildSetDirectory[strlen(pBuildSetDirectory)-1] == '/' ? "" : "/", pBuildSetFile);
s_pBuildSetManager->populateBuildSet();
}
return s_pBuildSetManager;
}

CBuildSetManager::CBuildSetManager(const char* pBuildSetFile, const char* pBuildSetDir) : m_buildSetFile(pBuildSetFile), m_buildSetDir(pBuildSetDir)
{
if (pBuildSetFile != NULL && pBuildSetDir != NULL)
m_buildSetPath.clear().appendf("%s%s%s", pBuildSetDir, pBuildSetDir[strlen(pBuildSetDir)-1] == '/' ? "" : "/", pBuildSetFile);
}

CBuildSetManager::CBuildSetManager()
{
}

CBuildSetManager::~CBuildSetManager()
{
m_buildSetArray.kill();
}

void CBuildSetManager::getBuildSetComponents(StringArray& buildSetArray) const
{
int nLength = this->getBuildSetComponentCount();

for (int idx = 0; idx < nLength; idx++)
{
buildSetArray.append(this->getBuildSetComponentTypeName(idx));
}
}

void CBuildSetManager::getBuildSetServices(StringArray& buildSetArray) const
{
int nLength = this->getBuildSetServiceCount();

for (int idx = 0; idx < nLength; idx++)
{
buildSetArray.append(this->getBuildSetServiceName(idx));
}
}

const char* CBuildSetManager::getBuildSetServiceName(int index) const
{
return this->getBuildSetService(index)->getName();
}

const char* CBuildSetManager::getBuildSetServiceFileName(int index) const
{
return this->getBuildSetService(index)->getSchema();
}

const char* CBuildSetManager::getBuildSetComponentTypeName(int index) const
{
return this->getBuildSetComponent(index)->getName();
}

const char* CBuildSetManager::getBuildSetComponentFileName(int index) const
{
return this->getBuildSetComponent(index)->getSchema();
}

const char* CBuildSetManager::getBuildSetProcessName(int index) const
{
return this->getBuildSetComponent(index)->getProcessName();
}

bool CBuildSetManager::populateBuildSet()
{
StringBuffer xpath;

if (m_buildSetTree.get() != NULL)
return false;

try
{
m_buildSetTree.set(createPTreeFromXMLFile(m_buildSetPath.str()));
}
catch(...)
{
return false;
}

xpath.appendf("./%s/%s/%s", XML_TAG_PROGRAMS, XML_TAG_BUILD, XML_TAG_BUILDSET);

Owned<IPropertyTreeIterator> iter = m_buildSetTree->getElements(xpath.str());

ForEach(*iter)
{
IPropertyTree* pTree = &iter->query();

if ( pTree->queryProp(XML_ATTR_PROCESS_NAME) == NULL || pTree->queryProp(XML_ATTR_OVERIDE) != NULL || ( (pTree->queryProp(XML_ATTR_DEPLOYABLE) != NULL && \
stricmp(pTree->queryProp(XML_ATTR_DEPLOYABLE), "no") == 0 && stricmp(pTree->queryProp(XML_ATTR_PROCESS_NAME), XML_TAG_ESPSERVICE) != 0) ) )
continue;

Owned<CBuildSet> pBuildSet = new CBuildSet(pTree->queryProp(XML_ATTR_INSTALLSET), pTree->queryProp(XML_ATTR_NAME), pTree->queryProp(XML_ATTR_PROCESS_NAME),\
pTree->queryProp(XML_ATTR_SCHEMA), pTree->queryProp(XML_ATTR_DEPLOYABLE), pTree->queryProp(XML_ATTR_OVERIDE));

m_buildSetArray.append(*pBuildSet.getLink());
}
return true;
}

void CBuildSetManager::setBuildSetArray(const StringArray &strArray)
{
m_buildSetArray.kill();

for (int idx = 0; idx < strArray.length(); idx++)
{
Owned<CBuildSet> pBSet = new CBuildSet(NULL, strArray.item(idx), NULL, strArray.item(idx));
assert (pBSet != NULL);
m_buildSetArray.append(*pBSet.getClear());
}
}

const char* CBuildSetManager::getBuildSetSchema(int index) const
{
assert(index < m_buildSetArray.length());
if (index < m_buildSetArray.length())
return m_buildSetArray.item(index).getSchema();
else
return NULL;
}

const int CBuildSetManager::getBuildSetSchemaCount() const
{
return m_buildSetArray.length();
}

const int CBuildSetManager::getBuildSetServiceCount() const
{
int nCount = 0;

LOOP_THRU_BUILD_SET
{
if (m_buildSetArray.item(idx).getProcessName() != NULL && strcmp(m_buildSetArray.item(idx).getProcessName(), XML_TAG_ESPSERVICE) == 0 && \
(m_buildSetArray.item(idx).getDeployable() != NULL && stricmp(m_buildSetArray.item(idx).getDeployable(), "no") == 0))
nCount++;
}
return nCount;
}

const int CBuildSetManager::getBuildSetComponentCount() const
{
int nCount = 0;

LOOP_THRU_BUILD_SET
{
if ( ((m_buildSetArray.item(idx).getProcessName() == NULL) || (strcmp(m_buildSetArray.item(idx).getProcessName(), XML_TAG_ESPSERVICE) != 0)) && \
( (m_buildSetArray.item(idx).getDeployable() == NULL) || (stricmp(m_buildSetArray.item(idx).getDeployable(), "no") != 0) ) && \
( (m_buildSetArray.item(idx).getOveride() == NULL) || (stricmp(m_buildSetArray.item(idx).getOveride(), "no") != 0) ) )
nCount++;
}
return nCount;
}

const CBuildSet* CBuildSetManager::getBuildSetComponent(int index) const
{
int nCount = 0;

LOOP_THRU_BUILD_SET
{
if (index == 0)
{
if ( ((m_buildSetArray.item(idx).getProcessName() == NULL) || (strcmp(m_buildSetArray.item(idx).getProcessName(), XML_TAG_ESPSERVICE) != 0)) && \
( (m_buildSetArray.item(idx).getDeployable() == NULL) || (stricmp(m_buildSetArray.item(idx).getDeployable(), "no") != 0) ) && \
( (m_buildSetArray.item(idx).getOveride() == NULL) || (stricmp(m_buildSetArray.item(idx).getOveride(), "no") != 0) ) )
return &(m_buildSetArray.item(idx));
else
continue;
}
if ( ((m_buildSetArray.item(idx).getProcessName() == NULL) || (strcmp(m_buildSetArray.item(idx).getProcessName(), XML_TAG_ESPSERVICE) != 0)) && \
( (m_buildSetArray.item(idx).getDeployable() == NULL)|| (stricmp(m_buildSetArray.item(idx).getDeployable(), "no") != 0) ) && \
( (m_buildSetArray.item(idx).getOveride() == NULL) || (stricmp(m_buildSetArray.item(idx).getOveride(), "no") != 0) ) )
index--;
}
assert(!"index invalid");
return NULL;
}

const CBuildSet* CBuildSetManager::getBuildSetService(int index) const
{
LOOP_THRU_BUILD_SET
{
if (index == 0)
{
if (m_buildSetArray.item(idx).getProcessName() != NULL && strcmp(m_buildSetArray.item(idx).getProcessName(), XML_TAG_ESPSERVICE) == 0 && \
(m_buildSetArray.item(idx).getDeployable() != NULL && stricmp(m_buildSetArray.item(idx).getDeployable(), "no") == 0))
return &(m_buildSetArray.item(idx));
else
continue;
}
if (m_buildSetArray.item(idx).getProcessName() != NULL && strcmp(m_buildSetArray.item(idx).getProcessName(), XML_TAG_ESPSERVICE) == 0 && \
(m_buildSetArray.item(idx).getDeployable() != NULL && stricmp(m_buildSetArray.item(idx).getDeployable(), "no") == 0))
index--;
}

assert(!"index invalid");
return NULL;
}
Loading

0 comments on commit c8b73e1

Please sign in to comment.