00001
00002
00003
00004
00005
00006 #include "dataPut.h"
00007 #include "rodsLog.h"
00008 #include "miscServerFunct.h"
00009 #include "rsGlobalExtern.h"
00010 #include "rcGlobalExtern.h"
00011
00012
00013
00014
00015
00016 int
00017 rsDataPut (rsComm_t *rsComm, dataOprInp_t *dataOprInp,
00018 portalOprOut_t **portalOprOut)
00019 {
00020 int status;
00021 int remoteFlag;
00022 int l3descInx;
00023 rodsServerHost_t *rodsServerHost;
00024
00025 l3descInx = dataOprInp->destL3descInx;
00026
00027 if (getValByKey (&dataOprInp->condInput, EXEC_LOCALLY_KW) != NULL) {
00028 remoteFlag = LOCAL_HOST;
00029 } else {
00030 rodsServerHost = FileDesc[l3descInx].rodsServerHost;
00031 if (rodsServerHost == NULL) {
00032 rodsLog (LOG_NOTICE, "rsDataPut: NULL rodsServerHost");
00033 return (SYS_INTERNAL_NULL_INPUT_ERR);
00034 }
00035 remoteFlag = rodsServerHost->localFlag;
00036 }
00037
00038 if (remoteFlag == LOCAL_HOST) {
00039 status = _rsDataPut (rsComm, dataOprInp, portalOprOut);
00040 } else {
00041 addKeyVal (&dataOprInp->condInput, EXEC_LOCALLY_KW, "");
00042 status = remoteDataPut (rsComm, dataOprInp, portalOprOut,
00043 rodsServerHost);
00044 clearKeyVal (&dataOprInp->condInput);
00045 }
00046
00047
00048 return (status);
00049 }
00050
00051 int
00052 _rsDataPut (rsComm_t *rsComm, dataOprInp_t *dataOprInp,
00053 portalOprOut_t **portalOprOut)
00054 {
00055 int status;
00056
00057 status = setupSrvPortalForParaOpr (rsComm, dataOprInp, PUT_OPR,
00058 portalOprOut);
00059
00060 return status;
00061 #if 0
00062 portalOprOut_t *myDataObjPutOut;
00063 int portalSock;
00064 int proto;
00065
00066 #ifdef RBUDP_TRANSFER
00067 if (getValByKey (&dataOprInp->condInput, RBUDP_TRANSFER_KW) != NULL) {
00068 proto = SOCK_DGRAM;
00069 } else {
00070 proto = SOCK_STREAM;
00071 }
00072 #else
00073 proto = SOCK_STREAM;
00074 #endif
00075
00076 myDataObjPutOut = (portalOprOut_t *) malloc (sizeof (portalOprOut_t));
00077 memset (myDataObjPutOut, 0, sizeof (portalOprOut_t));
00078
00079 *portalOprOut = myDataObjPutOut;
00080
00081 if (getValByKey (&dataOprInp->condInput, STREAMING_KW) != NULL ||
00082 proto == SOCK_DGRAM) {
00083
00084 myDataObjPutOut->numThreads = 1;
00085 } else {
00086 myDataObjPutOut->numThreads =
00087 myDataObjPutOut->numThreads = getNumThreads (rsComm,
00088 dataOprInp->dataSize, dataOprInp->numThreads,
00089 &dataOprInp->condInput);
00090 }
00091
00092 if (myDataObjPutOut->numThreads == 0) {
00093 return 0;
00094 } else {
00095 portalOpr_t *myPortalOpr;
00096
00097
00098 portalSock = createSrvPortal (rsComm, &myDataObjPutOut->portList,
00099 proto);
00100 if (portalSock < 0) {
00101 rodsLog (LOG_NOTICE,
00102 "_rsDataPut: createSrvPortal error, ststus = %d", portalSock);
00103 myDataObjPutOut->status = portalSock;
00104 return portalSock;
00105 }
00106 myPortalOpr = rsComm->portalOpr =
00107 (portalOpr_t *) malloc (sizeof (portalOpr_t));
00108 myPortalOpr->oprType = PUT_OPR;
00109 myPortalOpr->portList = myDataObjPutOut->portList;
00110 myPortalOpr->dataOprInp = *dataOprInp;
00111 memset (&dataOprInp->condInput, 0, sizeof (dataOprInp->condInput));
00112 myPortalOpr->dataOprInp.numThreads = myDataObjPutOut->numThreads;
00113 }
00114 return (0);
00115 #endif
00116 }
00117
00118
00119 int
00120 remoteDataPut (rsComm_t *rsComm, dataOprInp_t *dataOprInp,
00121 portalOprOut_t **portalOprOut, rodsServerHost_t *rodsServerHost)
00122 {
00123 int status;
00124
00125 if (rodsServerHost == NULL) {
00126 rodsLog (LOG_NOTICE,
00127 "remoteDataPut: Invalid rodsServerHost");
00128 return SYS_INVALID_SERVER_HOST;
00129 }
00130
00131 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00132 return status;
00133 }
00134
00135 dataOprInp->destL3descInx = convL3descInx (dataOprInp->destL3descInx);
00136
00137 status = rcDataPut (rodsServerHost->conn, dataOprInp, portalOprOut);
00138
00139 return (status);
00140 }
00141