00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "rsIcatOpr.h"
00010 #include "initServer.h"
00011 #include "rsGlobalExtern.h"
00012 #include "readServerConfig.h"
00013 #include "icatHighLevelRoutines.h"
00014
00015 #ifdef RODS_CAT
00016 int
00017 connectRcat (rsComm_t *rsComm)
00018 {
00019 int status = 0;
00020 rodsServerHost_t *tmpRodsServerHost;
00021 int gotRcatHost = 0;
00022 rodsServerConfig_t serverConfig;
00023
00024 if (IcatConnState == INITIAL_DONE) {
00025 return (0);
00026 }
00027
00028
00029 tmpRodsServerHost = ServerHostHead;
00030
00031 while (tmpRodsServerHost != NULL) {
00032 if (tmpRodsServerHost->rcatEnabled == LOCAL_ICAT ||
00033 tmpRodsServerHost->rcatEnabled == LOCAL_SLAVE_ICAT) {
00034 if (tmpRodsServerHost->localFlag == LOCAL_HOST) {
00035 memset(&serverConfig, 0, sizeof(serverConfig));
00036 status = readServerConfig(&serverConfig);
00037 status = chlOpen (serverConfig.DBUsername,
00038 serverConfig.DBPassword);
00039 memset(&serverConfig, 0, sizeof(serverConfig));
00040 if (status < 0) {
00041 rodsLog (LOG_NOTICE,
00042 "connectRcat: chlOpen Error. Status = %d", status);
00043 } else {
00044 IcatConnState = INITIAL_DONE;
00045 gotRcatHost ++;
00046 }
00047 } else {
00048 gotRcatHost ++;
00049 }
00050 }
00051 tmpRodsServerHost = tmpRodsServerHost->next;
00052 }
00053
00054 if (gotRcatHost == 0) {
00055 if (status >= 0) {
00056 status = SYS_NO_ICAT_SERVER_ERR;
00057 }
00058 rodsLog (LOG_SYS_FATAL,
00059 "initServerInfo: no rcatHost error, status = %d",
00060 status);
00061 } else {
00062 status = 0;
00063 }
00064
00065 return (status);
00066 }
00067
00068 int
00069 disconnectRcat (rsComm_t *rsComm)
00070 {
00071 int status;
00072
00073 if (IcatConnState == INITIAL_DONE) {
00074 if ((status = chlClose ()) != 0) {
00075 rodsLog (LOG_NOTICE,
00076 "initInfoWithRcat: chlClose Error. Status = %d",
00077 status);
00078 }
00079 IcatConnState = INITIAL_NOT_DONE;
00080 } else {
00081 status = 0;
00082 }
00083 return (status);
00084 }
00085
00086 int
00087 resetRcat (rsComm_t *rsComm)
00088 {
00089 IcatConnState = INITIAL_NOT_DONE;
00090 return 0;
00091 }
00092
00093 #endif