00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "hdf5MS.h"
00021 #include "objMetaOpr.h"
00022 #include "dataObjOpr.h"
00023 #include "miscServerFunct.h"
00024 #include "rsGlobalExtern.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 int
00061 msiH5File_open (msParam_t *inpH5FileParam, msParam_t *inpFlagParam,
00062 msParam_t *outH5FileParam, ruleExecInfo_t *rei)
00063 {
00064 rsComm_t *rsComm;
00065 H5File *inf = 0;
00066 H5File *outf;
00067 int inpFlag;
00068 int l1descInx;
00069 dataObjInp_t dataObjInp;
00070 openedDataObjInp_t dataObjCloseInp;
00071 dataObjInfo_t *dataObjInfo, *tmpDataObjInfo;
00072 int remoteFlag;
00073 rodsServerHost_t *rodsServerHost;
00074 int fid;
00075
00076 RE_TEST_MACRO (" Calling msiH5File_open")
00077
00078 if (rei == NULL || rei->rsComm == NULL) {
00079 rodsLog (LOG_ERROR,
00080 "msiH5File_open: input rei or rsComm is NULL");
00081 return (SYS_INTERNAL_NULL_INPUT_ERR);
00082 }
00083
00084 rsComm = rei->rsComm;
00085
00086 if (inpH5FileParam == NULL || inpFlagParam == NULL ||
00087 outH5FileParam == NULL) {
00088 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00089 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00090 "msiH5File_open: NULL input/output Param");
00091 return (rei->status);
00092 }
00093
00094 if (strcmp (inpH5FileParam->type, h5File_MS_T) == 0) {
00095 inf = (H5File*)inpH5FileParam->inOutStruct;
00096 } else {
00097 rei->status = USER_PARAM_TYPE_ERR;
00098 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00099 "msiH5File_open: inpH5FileParam must be h5File_MS_T");
00100 return (rei->status);
00101 }
00102
00103 if( NULL == inf ) {
00104 rodsLog( LOG_ERROR, "msiH5File_open :: null inOutStruct for file param" );
00105 return rei->status;
00106 }
00107
00108 inpFlag = parseMspForPosInt (inpFlagParam);
00109 if (inpFlag < 0) {
00110 inpFlag = 0;
00111 }
00112
00113
00114
00115
00116 memset (&dataObjInp, 0, sizeof (dataObjInp));
00117 rstrcpy (dataObjInp.objPath, inf->filename, MAX_NAME_LEN);
00118 dataObjInp.openFlags = O_RDONLY;
00119 addKeyVal (&dataObjInp.condInput, NO_OPEN_FLAG_KW, "");
00120 rei->status = l1descInx =
00121 _rsDataObjOpen (rsComm, &dataObjInp);
00122
00123 if (rei->status < 0) {
00124 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00125 "msiH5File_open: _rsDataObjOpen of %s error",
00126 dataObjInp.objPath);
00127 return (rei->status);
00128 }
00129
00130 dataObjCloseInp.l1descInx = l1descInx;
00131 dataObjInfo = L1desc[l1descInx].dataObjInfo;
00132
00133 if ((inpFlag & LOCAL_H5_OPEN) != 0) {
00134
00135 tmpDataObjInfo = dataObjInfo;
00136 while (tmpDataObjInfo != NULL) {
00137 remoteFlag = resolveHostByDataObjInfo (tmpDataObjInfo,
00138 &rodsServerHost);
00139 if (remoteFlag == LOCAL_HOST) {
00140 requeDataObjInfoByReplNum (&dataObjInfo,
00141 tmpDataObjInfo->replNum);
00142
00143 L1desc[l1descInx].dataObjInfo = dataObjInfo;
00144 break;
00145 }
00146 }
00147 if (remoteFlag != LOCAL_HOST) {
00148
00149 rei->status = SYS_COPY_NOT_EXIST_IN_RESC;
00150 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00151 "msiH5File_open: _local copy of %s does not exist",
00152 dataObjInp.objPath);
00153 rsDataObjClose (rsComm, &dataObjCloseInp);
00154 return (rei->status);
00155 }
00156 } else {
00157 remoteFlag = resolveHostByDataObjInfo (dataObjInfo,
00158 &rodsServerHost);
00159 }
00160
00161 if (remoteFlag == LOCAL_HOST) {
00162 outf = (H5File*)malloc (sizeof (H5File));
00163
00164 if (inf->filename != NULL) {
00165 free (inf->filename);
00166 }
00167 inf->filename = strdup (dataObjInfo->filePath);
00168 fid = H5File_open(inf, outf);
00169 } else {
00170
00171 if ((rei->status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00172 rsDataObjClose (rsComm, &dataObjCloseInp);
00173 return rei->status;
00174 }
00175
00176 outf = NULL;
00177 fid = _clH5File_open (rodsServerHost->conn, inf, &outf, LOCAL_H5_OPEN);
00178 }
00179
00180 if (fid >= 0) {
00181 L1desc[l1descInx].l3descInx = outf->fid;
00182 } else {
00183 rei->status = fid;
00184 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00185 "msiH5File_open: H5File_open %s error",
00186 dataObjInp.objPath);
00187 rsDataObjClose (rsComm, &dataObjCloseInp);
00188 return rei->status;
00189 }
00190
00191
00192
00193 #if 0
00194 outf->fid = l1descInx;
00195 #endif
00196 fillMsParam (outH5FileParam, NULL, h5File_MS_T, outf, NULL);
00197
00198 if (inf) H5File_dtor(inf);
00199
00200 return (rei->status);
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 int
00236 msiH5File_close (msParam_t *inpH5FileParam, msParam_t *outH5FileParam,
00237 ruleExecInfo_t *rei)
00238 {
00239 rsComm_t *rsComm;
00240 H5File *inf = 0;
00241 H5File *outf;
00242 openedDataObjInp_t dataObjCloseInp;
00243 dataObjInfo_t *dataObjInfo;
00244 int remoteFlag;
00245 rodsServerHost_t *rodsServerHost;
00246 int l1descInx;
00247
00248 RE_TEST_MACRO (" Calling msiH5File_close")
00249
00250 if (rei == NULL || rei->rsComm == NULL) {
00251 rodsLog (LOG_ERROR,
00252 "msiH5File_close: input rei or rsComm is NULL");
00253 return (SYS_INTERNAL_NULL_INPUT_ERR);
00254 }
00255
00256 rsComm = rei->rsComm;
00257
00258 if (inpH5FileParam == NULL || outH5FileParam == NULL) {
00259 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00260 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00261 "msiH5File_close: NULL input/output Param");
00262 return (rei->status);
00263 }
00264
00265 if (strcmp (inpH5FileParam->type, h5File_MS_T) == 0) {
00266 inf = (H5File*)inpH5FileParam->inOutStruct;
00267 } else {
00268 rei->status = USER_PARAM_TYPE_ERR;
00269 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00270 "msiH5File_close: wrong inpH5FileParam type %s",
00271 inpH5FileParam->type);
00272 return (rei->status);
00273 }
00274
00275 if( NULL == inf ) {
00276 rodsLog( LOG_ERROR, "msiH5File_close :: null inOutStruct for file param" );
00277 return rei->status;
00278 }
00279
00280 l1descInx = getL1descInxByFid (inf->fid);
00281 if (l1descInx < 0) {
00282 rei->status = SYS_BAD_FILE_DESCRIPTOR;
00283 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00284 "msiH5File_close: bad fid %d", inf->fid);
00285 return (rei->status);
00286 }
00287
00288 dataObjCloseInp.l1descInx = l1descInx;
00289 dataObjInfo = L1desc[l1descInx].dataObjInfo;
00290
00291 remoteFlag = resolveHostByDataObjInfo (dataObjInfo,
00292 &rodsServerHost);
00293
00294 if (remoteFlag == LOCAL_HOST) {
00295 outf = (H5File*)malloc (sizeof (H5File));
00296
00297 inf->fid = L1desc[l1descInx].l3descInx;
00298 rei->status = H5File_close (inf, outf);
00299 } else {
00300
00301 if ((rei->status = svrToSvrConnect (rsComm, rodsServerHost)) >= 0) {
00302 rei->status = _clH5File_close (rodsServerHost->conn, inf, &outf);
00303 }
00304 }
00305
00306 if (rei->status < 0) {
00307 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00308 "msiH5File_close: H5File_close error for %d", l1descInx);
00309 }
00310
00311 L1desc[l1descInx].l3descInx = 0;
00312 rsDataObjClose (rsComm, &dataObjCloseInp);
00313
00314
00315
00316 fillMsParam (outH5FileParam, NULL, h5File_MS_T, outf, NULL);
00317
00318 if (inf) H5File_dtor(inf);
00319
00320 return rei->status;
00321 }
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 int
00357 msiH5Dataset_read (msParam_t *inpH5DatasetParam, msParam_t *outH5DatasetParam,
00358 ruleExecInfo_t *rei)
00359 {
00360 rsComm_t *rsComm;
00361 H5Dataset *ind;
00362 H5Dataset *outd;
00363 int l1descInx;
00364 dataObjInfo_t *dataObjInfo;
00365 int remoteFlag;
00366 rodsServerHost_t *rodsServerHost;
00367
00368 RE_TEST_MACRO (" Calling msiH5Dataset_read")
00369
00370 if (rei == NULL || rei->rsComm == NULL) {
00371 rodsLog (LOG_ERROR,
00372 "msiH5Dataset_read: input rei or rsComm is NULL");
00373 return (SYS_INTERNAL_NULL_INPUT_ERR);
00374 }
00375
00376 rsComm = rei->rsComm;
00377
00378 if (inpH5DatasetParam == NULL || outH5DatasetParam == NULL) {
00379 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00380 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00381 "msiH5Dataset_read: NULL input/output Param");
00382 return (rei->status);
00383 }
00384
00385 if (strcmp (inpH5DatasetParam->type, h5Dataset_MS_T) == 0) {
00386 ind = (H5Dataset*)inpH5DatasetParam->inOutStruct;
00387 } else {
00388 rei->status = USER_PARAM_TYPE_ERR;
00389 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00390 "msiH5Dataset_read: wrong inpH5DatasetParam type %s",
00391 inpH5DatasetParam->type);
00392 return (rei->status);
00393 }
00394
00395 if( NULL == ind ) {
00396 rodsLog( LOG_ERROR, "msiH5File_read :: null inOutStruct for file param" );
00397 return rei->status;
00398 }
00399
00400 l1descInx = getL1descInxByFid (ind->fid);
00401 if (l1descInx < 0) {
00402 rei->status = SYS_BAD_FILE_DESCRIPTOR;
00403 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00404 "msiH5Dataset_read: bad fid %d", ind->fid);
00405 return (rei->status);
00406 }
00407
00408 dataObjInfo = L1desc[l1descInx].dataObjInfo;
00409
00410 remoteFlag = resolveHostByDataObjInfo (dataObjInfo,
00411 &rodsServerHost);
00412
00413 if (remoteFlag == LOCAL_HOST) {
00414 outd = (H5Dataset*)malloc (sizeof (H5Dataset));
00415 #if 0
00416
00417 ind->fid = L1desc[l1descInx].l3descInx;
00418 #endif
00419 rei->status = H5Dataset_read (ind, outd);
00420 } else {
00421
00422 outd = NULL;
00423 if ((rei->status = svrToSvrConnect (rsComm, rodsServerHost)) >= 0) {
00424 rei->status = _clH5Dataset_read (rodsServerHost->conn, ind, &outd);
00425 }
00426 }
00427
00428
00429
00430 fillMsParam (outH5DatasetParam, NULL, h5Dataset_MS_T, outd, NULL);
00431
00432 if (ind) H5Dataset_dtor(ind);
00433
00434 return rei->status;
00435 }
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469 int
00470 msiH5Dataset_read_attribute (msParam_t *inpH5DatasetParam, msParam_t *outH5DatasetParam, ruleExecInfo_t *rei)
00471 {
00472 rsComm_t *rsComm;
00473 H5Dataset *ind;
00474 H5Dataset *outd;
00475 int l1descInx;
00476 dataObjInfo_t *dataObjInfo;
00477 int remoteFlag;
00478 rodsServerHost_t *rodsServerHost;
00479
00480 RE_TEST_MACRO (" Calling msiH5Dataset_read_attribute")
00481
00482 if (rei == NULL || rei->rsComm == NULL) {
00483 rodsLog (LOG_ERROR,
00484 "msiH5Dataset_read_attribute: input rei or rsComm is NULL");
00485 return (SYS_INTERNAL_NULL_INPUT_ERR);
00486 }
00487
00488 rsComm = rei->rsComm;
00489
00490 if (inpH5DatasetParam == NULL || outH5DatasetParam == NULL) {
00491 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00492 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00493 "msiH5Dataset_read_attribute: NULL input/output Param");
00494 return (rei->status);
00495 }
00496
00497 if (strcmp (inpH5DatasetParam->type, h5Dataset_MS_T) == 0) {
00498 ind = (H5Dataset*)inpH5DatasetParam->inOutStruct;
00499 } else {
00500 rei->status = USER_PARAM_TYPE_ERR;
00501 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00502 "msiH5Dataset_read_attribute: wrong inpH5DatasetParam type %s",
00503 inpH5DatasetParam->type);
00504 return (rei->status);
00505 }
00506
00507 if( NULL == ind ) {
00508 rodsLog( LOG_ERROR, "msiH5File_read_attribute :: null inOutStruct for file param" );
00509 return rei->status;
00510 }
00511
00512 l1descInx = getL1descInxByFid (ind->fid);
00513 if (l1descInx < 0) {
00514 rei->status = SYS_BAD_FILE_DESCRIPTOR;
00515 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00516 "msiH5Dataset_read_attribute: bad fid %d", ind->fid);
00517 return (rei->status);
00518 }
00519
00520 dataObjInfo = L1desc[l1descInx].dataObjInfo;
00521
00522 remoteFlag = resolveHostByDataObjInfo (dataObjInfo,
00523 &rodsServerHost);
00524
00525 if (remoteFlag == LOCAL_HOST) {
00526 outd = (H5Dataset*)malloc (sizeof (H5Dataset));
00527 #if 0
00528
00529 ind->fid = L1desc[l1descInx].l3descInx;
00530 #endif
00531 rei->status = H5Dataset_read_attribute (ind, outd);
00532 } else {
00533
00534 outd = NULL;
00535 if ((rei->status = svrToSvrConnect (rsComm, rodsServerHost)) >= 0) {
00536 rei->status = _clH5Dataset_read_attribute (rodsServerHost->conn,
00537 ind, &outd);
00538 }
00539 }
00540
00541
00542
00543 fillMsParam (outH5DatasetParam, NULL, h5Dataset_MS_T, outd, NULL);
00544
00545 if (ind) H5Dataset_dtor(ind);
00546
00547 return rei->status;
00548 }
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582 int
00583 msiH5Group_read_attribute (msParam_t *inpH5GroupParam,
00584 msParam_t *outH5GroupParam, ruleExecInfo_t *rei)
00585 {
00586 rsComm_t *rsComm;
00587 H5Group *ing;
00588 H5Group *outg;
00589 int l1descInx;
00590 dataObjInfo_t *dataObjInfo;
00591 int remoteFlag;
00592 rodsServerHost_t *rodsServerHost;
00593
00594 RE_TEST_MACRO (" Calling msiH5Group_read_attribute")
00595
00596 if (rei == NULL || rei->rsComm == NULL) {
00597 rodsLog (LOG_ERROR,
00598 "msiH5Group_read_attribute: input rei or rsComm is NULL");
00599 return (SYS_INTERNAL_NULL_INPUT_ERR);
00600 }
00601
00602 rsComm = rei->rsComm;
00603
00604 if (inpH5GroupParam == NULL || outH5GroupParam == NULL) {
00605 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00606 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00607 "msiH5Group_read_attribute: NULL input/output Param");
00608 return (rei->status);
00609 }
00610
00611 #if 0
00612 if (strcmp (inpH5GroupParam->type, h5Dataset_MS_T) == 0) {
00613 #endif
00614 if (strcmp (inpH5GroupParam->type, h5Group_MS_T) == 0) {
00615 ing = (H5Group*)inpH5GroupParam->inOutStruct;
00616 } else {
00617 rei->status = USER_PARAM_TYPE_ERR;
00618 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00619 "msiH5Group_read_attribute: wrong inpH5GroupParam type %s",
00620 inpH5GroupParam->type);
00621 return (rei->status);
00622 }
00623
00624 if( NULL == ing ) {
00625 rodsLog( LOG_ERROR, "msiH5File_read_attribute :: null inOutStruct for file param" );
00626 return rei->status;
00627 }
00628
00629 l1descInx = getL1descInxByFid (ing->fid);
00630 if (l1descInx < 0) {
00631 rei->status = SYS_BAD_FILE_DESCRIPTOR;
00632 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00633 "msiH5Group_read_attribute: bad fid %d", ing->fid);
00634 return (rei->status);
00635 }
00636
00637
00638 dataObjInfo = L1desc[l1descInx].dataObjInfo;
00639
00640 remoteFlag = resolveHostByDataObjInfo (dataObjInfo,
00641 &rodsServerHost);
00642
00643 if (remoteFlag == LOCAL_HOST) {
00644 outg = (H5Group*)malloc (sizeof (H5Group));
00645 #if 0
00646
00647 ing->fid = L1desc[l1descInx].l3descInx;
00648 #endif
00649 rei->status = H5Group_read_attribute (ing, outg);
00650 } else {
00651
00652 outg = NULL;
00653 if ((rei->status = svrToSvrConnect (rsComm, rodsServerHost)) >= 0) {
00654 rei->status = _clH5Group_read_attribute (rodsServerHost->conn,
00655 ing, &outg);
00656 }
00657 }
00658
00659
00660
00661 fillMsParam (outH5GroupParam, NULL, h5Group_MS_T, outg, NULL);
00662
00663 if (ing) H5Group_dtor(ing);
00664
00665 return rei->status;
00666 }
00667
00668 int
00669 getL1descInxByFid (int fid)
00670 {
00671 int i;
00672
00673 for (i = 3; i < NUM_L1_DESC; i++) {
00674 if (L1desc[i].inuseFlag == 1 && L1desc[i].l3descInx == fid) return i;
00675 }
00676
00677 return (-1);
00678 }
00679