int CDfuPlusHelper::replicate() { const char* srcname = globals->queryProp("srcname"); if(srcname == NULL) throw MakeStringException(-1, "srcname not specified"); bool nowait = globals->getPropBool("nowait", false); Owned<IClientReplicate> req = sprayclient->createReplicateRequest(); req->setSourceLogicalName(srcname); req->setReplicateOffset(globals->getPropInt("replicateoffset",1)); bool repeatlast = globals->getPropBool("repeatlast"); bool onlyrepeated = repeatlast&&globals->getPropBool("onlyrepeated"); StringBuffer cluster; globals->getProp("cluster",cluster); if (cluster.length()) req->setCluster(cluster.str()); else if (repeatlast) { error("replicate repeatlast specified with no cluster\n"); return 0; } if (repeatlast) req->setRepeatLast(true); if (onlyrepeated) req->setOnlyRepeated(true); Owned<IClientReplicateResponse> result = sprayclient->Replicate(req); const char* wuid = result->getWuid(); if(wuid == NULL || *wuid == '\0') exc(result->getExceptions(),"replicating"); else { const char* jobname = globals->queryProp("jobname"); if(jobname && *jobname) updatejobname(wuid, jobname); info("Submitted WUID %s\n", wuid); if(!nowait) waitToFinish(wuid); } return 0; }
int CDfuPlusHelper::copy() { const char* srcname = globals->queryProp("srcname"); if(srcname == NULL) throw MakeStringException(-1, "srcname not specified"); const char* dstname = globals->queryProp("dstname"); if(dstname == NULL) throw MakeStringException(-1, "dstname not specified"); const char* dstcluster = globals->queryProp("dstcluster"); const char* dstclusterroxie = globals->queryProp("dstclusterroxie"); const char* srcdali = globals->queryProp("srcdali"); const char* srcusername = globals->queryProp("srcusername"); const char* srcpassword = globals->queryProp("srcpassword"); const char* diffkeydst = globals->queryProp("diffkeysrc"); const char* diffkeysrc = globals->queryProp("diffkeydst"); bool nowait = globals->getPropBool("nowait", false); info("\nCopying from %s to %s\n", srcname, dstname); Owned<IClientCopy> req = sprayclient->createCopyRequest(); req->setSourceLogicalName(srcname); req->setDestLogicalName(dstname); if(dstcluster != NULL) req->setDestGroup(dstcluster); if(dstclusterroxie && !stricmp(dstclusterroxie, "Yes")) req->setDestGroupRoxie("Yes"); if(srcdali != NULL) req->setSourceDali(srcdali); if(diffkeysrc != NULL) req->setSourceDiffKeyName(diffkeysrc); if(diffkeydst != NULL) req->setDestDiffKeyName(diffkeydst); if(srcusername && *srcusername) req->setSrcusername(srcusername); if(srcpassword && *srcpassword) req->setSrcpassword(srcpassword); req->setOverwrite(globals->getPropBool("overwrite", false)); req->setReplicate(globals->getPropBool("replicate", true)); req->setReplicateOffset(globals->getPropInt("replicateoffset",1)); if(globals->hasProp("nosplit")) req->setNosplit(globals->getPropBool("nosplit", false)); if(globals->hasProp("push")) { if (globals->getPropBool("push")) req->setPush(true); else req->setPull(true); } if(globals->hasProp("compress")) req->setCompress(globals->getPropBool("compress", false)); if(globals->hasProp("encrypt")) req->setEncrypt(globals->queryProp("encrypt")); if(globals->hasProp("decrypt")) req->setDecrypt(globals->queryProp("decrypt")); if(globals->hasProp("connect")) req->setMaxConnections(globals->getPropInt("connect")); if(globals->hasProp("throttle")) req->setThrottle(globals->getPropInt("throttle")); if(globals->hasProp("transferbuffersize")) req->setTransferBufferSize(globals->getPropInt("transferbuffersize")); if(globals->hasProp("wrap")) req->setWrap(globals->getPropBool("wrap", false)); if(globals->hasProp("multicopy")) req->setMulticopy(globals->getPropBool("multicopy", false)); else if(globals->hasProp("multiCopy")) req->setMulticopy(globals->getPropBool("multiCopy", false)); if(globals->hasProp("norecover")) req->setNorecover(globals->getPropBool("norecover", false)); else if(globals->hasProp("noRecover")) req->setNorecover(globals->getPropBool("noRecover", false)); Owned<IClientCopyResponse> result = sprayclient->Copy(req); const char* wuid = result->getResult(); if(wuid == NULL || *wuid == '\0') exc(result->getExceptions(),"copying"); else { const char* jobname = globals->queryProp("jobname"); if(jobname && *jobname) updatejobname(wuid, jobname); info("Submitted WUID %s\n", wuid); if(!nowait) waitToFinish(wuid); } return 0; }
int CDfuPlusHelper::despray() { const char* srcname = globals->queryProp("srcname"); if(srcname == NULL) throw MakeStringException(-1, "srcname not specified"); const char* dstxml = globals->queryProp("dstxml"); const char* dstip = globals->queryProp("dstip"); const char* dstfile = globals->queryProp("dstfile"); bool nowait = globals->getPropBool("nowait", false); MemoryBuffer xmlbuf; if(dstxml == NULL) { if(dstfile == NULL) throw MakeStringException(-1, "dstfile not specified"); if(dstip == NULL) { #ifdef DAFILESRV_LOCAL progress("dstip not specified - assuming spray from local machine\n"); dstip = "."; #else throw MakeStringException(-1, "dstip not specified"); #endif } } else { if(dstip != NULL || dstfile != NULL) throw MakeStringException(-1, "dstip/dstfile and dstxml can't be used at the same time"); StringBuffer buf; buf.loadFile(dstxml); int len = buf.length(); xmlbuf.setBuffer(len, buf.detach(), true); } if(dstxml == NULL) info("\nDespraying %s to host %s file %s\n", srcname, dstip, dstfile); else info("\nDespraying %s\n", srcname); Owned<IClientDespray> req = sprayclient->createDesprayRequest(); req->setSourceLogicalName(srcname); if(dstxml == NULL) { req->setDestIP(dstip); req->setDestPath(dstfile); } else req->setDstxml(xmlbuf); req->setOverwrite(globals->getPropBool("overwrite", false)); if(globals->hasProp("connect")) req->setMaxConnections(globals->getPropInt("connect")); if(globals->hasProp("throttle")) req->setThrottle(globals->getPropInt("throttle")); if(globals->hasProp("transferbuffersize")) req->setTransferBufferSize(globals->getPropInt("transferbuffersize")); if(globals->hasProp("norecover")) req->setNorecover(globals->getPropBool("norecover", false)); else if(globals->hasProp("noRecover")) req->setNorecover(globals->getPropBool("noRecover", false)); if(globals->hasProp("splitprefix")) req->setSplitprefix(globals->queryProp("splitprefix")); else if(globals->hasProp("splitPrefix")) req->setSplitprefix(globals->queryProp("splitPrefix")); if(globals->hasProp("wrap")) req->setWrap(globals->getPropBool("wrap", false)); if(globals->hasProp("multicopy")) req->setMultiCopy(globals->getPropBool("multicopy", false)); else if(globals->hasProp("multiCopy")) req->setMultiCopy(globals->getPropBool("multiCopy", false)); if(globals->hasProp("compress")) req->setCompress(globals->getPropBool("compress", false)); if(globals->hasProp("encrypt")) req->setEncrypt(globals->queryProp("encrypt")); if(globals->hasProp("decrypt")) req->setDecrypt(globals->queryProp("decrypt")); SocketEndpoint localep; StringBuffer localeps; if (checkLocalDaFileSvr(dstip,localep)) dstip = localep.getUrlStr(localeps).str(); Owned<IClientDesprayResponse> result = sprayclient->Despray(req); const char* wuid = result->getWuid(); if(wuid == NULL || *wuid == '\0') exc(result->getExceptions(),"despraying"); else { const char* jobname = globals->queryProp("jobname"); if(jobname && *jobname) updatejobname(wuid, jobname); info("Submitted WUID %s\n", wuid); if(!nowait) waitToFinish(wuid); } return 0; }
int CDfuPlusHelper::spray() { const char* srcxml = globals->queryProp("srcxml"); const char* srcip = globals->queryProp("srcip"); const char* srcfile = globals->queryProp("srcfile"); bool nowait = globals->getPropBool("nowait", false); MemoryBuffer xmlbuf; if(srcxml == NULL) { if(srcfile == NULL) throw MakeStringException(-1, "srcfile not specified"); if(srcip == NULL) { #ifdef DAFILESRV_LOCAL progress("srcip not specified - assuming spray from local machine\n"); srcip = "."; #else throw MakeStringException(-1, "srcip not specified"); #endif } } else { if(srcip != NULL || srcfile != NULL) throw MakeStringException(-1, "srcip/srcfile and srcxml can't be used at the same time"); StringBuffer buf; buf.loadFile(srcxml); int len = buf.length(); xmlbuf.setBuffer(len, buf.detach(), true); } const char* dstname = globals->queryProp("dstname"); if(dstname == NULL) throw MakeStringException(-1, "dstname not specified"); const char* dstcluster = globals->queryProp("dstcluster"); if(dstcluster == NULL) throw MakeStringException(-1, "dstcluster not specified"); const char* format = globals->queryProp("format"); if(format == NULL) format = "fixed"; SocketEndpoint localep; StringBuffer localeps; if (checkLocalDaFileSvr(srcip,localep)) srcip = localep.getUrlStr(localeps).str(); StringBuffer wuid; StringBuffer errmsg; bool ok; if ((stricmp(format, "fixed") == 0)||(stricmp(format, "recfmvb") == 0)||(stricmp(format, "recfmv") == 0)||(stricmp(format, "variablebigendian") == 0)) ok = fixedSpray(srcxml,srcip,srcfile,xmlbuf,dstcluster,dstname,format,wuid,errmsg); else if((stricmp(format, "csv") == 0) ||(stricmp(format, "xml") == 0)||(stricmp(format, "variable") == 0)) ok = variableSpray(srcxml,srcip,srcfile,xmlbuf,dstcluster,dstname,format,wuid, errmsg); else throw MakeStringException(-1, "format %s not supported", format); if (!ok) { if(errmsg.length()) error("%s\n", errmsg.str()); else throw MakeStringException(-1, "unknown error spraying"); } else { const char* jobname = globals->queryProp("jobname"); if(jobname && *jobname) updatejobname(wuid.str(), jobname); info("Submitted WUID %s\n", wuid.str()); if(!nowait) waitToFinish(wuid.str()); } return 0; }
multithreading::producerConsumer::Consumer::~Consumer() { stop(); waitToFinish(); }