185 #include <netinet/in.h>
186 #include <sys/stat.h>
191 #define MAX_LOG_FILE 64
194 #define fprintf fprintm
201 #include "error_mac.h"
202 #include "errnum_def.h"
203 #include "err_mask_def.h"
204 #include "f_ut_printm.h"
231 #define MAX_BUFSIZE 32768
256 {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
258 #ifdef __USE_LARGEFILE64
267 int rfio_open64(
const char *pcFile,
271 char cModule[32] =
"rfio_open64";
277 "\n-D- begin %s: file %s, flags %d, mode %d\n",
278 cModule, pcFile, iFlags, iMode);
284 "-E- 32 bit client: %s not supported\n", cModule);
289 iFileId =
rfio_open(pcFile, iFlags, iMode);
292 "-D- end %s: iFileId(rfio_open) = %d\n\n", cModule, iFileId);
311 char cModule[32] =
"rfio_open";
315 char *pcCopyPath = NULL;
316 int iCopyFraction = 0;
318 int iPathConvention = 0;
321 printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
331 "-D- end %s, iFileId(rfio_open_gsidaq) = %d\n\n",
391 char cModule[32] =
"rfio_open_gsidaq";
396 int ii, ii1, ii2, iiopen;
406 unsigned long *plFileSizeC;
419 int iDataMoverSelect = 0;
433 char cServer[24] =
"";
434 int iSockMaster = -1;
444 char *pcc, *pcc1, *pcc2;
454 char cAccess[16] =
"";
492 printf(
"DDD iFlags %d, ii %d, ii1 %d, ii2 %d\n",
493 iFlags, ii, ii1, ii2);
496 printf(
"DDD iFlags %d, iFlags & O_RDONLY %d, iFlags & O_WRONLY %d, iFlags & O_ACCMODE %d\n",
497 iFlags, (iFlags & ii), (iFlags & ii1), (iFlags & ii2));
500 if ( (iFlags & O_ACCMODE) == O_RDONLY)
503 strcpy(cAccess,
"read");
508 strcpy(cAccess,
"write");
514 else if (ii != 4) printf(
515 "-W- unexpected size of long integer: %d byte\n", ii);
520 printf(
"\n-D- begin %s (%d bit OS)", cModule, ii);
522 printf(
", %d remote files currently open",
iFileCount);
528 if ( (strlen(pcc) == 0) || (strcmp(pcc,
" ") == 0) )
533 if (strstr(pcFile,
"lxgstoredel"))
537 for (ii=0; ii<10; ii++)
539 sprintf(cTemp,
"lxgstore%ddel", ii);
540 if (strstr(pcFile, cTemp))
548 if ( (iDebug) && (iAction == 9) ) printf(
549 " file %s will be deleted in gStore\n", pcFile);
559 pCommAPI = &(
pAPIFile[iiopen]->sCommAPI);
561 if ( (strlen(pCommAPI->
cNamefs)) &&
566 strcpy(cObject, pCommAPI->
cNamefs);
567 strcat(cObject, pCommAPI->
cNamehl);
568 strcat(cObject, pCommAPI->
cNamell);
571 printf(
" %d: %s already open\n", iiopen, cObject);
576 pcc = strstr(pcFile, cObject);
580 printf(
" %d: %s maps\n", iiopen, cObject);
603 if (ii1 == 0) printf(
604 "%d. file buffer: %s:%d already open\n",
607 "%d. file buffer: %s%d:%d already open\n",
611 pcc = strstr(pcFile,
"lxgstore");
612 pcc1 = strstr(pcFile,
"rfiocopy");
613 if ( (pcc) && (pcc1 == NULL) )
631 strncpy(pcc,
"\0", 1);
637 " cur file: node name lxgstore%d\n",
640 if (atoi(pcc) == ii1)
652 if (strcmp(pcc,
"del") == 0)
657 "-E- %s: invalid node name %s\n",
669 printf(
"-E- available fileId %d maps %s\n",
681 " %d open gStore connections or files found\n",
693 fprintf(
fLogClient,
"-E- %s: %s is already open\n",
703 "-E- %s: max %d remote files may be open simultaneously\n",
714 "-E- %s: allocating file control block no. %d (%d byte)\n",
725 " file control block no. %d allocated (%d byte, fileId %d)\n",
736 printf(
" query only, iOpenMode %d reset to 0\n", iOpenMode);
741 pcurAPIFile->
iFileId = iFileId;
742 pcurAPIFile->
iFlags = iFlags;
743 pcurAPIFile->
iMode = iOpenMode;
747 pcurAPIFile->
iOffset = iOffset;
751 pcurAPIFile->
iAction = iAction;
753 pCommAPI = &(pcurAPIFile->
sCommAPI);
767 if ( (strchr(pcFile, *
pcStar) != NULL) ||
768 (strchr(pcFile, *
pcQM) != NULL) ||
769 (strchr(pcFile, *
pcPerc) != NULL) )
772 "-E- %s: files with wildcard characters ('%s') not allowed using RFIO\n",
784 "-E- %s(1): invalid remote file name '%s': node name missing\n",
792 strcpy(cTemp, pcFile);
800 pcc = strstr(cTemp,
"lxgstore");
806 "-E- %s: invalid node name in remote file name '%s'\n",
813 pcc2 = strstr(cTemp,
"rfio:");
819 strncpy(pcc1,
"\0", 1);
829 "-W- non-standard port no. %d for entry server\n", iPort);
835 "-E- %s(2): invalid remote file name '%s'\n",
843 strcpy(cObject, pcc);
848 strcpy(cObject, pcc1);
853 printf(
" node:port %s:%d\n", pcc2, iPort);
855 printf(
" gStore object %s\n", cObject);
868 strncpy(pcc,
"\0", 1);
871 while (*pcc1 !=
'\0')
873 *pcc1 = tolower(*pcc1);
879 printf(
" URL in small letters: '%s'\n", cTemp);
882 pcc = strstr(cTemp,
".gsi.de");
885 strncpy(pcc++,
":", 1);
886 strncpy(pcc,
"\0", 1);
888 printf(
" remove trailing '.gsi.de': %s\n", cTemp);
892 if (strncmp(cTemp,
"rfio", 4) == 0)
900 "-E- %s(3): invalid prefix '%s' of remote file name: node name missing\n",
912 strncpy(pcc2,
"\0", 1);
915 if ( (iPort == 0) && (strlen(pcc1) > 1) ) fprintf(
fLogClient,
916 "-W- invalid name part %s in URL ignored\n", pcc1);
918 printf(
" node:port %s, port %s, iPort %d\n", pcc, pcc1, iPort);
923 strncpy(pcc1,
"\0", 1);
926 if (strlen(pcc) == 0)
929 "-E- %s(4): invalid remote file name '%s': node name missing\n",
940 if (strncmp(cTemp,
"rfiodaq:", 8) == 0)
944 fprintf(
fLogClient,
"-E- %s: reading from DaqPool not allowed\n",
946 fprintf(
fLogClient,
" correct object specification:\n");
947 fprintf(
fLogClient,
" [rfio:]node:/archive/path/file\n");
954 strcpy(cServer,
"gStore entry server");
957 else if (strncmp(cTemp,
"rfio:", 5) == 0)
960 strcpy(cServer,
"gStore entry server");
966 else if (iAction == 2)
971 else if (strncmp(cTemp,
"rfiocopy:", 9) == 0)
974 strcpy(cServer,
"RFIO server");
990 "-E- %s: invalid remote file name '%s': unknown prefix\n",
1001 if (strlen(pcc) == 0)
1004 "-E- %s(5): invalid remote file name '%s': node name missing\n",
1011 strncpy(pcc,
"\0", 1);
1017 strncpy(pcc1,
"\0", 1);
1020 if ( (iPort == 0) && (strlen(pcc) > 1) ) fprintf(
fLogClient,
1021 "-W- invalid name part %s in URL ignored\n", pcc);
1023 printf(
" node %s, port %s, iPort %d\n", cTemp, pcc, iPort);
1027 strcpy(cServer,
"gStore entry server");
1033 else if (iAction == 2)
1050 fprintf(
fLogClient,
"-E- %s: gStore server %s no longer supported\n",
1060 if ( (iAction == 2) ||
1062 printf(
" %s, request poolId %d\n", cServer, iPoolId);
1063 else if (iAction != 9)
1064 printf(
" %s\n", cServer);
1076 printf(
" remote object will be initialized later\n");
1078 printf(
" remote file will be initialized later\n");
1083 strcpy(pcNamefs,
"");
1084 strcpy(pcNamehl,
"");
1085 strcpy(pcNamell,
"");
1086 strcpy(pCommAPI->
cNamefs,
"");
1087 strcpy(pCommAPI->
cNamehl,
"");
1088 strcpy(pCommAPI->
cNamell,
"");
1093 strcpy(cTemp, cObject);
1101 pcc = (
char *) strchr(cTemp, *pcObjDelim);
1105 "-E- %s: invalid remote file name %s\n", cModule, pcFile);
1112 pcc1 = (
char *) strchr(pcc, *pcObjDelim);
1117 printf(
" remote object %s\n", cTemp);
1119 if ( (pcc == NULL) || (pcc1 == NULL) )
1122 "-E- %s: invalid remote object name '%s': archive name missing\n",
1130 strncpy(pcc1,
"\0", 1);
1134 fprintf(
fLogClient,
"-E- %s: archive name '%s' too long (max %d)\n",
1135 cModule, cTemp, ii);
1141 if (strlen(cTemp) < 2)
1143 fprintf(
fLogClient,
"-E- %s: invalid archive name '%s'\n",
1150 strcpy(pcNamefs, cTemp);
1152 printf(
" archive name %s\n", pcNamefs);
1154 strncpy(pcc, pcObjDelim, 1);
1156 pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
1160 "-E- %s: invalid remote object name '%s': path name missing\n",
1170 fprintf(
fLogClient,
"-E- %s: file name '%s' too long (max %d)\n",
1177 if (strlen(pcc1) < 2)
1179 fprintf(
fLogClient,
"-E- %s: invalid file name '%s'\n", cModule, pcc1);
1185 strcpy(pcNamell, pcc1);
1187 printf(
" file name %s\n", pcNamell);
1190 strncpy(pcc1,
"\0", 1);
1194 fprintf(
fLogClient,
"-E- %s: path name '%s' too long (max %d)\n",
1201 if (strlen(pcc) < 2)
1203 fprintf(
fLogClient,
"-E- %s: invalid path name '%s'\n", cModule, pcc);
1209 strcpy(pcNamehl, pcc);
1211 printf(
" path name %s\n", pcNamehl);
1217 fprintf(
fLogClient,
"-E- %s: invalid gStore file name: %s\n",
1225 if (strcmp(pcNamehl, pCommAPI->
cNamehl))
1227 strcpy(pcNamehl, pCommAPI->
cNamehl);
1228 printf(
" gStore path name corrected to %s\n", pcNamehl);
1230 strcpy((
char *) pcFile,
cPrefix);
1231 strcat((
char *) pcFile, pCommAPI->
cNamefs);
1232 strcat((
char *) pcFile, pCommAPI->
cNamehl);
1233 strcat((
char *) pcFile, pCommAPI->
cNamell);
1235 " new full file name: %s\n", pcFile);
1241 printf(
" remote file %s\n", cTemp);
1243 strcpy(pcNamefs,
"");
1246 pcc1 = (
char *) strrchr(cTemp, *pcObjDelim);
1249 fprintf(
fLogClient,
"-E- %s: invalid remote file name '%s'\n",
1259 fprintf(
fLogClient,
"-E- %s: file name '%s' too long (max %d)\n",
1266 if (strlen(pcc1) < 2)
1268 fprintf(
fLogClient,
"-E- %s: invalid file name '%s'\n", cModule, pcc1);
1274 strcpy(pcNamell, pcc1);
1276 printf(
" file name %s\n", pcNamell);
1278 strncpy(pcc1,
"\0", 1);
1282 fprintf(
fLogClient,
"-E- %s: path name '%s' too long (max %d)\n",
1283 cModule, cTemp, ii);
1289 if (strlen(cTemp) < 2)
1291 fprintf(
fLogClient,
"-E- %s: invalid path name '%s'\n",
1298 strcpy(pcNamehl, cTemp);
1300 printf(
" path name %s\n", pcNamehl);
1302 strcpy(pCommAPI->
cNamefs,
"\0");
1303 strcpy(pCommAPI->
cNamehl, pcNamehl);
1304 strcpy(pCommAPI->
cNamell, pcNamell);
1316 "-E- copy from write cache only for write actions\n");
1325 "-E- copy from write cache to lustre only when writing to DAQPool\n");
1334 "-E- copy from write cache only supported with rfio_[f]newfile\n");
1340 if ( (iCopyMode < 0) || (iCopyMode > 2) )
1342 fprintf(
fLogClient,
"-E- invalid copy mode: %d\n", iCopyMode);
1348 if ( (strlen(pcCopyPath) == 0) || (pcCopyPath == NULL) )
1350 fprintf(
fLogClient,
"-E- copy path missing\n");
1356 if (iCopyFraction < 0)
1359 "-E- invalid fraction of files to copied: %d (must be > 0)\n",
1366 if (iCopyFraction == 0)
1369 "-W- fraction of files to copied: 0 specified, assume 1 (copy all)\n");
1374 strcpy(cTemp, pcCopyPath);
1378 while (*pcc !=
'\0')
1380 *pcc = tolower(*pcc);
1383 if (strcmp(cTemp,
"rc") == 0)
1386 "-E- copy to read cache not yet implemented\n");
1392 strcpy(cTemp, pcCopyPath);
1400 pcc1 = strrchr(cTemp,
'/');
1401 ii = pcc1 - pcc + 1;
1402 if (ii == strlen(pcc))
1405 strncpy(pcc1,
"\0", 1);
1413 strcpy(pcCopyPath, cTemp);
1415 " %d trailing '/' ignored, use copy destination '%s'\n",
1424 "-E- invalid copy destination %s\n", pcCopyPath);
1433 "-E- invalid max file no. for copy destination: %d\n",
1440 if ( (iPathConvention < 0) || (iPathConvention > 1) )
1443 "-E- invalid convention no. for creation of new copy destination path: %d\n",
1453 "-I- copy each file to %s", pcCopyPath);
1455 "-I- copy each %d. file to %s", iCopyFraction, pcCopyPath);
1456 if (iPathConvention == 1)
1458 fprintf(
fLogClient,
" before tape migration\n");
1459 fprintf(
fLogClient,
" check success as asynchroneous copy process\n");
1464 "-I- write data buffers of each file to gStore write cache and to %s",
1467 "-I- for each %d. file write data buffers additionally to %s",
1468 iCopyFraction, pcCopyPath);
1469 if (iPathConvention == 1)
1474 if ( (iMaxFile) && (strcmp(
"rc", pcCopyPath)) ) fprintf(
fLogClient,
1475 " if %d files are written, create new directory (convention no. %d)\n",
1476 iMaxFile, iPathConvention);
1480 pCopyCacheServ->
iCopyMode = htonl(iCopyMode);
1481 pCopyCacheServ->
iCopyLen = htonl(0);
1483 strcpy(pCopyCacheServ->
cCopyPath, pcCopyPath);
1485 pCopyCacheServ->
iMaxFile = htonl(iMaxFile);
1489 " parameters for write cache copy stored\n");
1506 printf(
" switch to test system\n");
1512 "-W- invalid port no. %d for gStore entry server ignored\n",
1522 strcpy(cTemp,
"lx");
1526 " correct node '%s' to '%s'\n",
1552 " client %d for %s:%d\n",
1556 if ( (iAction == 9) &&
1557 (strncmp(pcc,
"del", 3) == 0) ) printf(
1570 if ( (iAction == 9) &&
1571 ((strncmp(pcc,
"del", 3) == 0) ||
1572 (strncmp(pcc,
"Del", 3) == 0)) ) printf(
1574 else if (*pcc !=
':') printf(
1575 "-W- invalid appendix '%s' in URL %s ignored\n",
1587 " gStore entry server %s (node in URL %s)\n",
1613 else if (iAction == 2)
1620 else if (iAction == 9)
1627 if (iObjInit) printf(
1628 " %s node %s:%d, file %s%s",
1635 printf(
" set gStore action to %d\n", pCommAPI->
iAction);
1636 if (iObjInit) printf(
1637 " %s:%d, object %s%s%s",
1646 printf(
", request StagePool\n");
1647 else if (iPoolId == 3)
1648 printf(
", request ArchivePool\n");
1649 else if (iPoolId == 4)
1650 printf(
", request DaqPool\n");
1655 printf(
" will be deleted\n");
1660 if (iObjInit) printf(
1661 " FS name '%s', HL name '%s', LL name '%s', action %d\n",
1665 " action %d, object follows later\n", pCommAPI->
iAction);
1672 iRC = gethostname(cliNode,
MAX_NODE);
1675 fprintf(
fLogClient,
"-E- %s: getting client host name: %s\n",
1676 cModule, strerror(iRC));
1683 " user %s on node %s, platform %s\n",
1684 cOwner, cliNode, cOS);
1695 sprintf(cstr,
".t%d", (
int) tstr);
1698 sprintf(cstr,
".p%d", pstr);
1705 printf(
"-E- %s: log file name %s too long (%d, max %d)\n",
1711 printf(
"-W- can not open log file %s, write to stdout\n",
1718 fprintf(
fLogClient,
"*** log file: %s, client node: %s\n",
1723 ptloc = localtime_r(&tcur, ptloc);
1725 ptloc->tm_year += 1900;
1728 " current date %d/%.2d/%.2d, time %.2d:%.2d:%.2d\n",
1741 strcpy(pCommAPI->
cOwner, cOwner);
1742 strcpy(pCommAPI->
cliNode, cliNode);
1743 strcpy(pCommAPI->
cOS, cOS);
1744 strcpy(pCommAPI->
cDataFS,
"");
1751 strcpy(pCommAPI->
cNodeRC,
"");
1759 else if (iAction == 1)
1769 printf(
" request WC poolId %d, device %d\n",
1771 else if ( (iAction == 1) && (
iOnlyQuery == 0) )
1772 printf(
" request RC poolId %d, device %d\n",
1787 strcpy(pCommServ->
cOS, pCommAPI->
cOS);
1804 " connecting to %s %s:%d\n",
1810 fprintf(
fLogClient,
"-E- %s: cannot connect to %s %s:%d\n",
1822 printf(
"-I- successfully connected to %s %s:%d",
1825 printf(
" after %ds", iMaxConnect);
1826 printf(
" (socket %d)\n", iSockMaster);
1847 iSockMover = iSockMaster;
1874 pBufQuery = &sQuery;
1879 printf(
" query file %s in gStore\n", pcFile);
1885 iRC =
rawQueryFile(iSockMaster, ii, pCommServ, &pBufQuery);
1899 "-E- no %s access to archive %s in all ATL servers\n",
1902 "-E- no %s access to archive %s in ATL server %d\n",
1906 "-E- no archive %s in ATL server %d found\n",
1909 "-E- file %s: query in ATL server %d failed, rc = %d\n",
1920 if ( (iAction == 1) || (iAction == 9) )
1924 " file %s not available in gStore\n", pcFile);
1927 "-E- %s: file %s not available in gStore\n",
1937 " file %s not yet available in gStore\n", pcFile);
1941 if ( (iAction == 1) &&
1947 "-E- filesize of %s >= 4 GB, cannot be read with 32 bit client\n",
1956 else if (iAction == 2)
1959 "-E- file %s already available in gStore\n", pcFile);
1967 memcpy(pQueryAPI, pQAttr, (
unsigned)
iObjAttr);
1971 printf(
" file %s available in gStore (ATL server %d)\n",
1974 if (iRC > 1) printf(
1975 "-W- %d versions of file %s exist\n", iRC, pcFile);
1983 printf(
" %s", cMsg);
1990 printf(
" file staged \n");
1992 iStage = ntohl(pQAttr->
iFS);
1995 if ( (iAction == 9) &&
1997 (ntohl(pQAttr->
iObjLow) == 0) )
2008 strcpy(pCommAPI->
cNodeWC,
"");
2014 printf(
" staged instance of write cache file\n");
2015 printf(
" file %s staged in FS %d of DM %s (poolId %d)",
2018 printf(
", still incomplete)\n");
2020 printf(
", already locked)\n");
2029 printf(
" write cache file\n");
2031 iCache = ntohl(pQAttr->
iFS);
2041 strcpy(pCommAPI->
cNodeRC,
"");
2046 printf(
" file %s cached in FS %d of DM %s (poolId %d)",
2049 printf(
", still incomplete)\n");
2051 printf(
", already locked)\n");
2062 strcpy(pCommAPI->
cNodeRC,
"");
2064 strcpy(pCommAPI->
cNodeWC,
"");
2068 printf(
" file %s in TSM storage\n", pcFile);
2082 "DDD file staged(0) in FS %d on DM %s in poolId %d\n",
2085 else if (iCache) printf(
2086 "DDD file cached(0) in FS %d on DM %s in poolId %d\n",
2100 " send command buffer to %s: id: %d, action %d (ATL server %d), len %d\n",
2101 cServer, ntohl(pCommServ->
iIdent),
2108 else if (iAction == 1)
2113 " keep entry server session for next query\n");
2115 pcc = (
char *) pCommServ;
2116 iRC = send(iSockMaster, pcc, (
unsigned)
irawComm, 0);
2120 "-E- %s: sending command buffer (action %d) to %s\n",
2121 cModule, ntohl(pCommServ->
iAction), cServer);
2132 "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
2141 " command buffer (action %d) sent to %s (%d byte)\n",
2151 if ( ( (iAction == 1) &&
2152 ( (iObjInit == 0) ||
2154 (iStage == 0) && (iCache == 0) ) ) ) ||
2158 " receiving attributes of data mover selected by master\n");
2160 iDataMoverSelect = 0;
2162 while (iDataMoverSelect == 0)
2164 pcc = (
char *) &sDataMoverSelect;
2169 iIdent = ntohl(sDataMoverSelect.
iIdent);
2170 iStatus = ntohl(sDataMoverSelect.
iStatus);
2171 iStatusLen = ntohl(sDataMoverSelect.
iStatusLen);
2174 " ident %d, status %d, len %d\n",
2175 iIdent, iStatus, iStatusLen);
2180 "-E- %s: receiving data mover attr header\n%s",
2189 "-W- %s: write cache currently full (select) ... sleep %d s (%d of %d)\n",
2195 "-W- %s: write cache currently full, archive to tape\n",
2199 " received DM name: %s\n", cMsg);
2200 iDataMoverSelect = 1;
2202 strcpy(pDataMoverSelect->
cNode, cMsg);
2204 pDataMoverSelect->
iPoolId = htonl(0);
2220 " send command buffer to %s: id: %d, action %d, len %d\n",
2221 cServer, pCommAPI->
iIdent,
2225 pcc = (
char *) pCommServ;
2226 iRC = send(iSockMaster, pcc, (
unsigned)
irawComm, 0);
2232 "-E- %s: sending command buffer (action %d) to %s\n",
2233 cModule, ntohl(pCommServ->
iAction), cServer);
2237 "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
2246 " command buffer (action %d) sent to %s (%d byte)\n",
2253 fprintf(
fLogClient,
"-E- %s: received error status from %s",
2256 printf(
"\n%s" , cMsg);
2267 " header of data mover attr received (%d bytes)\n",
2276 if ( (iRC = recv( iSockMaster, pcc, (
unsigned) iBuf, 0 )) < 0 )
2279 "-E- %s: receiving data part of data mover info\n",
2281 perror(
"-E- receiving data part of data mover info");
2292 "-E- %s: connection to sender broken, %d byte of data part of data mover info (%d byte) received\n",
2293 cModule, ii, iBufl);
2308 ii = (int) ntohl(pDataMoverSelect->
iATLServer);
2312 "-E- %s: invalid ATL server no. %d received\n",
2322 "-W- %s: unexpected ATL server of selected DM: %d, expected %d\n",
2332 printf(
" data part of data mover info received (%d byte)\n",
2334 printf(
" %d data mover selected: %s for ATL server %d\n",
2337 else if ( (iAction == 1) && (iObjInit) ) printf(
2338 "-I- staging file to data mover %s (ATL server %d) ...\n",
2343 if (iDataMoverSelect != 1)
2346 "-W- expected 1 selected data mover, ignore remaining %d\n",
2347 --iDataMoverSelect);
2348 iDataMoverSelect = 1;
2357 if ( ( (iAction == 1) || (iAction == 9) ) &&
2374 pCommServ->
iObjLow = htonl(0);
2405 " delete file on entry server %s:%d\n",
2414 fprintf(
fLogClient,
"-E- %s: delete %s in gStore failed\n",
2423 " %s successfully deleted\n", pcFile);
2431 if ( (iAction == 1) && (iObjInit) && (iStage) )
2435 " connecting to data mover %s:%d\n",
2439 &iMaxConnect, &iSockMover);
2443 "-E- %s: cannot connect to data mover %s:%d (ATL server %d)\n",
2452 "-I- successfully connected to data mover %s:%d (ATL server %d)",
2457 fprintf(
fLogClient,
" after %ds", iMaxConnect);
2458 fprintf(
fLogClient,
" (socket %d)\n", iSockMover);
2465 strcpy(cServer,
"data mover");
2481 else if (iAction == 2)
2503 printf(
" after query: switch gStore action to %d\n",
2506 " send command buffer to %s: id: %d, action %d, data len %d\n",
2507 cServer, pCommAPI->
iIdent,
2515 plFileSizeC = (
unsigned long *) &(pCommServ->
iFileSize);
2517 printf(
" filesize %lu bytes, record size %d",
2519 if (iAction == 1) printf(
2520 ", poolIdRC %d, poolIdWC %d, obj id %d-%d\n",
2524 printf(
", poolIdWC %d\n", ntohl(pCommServ->
iPoolIdWC));
2529 "DDD file staged(1) in FS %d on DM %s in poolId %d\n",
2532 else if (iCache) printf(
2533 "DDD file cached(1) in FS %d on DM %s in poolId %d\n",
2544 pcc = (
char *) pCommServ;
2545 if ( (iRC = send(iSockMover, pcc, (
unsigned)
irawComm, 0 )) < 0 )
2547 fprintf(
fLogClient,
"-E- %s: sending command buffer to %s (rc = %d)\n",
2548 cModule, cServer, iRC);
2559 "-E- %s: incomplete command buffer sent to %s (%d of %d bytes)\n",
2568 " command buffer sent to %s %s (%d byte)\n",
2604 while (iStatusOkay == 0)
2614 fprintf(
fLogClient,
"-E- %s: receiving status buffer from %s",
2629 "-W- %s: write cache currently full (create) ... sleep %d s (%d of %d)\n",
2637 "-W- %s: write cache currently full: archive to tape\n",
2653 "-W- write cache on DM %s full, switch to %s\n",
2657 " close connection to data mover %s (socket %d)\n",
2659 iRC = shutdown(iSockMover, 2);
2661 printf(
" rc shutdown = %d\n", iRC);
2662 iRC = close(iSockMover);
2664 printf(
" rc close = %d\n", iRC);
2669 " connecting to data mover %s:%d\n",
2673 &iMaxConnect, &iSockMover);
2677 "-E- %s: cannot connect to new data mover %s:%d (ATL server %d)\n",
2683 "-I- successfully connected to new data mover %s:%d (ATL server %d)",
2686 fprintf(
fLogClient,
" after %ds", iMaxConnect);
2688 printf(
" (socket %d)\n", iSockMover);
2700 fprintf(
fLogClient,
"-E- %s: message received from %s:\n",
2717 printf(
" status (%d) received from %s (%d bytes",
2718 iStatus, cServer, iRC);
2719 if (iStatusLoop > 1)
2720 printf(
", iter %d)\n", iStatusLoop);
2729 if ( (iSockMaster >= 0) &&
2730 ((iError) || (iAction == 9)) )
2737 "-E- %s: sending status buffer to entry server (EOS)\n", cModule);
2738 else if (iDebug) printf(
2739 " status buffer (EOS) sent to entry server (%d bytes)\n", iRC);
2743 " close connection to entry server (socket %d)\n",
2746 iRC = shutdown(iSockMaster, 2);
2748 printf(
" irc shutdown = %d\n", iRC);
2749 iRC = close(iSockMaster);
2751 printf(
" irc close = %d\n", iRC);
2753 if ( (iFileId >= 0) && (iAction == 9) )
2758 printf(
"-W- free fileId %d: %s\n", iFileId, strerror(errno));
2761 else if (iDebug) printf(
2762 " fileId %d deleted\n", iFileId);
2775 if (iSockMover >= 0)
2783 "-E- %s: sending status buffer (EOS) to %s\n",
2785 else if (iDebug) printf(
2786 " status buffer (EOS) sent to %s (%d bytes)\n",
2791 " close connection to %s (socket %d)\n",
2792 cServer, iSockMover);
2793 iRC = shutdown(iSockMover, 2);
2795 printf(
" rc shutdown = %d\n", iRC);
2796 iRC = close(iSockMover);
2798 printf(
" rc close = %d\n", iRC);
2806 printf(
"-W- free fileId %d: %s\n", iFileId, strerror(errno));
2816 printf(
"-D- end %s\n\n", cModule);
2820 else if (iAction == 9)
2838 char cModule[32] =
"rfio_endfile";
2845 char cServer[16] =
"data mover";
2855 "\n-D- begin %s: close remote file %d\n", cModule, iFileId);
2861 "-E- %s: no remote file available for close\n", cModule);
2869 if (
pAPIFile[ii]->iFileId == iFileId)
2877 fprintf(
fLogClient,
"-E- %s: remote file %d cannot be closed: not found\n",
2883 pCommAPI = &(pcurAPIFile->
sCommAPI);
2895 fprintf(
fLogClient,
"-E- %s: sending status buffer (EOF) to %s\n",
2897 else if (iDebug) printf(
2898 " status buffer (EOF) sent to %s (%d bytes)\n",
2904 fprintf(
fLogClient,
"-E- %s: receiving status buffer\n", cModule);
2911 " status buffer (%d) received (%d byte)\n",
2921 "-W- %s: message received from server:\n", cModule);
2934 if ( (pcurAPIFile->
iOpMode != 2) &&
2937 "-I- gStore file %s%s%s closed\n",
2941 "-I- remote output file %s%s%s closed\n",
2947 " remote file control block %d still active (overall %d)\n",
2954 printf(
"-D- end %s\n\n", cModule);
2971 char cModule[32] =
"rfio_read";
2996 printf(
"\n-D- begin %s: fileId %d\n", cModule, iFileId);
3000 fprintf(
fLogClient,
"-E- %s: no remote file open for read\n", cModule);
3008 if (
pAPIFile[ii]->iFileId == iFileId)
3016 fprintf(
fLogClient,
"-E- %s: remote file %d cannot be read: not opened\n",
3022 printf(
" open buffer %d, fileId %d\n", ii, iFileId);
3025 pCommAPI = &(pcurAPIFile->
sCommAPI);
3034 printf(
" remote file control block %d selected\n", ii);
3035 printf(
" file %d, buffer %d: read %d bytes\n",
3036 iFileId, iBufnoServ, (
int) iItems);
3042 if (iBufsizeRead != iItems)
3043 printf(
" new buffer size %d\n", (
int) iItems);
3044 printf(
" send request for new buffer\n");
3049 iOffset = pcurAPIFile->
iOffset;
3050 iRC =
rawSendRequest(iSockMover, iSeekMode, iOffset, (
signed) iItems);
3053 fprintf(
fLogClient,
"-E- %s: sending request for next data buffer\n",
3059 if (iSeekMode != -1)
3071 pcc = (
char *) &iBufsizeRecv;
3076 if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
3079 "-E- %s: receiving data length from server (buffer %d)",
3080 cModule, iBufnoServ);
3089 "-E- %s: connection to sender broken, %d byte of data length (%d byte) received (buffer %d)\n",
3090 cModule, ii,
iint, iBufnoServ);
3105 iBufsizeRecv = ntohl(iBufsizeRecv);
3107 printf(
"%d_", iBufsizeRecv);
3109 if (iBufsizeRecv < 0)
3113 fprintf(
fLogClient,
"-E- %s: invalid status header received (%d)\n",
3114 cModule, iBufsizeRecv);
3118 printf(
"-W- status header found\n");
3126 if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
3129 "-E- %s: receiving remainder of status header from server (buffer %d)",
3130 cModule, iBufnoServ);
3140 "-W- %s: connection to sender broken, %d byte of remainder of status header (%d byte) received (buffer %d)\n",
3141 cModule, ii, iBufl, iBufnoServ);
3153 pint = (
int *) pcBuffer;
3154 iStatus = ntohl(*pint);
3164 fprintf(
fLogClient,
"-E- %s: unexpected status from server: %d\n",
3172 if (iDebug) printf(
" EOF on input\n");
3176 fprintf(
fLogClient,
"-E- %s: %s%s%s empty\n",
3186 iStatusLen = ntohl(*pint);
3193 "-E- %s: receiving status message from server, rc = %d\n",
3202 "-E- %s: received error status from server:\n",
3209 printf(
"%s\n", pcc);
3215 else if (iBufsizeRecv != iItems)
3220 printf(
" requested %d bytes, received buffer length %d bytes\n", (
int)iItems, iBufsizeRecv);
3222 printf(
"-I- EOF reached\n");
3224 iItems = (size_t) iBufsizeRecv;
3228 iBuf = iBufsizeRecv;
3233 if ( (iRC = recv( iSockMover, pcc, (
unsigned) iBuf, 0 )) < 0 )
3236 "-E- %s: receiving data from server (buffer %d)\n",
3237 cModule, iBufnoServ);
3244 ii = iBufsizeRecv - iBuf;
3246 "-W- %s: connection to sender broken, %d byte of data buffer (%d byte) received (buffer %d)\n",
3247 cModule, ii, iBufsizeRecv, iBufnoServ);
3268 printf(
" buffer %d received\n", pcurAPIFile->
iBufnoServ);
3272 printf(
"-D- end %s\n\n", cModule);
3274 return iBufsizeRecv;
3286 const char *pcBuffer,
3289 char cModule[32] =
"rfio_write";
3308 printf(
"\n-D- begin %s\n", cModule);
3315 "-W- invalid no. of bytes to write: %d\n", (
int) iItems);
3321 fprintf(
fLogClient,
"-E- %s: no remote file open for write\n", cModule);
3330 if (
pAPIFile[ii]->iFileId == iFileId)
3339 "-E- %s: remote file %d cannot be written: not opened\n",
3346 pCommAPI = &(pcurAPIFile->
sCommAPI);
3353 printf(
" remote file control block %d selected\n", ii);
3354 printf(
" file %d, buffer %d: write %d bytes\n",
3355 iFileId, iBufnoServ, (
int) iItems);
3367 printf(
" new buffer size %d\n", (
int) iItems);
3368 printf(
" send new buffer\n");
3376 iBufsizeWrite = htonl( (
int) iItems);
3378 pcc = (
char *) &iBufsizeWrite;
3381 iRC = send( iSockMover, pcc, (
unsigned) iBuf, 0 );
3385 "-E- %s: sending data length to server broken\n", cModule);
3389 "-E- %s: sending data length to server (buffer %d)",
3390 cModule, iBufnoServ);
3401 printf(
"%d(%d)_", iRC, (
int) iItems);
3407 iBuf = (int) iItems;
3408 pcc = (
char *) pcBuffer;
3411 iRC = send( iSockMover, pcc, (
unsigned) iBuf, 0 );
3415 "-E- %s: sending data to server broken\n", cModule);
3419 "-E- %s: sending data to server (buffer %d, %d bytes)",
3420 cModule, iBufnoServ, iBuf);
3442 printf(
" buffer %d sent\n", pcurAPIFile->
iBufnoServ);
3446 printf(
"-D- end %s\n", cModule);
3448 return (ssize_t) iItems;
3462 char cModule[32] =
"rfio_newfile";
3471 int iCopyBuffer = 0;
3476 int iMaxConnect = 0;
3482 int iStatusOkay = 0;
3483 int iStatusLoop = 0;
3485 char *pcc, *pcc1, *pcc2;
3509 printf(
"\n-D- begin %s\n", cModule);
3514 "-E- %s: no open connection to server existing\n", cModule);
3524 if (
pAPIFile[ii]->iFileId == iFileId)
3532 fprintf(
fLogClient,
"-E- %s: no open connection to server\n", cModule);
3538 printf(
" requested API control block %d\n", iFileId);
3541 pCommAPI = &(pcurAPIFile->
sCommAPI);
3545 if (pcurAPIFile->
iAction == 1)
3549 printf(
" connection is open for read\n");
3551 else if (pcurAPIFile->
iAction == 2)
3554 printf(
" connection is open for write\n");
3558 fprintf(
fLogClient,
"-E- %s: connection is open for unexpected action %d\n",
3559 cModule, pcurAPIFile->
iAction);
3565 printf(
" check name parts in %s\n", pcFile);
3567 pcc1 = (
char *) strrchr(pcFile, *
pcDevDelim);
3571 "-E- %s: invalid remote file name %s: node name missing\n",
3577 strcpy(cTemp, pcFile);
3578 pcc = (
char *) strchr(cTemp, *pcObjDelim);
3581 fprintf(
fLogClient,
"-E- %s: invalid remote file name %s\n",
3587 strncpy(pcc,
"\0", 1);
3589 pcc = (
char *) strchr(pcFile, *pcObjDelim);
3590 strcpy(cTemp2, pcc);
3592 if (strncmp(cTemp,
"rfiocopy:", 9) == 0)
3596 printf(
" copy via RFIO server\n");
3598 else if (strncmp(cTemp,
"rfiodaq:", 8) == 0)
3602 printf(
" copy to gStore (DAQPool)\n");
3604 else if (strncmp(cTemp,
"rfio:", 5) == 0)
3609 if (pcurAPIFile->
iAction == 2)
3610 printf(
" copy to gStore (ArchivePool)\n");
3612 printf(
" copy from gStore\n");
3620 if (pcurAPIFile->
iAction == 2)
3621 printf(
" copy to gStore (ArchivePool)\n");
3623 printf(
" copy from gStore\n");
3627 if (pcurAPIFile->
iMassSto != iMassSto)
3630 "-E- %s: remote file %s incompatible with open server connection\n",
3637 " requested server consistent with open connection (%d)\n",
3645 strcpy(pcNamefs, cTemp2);
3649 pcc1 = (
char *) strchr(pcc, *pcObjDelim);
3654 "-E- archive name starting with %s too long, max allowed %d chars\n",
3657 "-E- %s: archive name starting with %s too long, max allowed %d chars\n",
3658 cModule, pcNamefs, ii);
3663 strncpy(pcc1,
"\0", 1);
3664 if (strlen(pCommServ->
cNamefs))
3666 if (strcmp(pCommServ->
cNamefs, pcNamefs))
3669 "-E- %s: invalid archive name %s, expected %s\n",
3670 cModule, pcNamefs, pCommServ->
cNamefs);
3676 strcpy(pCommServ->
cNamefs, pcNamefs);
3677 iArchLen = strlen(pcNamefs);
3680 " archive name: %s (len %d chars)\n", pcNamefs, iArchLen);
3685 "-E- %s: invalid archive name '%s'\n", cModule, pcNamefs);
3690 pcc = (
char *) strchr(cTemp2, *pcObjDelim);
3692 pcc2 = (
char *) strchr(pcc, *pcObjDelim);
3696 "-E- %s: invalid remote file name %s: missing path name\n",
3703 printf(
" path + file name: %s\n", pcc2);
3707 pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
3711 "-E- %s: invalid remote file name %s: missing file name\n",
3717 iPathLen = pcc2-pcc1;
3719 iPathLen = -iPathLen;
3721 printf(
" length path name: %d\n", iPathLen);
3727 printf(
"-E- path name too long, max allowed %d chars\n", ii);
3729 "-E- %s: remote path name (%d chars) too long, max allowed %d\n",
3730 cModule, iPathLen, ii);
3735 strncpy(pcNamehl, pcc2, (
unsigned) iPathLen);
3737 printf(
" path name: %s\n", pcNamehl);
3740 if (strcmp(pcNamehl, pCommAPI->
cNamehl))
3742 strcpy(pcNamehl, pCommAPI->
cNamehl);
3743 printf(
" gStore path name corrected to %s\n", pcNamehl);
3748 strcat(pcFile, pcc1);
3750 " new full file name: %s\n", pcFile);
3753 iFileLen = strlen(pcc1);
3755 printf(
" length file name: %d\n", iFileLen);
3758 if ((
int) strlen(pcc1) > ii)
3761 printf(
"-E- file name too long, max allowed %d chars\n", ii);
3763 "-E- %s: file name %s (%d chars) too long, max allowed %d\n",
3764 cModule, pcc1, iFileLen, ii);
3769 strcpy(pcNamell, pcc1);
3771 printf(
" file name: %s\n", pcNamell);
3776 strcpy(pCommServ->
cNamefs,
"");
3780 pcc1 = (
char *) strrchr(pcc, *pcObjDelim);
3783 fprintf(
fLogClient,
"-E- %s: invalid remote file name %s\n",
3793 "-E- %s: remote file name %s too long (max %d chars)\n",
3799 strcpy(pcNamell, pcc1);
3801 " remote file name on RFIO server: %s\n", pcNamell);
3803 strncpy(pcc1,
"\0", 1);
3808 "-E- %s: remote path name %s too long (max %d chars)\n",
3809 cModule, cTemp2, ii);
3814 strcpy(pcNamehl, cTemp2);
3816 " remote path name on RFIO server: %s\n", pcNamehl);
3820 if (strlen(pCommServ->
cNamehl))
3822 if (strcmp(pCommServ->
cNamehl, pcNamehl))
3824 if (pcurAPIFile->
iAction == 2)
3826 fprintf(
fLogClient,
"-W- new path name %s, previous %s\n",
3827 pcNamehl, pCommServ->
cNamehl);
3833 "-E- %s: remote path name %s not existing)\n",
3844 strcpy(pCommServ->
cNamehl, pcNamehl);
3845 strcpy(pCommAPI->
cNamehl, pcNamehl);
3848 if (strlen(pCommAPI->
cNamefs) < 3)
3851 strcpy(pCommAPI->
cNamell, pcNamell);
3852 strcpy(pCommServ->
cNamell, pcNamell);
3855 strcpy(pCommServ->
cNamehl, pcNamehl);
3856 strcpy(pCommAPI->
cNamehl, pcNamehl);
3860 printf(
" file name: %s\n", pcNamell);
3869 if (pcurAPIFile->
iAction == 2)
3875 " query file %s in ATL server %d (socket %d, action %d)\n",
3879 pBufQuery = &sQuery;
3882 pCommServ, &pBufQuery);
3884 if (pcurAPIFile->
iAction == 2)
3891 "-E- no write access to archive %s in gStore\n",
3894 "-E- no archive %s in gStore found\n",
3897 "-E- file %s: query in gStore failed, rc = %d\n",
3901 "-E- file %s already available in gStore\n",
3906 if ( (iRC == -1001) || (iRC == -1000) )
3915 " file %s not yet available in gStore\n", pcFile);
3926 "-E- file %s not available in gStore\n", pcFile);
3935 " file %s available in gStore\n", pcFile);
3954 "-W- %s: expected ATL server %d, found %d",
3962 if ( (pQAttr->
iFS) && (strlen(pQAttr->
cNode)) )
3965 if ( (ii == 1) || (ii == 2) || (ii == 3) || (ii == 4) || (ii == 5) )
3967 if ( ((ii == 1) || (ii == 2) || (ii == 5)) &&
3975 " file in read cache (poolId %d) on %s in FS %d (ATL server %d)\n",
3981 pCommServ->
iFSidWC = htonl(0);
3982 strcpy(pCommServ->
cNodeWC,
"");
3991 " file in (global) write cache (poolId %d) on %s in FS %d (ATL server %d)\n",
3997 strcpy(pCommServ->
cNodeRC,
"");
4004 "-E- %s: invalid poolId %d found\n", cModule, ii);
4015 strcpy(pCommServ->
cNodeWC,
"");
4016 pCommServ->
iFSidWC = htonl(0);
4019 strcpy(pCommServ->
cNodeRC,
"");
4036 iCopyMode = ntohl(pCopyCacheServ->
iCopyMode);
4039 iCopyLen = ntohl(pCopyCacheServ->
iCopyLen);
4044 pCopyCacheServ->
iCopyLen = htonl(ii);
4046 printf(
" send copy parameters to DM (%d byte)\n", ii);
4049 printf(
" copy parameters already sent to DM\n");
4051 else if ( (iDebug) && (pcurAPIFile->
iAction == 2) )
4052 printf(
" data are written to WC\n");
4056 printf(
" send command buffer to server %s: id: %d, action %d, bufsize %d",
4064 printf(
", copyid %d, data len %d\n",
4065 ntohl(pCopyCacheServ->
iIdent),
4069 printf(
", data len %d\n", pCommAPI->
iCommLen);
4073 pcc = (
char *) pCommServ;
4078 if ( (iRC = send(iSockMover, pcc, (
unsigned)
irawComm, 0 )) < 0 )
4081 "-E- %s: sending command buffer to server %s (rc = %d)\n",
4091 "-E- %s: incomplete command buffer sent to server %s (%d of %d bytes)\n",
4099 " command buffer sent to server %s (%d byte)\n",
4104 pcc = (
char *) pCopyCacheServ;
4105 if ( (iRC = send(iSockMover, pcc, (
unsigned)
irawCopyCache, 0 )) < 0 )
4108 "-E- %s: sending copy buffer to server %s (rc = %d)\n",
4118 "-E- %s: incomplete copy buffer sent to server %s (%d of %d bytes)\n",
4126 " copy buffer sent to server %s (%d byte)\n",
4141 while (iStatusOkay == 0)
4150 "-E- %s: receiving status buffer from server\n",
4160 "-W- %s: write cache currently full ... sleep %d s (%d of %d)\n",
4168 "-W- %s: write cache currently full, archive to tape\n",
4179 goto gNextCmdNewFile;
4187 "-W- write cache on DM %s full or too much load, switch to %s\n",
4191 " close connection to data mover %s (socket %d)\n",
4193 iRC = shutdown(iSockMover, 2);
4195 printf(
" rc shutdown = %d\n", iRC);
4197 iRC = close(iSockMover);
4199 printf(
" rc close = %d\n", iRC);
4202 "-I- connection to data mover %s closed\n",
4208 " connecting to data mover %s:%d\n",
4212 &iMaxConnect, &iSockMover);
4216 "-E- %s: cannot connect to new data mover %s:%d (ATL server %d)\n",
4222 "-I- successfully connected to new data mover %s:%d (ATL server %d)",
4225 fprintf(
fLogClient,
" after %ds", iMaxConnect);
4227 printf(
" (socket %d)\n", iSockMover);
4234 pCopyCacheServ->
iCopyLen = htonl(0);
4236 goto gNextCmdNewFile;
4242 "-E- message received from server(%d):\n", iStatus);
4265 printf(
" status (%d) received from server (%d bytes",
4267 if (iStatusLoop > 1)
4268 printf(
", iter %d)\n", iStatusLoop);
4284 printf(
"-D- end %s, rc=%d\n\n", cModule, iError);
4301 char cModule[32] =
"rfio_close";
4314 "\n-D- begin %s: close remote file %d\n", cModule, iFileId);
4319 "-E- %s: no remote file available for close\n", cModule);
4327 if (
pAPIFile[ii]->iFileId == iFileId)
4335 fprintf(
fLogClient,
"-E- %s: remote file %d cannot be closed: not found\n",
4341 pCommAPI = &(pcurAPIFile->
sCommAPI);
4347 fprintf(
fLogClient,
"-I- gStore file %s%s%s closed\n",
4350 if (iSockMaster >= 0)
4355 "-E- %s: sending status buffer (EOS) to master\n", cModule);
4356 else if (iDebug) printf(
4357 " status buffer (EOS) sent to master (%d bytes)\n", iRC);
4360 " close connection to master (socket %d)\n", iSockMaster);
4361 iRC = shutdown(iSockMaster, 2);
4363 printf(
" rc shutdown = %d\n", iRC);
4364 iRC = close(iSockMaster);
4366 printf(
" rc close = %d\n", iRC);
4371 if (iSockMover >= 0)
4376 "-E- %s: sending status buffer (EOS) to data mover\n", cModule);
4377 else if (iDebug) printf(
4378 " status buffer (EOS) sent to data mover (%d bytes)\n", iRC);
4388 "-E- %s: receiving confirmation of status buffer (EOS)\n",
4390 else if (iDebug) printf(
4391 " status (%d) confirmed by server (%d bytes)\n",
4396 " close connection to data mover (socket %d)\n", iSockMover);
4397 iRC = shutdown(iSockMover, 2);
4399 printf(
" rc shutdown = %d\n", iRC);
4400 iRC = close(iSockMover);
4402 printf(
" rc close = %d\n", iRC);
4404 "-I- connection to data mover %s closed\n",
4416 " remote file control block %d deleted (%d still active)\n",
4418 printf(
"-D- end %s\n\n", cModule);
4425 #ifdef __USE_LARGEFILE64
4437 const struct iovec64 *piov,
4440 char cModule[32] =
"rfio_preseek64";
4445 "\n-D- begin %s: iFileId %d\n", cModule, iFileId);
4451 "-E- 32 bit client: %s not supported\n", cModule);
4457 "-W- %s not yet implemented for gStore\n", cModule);
4460 fprintf(
fLogClient,
"-D- end %s\n\n", cModule);
4474 int64_t rfio_lseek64(
4476 int64_t i64locOffset,
4479 char cModule[32] =
"rfio_lseek64";
4489 "-E- 32 bit client: %s not supported\n", cModule);
4495 "\n-D- begin %s: iFileId %d, Offset %lld, SeekMode %d\n",
4496 cModule, iFileId, (
unsigned long) i64locOffset, ilocSeekMode);
4498 ilocOffset = (int) i64locOffset;
4500 iRC =
rfio_lseek(iFileId, ilocOffset, ilocSeekMode);
4503 "-D- end %s: rc(rfio_lseek) = %d \n\n", cModule, iRC);
4505 return (int64_t) iRC;
4523 char cModule[32] =
"rfio_lseek";
4534 printf(
"\n-D- begin %s: file %d\n", cModule, iFileId);
4535 if (ilocSeekMode == SEEK_SET)
4536 printf(
" position to %d bytes, \n", ilocOffset);
4537 else if (ilocSeekMode == SEEK_CUR)
4538 printf(
" position to current + %d bytes, \n", ilocOffset);
4539 else if (ilocSeekMode == SEEK_END)
4540 printf(
" position to file size + %d bytes, \n", ilocOffset);
4543 fprintf(
fLogClient,
"-E- %s: unexpected offset (%d)\n",
4544 cModule, ilocSeekMode);
4553 if (iSeekMode != -1)
4556 iOffset = pcurAPIFile->
iOffset;
4560 fprintf(
fLogClient,
"-E- %s: sending request for seek\n", cModule);
4566 pcurAPIFile->
iOffset = ilocOffset;
4569 printf(
"-D- end %s\n\n", cModule);
4585 char cModule[32] =
"rfio_ffileid";
4590 printf(
"\n-D- begin %s\n", cModule);
4592 for (iFileId=0; iFileId<
iFileMax; iFileId++)
4594 if (
pAPIFile[iFileId] == fRemoteFile)
4598 printf(
" fileId %d\n", iFileId);
4599 printf(
"-D- end %s\n\n", cModule);
4608 printf(
"-W- no fileId found\n");
4609 printf(
"-D- end %s\n\n", cModule);
4626 char cModule[32] =
"rfio_fopen";
4628 RFILE *fRemoteFile = NULL;
4630 char *pcCopyPath = NULL;
4631 int iCopyFraction = 0;
4633 int iPathConvention = 0;
4636 printf(
"\n-D- begin %s: calling rfio_fopen_gsidaq\n", cModule);
4648 printf(
"-D- end %s\n\n", cModule);
4701 int iPathConvention)
4712 char cModule[32] =
"rfio_fopen_gsidaq_dm";
4720 printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
4722 if (*pcOptions ==
'r')
4725 pcFile, O_RDONLY, 0,
4726 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4729 if (*pcOptions ==
'w')
4732 pcFile, O_WRONLY | O_CREAT, 0,
4733 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4742 " connected with data mover %s\n", pcDataMover);
4746 iDataMover = atoi(pcc);
4747 *piDataMover = iDataMover;
4750 " running number data mover: %d\n", iDataMover);
4754 "-D- end %s: iFileId(rfio_open_gsidaq) = %d\n\n",
4808 int iPathConvention)
4819 char cModule[32] =
"rfio_fopen_gsidaq";
4824 printf(
"\n-D- begin %s: calling rfio_open_gsidaq\n", cModule);
4826 if (*pcOptions ==
'r')
4829 pcFile, O_RDONLY, 0,
4830 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4833 if (*pcOptions ==
'w')
4836 pcFile, O_WRONLY | O_CREAT, 0,
4837 iCopyMode, pcCopyPath, iCopyFraction, iMaxFile,
4842 "-D- end %s: iFileId(rfio_open_gsidaq) = %d\n\n",
4862 char cModule[32] =
"rfio_fnewfile";
4870 printf(
"\n-D- begin %s\n", cModule);
4876 fprintf(
fLogClient,
"-E- %s: still no connection to server opened\n",
4881 if (pRemFile == NULL)
4883 fprintf(
fLogClient,
"-E- %s: invalid file ptr (NULL) specified\n", cModule);
4887 if ( (pcFile == NULL) || (strlen(pcFile) < 5) )
4889 fprintf(
fLogClient,
"-E- %s: invalid file '%s' specified\n",
4904 fprintf(
fLogClient,
"-E- %s: invalid file ptr specified\n", cModule);
4908 iFileId = pRemFile->iFileId;
4912 printf(
"-D- end %s\n\n", cModule);
4933 char cModule[32]=
"rfio_fread";
4940 printf(
"\n-D- begin %s\n", cModule);
4942 if (pRemFile == NULL)
4944 fprintf(
fLogClient,
"-E- %s: remote file not open for read\n", cModule);
4948 iFileId = pRemFile->iFileId;
4949 iBytes = iSize*iItems;
4950 iRC = (int)
rfio_read(iFileId, pcBuffer, iBytes);
4953 printf(
"-D- end %s\n", cModule);
4955 return (
unsigned) iRC;
4971 char cModule[32]=
"rfio_fwrite";
4978 printf(
"\n-D- begin %s\n", cModule);
4980 if (pRemFile == NULL)
4982 fprintf(
fLogClient,
"-E- %s: remote file not open for write\n", cModule);
4986 iFileId = pRemFile->iFileId;
4987 iBytes = iSize*iItems;
4988 iRC = (int)
rfio_write(iFileId, pcBuffer, iBytes);
4991 printf(
"-D- end %s\n", cModule);
4993 return (
unsigned) iRC;
5008 char cModule[32] =
"rfio_fendfile";
5014 printf(
"\n-D- begin %s\n", cModule);
5016 iFileId = pRemFile->iFileId;
5020 printf(
"-D- end %s\n", cModule);
5037 char cModule[32] =
"rfio_fclose";
5043 printf(
"\n-D- begin %s\n", cModule);
5045 iFileId = pRemFile->iFileId;
5049 printf(
"-D- end %s\n", cModule);
5066 char cModule[32] =
"rfio_access";
5073 printf(
"\n-D- begin %s\n", cModule);
5079 printf(
" check if executable - not supported\n");
5087 printf(
" check for existence\n");
5089 iFileId =
rfio_open(pcFile, O_RDONLY, -1);
5095 printf(
"-E- closing remote file %s\n", pcFile);
5099 printf(
"-D- remote file %s closed\n", pcFile);
5107 printf(
" file %s must not be overwritten\n",
5111 else if (iMode == R_OK)
5114 printf(
" file %s is readable\n", pcFile);
5120 printf(
" file %s exists\n", pcFile);
5130 printf(
" file %s may be written\n", pcFile);
5136 printf(
" file %s not existing\n", pcFile);
5146 printf(
" file %s is readable\n", pcFile);
5152 printf(
" file %s may be written\n", pcFile);
5158 printf(
"-D- end %s\n", cModule);
5164 #ifdef __USE_LARGEFILE64
5174 int rfio_fstat64(
int iFileId,
5175 struct stat64 *pStatBuf64)
5177 char cModule[32] =
"rfio_fstat64";
5182 unsigned long *plFileSizeC;
5187 fprintf(
fLogClient,
"\n-D- begin %s: file %d\n", cModule, iFileId);
5198 "-E- 32 bit client: %s not supported\n", cModule);
5208 if (
pAPIFile[ii]->iFileId == iFileId)
5217 fprintf(
fLogClient,
"-E- %s: specified remote fileId %d not found\n",
5220 fprintf(
fLogClient,
"-D- end %s\n\n", cModule);
5226 plFileSizeC = (
unsigned long *) &(pComm->
iFileSize);
5230 fprintf(
fLogClient,
" specified remote fileId %d found:\n", iFileId);
5231 fprintf(
fLogClient,
" object %s%s%s, filesize %lu byte\n",
5236 iRC = fstat64(0, pStatBuf64);
5239 fprintf(
fLogClient,
"-E- %s: fstat64() failed, rc = %d\n", cModule, iRC);
5241 printf(
"-D- end %s\n\n", cModule);
5247 pStatBuf64->st_size = *plFileSizeC;
5250 "-D- end %s: irc(fstat64) = %d\n", cModule, iRC);
5267 struct stat *pStatBuf)
5269 char cModule[32] =
"rfio_fstat";
5278 printf(
"\n-D- begin %s", cModule);
5280 printf(
", %d remote files currently open\n",
iFileCount);
5290 if (
pAPIFile[ii]->iFileId == iFileId)
5299 fprintf(
fLogClient,
"-E- %s: specified remote fileId %d not found\n",
5302 printf(
"-D- end %s\n\n", cModule);
5310 printf(
" specified remote fileId %d found:\n", iFileId);
5311 printf(
" object %s%s%s, filesize %u byte\n",
5319 iRC = fstat(0, pStatBuf);
5322 fprintf(
fLogClient,
"-E- %s: fstat() failed, rc = %d\n", cModule, iRC);
5324 printf(
"-D- end %s\n\n", cModule);
5333 printf(
"-D- end %s\n\n", cModule);
5351 char cModule[32] =
"rfio_parse";
5355 printf(
"\n-D- begin %s\n", cModule);
5358 printf(
"-D- end %s\n", cModule);
5374 char cModule[32] =
"rfio_perror";
5378 printf(
"\n-D- begin %s\n", cModule);
5381 fprintf(stderr,
"%s : No error message\n", pUMsg);
5386 printf(
"-D- end %s\n", cModule);
5402 char cModule[32] =
"rfio_serror";
5406 "\n-D- begin %s: error (len %d byte):\n",
5413 printf(
"-D- end %s\n", cModule);
5431 char cModule[32] =
"rfio_unlink";
5437 char *pcc, *pcc1, *pcc2;
5440 int iSockMaster = -1;
5447 "\n-D- begin %s: delete file %s in gStore\n", cModule, pcFile);
5450 pcc = strstr(pcFile,
"lxgstore");
5454 "-E- %s: for delete action, node name 'lxgstore' missing in '%s'\n",
5466 if ( (strncmp(pcc1,
"del:", 4) == 0) ||
5467 (strncmp(pcc1,
"Del:", 4) == 0) ||
5468 (strncmp(pcc2,
"del:", 4) == 0) ||
5469 (strncmp(pcc2,
"Del:", 4) == 0) )
5471 if (strncmp(pcc1,
"Del:", 4) == 0)
5473 strncpy(pcc1,
"d", 1);
5474 printf(
" delete identifier modified: %s\n", pcFile);
5477 if (strncmp(pcc2,
"Del:", 4) == 0)
5479 strncpy(pcc2,
"d", 1);
5480 printf(
" delete identifier modified: %s\n", pcFile);
5482 else if (iDebug) printf(
5483 " delete identifier '%s' already specified in node name\n",
5486 else if ( (strncmp(pcc1,
":", 1) == 0) ||
5487 (strncmp(pcc2,
":", 1) == 0) )
5491 strcpy(cTemp, pcFile);
5492 pcc1 = strstr(cTemp,
"lxgstore:");
5496 strncpy(pcc1,
"del:", 4);
5504 pcc1 = strstr(cTemp,
"lxgstore");
5511 " client %d (%s)\n", ii, pcFile);
5516 "-E- %s: for delete action, invalid node name in '%s'\n",
5524 strncpy(pcc1,
"del:", 4);
5532 " modified file name '%s'\n", cTemp);
5537 iFileId =
rfio_open(cTemp, O_WRONLY , 0);
5539 iFileId =
rfio_open(pcFile, O_WRONLY , 0);
5543 fprintf(
fLogClient,
"-E- %s: delete gStore file %s failed\n",
5551 "-I- file %s successfully deleted in gStore\n", pcFile);
5557 if (iSockMaster >= 0)
5560 printf(
" close connection to master (socket %d)\n", iSockMaster);
5562 iRC = shutdown(iSockMaster, 2);
5564 printf(
" rc shutdown = %d\n", iRC);
5565 iRC = close(iSockMaster);
5567 printf(
" rc close = %d\n", iRC);
5572 printf(
"-D- end %s\n\n", cModule);
5587 char cModule[32] =
"rfiosetopt";
5591 printf(
"\n-D- begin %s\n", cModule);
5594 printf(
"-D- end %s\n", cModule);
5609 char cModule[32] =
"rfio_mkdir";
5613 printf(
"\n-D- begin %s\n", cModule);
5616 "-W- %s not yet implemented for gStore\n", cModule);
5619 printf(
"-D- end %s\n", cModule);
5634 char cModule[32] =
"rfio_opendir";
5638 printf(
"\n-D- begin %s\n", cModule);
5641 "-W- %s not yet implemented for gStore\n", cModule);
5644 printf(
"-D- end %s\n", cModule);
5659 char cModule[32] =
"rfio_readdir";
5663 printf(
"\n-D- begin %s\n", cModule);
5666 "-W- %s not yet implemented for gStore\n", cModule);
5669 printf(
"-D- end %s\n", cModule);
5684 char cModule[32] =
"rfio_closedir";
5688 printf(
"\n-D- begin %s\n", cModule);
5691 "-W- %s not yet implemented for gStore\n", cModule);
5694 printf(
"-D- end %s\n", cModule);
5700 #ifdef __USE_LARGEFILE64
5710 int rfio_stat64(
const char *pcFile,
struct stat64 *pStatBuf64)
5712 char cModule[32] =
"rfio_stat64";
5724 unsigned long *plFileSizeC;
5727 fprintf(
fLogClient,
"\n-D- begin %s: file %s\n", cModule, pcFile);
5733 "-E- 32 bit client: %s not supported\n", cModule);
5746 strcpy(cObject, pComm->
cNamefs);
5747 strcat(cObject, pComm->
cNamehl);
5748 strcat(cObject, pComm->
cNamell);
5751 " %d: %s already open\n", ii, cObject);
5753 pcc = strstr(pcFile, cObject);
5758 fprintf(
fLogClient,
" %d: %s maps\n", ii, cObject);
5763 " %d: no (more) open file found\n", ii);
5771 " remote file %s not yet open\n", pcFile);
5773 iFileId =
rfio_open( (
char *) pcFile, O_RDONLY, -1);
5775 "-E- %s: open for remote file %s failed\n", cModule, pcFile);
5781 "-E- %s: invalid handle (%d) for remote file %s found\n",
5782 cModule, iFileId, pcFile);
5789 plFileSizeC = (
unsigned long *) &(pComm->
iFileSize);
5793 fprintf(
fLogClient,
" remote fileId %d:\n", iFileId);
5794 fprintf(
fLogClient,
" object %s%s%s, filesize %lu byte\n",
5800 pStatBuf64->st_size = *plFileSizeC;
5809 fprintf(
fLogClient,
"-D- end %s\n\n", cModule);
5827 char cModule[32] =
"rfio_stat";
5840 printf(
"\n-D- begin %s\n", cModule);
5850 strcpy(cObject, pComm->
cNamefs);
5851 strcat(cObject, pComm->
cNamehl);
5852 strcat(cObject, pComm->
cNamell);
5855 printf(
" %d: %s already open\n", ii, cObject);
5857 pcc = strstr(pcFile, cObject);
5862 printf(
" %d: %s maps\n", ii, cObject);
5867 printf(
" %d: no (more) open file found\n", ii);
5875 " remote file %s not yet open\n", pcFile);
5877 iFileId =
rfio_open( (
char *) pcFile, O_RDONLY, -1);
5879 "-E- %s: open for remote file %s failed\n", cModule, pcFile);
5885 "-E- %s: invalid handle (%d) for remote file %s found\n",
5886 cModule, iFileId, pcFile);
5895 printf(
" remote fileId %d:\n", iFileId);
5896 printf(
" object %s%s%s, filesize %u byte\n",
5910 printf(
"-D- end %s\n\n", cModule);
5936 char cModule[32] =
"rfio_cache_stat";
5951 printf(
"\n-D- begin %s: %d files open\n", cModule,
iFileCount);
5952 printf(
" get cache status of file %s\n", pcFile);
5963 strcpy(cObject, pComm->
cNamefs);
5964 strcat(cObject, pComm->
cNamehl);
5965 strcat(cObject, pComm->
cNamell);
5968 printf(
" %d: %s already open\n", ii, cObject);
5970 pcc = strstr(pcFile, cObject);
5975 printf(
" %d: %s maps\n", ii, cObject);
5980 printf(
" %d: no (more) open file found\n", ii);
5988 " remote file %s not yet open\n", pcFile);
5990 iFileId =
rfio_open( (
char *) pcFile, O_RDONLY, -1);
5994 "-E- remote file %s not in gStore or unavailable\n",
6002 " remote file %s successfully opened for query and closed\n", pcFile);
6010 "-E- %s: invalid handle (%d) for remote file %s found\n",
6011 cModule, iFileId, pcFile);
6031 printf(
" remote fileId %d:\n", iFileId);
6032 printf(
" object %s%s%s, size %u byte, cache status %d\n",
6036 printf(
" read cache FS %d\n", pComm->
iStageFSid);
6038 printf(
" write cache FS %d\n", pComm->
iFSidWC);
6049 printf(
"-D- end %s\n\n", cModule);
6067 char cModule[32] =
"rfio_gsi_query";
6076 printf(
"\n-D- begin %s\n", cModule);
6080 printf(
"-E- %s: no remote file available\n", cModule);
6089 if (
pAPIFile[ii]->iFileId == iFileId)
6097 printf(
"-E- %s: remote file %d not found\n", cModule, iFileId);
6107 printf(
" %s\n", pInfo);
6108 if (iRC != iOut) printf(
6109 " (used %d byte, avail %d byte)\n", iRC, iOut);
6114 printf(
"-D- end %s\n\n", cModule);
int rawQueryString(srawObjAttr *pQAttr, int ipMode, int iOut, char *pcOut)
static char cNamefs[MAX_OBJ_FS]
static char cNamehl[MAX_OBJ_HL]
RFILE * rfio_fopen(char *pcFile, char *pcOptions)
int rfio_open(const char *pcFile, int iFlags, int iOpenMode)
int rfio_mkdir(const char *path, int mode)
ssize_t rfio_write(int iFileId, const char *pcBuffer, size_t iItems)
ssize_t rfio_read(int iFileId, char *pcBuffer, size_t iItems)
int rfio_unlink(const char *pcFile)
void rfio_perror(const char *pUMsg)
size_t rfio_fwrite(const char *pcBuffer, size_t iSize, size_t iItems, RFILE *pRemFile)
int rfio_newfile(int iFileId, char *pcFile)
int rfio_parse(char *pcFile, char **pcNode, char **pcPath)
int rfio_access(const char *pcFile, int iMode)
static char cNodePrefix[MAX_NODE]
static char cNodeMaster[MAX_NODE]
int rfio_lseek(int iFileId, int ilocOffset, int ilocSeekMode)
int rfio_fclose(RFILE *pRemFile)
static int iStatusLoopMax
RFILE * rfio_fopen_gsidaq_dm(char *pcFile, char *pcOptions, char *pcDataMover, int *piDataMover, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
int rfiosetopt(int iopt, int *pival, int ilen)
int rfio_stat(const char *pcFile, struct stat *pStatBuf)
char * rawGetFSpName(char *)
int rfio_fstat(int iFileId, struct stat *pStatBuf)
RFILE * rfio_fopen_gsidaq(char *pcFile, char *pcOptions, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
static RFILE * pAPIFile[10]
int rfio_open_gsidaq(const char *pcFile, int iFlags, int iOpenMode, int iCopyMode, char *pcCopyPath, int iCopyFraction, int iMaxFile, int iPathConvention)
static char cNodeMover[MAX_NODE]
int rfio_closedir(void *dirp)
static int irawFileSystem
int rfio_fendfile(RFILE *pRemFile)
int rfio_gsi_query(int iFileId, int iFull, int iOut, char *pInfo)
int rfio_fnewfile(RFILE *pRemFile, char *pcFile)
size_t rfio_fread(char *pcBuffer, size_t iSize, size_t iItems, RFILE *pRemFile)
int rfio_endfile(int iFileId)
static char rfio_errmsg[STATUS_LEN]
int rfio_cache_stat(const char *pcFile)
int rfio_ffileid(RFILE *fRemoteFile)
static char cPrefix[MAX_FULL_FILE]
int rfio_close(int iFileId)
static int iSleepCacheFull
void * rfio_readdir(void *dirp)
static char cLogClient[MAX_LOG_FILE]
void * rfio_opendir(const char *dirpath)
#define GSI_CACHE_INCOMPLETE
#define GSI_MEDIA_INCOMPLETE
#define DSM_MAX_OWNER_LENGTH
static char cApplType[MAX_APPLTYPE]
#define ATLSERVER_ARCHIVE
static char cDataFSHigh2[16]
#define PORT_MOVER_DATAFS
static char cDataFSHigh1[16]
#define MAXLOOP_CACHE_FULL
static char cNodeMaster0[MAX_NODE]
static const char * pcDevDelim
static const char * pcPerc
static const char * pcStar
int rawRecvHeadC(int, char *, int, int, char *)
int rawGetLLName(char *, const char *, char *)
int rconnect(char *, int, int *, int *)
int rawDelFile(int, srawComm *)
int rawRecvStatus(int, srawStatus *)
int rawSendStatus(int, int, char *)
int rawRecvError(int, int, char *)
int rawSendRequest(int, int, int, int)
char * rawGetHLName(char *)
int rawQueryFile(int, int, srawComm *, void **)
char cNodeMaster[MAX_NODE]
char cNodeMover[MAX_NODE]
srawCopyCache sCopyCacheServ
char cDataFS[MAX_FULL_FILE]
char cApplType[MAX_APPLTYPE]
char cNodeCacheMgr[MAX_NODE]
char cCopyPath[MAX_FULL_FILE]
srawDataMoverAttr sDataMoverAttr