]> git.mxchange.org Git - hub.git/commitdiff
Clear redundant database wrapper class as it is now done in DHT
authorRoland Häder <roland@mxchange.org>
Thu, 31 Jan 2013 15:44:05 +0000 (15:44 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 31 Jan 2013 15:44:05 +0000 (15:44 +0000)
application/hub/config.php
application/hub/main/database/wrapper/node/class_NodeListDatabaseWrapper.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php
application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php
application/hub/main/handler/message-types/class_BaseMessageHandler.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/tools/class_HubTools.php

index 9e0d418055bac626485d73bfc7fe3ea213ffc992..47f92d0a2b843976e8c45a6a094fd5a5727194eb 100644 (file)
@@ -48,9 +48,6 @@ $cfg->setConfigEntry('debug_class', 'DebugConsoleOutput');
 // CFG: NODE-INFO-DB-WRAPPER-CLASS
 $cfg->setConfigEntry('node_info_db_wrapper_class', 'NodeInformationDatabaseWrapper');
 
-// CFG: NODE-LIST-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('node_list_db_wrapper_class', 'NodeListDatabaseWrapper');
-
 // CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
 $cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper');
 
index 8b55018a1c6174e7af61a37cbd29842c24a8d695..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,218 +1,3 @@
 <?php
-/**
- * A database wrapper for node list
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeListDatabaseWrapper extends BaseDatabaseWrapper implements NodeListWrapper, Registerable {
-       // Table names
-       const DB_TABLE_NODE_LIST = 'node_list';
-
-       // Table columns
-       const DB_COLUMN_ANSWER_STATUS = 'last_answer_status';
-       const DB_COLUMN_MESSAGE_TYPE  = 'last_message_type';
-
-       // Other constants
-       const INVALID_IP_PORT = 'invalid:invalid';
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this database wrapper by a provided user class
-        *
-        * @return      $wrapperInstance        An instance of the created wrapper class
-        */
-       public static final function createNodeListDatabaseWrapper () {
-               // Get a new instance
-               $wrapperInstance = new NodeListDatabaseWrapper();
-
-               // Set (primary!) table name
-               $wrapperInstance->setTableName(self::DB_TABLE_NODE_LIST);
-
-               // Return the instance
-               return $wrapperInstance;
-       }
-
-       /**
-        * Resolves a session id into an ip:port combination
-        *
-        * @param       $sessionId      A valid session id
-        * @param       $protocol       Name of the protocol (TCP/UDP)
-        * @return      $recipient      Recipient as ip:port combination
-        */
-       public function resolveIpPortBySessionId ($sessionId, $protocol) {
-               // Set invalid ip:port combination
-               $recipient = self::INVALID_IP_PORT;
-
-               // Now get a search criteria instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for the node session id
-               $searchInstance->addCriteria('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID, $sessionId);
-               $searchInstance->setLimit(1);
-
-               // Get a result back
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Is it valid?
-               if ($resultInstance->next()) {
-                       // Save the result instance in this class
-                       $this->setResultInstance($resultInstance);
-
-                       // Get the node id from result and set it
-                       $recipientIp   = $this->getField('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP);
-
-                       // Which protocol?
-                       switch ($protocol) {
-                               case NetworkPackage::PROTOCOL_TCP: // Transmission Control Protocol has been used
-                                       $recipientPort = $this->getField('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT);
-                                       break;
-
-                               case NetworkPackage::PROTOCOL_UDP: // User Datagram Protocol has been used
-                                       $recipientPort = $this->getField('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT);
-                                       break;
-
-                               default: // Unsupported protocol detected!
-                                       $this->debugBackTrace('Unsupported protocol ' . $protocol . ' specified!');
-                                       break;
-                       } // END - switch
-
-                       // Now put both together
-                       $recipient = $recipientIp . ':' . $recipientPort;
-
-                       // Debug message
-                       self::createDebugInstance(__CLASS__)->debugOutput('DATABASE-WRAPPER: sessionId[' . $protocol . ']=' . $sessionId . ' resolved as recipient=' . $recipient);
-               } // END - if
-
-               // Return result
-               return $recipient;
-       }
-
-       /**
-        * Resolves a ip:port combination into a session id
-        *
-        * @param       $ipPort         Ip:port combination
-        * @param       $protocol       Name of the used protocol (TCP/UDP)
-        * @return      $sessionId      A valid session id
-        */
-       public function resolveSessionIdByIpPort ($ipPort, $protocol) {
-               // Set invalid session id as default
-               $sessionId = 'invalid';
-
-               // Split ip:port
-               $ipPortArray = explode(':', $ipPort);
-
-               // Now get a search criteria instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for the node session id
-               $searchInstance->addCriteria('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_IP, $ipPortArray[0]);
-
-               // Which protocol?
-               switch ($protocol) {
-                       case NetworkPackage::PROTOCOL_TCP: // Transmission Control Procol has been used
-                               $searchInstance->addCriteria('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT, $ipPortArray[1]);
-                               break;
-
-                       case NetworkPackage::PROTOCOL_UDP: // User Datagram Protocol has been used
-                               $searchInstance->addCriteria('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT, $ipPortArray[1]);
-                               break;
-
-                       default: // Unsupported protocol detected!
-                               $this->debugBackTrace('Unsupported protocol ' . $protocol . ' specified!');
-                               break;
-               } // END - switch
-
-               // Only one record
-               $searchInstance->setLimit(1);
-
-               // Get a result back
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Is it valid?
-               if ($resultInstance->next()) {
-                       // Save the result instance in this class
-                       $this->setResultInstance($resultInstance);
-
-                       // Get the session from result
-                       $sessionId = $this->getField('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID);
-               } // END - if
-
-               // Return result
-               return $sessionId;
-       }
-
-       /**
-        * Registeres a node by given message data.
-        *
-        * @param       $messageData            An array of all message data
-        * @param       $handlerInstance        An instance of a HandleableMessage class
-        * @return      void
-        */
-       public function registerNodeByMessageData (array $messageData, Handleable $handlerInstance) {
-               // Get a data set instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_LIST));
-
-               // Set primary key (session id)
-               $dataSetInstance->setUniqueKey('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID);
-
-               // Add all array elements
-               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Run the "INSERT" query
-               $this->queryInsertDataSet($dataSetInstance);
-       }
-
-       /**
-        * Updates an existing entry in node list
-        *
-        * @param       $messageData            An array of all message data
-        * @param       $handlerInstance        An instance of a HandleableMessage class
-        * @param       $searchInstance         An instance of LocalSearchCriteria class
-        * @return      void
-        */
-       public function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance) {
-               // Get a data set instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_LIST));
-
-               // Add search instance
-               $dataSetInstance->setSearchInstance($searchInstance);
-
-               // Set primary key (session id)
-               $dataSetInstance->setUniqueKey('node_' . XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID);
-
-               // Add all array elements
-               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Run the "UPDATE" query
-               $this->queryUpdateDataSet($dataSetInstance);
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
index 05dbf779a2b610d255e9922e017e5a70d462a3f7..e0f708e4fa2d8743e2af3b73c4ea5a6d5c5ed66a 100644 (file)
@@ -56,6 +56,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
         * @return      void
         * @throws      NodeSessionIdVerficationException       If the provided session id is not matching
         * @todo        Do some more here: Handle karma, et cetera?
+        * @todo        Rewrite this to use DHT
         */
        public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
                // Get a database wrapper instance
index a4b198ae57f9d453c01d5a43cd6324e947cfc562..e3c81adaad3d8d1ae22b599acae44c3cccbd6600 100644 (file)
@@ -50,11 +50,14 @@ abstract class BaseAnserStatusHandler extends BaseDataHandler {
         * @param       $dataSetInstance        An instance of a StoreableCriteria class
         * @param       $messageData            An array with all message data
         * @return      void
+        * @todo        Rewrite this to use DHT
         */
        public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
                // Add some generic data all messageData arrays provide
+               /*
                $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]);
                $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]);
+               */
        }
 }
 
index 0d4fd9b88e5326d88bc30bd593757bb628b7f1a1..c3f7757890a9cd568fdb851597fa6a0e2aa9c5d5 100644 (file)
@@ -56,6 +56,7 @@ class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements
         * @return      void
         * @throws      NodeSessionIdVerficationException       If the provided session id is not matching
         * @todo        Do some more here: Handle karma, et cetera?
+        * @todo        Rewrite this to use DHT
         */
        public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
                // Get a database wrapper instance
index 7770d236b39bd613c4163a46d8341ed3d28622c3..864c3d37fd6a3aca98476efd1eb4d50ff28741f4 100644 (file)
@@ -63,7 +63,7 @@ abstract class BaseMessageHandler extends BaseDataHandler {
         *
         * @param       $messageArray   An array with all minimum message data
         * @return      void
-        * @todo        Add something more, e.g. spreading information over DHT
+        * @todo        Rewrite this to use DHT
         */
        protected function registerNodeByMessageData (array $messageData) {
                // Check if searchData has entries
index f207147bfc2d76ee5403cc8df6abf30d0eef4715..3795850cabc5b05742845c7f832023d928e0919a 100644 (file)
@@ -656,36 +656,12 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
         * Restores a previously stored node list from database
         *
         * @return      void
+        * @todo        Rewrite this to use DHT instead
         */
        public function bootstrapRestoreNodeList () {
                // Debug output
                self::createDebugInstance(__CLASS__)->debugOutput('HUB: Restore node list: START');
 
-               // Get a wrapper instance
-               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_list_db_wrapper_class');
-
-               // Now get a search criteria instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for the node number zero which is hard-coded the default
-               // @TODO Add some criteria, e.g. if the node is active or so
-               //$searchInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
-               //$searchInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
-               //$searchInstance->setLimit(1);
-
-               // Get a result back
-               $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
-
-               // Is it valid?
-               if ($resultInstance->next()) {
-                       $this->partialStub('Do something for restoring the list.');
-                       // Output message
-                       //self::createDebugInstance(__CLASS__)->debugOutput('HUB: ');
-               } else {
-                       // No previously saved node list found!
-                       self::createDebugInstance(__CLASS__)->debugOutput('HUB: No previously saved node list found. This is fine.');
-               }
-
                // Debug output
                self::createDebugInstance(__CLASS__)->debugOutput('HUB: Restore node list: FINISHED.');
        }
index 0d8b4f0d9ce5c9e4ed3a56ba274143def0e7d2dd..f0d1baf55ffacc0d2f857e6f91a340585fd397ca 100644 (file)
@@ -85,6 +85,7 @@ class HubTools extends BaseHubSystem {
         * @param       $sessionId      A valid session id
         * @param       $protocol       Name of the used protocol: TCP/UDP
         * @return      $recipient      Recipient as ip:port combination
+        * @todo        Rewrite this to use DHT
         */
        protected function resolveIpPortBySessionId ($sessionId, $protocol) {
                // Get a wrapper instance
@@ -115,6 +116,7 @@ class HubTools extends BaseHubSystem {
         * @param       $ipPort         Ip:port combination
         * @param       $protocol       Name of used protocol (TCP/UDP)
         * @return      $sessionId      Valid session id
+        * @todo        Rewrite this to use DHT
         */
        public static function resolveSessionIdByIpPort ($ipPort, $protocol) {
                // Get a wrapper instance