00001
00002
00003
00004
00005
00006
00007
00008 #include "dataCopy.h"
00009 #include "rcPortalOpr.h"
00010 #include "miscServerFunct.h"
00011 #include "rsGlobalExtern.h"
00012 #include "rcGlobalExtern.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 int
00033 rsDataCopy (rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
00034 {
00035 int status;
00036 int l3descInx;
00037 rodsServerHost_t *rodsServerHost;
00038 dataOprInp_t *dataOprInp;
00039
00040 dataOprInp = &dataCopyInp->dataOprInp;
00041
00042
00043 if (getValByKey (&dataOprInp->condInput, EXEC_LOCALLY_KW) != NULL ||
00044 dataCopyInp->portalOprOut.numThreads == 0) {
00045
00046 status = _rsDataCopy (rsComm, dataCopyInp);
00047 } else {
00048 if (dataOprInp->destL3descInx > 0) {
00049 l3descInx = dataOprInp->destL3descInx;
00050 } else {
00051 l3descInx = dataOprInp->srcL3descInx;
00052 }
00053 rodsServerHost = FileDesc[l3descInx].rodsServerHost;
00054 if (rodsServerHost != NULL && rodsServerHost->localFlag != LOCAL_HOST) {
00055 addKeyVal (&dataOprInp->condInput, EXEC_LOCALLY_KW, "");
00056 status = remoteDataCopy (rsComm, dataCopyInp, rodsServerHost);
00057 clearKeyVal (&dataOprInp->condInput);
00058 } else {
00059 status = _rsDataCopy (rsComm, dataCopyInp);
00060 }
00061 }
00062 return (status);
00063 }
00064
00065 int
00066 remoteDataCopy (rsComm_t *rsComm, dataCopyInp_t *dataCopyInp,
00067 rodsServerHost_t *rodsServerHost)
00068 {
00069 int status;
00070
00071 if (rodsServerHost == NULL) {
00072 rodsLog (LOG_NOTICE,
00073 "remoteDataCopy: Invalid rodsServerHost");
00074 return SYS_INVALID_SERVER_HOST;
00075 }
00076
00077 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00078 return status;
00079 }
00080
00081 dataCopyInp->dataOprInp.destL3descInx =
00082 convL3descInx (dataCopyInp->dataOprInp.destL3descInx);
00083
00084 status = rcDataCopy (rodsServerHost->conn, dataCopyInp);
00085
00086 if (status < 0) {
00087 rodsLog (LOG_NOTICE,
00088 "remoteDataCopy: rcDataCopy failed");
00089 }
00090
00091 return status;
00092 }
00093
00094 int
00095 _rsDataCopy (rsComm_t *rsComm, dataCopyInp_t *dataCopyInp)
00096 {
00097 dataOprInp_t *dataOprInp;
00098 int retVal;
00099
00100 if (dataCopyInp == NULL) {
00101 rodsLog (LOG_NOTICE,
00102 "_rsDataCopy: NULL dataCopyInp input");
00103 return (SYS_INTERNAL_NULL_INPUT_ERR);
00104 }
00105
00106 dataOprInp = &dataCopyInp->dataOprInp;
00107 if (dataOprInp->oprType == SAME_HOST_COPY_OPR) {
00108
00109 retVal = sameHostCopy (rsComm, dataCopyInp);
00110 } else if (dataOprInp->oprType == COPY_TO_LOCAL_OPR ||
00111 dataOprInp->oprType == COPY_TO_REM_OPR) {
00112 retVal = remLocCopy (rsComm, dataCopyInp);
00113 } else {
00114 rodsLog (LOG_NOTICE,
00115 "_rsDataCopy: Invalid oprType %d", dataOprInp->oprType);
00116 return (SYS_INVALID_OPR_TYPE);
00117 }
00118
00119 return (retVal);
00120 }
00121