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