|
@@ -522,61 +522,59 @@ bool CFileSprayEx::ParseLogicalPath(const char * pLogicalPath, StringBuffer &tit
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-DFUclusterPartDiskMapping readClusterMappingSettings(const char *cluster, StringBuffer &dir, int& offset, ClusterPartDiskMapSpec& mspec)
|
|
|
+void setClusterPartDiskMapping(const char *clusterName, const char *defaultFolder, const char *defaultReplicateFolder,
|
|
|
+ bool supercopy, IDFUfileSpec *wuFSpecDest, IDFUoptions *wuOptions)
|
|
|
{
|
|
|
- DFUclusterPartDiskMapping mapping = DFUcpdm_c_only;
|
|
|
Owned<IEnvironmentFactory> envFactory = getEnvironmentFactory();
|
|
|
envFactory->validateCache();
|
|
|
|
|
|
StringBuffer dirxpath;
|
|
|
- dirxpath.appendf("Software/RoxieCluster[@name=\"%s\"]",cluster);
|
|
|
+ dirxpath.appendf("Software/RoxieCluster[@name=\"%s\"]",clusterName);
|
|
|
Owned<IConstEnvironment> constEnv = envFactory->openEnvironmentByFile();
|
|
|
Owned<IPropertyTree> pEnvRoot = &constEnv->getPTree();
|
|
|
Owned<IPropertyTreeIterator> processes = pEnvRoot->getElements(dirxpath);
|
|
|
- if (processes->first())
|
|
|
+ if (!processes->first())
|
|
|
{
|
|
|
- IPropertyTree &process = processes->query();
|
|
|
- const char *slaveConfig = process.queryProp("@slaveConfig");
|
|
|
- if (slaveConfig && *slaveConfig)
|
|
|
- {
|
|
|
- if (!strnicmp(slaveConfig, "simple", 6))
|
|
|
- {
|
|
|
- mapping = DFUcpdm_c_only;
|
|
|
- }
|
|
|
- else if (!strnicmp(slaveConfig, "overloaded", 10))
|
|
|
- {
|
|
|
- mapping = DFUcpdm_c_then_d;
|
|
|
- mspec.setRoxie(0, processe.getCount("RoxieSlave[1]/RoxieChannel"));
|
|
|
- }
|
|
|
- else if (!strnicmp(slaveConfig, "full", 4))
|
|
|
- {
|
|
|
- mapping = DFUcpdm_c_only;
|
|
|
- }
|
|
|
- else if (!strnicmp(slaveConfig, "cyclic", 6))
|
|
|
- {
|
|
|
- mapping = DFUcpdm_c_replicated_by_d;
|
|
|
- offset = process.getPropInt("@cyclicOffset");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DBGLOG("Failed to get RoxieCluster settings");
|
|
|
- throw MakeStringException(ECLWATCH_INVALID_CLUSTER_INFO, "Failed to get RoxieCluster settings. The workunit will not be created.");
|
|
|
- }
|
|
|
- dir = process.queryProp("@slaveDataDir");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DBGLOG("Failed to get RoxieCluster settings");
|
|
|
- throw MakeStringException(ECLWATCH_INVALID_CLUSTER_INFO, "Failed to get RoxieCluster settings. The workunit will not be created.");
|
|
|
- }
|
|
|
+ DBGLOG("Failed to get RoxieCluster settings");
|
|
|
+ throw MakeStringException(ECLWATCH_INVALID_CLUSTER_INFO, "Failed to get RoxieCluster settings. The workunit will not be created.");
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ IPropertyTree &processe = processes->query();
|
|
|
+ const char *slaveConfig = processe.queryProp("@slaveConfig");
|
|
|
+ if (!slaveConfig || !*slaveConfig)
|
|
|
{
|
|
|
DBGLOG("Failed to get RoxieCluster settings");
|
|
|
throw MakeStringException(ECLWATCH_INVALID_CLUSTER_INFO, "Failed to get RoxieCluster settings. The workunit will not be created.");
|
|
|
}
|
|
|
|
|
|
- return mapping;
|
|
|
+ ClusterPartDiskMapSpec spec;
|
|
|
+ spec.setDefaultBaseDir(defaultFolder);
|
|
|
+ if (strieq(slaveConfig, "simple"))
|
|
|
+ {
|
|
|
+ spec.setRoxie(0,1);
|
|
|
+ wuOptions->setReplicate(false);
|
|
|
+ }
|
|
|
+ else if (strieq(slaveConfig, "full redundancy"))
|
|
|
+ {
|
|
|
+ spec.setRoxie(1,1,0);
|
|
|
+ wuOptions->setReplicate(true);
|
|
|
+ }
|
|
|
+ else if (strieq(slaveConfig, "overloaded"))
|
|
|
+ {
|
|
|
+ spec.setRoxie(0, processe.getCount("RoxieSlave[1]/RoxieChannel"));
|
|
|
+ spec.setDefaultReplicateDir(defaultReplicateFolder);
|
|
|
+ wuOptions->setReplicate(false);
|
|
|
+ }
|
|
|
+ else //circular redundancy
|
|
|
+ {
|
|
|
+ spec.setRoxie(1, processe.getCount("RoxieSlave[1]/RoxieChannel"), processe.getPropInt("@cyclicOffset", 1));
|
|
|
+ spec.setDefaultReplicateDir(defaultReplicateFolder);
|
|
|
+ wuOptions->setReplicate(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!supercopy)
|
|
|
+ spec.setRepeatedCopies(CPDMSRP_lastRepeated,false);
|
|
|
+ wuFSpecDest->setClusterPartDiskMapSpec(clusterName,spec);
|
|
|
}
|
|
|
|
|
|
void getClusterFromLFN(const char* lfn, StringBuffer& cluster, const char* username, const char* passwd)
|
|
@@ -2398,27 +2396,12 @@ bool CFileSprayEx::onCopy(IEspContext &context, IEspCopy &req, IEspCopyResponse
|
|
|
wuFSpecDest->setFileMask(fileMask.str());
|
|
|
wuOptions->setOverwrite(req.getOverwrite());
|
|
|
|
|
|
- ClusterPartDiskMapSpec mspec;
|
|
|
- wuFSpecDest->getClusterPartDiskMapSpec(destCluster.str(), mspec);
|
|
|
if (bRoxie)
|
|
|
{
|
|
|
- int offset;
|
|
|
- StringBuffer baseDir;
|
|
|
- DFUclusterPartDiskMapping val = readClusterMappingSettings(destCluster.str(), baseDir, offset, mspec);
|
|
|
+ setClusterPartDiskMapping(destCluster.str(), defaultFolder.str(), defaultReplicateFolder.str(), supercopy, wuFSpecDest, wuOptions);
|
|
|
wuFSpecDest->setWrap(true); // roxie always wraps
|
|
|
if(req.getCompress())
|
|
|
wuFSpecDest->setCompressed(true);
|
|
|
- if (supercopy)
|
|
|
- wuFSpecDest->setClusterPartDiskMapping(val, baseDir.str(), destCluster.str());
|
|
|
- else
|
|
|
- wuFSpecDest->setClusterPartDiskMapping(val, baseDir.str(), destCluster.str(), true);
|
|
|
- if (val != DFUcpdm_c_replicated_by_d)
|
|
|
- wuOptions->setReplicate(false);
|
|
|
- else
|
|
|
- {
|
|
|
- wuOptions->setReplicate(true);
|
|
|
- wuFSpecDest->setReplicateOffset(offset);
|
|
|
- }
|
|
|
if (!supercopy)
|
|
|
wuOptions->setSuppressNonKeyRepeats(true); // **** only repeat last part when src kind = key
|
|
|
}
|
|
@@ -2457,11 +2440,13 @@ bool CFileSprayEx::onCopy(IEspContext &context, IEspCopy &req, IEspCopyResponse
|
|
|
wuOptions->setPush(true);
|
|
|
if (req.getIfnewer())
|
|
|
wuOptions->setIfNewer(true);
|
|
|
- }
|
|
|
|
|
|
- mspec.setDefaultBaseDir(defaultFolder.str());
|
|
|
- mspec.setDefaultReplicateDir(defaultReplicateFolder.str());
|
|
|
- wuFSpecDest->setClusterPartDiskMapSpec(destCluster.str(), mspec);
|
|
|
+ ClusterPartDiskMapSpec mspec;
|
|
|
+ wuFSpecDest->getClusterPartDiskMapSpec(destCluster.str(), mspec);
|
|
|
+ mspec.setDefaultBaseDir(defaultFolder.str());
|
|
|
+ mspec.setDefaultReplicateDir(defaultReplicateFolder.str());
|
|
|
+ wuFSpecDest->setClusterPartDiskMapSpec(destCluster.str(), mspec);
|
|
|
+ }
|
|
|
|
|
|
resp.setResult(wu->queryId());
|
|
|
resp.setRedirectUrl(StringBuffer("/FileSpray/GetDFUWorkunit?wuid=").append(wu->queryId()).str());
|