NetworkTable Class Reference

#include <Network.h>

Collaboration diagram for NetworkTable:

Collaboration graph
[legend]

Public Member Functions

 ~NetworkTable ()
DbRetVal initialize ()
void destroy ()
DbRetVal readNetworkConfig ()
NetworkClientgetNetworkClient ()
DbRetVal connect ()
DbRetVal disconnect ()
DbRetVal connectIfNotConnected ()

Detailed Description

Definition at line 102 of file Network.h.


Constructor & Destructor Documentation

NetworkTable::~NetworkTable (  ) 

Definition at line 31 of file NetworkTable.cxx.

00032 {
00033     //TODO::
00034 }


Member Function Documentation

DbRetVal NetworkTable::connect (  ) 

Definition at line 74 of file NetworkTable.cxx.

References NetworkClient::connect(), ErrOS, NetworkClient::getNetworkID(), OK, printError, and NetworkClient::setConnectFlag().

00075 {
00076     DbRetVal rv = nwClient->connect();
00077     if (rv != OK) {
00078         printError(ErrOS, "Unable to connect to peer %d\n", nwClient->getNetworkID());
00079         nwClient->setConnectFlag(false);
00080     }
00081     return rv;
00082 }

Here is the call graph for this function:

DbRetVal NetworkTable::connectIfNotConnected (  ) 

Definition at line 83 of file NetworkTable.cxx.

References NetworkClient::connect(), ErrAlready, NetworkClient::isConnected(), and OK.

Referenced by SqlLogConnection::connectIfNotConnected().

00084 {
00085    DbRetVal rv = OK;
00086    if (!nwClient->isConnected()) rv = nwClient->connect(); else rv =ErrAlready;
00087    return rv;
00088 }

Here is the call graph for this function:

Here is the caller graph for this function:

void NetworkTable::destroy (  )  [inline]

Definition at line 108 of file Network.h.

00108 {}

DbRetVal NetworkTable::disconnect (  ) 

Definition at line 90 of file NetworkTable.cxx.

References NetworkClient::disconnect(), NetworkClient::isConnected(), and OK.

00091 {
00092     if (nwClient->isConnected()) {
00093         nwClient->disconnect();
00094     }
00095     return OK;
00096 }

Here is the call graph for this function:

NetworkClient* NetworkTable::getNetworkClient (  )  [inline]

Definition at line 110 of file Network.h.

Referenced by SqlLogConnection::sendAndReceive().

00110 { return nwClient; }

Here is the caller graph for this function:

DbRetVal NetworkTable::initialize (  ) 

Definition at line 23 of file NetworkTable.cxx.

References Conf::config, OK, and readNetworkConfig().

00024 {
00025     DbRetVal rv = OK;
00026     if (!Conf::config.useReplication() && !Conf::config.useCache()) return OK;
00027     rv = readNetworkConfig();
00028     return rv;
00029     
00030 }

Here is the call graph for this function:

DbRetVal NetworkTable::readNetworkConfig (  ) 

Definition at line 35 of file NetworkTable.cxx.

References Conf::config, NetworkFactory::createClient(), DM_Network, ErrNotYet, ErrSysInit, fp, IDENTIFIER_LENGTH, OK, printDebug, printError, NetworkClient::setCacheClient(), NetworkClient::setHost(), and TCP.

Referenced by initialize().

00036 {
00037     FILE *fp;
00038     int nwid;
00039     char hostname[IDENTIFIER_LENGTH];
00040     int port;
00041     fp = fopen(Conf::config.getReplConfigFile(),"r");
00042     if( fp == NULL ) {
00043         printError(ErrSysInit, "Invalid path/filename for NETWORK_CONFIG_FILE.\n");
00044         return ErrSysInit;
00045     }
00046     int count = 0;
00047     while(!feof(fp)) {
00048        if (count >=1) 
00049        {
00050            fclose(fp);
00051            printError(ErrNotYet, "Only 2 hosts are allowed in this version"); 
00052            return ErrNotYet;
00053        }
00054        printDebug(DM_Network, "Count is %d\n", count);
00055        fscanf(fp, "%d:%d:%s\n", &nwid, &port, hostname);
00056        printDebug(DM_Network, "%d:%d:%s\n", nwid, port, hostname);
00057        NetworkClient* nClient;
00058        if (nwid == Conf::config.getNetworkID()) continue;
00059 
00060        nClient = NetworkFactory::createClient(TCP);
00061 
00062        printDebug(DM_Network, "nwid %d getCacheNetworkID %d\n", nwid,  Conf::config.getCacheNetworkID());
00063        if (nwid == Conf::config.getCacheNetworkID()) nClient->setCacheClient();
00064        nClient->setHost(hostname, port, nwid);
00065        nwClient = nClient;
00066        count++;
00067     }
00068     fclose(fp);
00069     return OK;
00070 }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:49:00 2008 for csql by  doxygen 1.4.7