X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fmain%2Fdatabase%2Fwrapper%2Fnode%2Fclass_NodeDistributedHashTableDatabaseWrapper.php;h=1d7bc252ba3e49f339ddb8a2933b170cdf748c06;hb=4a4fbfb80267fd344b37cef2b173f666ecb44646;hp=b9ea83a50407413b03b5f40e7e7537aa5c6cb3c6;hpb=2e00f351966a192c4b65e2dc64c4dad17e59a36c;p=hub.git diff --git a/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php index b9ea83a50..1d7bc252b 100644 --- a/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -25,6 +25,10 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem // Constants for database table names const DB_TABLE_NODE_DHT = 'node_dht'; + // Constants for database column names + const DB_COLUMN_SESSION_ID = 'session_id'; + const DB_COLUMN_IP_PORT = 'ip_port'; + /** * Protected constructor * @@ -50,6 +54,52 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem // Return the instance return $wrapperInstance; } + + /** + * Checks whether the local (*this*) node is registered in the DHT by + * checking if the external ip/port is found. + * + * @return $isRegistered Whether *this* node is registered in the DHT + */ + public function isLocalNodeRegistered () { + // Get node instance + $nodeInstance = Registry::getRegistry()->getInstance('node'); + + // Get a dataset instance + $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); + + // Add ip:port as criteria + $searchInstance->addCriteria(self::DB_COLUMN_IP_PORT, $nodeInstance->getAddressPort()); + $searchInstance->setLimit(1); + + // Query database and get a result instance back + $resultInstance = $this->doSelectByCriteria($searchInstance); + + // Is there an entry? + $isRegistered = $resultInstance->next(); + + // Return result + return $isRegistered; + } + + /** + * Updates local (*this*) node data in DHT, this is but not limited to the + * session id, ip number (and/or hostname) and port number. + * + * @return void + */ + public function updateLocalNode () { + $this->partialStub('Not implemented yet.'); + } + + /** + * Registeres the local (*this*) node with its data in the DHT. + * + * @return void + */ + public function registerLocalNode () { + $this->partialStub('Not implemented yet.'); + } } // [EOF]