Skip to content

Commit

Permalink
Clean roxie solution v2
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Dec 16, 2024
1 parent d706cc4 commit 849d415
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
48 changes: 33 additions & 15 deletions dali/base/dafdesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3729,8 +3729,7 @@ static void doInitializeStorageGroups(bool createPlanesFromGroups, IPropertyTree
if (!storage)
storage.set(newGlobalConfiguration->addPropTree("storage"));

#ifndef _CONTAINERIZED
if (createPlanesFromGroups)
if (!isContainerized() && createPlanesFromGroups)
{
// Remove old planes created from groups
while (storage->removeProp("planes[@fromGroup='1']"));
Expand Down Expand Up @@ -3785,7 +3784,6 @@ static void doInitializeStorageGroups(bool createPlanesFromGroups, IPropertyTree
//Uncomment the following to trace the values that been generated
//printYAML(storage);
}
#endif

//Ensure that host groups that are defined in terms of other host groups are expanded out so they have an explicit list of hosts
normalizeHostGroups();
Expand All @@ -3794,35 +3792,55 @@ static void doInitializeStorageGroups(bool createPlanesFromGroups, IPropertyTree
setupContainerizedStorageLocations();
}

//Store whether we are currently creating planes from groups, and what the last update was
static bool globalCreatePlanesFromGroups = false;
static bool lastCreatedPlanesFromGroups = false;
void initializeStoragePlanes(bool createPlanesFromGroups, bool threadSafe)
/*
* This function is used to:
*
* (a) create storage planes from bare-metal groups
* (b) to expand out host groups that are defined in terms of other host groups
* (c) to setup the base directory for the storage planes. (GH->JCS is this threadsafe?)
*
* For most components this init function is called only once - the exception is roxie (called when it connects and disconnects from dali).
* In thor it is important that the update of the global config does not clone the property trees
* In containerized mode, the update function can be called whenever the config file changes (but it will not be creating planes from groups)
* In bare-metal mode the update function may be called whenever the environment changes in dali. (see initClientProcess)
*
* Because of the requirement that thor does not clone the property trees, thor cannot support any background update - via the environment in
* bare-metal, or config files in containerized. If it was to support it the code in the master would need to change, and updates would
* need to be synchronized to the workers. To support this requiremnt a threadSafe parameter is provided to avoid the normal clone.
*
* For roxie, which dynamically connects and disconnects from dali, there are different problems. The code needs to retain whether or not roxie
* is connected to dali - and only create planes from groups if it is connected. There is another potential problem, which I don't think will
* actually be hit:
* Say roxie connects, updates planes from groups and disconnects. If the update functions were called again those storage planes would be lost,
* but in bare-metal only a change to the environment will trigger an update, and that update will not happen if roxie is not connected to dali.
*/

static bool savedConnectedToDali = false; // Store in a global so it can be used by the callback without having to reregister
static bool lastUpdateConnectedToDali = false;
void initializeStoragePlanes(bool connectedToDali, bool threadSafe)
{
Rename parameter to updatePlanesFromDali?
{
//If the createPlanesFromGroups parameter is now true, and was previously false, force an update
CriticalBlock block(storageCS);
if (!lastCreatedPlanesFromGroups && createPlanesFromGroups)
if (!lastUpdateConnectedToDali && connectedToDali)
configUpdateHook.clear();
globalCreatePlanesFromGroups = createPlanesFromGroups;
savedConnectedToDali = connectedToDali;
}
MORE: Check this logic

auto updateFunc = [](IPropertyTree * newComponentConfiguration, IPropertyTree * newGlobalConfiguration)
{
bool createPlanesFromGroups = globalCreatePlanesFromGroups;
lastCreatedPlanesFromGroups = createPlanesFromGroups;
bool connectedToDali = savedConnectedToDali;
lastUpdateConnectedToDali = connectedToDali;
PROGLOG("initializeStoragePlanes update");
doInitializeStorageGroups(createPlanesFromGroups, newGlobalConfiguration);
doInitializeStorageGroups(connectedToDali, newGlobalConfiguration);
};

configUpdateHook.installModifierOnce(updateFunc, threadSafe);
}

void disableStoragePlanesDaliUpdates()
{
globalCreatePlanesFromGroups = false;
savedConnectedToDali = false;
}

bool getDefaultStoragePlane(StringBuffer &ret)
Expand Down
2 changes: 1 addition & 1 deletion dali/base/dafdesc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ extern da_decl void setPartMask(const char * mask);
extern da_decl bool setReplicateDir(const char *name,StringBuffer &out, bool isrep=true,const char *baseDir=NULL,const char *repDir=NULL); // changes directory of name passed to backup directory

extern da_decl void initializeStoragePlanes(bool createPlanesFromGroups, bool threadSafe); // threadSafe should be true if no other threads will be accessing the global config
extern da_decl void disableStoragePlanesUpdater();
extern da_decl void disableStoragePlanesDaliUpdates();

extern da_decl bool getDefaultStoragePlane(StringBuffer &ret);
extern da_decl bool getDefaultSpillPlane(StringBuffer &ret);
Expand Down

0 comments on commit 849d415

Please sign in to comment.