]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 00:54:27 +0000 (01:54 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 01:14:55 +0000 (02:14 +0100)
- renamed "Wrapper" to "Frontend" (was pending anyway)
- added missing trait for above instance
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
35 files changed:
application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php [new file with mode: 0644]
application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php [deleted file]
application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseFrontend.php [new file with mode: 0644]
application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php [deleted file]
application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php [deleted file]
application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php [deleted file]
application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php [new file with mode: 0644]
application/hub/classes/database/frontend/node_information/class_NodeInformationDatabaseFrontend.php [new file with mode: 0644]
application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php [new file with mode: 0644]
application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php [deleted file]
application/hub/classes/dht/class_BaseDht.php
application/hub/classes/dht/node/class_NodeDhtFacade.php
application/hub/classes/factories/states/peer/class_PeerStateFactory.php
application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php
application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php
application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php
application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/locator/class_UniversalNodeLocator.php
application/hub/classes/nodes/class_BaseHubNode.php
application/hub/classes/producer/cruncher/work_units/cruncher/class_CruncherTestUnitProducer.php
application/hub/classes/recipient/dht/class_DhtRecipient.php
application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php
application/hub/classes/tools/hub/class_HubTools.php
application/hub/config.php
application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php
application/hub/exceptions/wrapper/class_NodeDataMissingException.php
application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php [deleted file]
application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php [deleted file]
application/hub/interfaces/database/frontend/class_UnitDatabaseWrapper.php [deleted file]
application/hub/interfaces/database/frontend/node_dht/class_NodeDhtFrontend.php [new file with mode: 0644]
application/hub/interfaces/database/frontend/node_information/class_NodeInformationFrontend.php [new file with mode: 0644]
application/hub/interfaces/database/frontend/work_unit/class_UnitDatabaseFrontend.php [new file with mode: 0644]
application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php
core

diff --git a/application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php b/application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php
new file mode 100644 (file)
index 0000000..ef72ac2
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
+use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
+use Org\Shipsimu\Hub\Generic\HubInterface;
+use Org\Shipsimu\Hub\Node\Node;
+use Org\Shipsimu\Hub\Pool\Poolable;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseFrontend;
+use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+
+/**
+ * A general hub database frontend
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2011 - 2014 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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/>.
+ */
+abstract class BaseHubDatabaseFrontend extends BaseDatabaseFrontend implements HubInterface {
+       /**
+        * Listener instance
+        */
+       private $listenerInstance = NULL;
+
+       /**
+        * Listener pool instance
+        */
+       private $listenerPoolInstance = NULL;
+
+       /**
+        * A StorableSocket instance
+        */
+       private $socketInstance = NULL;
+
+       /**
+        * Node instance
+        */
+       private $nodeInstance = NULL;
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct (string $className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Checks whether start/end marker are set
+        *
+        * @param       $data   Data to be checked
+        * @return      $isset  Whether start/end marker are set
+        */
+       public final function ifStartEndMarkersSet ($data) {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-DATABASE-WRAPPER: data()=%d - CALLED!', strlen($data)));
+
+               // Determine it
+               $isset = ((substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER) && (substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER));
+
+               // ... and return it
+               return $isset;
+       }
+
+       /**
+        * Setter for listener pool instance
+        *
+        * @param       $listenerPoolInstance   The new listener pool instance
+        * @return      void
+        */
+       protected final function setListenerPoolInstance (Poolable $listenerPoolInstance) {
+               $this->listenerPoolInstance = $listenerPoolInstance;
+       }
+
+       /**
+        * Getter for listener pool instance
+        *
+        * @return      $listenerPoolInstance   Our current listener pool instance
+        */
+       public final function getListenerPoolInstance () {
+               return $this->listenerPoolInstance;
+       }
+
+       /**
+        * Setter for socket instance
+        *
+        * @param       $socketInstance A StorableSocket instance
+        * @return      void
+        */
+       public final function setSocketInstance (StorableSocket $socketInstance) {
+               $this->socketInstance = $socketInstance;
+       }
+
+       /**
+        * Getter for socket instance
+        *
+        * @return      $socketInstance An instance of a StorableSocket class
+        */
+       public final function getSocketInstance () {
+               return $this->socketInstance;
+       }
+
+       /**
+        * Setter for node id
+        *
+        * @param       $nodeId         The new node id
+        * @return      void
+        */
+       protected final function setNodeId ($nodeId) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for node id
+        *
+        * @return      $nodeId         Current node id
+        */
+       public final function getNodeId () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for private key
+        *
+        * @param       $privateKey             The new private key
+        * @return      void
+        */
+       protected final function setPrivateKey ($privateKey) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for private key
+        *
+        * @return      $privateKey             Current private key
+        */
+       public final function getPrivateKey () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for private key hash
+        *
+        * @param       $privateKeyHash         The new private key hash
+        * @return      void
+        */
+       protected final function setNodePrivateKeyHash ($privateKeyHash) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $privateKeyHash         Current private key hash
+        */
+       public final function getNodePrivateKeyHash () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for session id
+        *
+        * @return      $sessionId      Current session id
+        */
+       public final function getSessionId () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for listener instance
+        *
+        * @param       $listenerInstance       A Listenable instance
+        * @return      void
+        */
+       public final function setListenerInstance (Listenable $listenerInstance) {
+               $this->listenerInstance = $listenerInstance;
+       }
+
+       /**
+        * Getter for listener instance
+        *
+        * @return      $listenerInstance       A Listenable instance
+        */
+       public final function getListenerInstance () {
+               return $this->listenerInstance;
+       }
+
+       /**
+        * Setter for node instance
+        *
+        * @param       $nodeInstance   A Node instance
+        * @return      void
+        */
+       public final function setNodeInstance (Node $nodeInstance) {
+               $this->nodeInstance = $nodeInstance;
+       }
+
+       /**
+        * Getter for node instance
+        *
+        * @return      $nodeInstance   A Node instance
+        */
+       public function getNodeInstance () {
+               return $this->nodeInstance;
+       }
+
+}
diff --git a/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php b/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php
deleted file mode 100644 (file)
index 67373b6..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
-use Org\Shipsimu\Hub\Generic\HubInterface;
-use Org\Shipsimu\Hub\Node\Node;
-use Org\Shipsimu\Hub\Pool\Poolable;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\BaseDatabaseWrapper;
-use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
-
-/**
- * A general hub database wrapper
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2011 - 2014 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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/>.
- */
-abstract class BaseHubDatabaseWrapper extends BaseDatabaseWrapper implements HubInterface {
-       /**
-        * Listener instance
-        */
-       private $listenerInstance = NULL;
-
-       /**
-        * Listener pool instance
-        */
-       private $listenerPoolInstance = NULL;
-
-       /**
-        * A StorableSocket instance
-        */
-       private $socketInstance = NULL;
-
-       /**
-        * Node instance
-        */
-       private $nodeInstance = NULL;
-
-       /**
-        * Protected constructor
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected function __construct (string $className) {
-               // Call parent constructor
-               parent::__construct($className);
-       }
-
-       /**
-        * Checks whether start/end marker are set
-        *
-        * @param       $data   Data to be checked
-        * @return      $isset  Whether start/end marker are set
-        */
-       public final function ifStartEndMarkersSet ($data) {
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-DATABASE-WRAPPER: data()=%d - CALLED!', strlen($data)));
-
-               // Determine it
-               $isset = ((substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER) && (substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER));
-
-               // ... and return it
-               return $isset;
-       }
-
-       /**
-        * Setter for listener pool instance
-        *
-        * @param       $listenerPoolInstance   The new listener pool instance
-        * @return      void
-        */
-       protected final function setListenerPoolInstance (Poolable $listenerPoolInstance) {
-               $this->listenerPoolInstance = $listenerPoolInstance;
-       }
-
-       /**
-        * Getter for listener pool instance
-        *
-        * @return      $listenerPoolInstance   Our current listener pool instance
-        */
-       public final function getListenerPoolInstance () {
-               return $this->listenerPoolInstance;
-       }
-
-       /**
-        * Setter for socket instance
-        *
-        * @param       $socketInstance A StorableSocket instance
-        * @return      void
-        */
-       public final function setSocketInstance (StorableSocket $socketInstance) {
-               $this->socketInstance = $socketInstance;
-       }
-
-       /**
-        * Getter for socket instance
-        *
-        * @return      $socketInstance An instance of a StorableSocket class
-        */
-       public final function getSocketInstance () {
-               return $this->socketInstance;
-       }
-
-       /**
-        * Setter for node id
-        *
-        * @param       $nodeId         The new node id
-        * @return      void
-        */
-       protected final function setNodeId ($nodeId) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Getter for node id
-        *
-        * @return      $nodeId         Current node id
-        */
-       public final function getNodeId () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Setter for private key
-        *
-        * @param       $privateKey             The new private key
-        * @return      void
-        */
-       protected final function setPrivateKey ($privateKey) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Getter for private key
-        *
-        * @return      $privateKey             Current private key
-        */
-       public final function getPrivateKey () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Setter for private key hash
-        *
-        * @param       $privateKeyHash         The new private key hash
-        * @return      void
-        */
-       protected final function setNodePrivateKeyHash ($privateKeyHash) {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Getter for private key hash
-        *
-        * @return      $privateKeyHash         Current private key hash
-        */
-       public final function getNodePrivateKeyHash () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Getter for session id
-        *
-        * @return      $sessionId      Current session id
-        */
-       public final function getSessionId () {
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Setter for listener instance
-        *
-        * @param       $listenerInstance       A Listenable instance
-        * @return      void
-        */
-       public final function setListenerInstance (Listenable $listenerInstance) {
-               $this->listenerInstance = $listenerInstance;
-       }
-
-       /**
-        * Getter for listener instance
-        *
-        * @return      $listenerInstance       A Listenable instance
-        */
-       public final function getListenerInstance () {
-               return $this->listenerInstance;
-       }
-
-       /**
-        * Setter for node instance
-        *
-        * @param       $nodeInstance   A Node instance
-        * @return      void
-        */
-       public final function setNodeInstance (Node $nodeInstance) {
-               $this->nodeInstance = $nodeInstance;
-       }
-
-       /**
-        * Getter for node instance
-        *
-        * @return      $nodeInstance   A Node instance
-        */
-       public function getNodeInstance () {
-               return $this->nodeInstance;
-       }
-
-}
diff --git a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseFrontend.php b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseFrontend.php
new file mode 100644 (file)
index 0000000..7e94017
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Cruncher\Unit;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseFrontend;
+use Org\Shipsimu\Hub\Database\Frontend\Unit\UnitDatabaseFrontend;
+use Org\Shipsimu\Hub\Producer\Cruncher\Unit\BaseUnitProducer;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+/**
+ * A database frontend for cruncher work/test units
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2011 - 2014 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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 CruncherUnitDatabaseFrontend extends BaseHubDatabaseFrontend implements UnitDatabaseFrontend, Registerable {
+       // Constants for database table names
+       const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units';
+
+       // Constants for database column names
+       const DB_COLUMN_UNIT_TYPE   = 'unit_type';
+       const DB_COLUMN_UNIT_STATUS = 'unit_status';
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this database frontend by a provided user class
+        *
+        * @return      $frontendInstance       An instance of the created frontend class
+        */
+       public static final function createCruncherUnitDatabaseFrontend () {
+               // Get a new instance
+               $frontendInstance = new CruncherUnitDatabaseFrontend();
+
+               // Set (primary!) table name
+               $frontendInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS);
+
+               // Return the instance
+               return $frontendInstance;
+       }
+
+       /**
+        * Checks whether a test unit has been produced
+        *
+        * @return      $isProduced             Whether a test unit has already been produced
+        */
+       public function isTestUnitProduced () {
+               // Now get a search instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add criteria for looking up already created and available test units
+               $searchInstance->addCriteria(self::DB_COLUMN_UNIT_TYPE  , BaseUnitProducer::UNIT_TYPE_TEST_UNIT);
+               $searchInstance->addCriteria(self::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE);
+               $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count');
+
+               // Search for our units
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Do we have some entries?
+               $isProduced = $resultInstance->next();
+
+               // Return it
+               return $isProduced;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php
deleted file mode 100644 (file)
index fcffd06..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Cruncher\Unit;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseWrapper;
-use Org\Shipsimu\Hub\Database\Frontend\Unit\UnitDatabaseWrapper;
-use Org\Shipsimu\Hub\Producer\Cruncher\Unit\BaseUnitProducer;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-
-/**
- * A database wrapper for cruncher work/test units
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2011 - 2014 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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 CruncherUnitDatabaseWrapper extends BaseHubDatabaseWrapper implements UnitDatabaseWrapper, Registerable {
-       // Constants for database table names
-       const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units';
-
-       // Constants for database column names
-       const DB_COLUMN_UNIT_TYPE   = 'unit_type';
-       const DB_COLUMN_UNIT_STATUS = 'unit_status';
-
-       /**
-        * 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 createCruncherUnitDatabaseWrapper () {
-               // Get a new instance
-               $wrapperInstance = new CruncherUnitDatabaseWrapper();
-
-               // Set (primary!) table name
-               $wrapperInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS);
-
-               // Return the instance
-               return $wrapperInstance;
-       }
-
-       /**
-        * Checks whether a test unit has been produced
-        *
-        * @return      $isProduced             Whether a test unit has already been produced
-        */
-       public function isTestUnitProduced () {
-               // Now get a search instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Add criteria for looking up already created and available test units
-               $searchInstance->addCriteria(self::DB_COLUMN_UNIT_TYPE  , BaseUnitProducer::UNIT_TYPE_TEST_UNIT);
-               $searchInstance->addCriteria(self::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE);
-               $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count');
-
-               // Search for our units
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Do we have some entries?
-               $isProduced = $resultInstance->next();
-
-               // Return it
-               return $isProduced;
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php
deleted file mode 100644 (file)
index 3537861..0000000
+++ /dev/null
@@ -1,720 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseWrapper;
-use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
-use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
-use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
-use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-use Org\Shipsimu\Hub\Node\BaseHubNode;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
-
-// Import SPL stuff
-use \InvalidArgumentException;
-
-/**
- * A database wrapper for distributed hash tables
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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 NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeDhtWrapper, Registerable {
-       /**
-        * "Cached" results for dabase for looking for unpublished entries
-        */
-       private $unpublishedEntriesInstance = NULL;
-
-       // Constants for database table names
-       const DB_TABLE_NODE_DHT = 'node_dht';
-
-       // Constants for database column names
-       const DB_COLUMN_NODE_ID            = 'node_id';
-       const DB_COLUMN_SESSION_ID         = 'session_id';
-       const DB_COLUMN_EXTERNAL_ADDRESS   = 'external_address';
-       const DB_COLUMN_PRIVATE_KEY_HASH   = 'private_key_hash';
-       const DB_COLUMN_NODE_MODE          = 'node_mode';
-       const DB_COLUMN_ACCEPTED_OBJECTS   = 'accepted_object_types';
-       const DB_COLUMN_NODE_LIST          = 'node_list';
-       const DB_COLUMN_PUBLICATION_STATUS = 'publication_status';
-       const DB_COLUMN_ANSWER_STATUS      = 'answer_status';
-       const DB_COLUMN_ACCEPT_BOOTSTRAP   = 'accept_bootstrap';
-
-       // Publication status'
-       const PUBLICATION_STATUS_PENDING = 'PENDING';
-
-       // Exception codes
-       const EXCEPTION_NODE_ALREADY_REGISTERED = 0x800;
-       const EXCEPTION_NODE_NOT_REGISTERED     = 0x801;
-
-       /**
-        * 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 createNodeDistributedHashTableDatabaseWrapper () {
-               // Get a new instance
-               $wrapperInstance = new NodeDistributedHashTableDatabaseWrapper();
-
-               // Set (primary!) table name
-               $wrapperInstance->setTableName(self::DB_TABLE_NODE_DHT);
-
-               // Get node instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Creating node instance ...');
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // And set it here
-               $wrapperInstance->setNodeInstance($nodeInstance);
-
-               // Return the instance
-               return $wrapperInstance;
-       }
-
-       /**
-        * Static getter for an array of all DHT database entries
-        *
-        * @return      $elements       All elements for the DHT dabase
-        */
-       public static final function getAllElements () {
-               // Create array and ...
-               $elements = array(
-                       self::DB_COLUMN_NODE_ID,
-                       self::DB_COLUMN_SESSION_ID,
-                       self::DB_COLUMN_EXTERNAL_ADDRESS,
-                       self::DB_COLUMN_PRIVATE_KEY_HASH,
-                       self::DB_COLUMN_NODE_MODE,
-                       self::DB_COLUMN_ACCEPTED_OBJECTS,
-                       self::DB_COLUMN_NODE_LIST
-               );
-
-               // ... return it
-               return $elements;
-       }
-
-       /**
-        * Prepares a search instance for given node data
-        *
-        * @param       $nodeData                       An array with valid node data
-        * @return      $searchInstance         An instance of a SearchCriteria class
-        */
-       private function prepareSearchInstance (array $nodeData) {
-               // Assert on array elements
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
-
-               // Get instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for node id and limit it to one entry
-               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeData[self::DB_COLUMN_NODE_ID]);
-               $searchInstance->setLimit(1);
-
-               // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-               return $searchInstance;
-       }
-
-       /**
-        * Prepares a "local" instance of a StoreableCriteria class with all node
-        * data for insert/update queries. This data set contains data from *this*
-        * (local) node.
-        *
-        * @return      $dataSetInstance        An instance of a StoreableCriteria class
-        */
-       private function prepareLocalDataSetInstance () {
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Get request instances
-               $requestInstance = FrameworkBootstrap::getRequestInstance();
-
-               // Get a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
-
-               // Set the primary key
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
-
-               // Get Universal Node Locator and "explode" it
-               $locatorInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
-
-               // Get external UNL
-               $externalUnl = $locatorInstance->getExternalUnl();
-
-               // Make sure both is valid
-               // @TODO Bad check on UNL, better use a proper validator
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: externalUnl=' . $externalUnl);
-               assert($externalUnl !== 'invalid');
-
-               // Get an array of all accepted object types
-               $objectList = $this->getNodeInstance()->getListFromAcceptedObjectTypes();
-
-               // Make sure this is an array
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: objectList()=' . count($objectList));
-               assert(is_array($objectList));
-
-               // Add public node data
-               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE       , $requestInstance->getRequestElement('mode'));
-               $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $externalUnl);
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeInstance->nodeId=' . $this->getNodeInstance()->getNodeId());
-               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $this->getNodeInstance()->getNodeId());
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeInstance->sessionId=' . $this->getNodeInstance()->getSessionId());
-               $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $this->getNodeInstance()->getSessionId());
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $this->getNodeInstance()->getNodePrivateKeyHash());
-               $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
-               $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($this->getNodeInstance()->isAcceptingDhtBootstrap()));
-
-               // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: dataSetInstance=' . $dataSetInstance->__toString() . ' - EXIT!');
-               return $dataSetInstance;
-       }
-
-       /**
-        * Getter for result instance for unpublished entries
-        *
-        * @return      $unpublishedEntriesInstance             Result instance
-        */
-       public final function getUnpublishedEntriesInstance () {
-               return $this->unpublishedEntriesInstance;
-       }
-
-       /**
-        * Checks whether the local (*this*) node is registered in the DHT by
-        * checking if the external address is found.
-        *
-        * @return      $isRegistered   Whether *this* node is registered in the DHT
-        */
-       public function isLocalNodeRegistered () {
-               // Get a search criteria instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Get Universal Node Locator and "explode" it
-               $locatorInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
-
-               // Make sure the external address is set and not invalid
-               // @TODO Bad check on UNL, better use a proper validator
-               $externalUnl = $locatorInstance->getExternalUnl();
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: externalUnl=%s', $externalUnl));
-               assert($externalUnl != 'invalid');
-
-               // Add Universal Node Locator/node id as criteria
-               $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $externalUnl);
-               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $this->getNodeInstance()->getNodeId());
-               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $this->getNodeInstance()->getSessionId());
-               $searchInstance->setLimit(1);
-
-               // Query database and get a result instance back
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Cache result of if there is an entry, valid() will tell us if an entry is there
-               $isRegistered = $resultInstance->valid();
-
-               // Return result
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: isRegistered=%d - EXIT!', intval($isRegistered)));
-               return $isRegistered;
-       }
-
-       /**
-        * Registeres the local (*this*) node with its data in the DHT.
-        *
-        * @return      void
-        */
-       public function registerLocalNode () {
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Assert to make sure this method is called with no record in DB (the actual backend of the DHT)
-               assert(!$this->isLocalNodeRegistered());
-
-               // Get prepared data set instance
-               $dataSetInstance = $this->prepareLocalDataSetInstance();
-
-               // "Insert" this dataset instance completely into the database
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling this->queryInsertDataSet(' . $dataSetInstance->__toString() . ') ...');
-               $this->queryInsertDataSet($dataSetInstance);
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-       }
-
-       /**
-        * Updates local (*this*) node's 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 () {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Assert to make sure this method is called with one record in DB (the actual backend of the DHT)
-               assert($this->isLocalNodeRegistered());
-
-               // Get search criteria
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for node id and limit it to one entry
-               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $this->getNodeInstance()->getNodeId());
-               $searchInstance->setLimit(1);
-
-               // Get a prepared dataset instance
-               $dataSetInstance = $this->prepareLocalDataSetInstance();
-
-               // Set search instance
-               $dataSetInstance->setSearchInstance($searchInstance);
-
-               // Update DHT database record
-               $this->queryUpdateDataSet($dataSetInstance);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-       }
-
-       /**
-        * Finds a node locally by given session id
-        *
-        * @param       $sessionId      Session id to lookup
-        * @return      $resultInstance         An instance of a SearchableResult class
-        * @throws      InvalidArgumentException        If parameter $sessionId is not valid
-        */
-       public function findNodeLocalBySessionId ($sessionId) {
-               // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: sessionId=%s - CALLED!', $sessionId));
-               if (empty($sessionId)) {
-                       // Cannot be empty
-                       throw new InvalidArgumentException('Parameter "sessionId" is empty.');
-               }
-
-               // Get search criteria
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for session id and limit it to one entry
-               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID, $sessionId);
-               $searchInstance->setLimit(1);
-
-               // Query database and get a result instance back
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Return result instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: resultInstance->valid()=%d - EXIT!', intval($resultInstance->valid())));
-               return $resultInstance;
-       }
-
-       /**
-        * Finds a node locally by given UNL instance
-        *
-        * @param       $locatorInstance        An instance of a LocateableNode class
-        * @return      $resultInstance         An instance of a SearchableResult class
-        */
-       public function findNodeLocalByLocatorInstance (LocateableNode $locatorInstance) {
-               // Get search criteria
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: locatorInstance=%s - CALLED!', $locatorInstance->__toString()));
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Search for session id and limit it to one entry
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: externalUnl=%s', $locatorInstance->getExternalUnl()));
-               $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $locatorInstance->getExternalUnl());
-               $searchInstance->setLimit(1);
-
-               // Query database and get a result instance back
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Return result instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: resultInstance->valid()=%d - EXIT!', intval($resultInstance->valid())));
-               return $resultInstance;
-       }
-
-       /**
-        * Registeres a node by given message data.
-        *
-        * @param       $messageInstance        An instance of a DeliverableMessage class
-        * @param       $handlerInstance        An instance of a HandleableDataSet class
-        * @return      void
-        */
-       public function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
-
-               // Get a data set instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
-
-               // Set primary key (session id)
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
-
-               // Add all array elements
-               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageInstance);
-
-               // Remove 'node_list'
-               $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST);
-
-               // Run the "INSERT" query
-               $this->queryInsertDataSet($dataSetInstance);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER - EXIT!');
-       }
-
-       /**
-        * Updates an existing entry in node list
-        *
-        * @param       $messageInstance        An instance of a DeliverableMessage class
-        * @param       $handlerInstance        An instance of a HandleableDataSet class
-        * @param       $searchInstance         An instance of LocalSearchCriteria class
-        * @return      void
-        */
-       public function updateNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Get a data set instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
-
-               // Add search instance
-               $dataSetInstance->setSearchInstance($searchInstance);
-
-               // Set primary key (session id)
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
-
-               // Add all array elements
-               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageInstance);
-
-               // Remove 'node_list'
-               $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST);
-
-               // Run the "UPDATE" query
-               $this->queryUpdateDataSet($dataSetInstance);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-       }
-
-       /**
-        * Determines whether the given node data is already inserted in the DHT
-        *
-        * @param       $nodeData               An array with valid node data
-        * @return      $isRegistered   Whether the given node data is already inserted
-        */
-       public function isNodeRegistered (array $nodeData) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Assert on array elements
-               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]);
-
-               // Get search criteria
-               $searchInstance = $this->prepareSearchInstance($nodeData);
-
-               // Query database and get a result instance back
-               $resultInstance = $this->doSelectByCriteria(
-                       // Search instance
-                       $searchInstance,
-                       // Only look for these array elements ("keys")
-                       array(
-                               self::DB_COLUMN_NODE_ID          => TRUE,
-                               self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE
-                       )
-               );
-
-               // Check if there is an entry
-               $isRegistered = $resultInstance->valid();
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!');
-
-               // Return registration status
-               return $isRegistered;
-       }
-
-       /**
-        * Registers a node with given data in the DHT. If the node is already
-        * registered this method shall throw an exception.
-        *
-        * @param       $nodeData       An array with valid node data
-        * @return      void
-        * @throws      NodeAlreadyRegisteredException  If the node is already registered
-        */
-       public function registerNode (array $nodeData) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Assert on array elements
-               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
-
-               // Is the node registered?
-               if ($this->isNodeRegistered($nodeData)) {
-                       // Throw an exception
-                       throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED);
-               } // END - if
-
-               // @TODO Unimplemented part
-               $this->partialStub('nodeData=' . print_r($nodeData, TRUE));
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-       }
-
-       /**
-        * Updates a node's entry in the DHT with given data. This will enrich or
-        * just update already exsiting data. If the node is not found this method
-        * shall throw an exception.
-        *
-        * @param       $nodeData       An array with valid node data
-        * @return      void
-        * @throws      NodeDataMissingException        If the node's data is missing
-        */
-       public function updateNode (array $nodeData) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeData=' . print_r($nodeData, TRUE));
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Assert on array elements
-               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...');
-
-               // Is the node registered?
-               if (!$this->isNodeRegistered($nodeData)) {
-                       // No, then throw an exception
-                       throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED);
-               } // END - if
-
-               // Get a search instance
-               $searchInstance = $this->prepareSearchInstance($nodeData);
-
-               // Get a data set instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
-
-               // Add search instance
-               $dataSetInstance->setSearchInstance($searchInstance);
-
-               // Set primary key (session id)
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
-
-               // Add all array elements
-               $this->getNodeInstance()->addArrayToDataSet($dataSetInstance, $nodeData);
-
-               // Remove 'node_list'
-               $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST);
-
-               // Run the "UPDATE" query
-               $this->queryUpdateDataSet($dataSetInstance);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-       }
-
-       /**
-        * Checks whether there are unpublished entries
-        *
-        * @return      $hasUnpublished         Whether there are unpublished entries
-        * @todo        Add minimum/maximum age limitations
-        */
-       public function hasUnpublishedEntries () {
-               // Get search instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Add exclusion key which is the publish status
-               $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PUBLICATION_STATUS, NodeDistributedHashTableDatabaseWrapper::PUBLICATION_STATUS_PENDING);
-
-               // Remember search instance
-               $this->setSearchInstance($searchInstance);
-
-               // Run the query
-               $this->unpublishedEntriesInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Check pending entries
-               $hasUnpublished = $this->unpublishedEntriesInstance->valid();
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-
-               // Return it
-               return $hasUnpublished;
-       }
-
-       /**
-        * Initializes publication of DHT entries. This does only prepare
-        * publication. The next step is to pickup such prepared entries and publish
-        * them by uploading to other (recently appeared) DHT members.
-        *
-        * @return      void
-        * @todo        Add timestamp to dataset instance
-        */
-       public function initEntryPublication () {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               /*
-                * Make sure that hasUnpublishedEntries() has been called first by
-                * asserting on the "cached" object instance. This "caching" saves some
-                * needless queries as this method shall be called immediately after
-                * hasUnpublishedEntries() returns TRUE.
-                */
-               assert($this->unpublishedEntriesInstance instanceof SearchableResult);
-
-               // Result is still okay?
-               assert($this->unpublishedEntriesInstance->valid());
-
-               // Remove 'publication_status'
-               $this->getSearchInstance()->unsetCriteria(self::DB_COLUMN_PUBLICATION_STATUS);
-
-               // Make sure all entries are marked as pending, first get a dataset instance.
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
-
-               // Add search instance
-               $dataSetInstance->setSearchInstance($this->getSearchInstance());
-
-               // Set primary key (node id)
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
-
-               // Add criteria (that should be set)
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PUBLICATION_STATUS, self::PUBLICATION_STATUS_PENDING);
-
-               // Run the "UPDATE" query
-               $this->queryUpdateDataSet($dataSetInstance);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-       }
-
-       /**
-        * Removes non-public data from given array.
-        *
-        * @param       $data   An array with possible non-public data that needs to be removed.
-        * @return      $data   A cleaned up array with only public data.
-        */
-       public function removeNonPublicDataFromArray(array $data) {
-               // Currently call only inner method
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
-               $data = parent::removeNonPublicDataFromArray($data);
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: data[]=' . gettype($data));
-
-               // Return cleaned data
-               return $data;
-       }
-
-       /**
-        * Find recipients for given package data and exclude the sender
-        *
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @return      $recipients                     An indexed array with DHT recipients
-        */
-       public function getResultFromExcludedSender (DeliverablePackage $packageInstance) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
-
-               // Get max recipients
-               $maxRecipients = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('max_dht_recipients');
-
-               // First creata a search instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Then exclude 'sender' field as the sender is the current (*this*) node
-               $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID, $packageInstance->getSenderAddress());
-
-               // Set limit to maximum DHT recipients
-               $searchInstance->setLimit($maxRecipients);
-
-               // Get a result instance back from DHT database wrapper.
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
-
-               // Return result instance
-               return $resultInstance;
-       }
-
-       /**
-        * Find recopients by given key/value pair. First look for the key and if it
-        * matches, compare the value.
-        *
-        * @param       $key                    Key to look for
-        * @param       $value                  Value to compare if key matches
-        * @return      $recipients             An indexed array with DHT recipients
-        * @throws      InvalidArgumentException        If $key is empty
-        */
-       public function getResultFromKeyValue (string $key, $value) {
-               // Is key parameter valid?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: key=%s,value[%s]=%s - CALLED!', $key, gettype($value), $value));
-               if (empty($key)) {
-                       // Throw exception
-                       throw new InvalidArgumentException('Parameter key is empty');
-               }
-
-               // Get max recipients
-               $maxRecipients = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('max_dht_recipients');
-
-               // First creata a search instance
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Find the key/value pair
-               $searchInstance->addCriteria($key, $value);
-
-               // Get a result instance back from DHT database wrapper.
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Return result instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: resultInstance=%s - EXIT!', $resultInstance->__toString()));
-               return $resultInstance;
-       }
-
-       /**
-        * Enable DHT bootstrap request acceptance for local node
-        *
-        * @return      void
-        */
-       public function enableAcceptDhtBootstrap () {
-               // Debug message
-               /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Enabling DHT bootstrap requests ...');
-
-               // Is the node already registered?
-               if ($this->isLocalNodeRegistered()) {
-                       // Just update our record
-                       $this->updateLocalNode();
-               } else {
-                       // Register it
-                       $this->registerLocalNode();
-               }
-       }
-
-}
diff --git a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php
deleted file mode 100644 (file)
index 702a228..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Node\Information;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseWrapper;
-use Org\Shipsimu\Hub\Database\Frontend\Node\NodeInformationWrapper;
-use Org\Shipsimu\Hub\Node\BaseHubNode;
-use Org\Shipsimu\Hub\Node\Node;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Registry\Registerable;
-
-/**
- * A database wrapper for node informations
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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 NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeInformationWrapper, Registerable {
-       // Constants for database table names
-       const DB_TABLE_NODE_INFORMATION = 'node_data';
-
-       // Constants for database column names
-       const DB_COLUMN_NODE_NR          = 'node_nr';
-       const DB_COLUMN_NODE_ID          = 'node_id';
-       const DB_COLUMN_SESSION_ID       = 'session_id';
-       const DB_COLUMN_PRIVATE_KEY      = 'private_key';
-       const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash';
-       const DB_COLUMN_NODE_MODE        = 'node_mode';
-       const DB_COLUMN_INTERNAL_UNL     = 'internal_unl';
-       const DB_COLUMN_EXTERNAL_UNL     = 'external_unl';
-
-       /**
-        * 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 createNodeInformationDatabaseWrapper () {
-               // Get a new instance
-               $wrapperInstance = new NodeInformationDatabaseWrapper();
-
-               // Set (primary!) table name
-               $wrapperInstance->setTableName(self::DB_TABLE_NODE_INFORMATION);
-
-               // Return the instance
-               return $wrapperInstance;
-       }
-
-       /**
-        * Checks whether there is an entry for given node instance
-        *
-        * @param       $nodeInstance   An instance of a Node class
-        * @return      $isFound                Whether a node id has been found for this node
-        */
-       public function ifNodeDataIsFound (Node $nodeInstance) {
-               // Is there cache?
-               if (!isset($GLOBALS[__METHOD__])) {
-                       // Now get a search criteria instance
-                       $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-                       // Search for the node number one which is hard-coded the default
-                       $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR  , 1);
-                       $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, FrameworkBootstrap::getRequestInstance()->getRequestElement('mode'));
-                       $searchInstance->setLimit(1);
-
-                       // Get a result back
-                       $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-                       // Is it valid?
-                       $GLOBALS[__METHOD__] = $resultInstance->next();
-               }
-
-               // Return it
-               return $GLOBALS[__METHOD__];
-       }
-
-       /**
-        * 'Registers' a new node id along with data provided in the node instance.
-        * This may sound confusing but avoids double code very nicely...
-        *
-        * @param       $nodeInstance           A node instance
-        * @return      void
-        */
-       public function registerNodeId (BaseHubNode $nodeInstance) {
-               // Get a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
-
-               // Set the primary key
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
-
-               // Add registration elements to the dataset
-               $nodeInstance->addElementsToDataSet($dataSetInstance);
-
-               // "Insert" this dataset instance completely into the database
-               $this->queryInsertDataSet($dataSetInstance);
-       }
-
-       /**
-        * 'Registers' a new session id along with data provided in the node instance.
-        * This may sound confusing but avoids double code very nicely...
-        *
-        * @param       $nodeInstance           An instance of a BaseHubNode class
-        * @param       $searchInstance         An instance of a LocalSearchCriteria class
-        * @return      void
-        */
-       public function registerSessionId (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance) {
-               // Get a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
-
-               // Set search instance
-               $dataSetInstance->setSearchInstance($searchInstance);
-
-               // Set the primary key
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
-
-               // Add registration elements to the dataset
-               $nodeInstance->addElementsToDataSet($dataSetInstance);
-
-               // Update database record
-               $this->queryUpdateDataSet($dataSetInstance);
-       }
-
-       /**
-        * 'Registers' a private key along with data provided in the node instance.
-        * This may sound confusing but avoids double code very nicely...
-        *
-        * @param       $nodeInstance           An instance of a BaseHubNode class
-        * @param       $searchInstance         An instance of a LocalSearchCriteria class
-        * @return      void
-        */
-       public function registerPrivateKey (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance) {
-               // Get a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
-
-               // Set the primary key
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
-
-               // Set search instance
-               $dataSetInstance->setSearchInstance($searchInstance);
-
-               // Add registration elements to the dataset
-               $nodeInstance->addElementsToDataSet($dataSetInstance);
-
-               // Update database record
-               $this->queryUpdateDataSet($dataSetInstance);
-       }
-
-       /**
-        * Removes non-public data from given array.
-        *
-        * @param       $data   An array with possible non-public data that needs to be removed.
-        * @return      $data   A cleaned up array with only public data.
-        */
-       public function removeNonPublicDataFromArray(array $data) {
-               // Currently call only inner method
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
-               $data = parent::removeNonPublicDataFromArray($data);
-
-               // Return cleaned data
-               return $data;
-       }
-
-}
diff --git a/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php
new file mode 100644 (file)
index 0000000..b4c63f9
--- /dev/null
@@ -0,0 +1,720 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseFrontend;
+use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
+use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
+use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
+use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
+use Org\Shipsimu\Hub\Node\BaseHubNode;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
+
+// Import SPL stuff
+use \InvalidArgumentException;
+
+/**
+ * A database frontend for distributed hash tables
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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 NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend implements NodeDhtFrontend, Registerable {
+       /**
+        * "Cached" results for dabase for looking for unpublished entries
+        */
+       private $unpublishedEntriesInstance = NULL;
+
+       // Constants for database table names
+       const DB_TABLE_NODE_DHT = 'node_dht';
+
+       // Constants for database column names
+       const DB_COLUMN_NODE_ID            = 'node_id';
+       const DB_COLUMN_SESSION_ID         = 'session_id';
+       const DB_COLUMN_EXTERNAL_ADDRESS   = 'external_address';
+       const DB_COLUMN_PRIVATE_KEY_HASH   = 'private_key_hash';
+       const DB_COLUMN_NODE_MODE          = 'node_mode';
+       const DB_COLUMN_ACCEPTED_OBJECTS   = 'accepted_object_types';
+       const DB_COLUMN_NODE_LIST          = 'node_list';
+       const DB_COLUMN_PUBLICATION_STATUS = 'publication_status';
+       const DB_COLUMN_ANSWER_STATUS      = 'answer_status';
+       const DB_COLUMN_ACCEPT_BOOTSTRAP   = 'accept_bootstrap';
+
+       // Publication status'
+       const PUBLICATION_STATUS_PENDING = 'PENDING';
+
+       // Exception codes
+       const EXCEPTION_NODE_ALREADY_REGISTERED = 0x800;
+       const EXCEPTION_NODE_NOT_REGISTERED     = 0x801;
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this database frontend by a provided user class
+        *
+        * @return      $frontendInstance       An instance of the created frontend class
+        */
+       public static final function createNodeDistributedHashTableDatabaseFrontend () {
+               // Get a new instance
+               $frontendInstance = new NodeDistributedHashTableDatabaseFrontend();
+
+               // Set (primary!) table name
+               $frontendInstance->setTableName(self::DB_TABLE_NODE_DHT);
+
+               // Get node instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Creating node instance ...');
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // And set it here
+               $frontendInstance->setNodeInstance($nodeInstance);
+
+               // Return the instance
+               return $frontendInstance;
+       }
+
+       /**
+        * Static getter for an array of all DHT database entries
+        *
+        * @return      $elements       All elements for the DHT dabase
+        */
+       public static final function getAllElements () {
+               // Create array and ...
+               $elements = array(
+                       self::DB_COLUMN_NODE_ID,
+                       self::DB_COLUMN_SESSION_ID,
+                       self::DB_COLUMN_EXTERNAL_ADDRESS,
+                       self::DB_COLUMN_PRIVATE_KEY_HASH,
+                       self::DB_COLUMN_NODE_MODE,
+                       self::DB_COLUMN_ACCEPTED_OBJECTS,
+                       self::DB_COLUMN_NODE_LIST
+               );
+
+               // ... return it
+               return $elements;
+       }
+
+       /**
+        * Prepares a search instance for given node data
+        *
+        * @param       $nodeData                       An array with valid node data
+        * @return      $searchInstance         An instance of a SearchCriteria class
+        */
+       private function prepareSearchInstance (array $nodeData) {
+               // Assert on array elements
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
+
+               // Get instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Search for node id and limit it to one entry
+               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $nodeData[self::DB_COLUMN_NODE_ID]);
+               $searchInstance->setLimit(1);
+
+               // Return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+               return $searchInstance;
+       }
+
+       /**
+        * Prepares a "local" instance of a StoreableCriteria class with all node
+        * data for insert/update queries. This data set contains data from *this*
+        * (local) node.
+        *
+        * @return      $dataSetInstance        An instance of a StoreableCriteria class
+        */
+       private function prepareLocalDataSetInstance () {
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Get request instances
+               $requestInstance = FrameworkBootstrap::getRequestInstance();
+
+               // Get a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
+
+               // Set the primary key
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Get Universal Node Locator and "explode" it
+               $locatorInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
+
+               // Get external UNL
+               $externalUnl = $locatorInstance->getExternalUnl();
+
+               // Make sure both is valid
+               // @TODO Bad check on UNL, better use a proper validator
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: externalUnl=' . $externalUnl);
+               assert($externalUnl !== 'invalid');
+
+               // Get an array of all accepted object types
+               $objectList = $this->getNodeInstance()->getListFromAcceptedObjectTypes();
+
+               // Make sure this is an array
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: objectList()=' . count($objectList));
+               assert(is_array($objectList));
+
+               // Add public node data
+               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_MODE       , $requestInstance->getRequestElement('mode'));
+               $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $externalUnl);
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeInstance->nodeId=' . $this->getNodeInstance()->getNodeId());
+               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $this->getNodeInstance()->getNodeId());
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeInstance->sessionId=' . $this->getNodeInstance()->getSessionId());
+               $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $this->getNodeInstance()->getSessionId());
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $this->getNodeInstance()->getNodePrivateKeyHash());
+               $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
+               $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($this->getNodeInstance()->isAcceptingDhtBootstrap()));
+
+               // Return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: dataSetInstance=' . $dataSetInstance->__toString() . ' - EXIT!');
+               return $dataSetInstance;
+       }
+
+       /**
+        * Getter for result instance for unpublished entries
+        *
+        * @return      $unpublishedEntriesInstance             Result instance
+        */
+       public final function getUnpublishedEntriesInstance () {
+               return $this->unpublishedEntriesInstance;
+       }
+
+       /**
+        * Checks whether the local (*this*) node is registered in the DHT by
+        * checking if the external address is found.
+        *
+        * @return      $isRegistered   Whether *this* node is registered in the DHT
+        */
+       public function isLocalNodeRegistered () {
+               // Get a search criteria instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Get Universal Node Locator and "explode" it
+               $locatorInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
+
+               // Make sure the external address is set and not invalid
+               // @TODO Bad check on UNL, better use a proper validator
+               $externalUnl = $locatorInstance->getExternalUnl();
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: externalUnl=%s', $externalUnl));
+               assert($externalUnl != 'invalid');
+
+               // Add Universal Node Locator/node id as criteria
+               $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $externalUnl);
+               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $this->getNodeInstance()->getNodeId());
+               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $this->getNodeInstance()->getSessionId());
+               $searchInstance->setLimit(1);
+
+               // Query database and get a result instance back
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Cache result of if there is an entry, valid() will tell us if an entry is there
+               $isRegistered = $resultInstance->valid();
+
+               // Return result
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: isRegistered=%d - EXIT!', intval($isRegistered)));
+               return $isRegistered;
+       }
+
+       /**
+        * Registeres the local (*this*) node with its data in the DHT.
+        *
+        * @return      void
+        */
+       public function registerLocalNode () {
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Assert to make sure this method is called with no record in DB (the actual backend of the DHT)
+               assert(!$this->isLocalNodeRegistered());
+
+               // Get prepared data set instance
+               $dataSetInstance = $this->prepareLocalDataSetInstance();
+
+               // "Insert" this dataset instance completely into the database
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling this->queryInsertDataSet(' . $dataSetInstance->__toString() . ') ...');
+               $this->queryInsertDataSet($dataSetInstance);
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+       }
+
+       /**
+        * Updates local (*this*) node's 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 () {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Assert to make sure this method is called with one record in DB (the actual backend of the DHT)
+               assert($this->isLocalNodeRegistered());
+
+               // Get search criteria
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Search for node id and limit it to one entry
+               $searchInstance->addCriteria(self::DB_COLUMN_NODE_ID, $this->getNodeInstance()->getNodeId());
+               $searchInstance->setLimit(1);
+
+               // Get a prepared dataset instance
+               $dataSetInstance = $this->prepareLocalDataSetInstance();
+
+               // Set search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
+               // Update DHT database record
+               $this->queryUpdateDataSet($dataSetInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+       }
+
+       /**
+        * Finds a node locally by given session id
+        *
+        * @param       $sessionId      Session id to lookup
+        * @return      $resultInstance         An instance of a SearchableResult class
+        * @throws      InvalidArgumentException        If parameter $sessionId is not valid
+        */
+       public function findNodeLocalBySessionId ($sessionId) {
+               // Validate parameter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: sessionId=%s - CALLED!', $sessionId));
+               if (empty($sessionId)) {
+                       // Cannot be empty
+                       throw new InvalidArgumentException('Parameter "sessionId" is empty.');
+               }
+
+               // Get search criteria
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Search for session id and limit it to one entry
+               $searchInstance->addCriteria(self::DB_COLUMN_SESSION_ID, $sessionId);
+               $searchInstance->setLimit(1);
+
+               // Query database and get a result instance back
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Return result instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: resultInstance->valid()=%d - EXIT!', intval($resultInstance->valid())));
+               return $resultInstance;
+       }
+
+       /**
+        * Finds a node locally by given UNL instance
+        *
+        * @param       $locatorInstance        An instance of a LocateableNode class
+        * @return      $resultInstance         An instance of a SearchableResult class
+        */
+       public function findNodeLocalByLocatorInstance (LocateableNode $locatorInstance) {
+               // Get search criteria
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: locatorInstance=%s - CALLED!', $locatorInstance->__toString()));
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Search for session id and limit it to one entry
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: externalUnl=%s', $locatorInstance->getExternalUnl()));
+               $searchInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $locatorInstance->getExternalUnl());
+               $searchInstance->setLimit(1);
+
+               // Query database and get a result instance back
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Return result instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: resultInstance->valid()=%d - EXIT!', intval($resultInstance->valid())));
+               return $resultInstance;
+       }
+
+       /**
+        * Registeres a node by given message data.
+        *
+        * @param       $messageInstance        An instance of a DeliverableMessage class
+        * @param       $handlerInstance        An instance of a HandleableDataSet class
+        * @return      void
+        */
+       public function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!');
+
+               // Get a data set instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
+
+               // Set primary key (session id)
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
+
+               // Add all array elements
+               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageInstance);
+
+               // Remove 'node_list'
+               $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST);
+
+               // Run the "INSERT" query
+               $this->queryInsertDataSet($dataSetInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER - EXIT!');
+       }
+
+       /**
+        * Updates an existing entry in node list
+        *
+        * @param       $messageInstance        An instance of a DeliverableMessage class
+        * @param       $handlerInstance        An instance of a HandleableDataSet class
+        * @param       $searchInstance         An instance of LocalSearchCriteria class
+        * @return      void
+        */
+       public function updateNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Get a data set instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
+
+               // Add search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
+               // Set primary key (session id)
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
+
+               // Add all array elements
+               $handlerInstance->addArrayToDataSet($dataSetInstance, $messageInstance);
+
+               // Remove 'node_list'
+               $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST);
+
+               // Run the "UPDATE" query
+               $this->queryUpdateDataSet($dataSetInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+       }
+
+       /**
+        * Determines whether the given node data is already inserted in the DHT
+        *
+        * @param       $nodeData               An array with valid node data
+        * @return      $isRegistered   Whether the given node data is already inserted
+        */
+       public function isNodeRegistered (array $nodeData) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Assert on array elements
+               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]);
+
+               // Get search criteria
+               $searchInstance = $this->prepareSearchInstance($nodeData);
+
+               // Query database and get a result instance back
+               $resultInstance = $this->doSelectByCriteria(
+                       // Search instance
+                       $searchInstance,
+                       // Only look for these array elements ("keys")
+                       array(
+                               self::DB_COLUMN_NODE_ID          => TRUE,
+                               self::DB_COLUMN_EXTERNAL_ADDRESS => TRUE
+                       )
+               );
+
+               // Check if there is an entry
+               $isRegistered = $resultInstance->valid();
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!');
+
+               // Return registration status
+               return $isRegistered;
+       }
+
+       /**
+        * Registers a node with given data in the DHT. If the node is already
+        * registered this method shall throw an exception.
+        *
+        * @param       $nodeData       An array with valid node data
+        * @return      void
+        * @throws      NodeAlreadyRegisteredException  If the node is already registered
+        */
+       public function registerNode (array $nodeData) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Assert on array elements
+               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
+
+               // Is the node registered?
+               if ($this->isNodeRegistered($nodeData)) {
+                       // Throw an exception
+                       throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED);
+               } // END - if
+
+               // @TODO Unimplemented part
+               $this->partialStub('nodeData=' . print_r($nodeData, TRUE));
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+       }
+
+       /**
+        * Updates a node's entry in the DHT with given data. This will enrich or
+        * just update already exsiting data. If the node is not found this method
+        * shall throw an exception.
+        *
+        * @param       $nodeData       An array with valid node data
+        * @return      void
+        * @throws      NodeDataMissingException        If the node's data is missing
+        */
+       public function updateNode (array $nodeData) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeData=' . print_r($nodeData, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Assert on array elements
+               assert(isset($nodeData[self::DB_COLUMN_NODE_ID]));
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...');
+
+               // Is the node registered?
+               if (!$this->isNodeRegistered($nodeData)) {
+                       // No, then throw an exception
+                       throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED);
+               } // END - if
+
+               // Get a search instance
+               $searchInstance = $this->prepareSearchInstance($nodeData);
+
+               // Get a data set instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
+
+               // Add search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
+               // Set primary key (session id)
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID);
+
+               // Add all array elements
+               $this->getNodeInstance()->addArrayToDataSet($dataSetInstance, $nodeData);
+
+               // Remove 'node_list'
+               $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST);
+
+               // Run the "UPDATE" query
+               $this->queryUpdateDataSet($dataSetInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+       }
+
+       /**
+        * Checks whether there are unpublished entries
+        *
+        * @return      $hasUnpublished         Whether there are unpublished entries
+        * @todo        Add minimum/maximum age limitations
+        */
+       public function hasUnpublishedEntries () {
+               // Get search instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add exclusion key which is the publish status
+               $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PUBLICATION_STATUS, NodeDistributedHashTableDatabaseFrontend::PUBLICATION_STATUS_PENDING);
+
+               // Remember search instance
+               $this->setSearchInstance($searchInstance);
+
+               // Run the query
+               $this->unpublishedEntriesInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Check pending entries
+               $hasUnpublished = $this->unpublishedEntriesInstance->valid();
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+
+               // Return it
+               return $hasUnpublished;
+       }
+
+       /**
+        * Initializes publication of DHT entries. This does only prepare
+        * publication. The next step is to pickup such prepared entries and publish
+        * them by uploading to other (recently appeared) DHT members.
+        *
+        * @return      void
+        * @todo        Add timestamp to dataset instance
+        */
+       public function initEntryPublication () {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               /*
+                * Make sure that hasUnpublishedEntries() has been called first by
+                * asserting on the "cached" object instance. This "caching" saves some
+                * needless queries as this method shall be called immediately after
+                * hasUnpublishedEntries() returns TRUE.
+                */
+               assert($this->unpublishedEntriesInstance instanceof SearchableResult);
+
+               // Result is still okay?
+               assert($this->unpublishedEntriesInstance->valid());
+
+               // Remove 'publication_status'
+               $this->getSearchInstance()->unsetCriteria(self::DB_COLUMN_PUBLICATION_STATUS);
+
+               // Make sure all entries are marked as pending, first get a dataset instance.
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT));
+
+               // Add search instance
+               $dataSetInstance->setSearchInstance($this->getSearchInstance());
+
+               // Set primary key (node id)
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Add criteria (that should be set)
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PUBLICATION_STATUS, self::PUBLICATION_STATUS_PENDING);
+
+               // Run the "UPDATE" query
+               $this->queryUpdateDataSet($dataSetInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+       }
+
+       /**
+        * Removes non-public data from given array.
+        *
+        * @param       $data   An array with possible non-public data that needs to be removed.
+        * @return      $data   A cleaned up array with only public data.
+        */
+       public function removeNonPublicDataFromArray(array $data) {
+               // Currently call only inner method
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
+               $data = parent::removeNonPublicDataFromArray($data);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: data[]=' . gettype($data));
+
+               // Return cleaned data
+               return $data;
+       }
+
+       /**
+        * Find recipients for given package data and exclude the sender
+        *
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @return      $recipients                     An indexed array with DHT recipients
+        */
+       public function getResultFromExcludedSender (DeliverablePackage $packageInstance) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!');
+
+               // Get max recipients
+               $maxRecipients = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('max_dht_recipients');
+
+               // First creata a search instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Then exclude 'sender' field as the sender is the current (*this*) node
+               $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_SESSION_ID, $packageInstance->getSenderAddress());
+
+               // Set limit to maximum DHT recipients
+               $searchInstance->setLimit($maxRecipients);
+
+               // Get a result instance back from DHT database frontend.
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!');
+
+               // Return result instance
+               return $resultInstance;
+       }
+
+       /**
+        * Find recopients by given key/value pair. First look for the key and if it
+        * matches, compare the value.
+        *
+        * @param       $key                    Key to look for
+        * @param       $value                  Value to compare if key matches
+        * @return      $recipients             An indexed array with DHT recipients
+        * @throws      InvalidArgumentException        If $key is empty
+        */
+       public function getResultFromKeyValue (string $key, $value) {
+               // Is key parameter valid?
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: key=%s,value[%s]=%s - CALLED!', $key, gettype($value), $value));
+               if (empty($key)) {
+                       // Throw exception
+                       throw new InvalidArgumentException('Parameter key is empty');
+               }
+
+               // Get max recipients
+               $maxRecipients = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('max_dht_recipients');
+
+               // First creata a search instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Find the key/value pair
+               $searchInstance->addCriteria($key, $value);
+
+               // Get a result instance back from DHT database frontend.
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Return result instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-WRAPPER: resultInstance=%s - EXIT!', $resultInstance->__toString()));
+               return $resultInstance;
+       }
+
+       /**
+        * Enable DHT bootstrap request acceptance for local node
+        *
+        * @return      void
+        */
+       public function enableAcceptDhtBootstrap () {
+               // Debug message
+               /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Enabling DHT bootstrap requests ...');
+
+               // Is the node already registered?
+               if ($this->isLocalNodeRegistered()) {
+                       // Just update our record
+                       $this->updateLocalNode();
+               } else {
+                       // Register it
+                       $this->registerLocalNode();
+               }
+       }
+
+}
diff --git a/application/hub/classes/database/frontend/node_information/class_NodeInformationDatabaseFrontend.php b/application/hub/classes/database/frontend/node_information/class_NodeInformationDatabaseFrontend.php
new file mode 100644 (file)
index 0000000..5194505
--- /dev/null
@@ -0,0 +1,193 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Node\Information;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseFrontend;
+use Org\Shipsimu\Hub\Database\Frontend\Node\NodeInformationFrontend;
+use Org\Shipsimu\Hub\Node\BaseHubNode;
+use Org\Shipsimu\Hub\Node\Node;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Registry\Registerable;
+
+/**
+ * A database frontend for node informations
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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 NodeInformationDatabaseFrontend extends BaseHubDatabaseFrontend implements NodeInformationFrontend, Registerable {
+       // Constants for database table names
+       const DB_TABLE_NODE_INFORMATION = 'node_data';
+
+       // Constants for database column names
+       const DB_COLUMN_NODE_NR          = 'node_nr';
+       const DB_COLUMN_NODE_ID          = 'node_id';
+       const DB_COLUMN_SESSION_ID       = 'session_id';
+       const DB_COLUMN_PRIVATE_KEY      = 'private_key';
+       const DB_COLUMN_PRIVATE_KEY_HASH = 'private_key_hash';
+       const DB_COLUMN_NODE_MODE        = 'node_mode';
+       const DB_COLUMN_INTERNAL_UNL     = 'internal_unl';
+       const DB_COLUMN_EXTERNAL_UNL     = 'external_unl';
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this database frontend by a provided user class
+        *
+        * @return      $frontendInstance       An instance of the created frontend class
+        */
+       public static final function createNodeInformationDatabaseFrontend () {
+               // Get a new instance
+               $frontendInstance = new NodeInformationDatabaseFrontend();
+
+               // Set (primary!) table name
+               $frontendInstance->setTableName(self::DB_TABLE_NODE_INFORMATION);
+
+               // Return the instance
+               return $frontendInstance;
+       }
+
+       /**
+        * Checks whether there is an entry for given node instance
+        *
+        * @param       $nodeInstance   An instance of a Node class
+        * @return      $isFound                Whether a node id has been found for this node
+        */
+       public function ifNodeDataIsFound (Node $nodeInstance) {
+               // Is there cache?
+               if (!isset($GLOBALS[__METHOD__])) {
+                       // Now get a search criteria instance
+                       $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+                       // Search for the node number one which is hard-coded the default
+                       $searchInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_NR  , 1);
+                       $searchInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE, FrameworkBootstrap::getRequestInstance()->getRequestElement('mode'));
+                       $searchInstance->setLimit(1);
+
+                       // Get a result back
+                       $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+                       // Is it valid?
+                       $GLOBALS[__METHOD__] = $resultInstance->next();
+               }
+
+               // Return it
+               return $GLOBALS[__METHOD__];
+       }
+
+       /**
+        * 'Registers' a new node id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           A node instance
+        * @return      void
+        */
+       public function registerNodeId (BaseHubNode $nodeInstance) {
+               // Get a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
+
+               // Set the primary key
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Add registration elements to the dataset
+               $nodeInstance->addElementsToDataSet($dataSetInstance);
+
+               // "Insert" this dataset instance completely into the database
+               $this->queryInsertDataSet($dataSetInstance);
+       }
+
+       /**
+        * 'Registers' a new session id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           An instance of a BaseHubNode class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return      void
+        */
+       public function registerSessionId (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance) {
+               // Get a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
+
+               // Set search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
+               // Set the primary key
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Add registration elements to the dataset
+               $nodeInstance->addElementsToDataSet($dataSetInstance);
+
+               // Update database record
+               $this->queryUpdateDataSet($dataSetInstance);
+       }
+
+       /**
+        * 'Registers' a private key along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           An instance of a BaseHubNode class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return      void
+        */
+       public function registerPrivateKey (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance) {
+               // Get a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_INFORMATION));
+
+               // Set the primary key
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
+
+               // Set search instance
+               $dataSetInstance->setSearchInstance($searchInstance);
+
+               // Add registration elements to the dataset
+               $nodeInstance->addElementsToDataSet($dataSetInstance);
+
+               // Update database record
+               $this->queryUpdateDataSet($dataSetInstance);
+       }
+
+       /**
+        * Removes non-public data from given array.
+        *
+        * @param       $data   An array with possible non-public data that needs to be removed.
+        * @return      $data   A cleaned up array with only public data.
+        */
+       public function removeNonPublicDataFromArray(array $data) {
+               // Currently call only inner method
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...');
+               $data = parent::removeNonPublicDataFromArray($data);
+
+               // Return cleaned data
+               return $data;
+       }
+
+}
diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php
new file mode 100644 (file)
index 0000000..bd4b101
--- /dev/null
@@ -0,0 +1,274 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Node\PeerState;
+
+// Import application-specific sutff
+use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
+use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseFrontend;
+use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
+use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
+use Org\Shipsimu\Hub\LookupTable\Lookupable;
+use Org\Shipsimu\Hub\State\Peer\Lookup\LookupablePeerState;
+use Org\Shipsimu\Hub\State\Peer\PeerStateable;
+use Org\Shipsimu\Hub\Tools\HubTools;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
+use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+
+/**
+ * A database frontend for peer state lookups
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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 PeerStateLookupDatabaseFrontend extends BaseHubDatabaseFrontend implements LookupablePeerState {
+       // Exception constants
+       const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300;
+
+       // Constants for database table names
+       const DB_TABLE_PEER_LOOKUP = 'peer_states';
+
+       // Constants for database column names
+       const DB_COLUMN_PEER_IP           = 'peer_ip';
+       const DB_COLUMN_PEER_PORT         = 'peer_port';
+       const DB_COLUMN_PEER_SESSION_ID   = 'peer_session_id';
+       const DB_COLUMN_PEER_STATE        = 'peer_state';
+       const DB_COLUMN_SOCKET_ERROR_CODE = 'socket_error_code';
+       const DB_COLUMN_SOCKET_ERROR_MSG  = 'socket_error_msg';
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this database frontend by a provided user class
+        *
+        * @return      $frontendInstance       An instance of the created frontend class
+        */
+       public static final function createPeerStateLookupDatabaseFrontend () {
+               // Get a new instance
+               $frontendInstance = new PeerStateLookupDatabaseFrontend();
+
+               // Set (primary!) table name
+               $frontendInstance->setTableName(self::DB_TABLE_PEER_LOOKUP);
+
+               // Return the instance
+               return $frontendInstance;
+       }
+
+       /**
+        * "Getter" for a LocalSearchCriteria from given package data's sender
+        *
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @return      $searchInstance         An instance of a LocalSearchCriteria class
+        */
+       private function getSenderSearchInstanceFromPackageInstance (DeliverablePackage $packageInstance) {
+               // Get the instance
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Searching for sender ' . $packageInstance->getSenderAddress());
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Add 'sender' as the peer's IP address
+               $searchInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageInstance->getSenderAddress());
+               $searchInstance->setLimit(1);
+
+               // Return the instance
+               return $searchInstance;
+       }
+
+       /**
+        * Checks whether given 'sender' is a new peer
+        *
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @param       $dataSetInstance        An optional instance of a StoreableCriteria class
+        * @return      $isNewPeer                      Whether 'sender' is a new peer to this peer
+        */
+       public function isSenderNewPeer (DeliverablePackage $packageInstance, StoreableCriteria $dataSetInstance = NULL) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: packageInstance=' . $packageInstance . ' - CALLED!');
+
+               // Get a search criteria instance from package data
+               $searchInstance = $this->getSenderSearchInstanceFromPackageInstance($packageInstance);
+
+               // Is the dataset instance set?
+               if ($dataSetInstance instanceof StoreableCriteria) {
+                       // Then remember the search instance in it
+                       $dataSetInstance->setSearchInstance($searchInstance);
+               } // END - if
+
+               // Count the query
+               $entries = $this->doSelectCountByCriteria($searchInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
+
+               // Is it there?
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: entries=' . $entries);
+               $isNewPeer = ($entries != 1);
+
+               // Return the result
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!');
+               return $isNewPeer;
+       }
+
+       /**
+        * Registers a new peer with given package data. We use the session id from it.
+        *
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @param       $socketResource         An instance of a StorableSocket class
+        * @return      void
+        * @throws      PeerAlreadyRegisteredException  If a peer is already registered
+        */
+       public function registerPeerByPackageInstance (DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
+               // Make sure only new peers can be registered with package data
+               if (!$this->isSenderNewPeer($packageInstance)) {
+                       // Throw an exception because this should normally not happen
+                       throw new PeerAlreadyRegisteredException(array($this, $packageInstance), self::EXCEPTION_PEER_ALREADY_REGISTERED);
+               } // END - if
+
+               // Generate a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP));
+
+               // Session ids must be unique
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID);
+
+               // Add session id
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageInstance->getSenderAddress());
+
+               // Init peer address/port
+               $peerAddress = '0.0.0.0';
+               $peerPort    = 0;
+
+               // Get peer name
+               if (!$socketInstance->determineSocketPeerName($peerAddress, $peerPort)) {
+                       // ... and cleartext message from it and put both into criteria
+                       $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $socketInstance->getLastSocketErrorCode());
+                       $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_MSG , $socketInstance->getLastSocketErrorMessage());
+               } // END - if
+
+               // Add ip address and port
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP  , $peerAddress);
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $peerPort);
+
+               // "Insert" the data set
+               $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageInstance->getSenderAddress() . ' has been registered.');
+       }
+
+       /**
+        * Registers the given peer state and An instance of a DeliverablePackage class
+        *
+        * @param       $stateInstance          A PeerStateable class instance
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @return      void
+        * @throws      PeerAlreadyRegisteredException  If a peer is already registered
+        * @todo        Unfinished area
+        */
+       public function registerPeerState (PeerStateable $stateInstance, DeliverablePackage $packageInstance) {
+               // Generate a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP));
+
+               // Session ids must be unique
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID);
+
+               // Add session id
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageInstance->getSenderAddress());
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_STATE     , $stateInstance->getStateName());
+
+               // Try to resolve sender's session id
+               $senderData = explode(':', HubTools::resolveSessionIdToUnl($packageInstance->getSenderAddress()));
+
+               // Just make sure that 'invalid:invalid' is not being processed
+               assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid') && ($senderData[2] != 'invalid'));
+
+               // Add ip address and port
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP  , $senderData[0]);
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $senderData[1]);
+
+               // Is this a new peer?
+               if ($this->isSenderNewPeer($packageInstance, $dataSetInstance)) {
+                       // "Insert" the data set
+                       $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
+               } else {
+                       // Update the data set
+                       $this->queryUpdateDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
+               }
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageInstance->getSenderAddress() . ' has been registered/updated with state ' . $stateInstance->getStateName());
+       }
+
+       /**
+        * Purges old entries of given socket resource. We use the IP address from that resource.
+        *
+        * @param       $socketInstance         An instance of a StorableSocket class
+        * @return      void
+        * @todo        Unfinished area, please rewrite!
+        */
+       public function purgeOldEntriesBySocketInstance (StorableSocket $socketInstance) {
+               $this->partialStub('Please finish this method.');
+       }
+
+       /**
+        * Checks whether a given peer state (in helper instance) is same as stored
+        * in database compared with the one from $helperInstance.
+        *
+        * @param       $helperInstance         An instance of a ConnectionHelper class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @return      $isSamePeerState        Whether the peer's state is the same
+        */
+       public function isSamePeerState (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...');
+
+               // Now get the search instance from given package data
+               $searchInstance = $this->getSenderSearchInstanceFromPackageInstance($packageInstance);
+
+               // With this search instance query the database for the peer and get a result instance
+               $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+               // Do we have an entry? This should always the case
+               assert($resultInstance->next());
+
+               // Yes, so get the current (=first) entry from it
+               $rowData = $resultInstance->current();
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE));
+
+               // Assert on important elements
+               assert(isset($rowData[self::DB_COLUMN_PEER_STATE]));
+
+               // Now just compare it with given state from helper instance
+               $isSamePeerState = ($rowData[self::DB_COLUMN_PEER_STATE] == $helperInstance->getPrintableState());
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState));
+
+               // Return it
+               return $isSamePeerState;
+       }
+
+}
diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php
deleted file mode 100644 (file)
index 594de0a..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Node\PeerState;
-
-// Import application-specific sutff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseWrapper;
-use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
-use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-use Org\Shipsimu\Hub\LookupTable\Lookupable;
-use Org\Shipsimu\Hub\State\Peer\Lookup\LookupablePeerState;
-use Org\Shipsimu\Hub\State\Peer\PeerStateable;
-use Org\Shipsimu\Hub\Tools\HubTools;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-
-/**
- * A database wrapper for peer state lookups
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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 PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements LookupablePeerState {
-       // Exception constants
-       const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300;
-
-       // Constants for database table names
-       const DB_TABLE_PEER_LOOKUP = 'peer_states';
-
-       // Constants for database column names
-       const DB_COLUMN_PEER_IP           = 'peer_ip';
-       const DB_COLUMN_PEER_PORT         = 'peer_port';
-       const DB_COLUMN_PEER_SESSION_ID   = 'peer_session_id';
-       const DB_COLUMN_PEER_STATE        = 'peer_state';
-       const DB_COLUMN_SOCKET_ERROR_CODE = 'socket_error_code';
-       const DB_COLUMN_SOCKET_ERROR_MSG  = 'socket_error_msg';
-
-       /**
-        * 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 createPeerStateLookupDatabaseWrapper () {
-               // Get a new instance
-               $wrapperInstance = new PeerStateLookupDatabaseWrapper();
-
-               // Set (primary!) table name
-               $wrapperInstance->setTableName(self::DB_TABLE_PEER_LOOKUP);
-
-               // Return the instance
-               return $wrapperInstance;
-       }
-
-       /**
-        * "Getter" for a LocalSearchCriteria from given package data's sender
-        *
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @return      $searchInstance         An instance of a LocalSearchCriteria class
-        */
-       private function getSenderSearchInstanceFromPackageInstance (DeliverablePackage $packageInstance) {
-               // Get the instance
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Searching for sender ' . $packageInstance->getSenderAddress());
-               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-               // Add 'sender' as the peer's IP address
-               $searchInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageInstance->getSenderAddress());
-               $searchInstance->setLimit(1);
-
-               // Return the instance
-               return $searchInstance;
-       }
-
-       /**
-        * Checks whether given 'sender' is a new peer
-        *
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @param       $dataSetInstance        An optional instance of a StoreableCriteria class
-        * @return      $isNewPeer                      Whether 'sender' is a new peer to this peer
-        */
-       public function isSenderNewPeer (DeliverablePackage $packageInstance, StoreableCriteria $dataSetInstance = NULL) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: packageInstance=' . $packageInstance . ' - CALLED!');
-
-               // Get a search criteria instance from package data
-               $searchInstance = $this->getSenderSearchInstanceFromPackageInstance($packageInstance);
-
-               // Is the dataset instance set?
-               if ($dataSetInstance instanceof StoreableCriteria) {
-                       // Then remember the search instance in it
-                       $dataSetInstance->setSearchInstance($searchInstance);
-               } // END - if
-
-               // Count the query
-               $entries = $this->doSelectCountByCriteria($searchInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
-
-               // Is it there?
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: entries=' . $entries);
-               $isNewPeer = ($entries != 1);
-
-               // Return the result
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!');
-               return $isNewPeer;
-       }
-
-       /**
-        * Registers a new peer with given package data. We use the session id from it.
-        *
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @param       $socketResource         An instance of a StorableSocket class
-        * @return      void
-        * @throws      PeerAlreadyRegisteredException  If a peer is already registered
-        */
-       public function registerPeerByPackageInstance (DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
-               // Make sure only new peers can be registered with package data
-               if (!$this->isSenderNewPeer($packageInstance)) {
-                       // Throw an exception because this should normally not happen
-                       throw new PeerAlreadyRegisteredException(array($this, $packageInstance), self::EXCEPTION_PEER_ALREADY_REGISTERED);
-               } // END - if
-
-               // Generate a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP));
-
-               // Session ids must be unique
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID);
-
-               // Add session id
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageInstance->getSenderAddress());
-
-               // Init peer address/port
-               $peerAddress = '0.0.0.0';
-               $peerPort    = 0;
-
-               // Get peer name
-               if (!$socketInstance->determineSocketPeerName($peerAddress, $peerPort)) {
-                       // ... and cleartext message from it and put both into criteria
-                       $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $socketInstance->getLastSocketErrorCode());
-                       $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_MSG , $socketInstance->getLastSocketErrorMessage());
-               } // END - if
-
-               // Add ip address and port
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP  , $peerAddress);
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $peerPort);
-
-               // "Insert" the data set
-               $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageInstance->getSenderAddress() . ' has been registered.');
-       }
-
-       /**
-        * Registers the given peer state and An instance of a DeliverablePackage class
-        *
-        * @param       $stateInstance          A PeerStateable class instance
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @return      void
-        * @throws      PeerAlreadyRegisteredException  If a peer is already registered
-        * @todo        Unfinished area
-        */
-       public function registerPeerState (PeerStateable $stateInstance, DeliverablePackage $packageInstance) {
-               // Generate a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP));
-
-               // Session ids must be unique
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID);
-
-               // Add session id
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageInstance->getSenderAddress());
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_STATE     , $stateInstance->getStateName());
-
-               // Try to resolve sender's session id
-               $senderData = explode(':', HubTools::resolveSessionIdToUnl($packageInstance->getSenderAddress()));
-
-               // Just make sure that 'invalid:invalid' is not being processed
-               assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid') && ($senderData[2] != 'invalid'));
-
-               // Add ip address and port
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP  , $senderData[0]);
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $senderData[1]);
-
-               // Is this a new peer?
-               if ($this->isSenderNewPeer($packageInstance, $dataSetInstance)) {
-                       // "Insert" the data set
-                       $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
-               } else {
-                       // Update the data set
-                       $this->queryUpdateDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE));
-               }
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageInstance->getSenderAddress() . ' has been registered/updated with state ' . $stateInstance->getStateName());
-       }
-
-       /**
-        * Purges old entries of given socket resource. We use the IP address from that resource.
-        *
-        * @param       $socketInstance         An instance of a StorableSocket class
-        * @return      void
-        * @todo        Unfinished area, please rewrite!
-        */
-       public function purgeOldEntriesBySocketInstance (StorableSocket $socketInstance) {
-               $this->partialStub('Please finish this method.');
-       }
-
-       /**
-        * Checks whether a given peer state (in helper instance) is same as stored
-        * in database compared with the one from $helperInstance.
-        *
-        * @param       $helperInstance         An instance of a ConnectionHelper class
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @return      $isSamePeerState        Whether the peer's state is the same
-        */
-       public function isSamePeerState (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...');
-
-               // Now get the search instance from given package data
-               $searchInstance = $this->getSenderSearchInstanceFromPackageInstance($packageInstance);
-
-               // With this search instance query the database for the peer and get a result instance
-               $resultInstance = $this->doSelectByCriteria($searchInstance);
-
-               // Do we have an entry? This should always the case
-               assert($resultInstance->next());
-
-               // Yes, so get the current (=first) entry from it
-               $rowData = $resultInstance->current();
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE));
-
-               // Assert on important elements
-               assert(isset($rowData[self::DB_COLUMN_PEER_STATE]));
-
-               // Now just compare it with given state from helper instance
-               $isSamePeerState = ($rowData[self::DB_COLUMN_PEER_STATE] == $helperInstance->getPrintableState());
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState));
-
-               // Return it
-               return $isSamePeerState;
-       }
-
-}
index 8dea3537a4d365b3d96a096cc6df3d8a320046a1..fda923cc6f014453bbfa92a2bdf1e08d0bcc61ea 100644 (file)
@@ -165,8 +165,8 @@ abstract class BaseDht extends BaseHubSystem implements Distributable {
         * @todo        Add minimum/maximum age limitations
         */
        public function hasUnpublishedEntries () {
-               // Call method on database wrapper
-               $hasUnpublished = $this->getWrapperInstance()->hasUnpublishedEntries();
+               // Call method on database frontend
+               $hasUnpublished = $this->getFrontendInstance()->hasUnpublishedEntries();
 
                // Return it
                return $hasUnpublished;
@@ -180,11 +180,11 @@ abstract class BaseDht extends BaseHubSystem implements Distributable {
         * @return      void
         */
        public function initEntryPublication () {
-               // Call method on database wrapper
-               $this->getWrapperInstance()->initEntryPublication();
+               // Call method on database frontend
+               $this->getFrontendInstance()->initEntryPublication();
 
                // Get result instance
-               $resultInstance = $this->getWrapperInstance()->getUnpublishedEntriesInstance();
+               $resultInstance = $this->getFrontendInstance()->getUnpublishedEntriesInstance();
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
@@ -260,8 +260,8 @@ abstract class BaseDht extends BaseHubSystem implements Distributable {
                assert(is_array($entry));
 
                // Remove any non-public data the database layer desires
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT: Calling this->getWrapperInstance()->removeNonPublicDataFromArray(data) ...');
-               $entry = $this->getWrapperInstance()->removeNonPublicDataFromArray($entry);
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT: Calling this->getFrontendInstance()->removeNonPublicDataFromArray(data) ...');
+               $entry = $this->getFrontendInstance()->removeNonPublicDataFromArray($entry);
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT: entry[]=' . gettype($entry));
 
                // Some sanity-checks again
@@ -293,8 +293,8 @@ abstract class BaseDht extends BaseHubSystem implements Distributable {
         * @todo        Switch flag 'accept_bootstrap'
         */
        public function enableAcceptDhtBootstrap () {
-               // Call method on database wrapper
-               $this->getWrapperInstance()->enableAcceptDhtBootstrap();
+               // Call method on database frontend
+               $this->getFrontendInstance()->enableAcceptDhtBootstrap();
        }
 
 }
index 97a635f7e67d24b9caf61b8d1a1e36809a3d2d1c..9f6e1d3bab282ab3ed37f71b0654ba9bac5e8b63 100644 (file)
@@ -12,11 +12,12 @@ use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
 use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
+use Org\Mxchange\CoreFramework\Traits\Database\Frontend\DatabaseFrontendTrait;
 
 // Import SPL stuff
 use \InvalidArgumentException;
@@ -44,6 +45,9 @@ use \InvalidArgumentException;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
+       // Load traits
+       use DatabaseFrontendTrait;
+
        /**
         * Protected constructor
         *
@@ -63,11 +67,11 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                // Get new instance
                $dhtInstance = new NodeDhtFacade();
 
-               // Get a database wrapper instance
-               $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_dht_db_wrapper_class');
+               // Get a database frontend instance
+               $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('node_dht_db_frontend_class');
 
                // Set it in this class
-               $dhtInstance->setWrapperInstance($wrapperInstance);
+               $dhtInstance->setFrontendInstance($frontendInstance);
 
                // Return the prepared instance
                return $dhtInstance;
@@ -85,21 +89,21 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
        protected function insertDataIntoDht (array $dhtData) {
                // Check if there is already an entry for given node_id
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: dhtData()=%d - CALLED!', count($dhtData)));
-               if ($this->getWrapperInstance()->isNodeRegistered($dhtData)) {
+               if ($this->getFrontendInstance()->isNodeRegistered($dhtData)) {
                        /*
                         * Update existing record. Please note that this step is not secure
                         * (e.g. DHT poisoning) it would be good to implement some checks if
                         * the both node owner trust each other (see sub-project 'DSHT').
                         */
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: Updating existing node data ...');
-                       $this->getWrapperInstance()->updateNode($dhtData);
+                       $this->getFrontendInstance()->updateNode($dhtData);
                } else {
                        /*
                         * Inserts given node data into the DHT. As above, this step does
                         * currently not perform any security checks.
                         */
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: Registering node data ...');
-                       $this->getWrapperInstance()->registerNode($dhtData);
+                       $this->getFrontendInstance()->registerNode($dhtData);
                }
 
                // Trace message
@@ -114,14 +118,14 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
        public function initDht () {
                // Is the local node registered?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: CALLED!');
-               if ($this->getWrapperInstance()->isLocalNodeRegistered()) {
+               if ($this->getFrontendInstance()->isLocalNodeRegistered()) {
                        // Then only update session id
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: Updating local node data ...');
-                       $this->getWrapperInstance()->updateLocalNode();
+                       $this->getFrontendInstance()->updateLocalNode();
                } else {
                        // No, so register it
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: Registering local node data ...');
-                       $this->getWrapperInstance()->registerLocalNode();
+                       $this->getFrontendInstance()->registerLocalNode();
                }
 
                // Change state
@@ -177,10 +181,10 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                $nodeData = [];
 
                /*
-                * Call the wrapper to do the job and get back a result instance. There
-                * will come back zero or one entry from the wrapper.
+                * Call the frontend to do the job and get back a result instance. There
+                * will come back zero or one entry from the frontend.
                 */
-               $resultInstance = $this->getWrapperInstance()->findNodeLocalBySessionId($sessionId);
+               $resultInstance = $this->getFrontendInstance()->findNodeLocalBySessionId($sessionId);
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
@@ -213,7 +217,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                $nodeData = [];
 
                // Query database
-               $resultInstance = $this->getWrapperInstance()->findNodeLocalByLocatorInstance($locatorInstance);
+               $resultInstance = $this->getFrontendInstance()->findNodeLocalByLocatorInstance($locatorInstance);
 
                // Make sure the result instance is valid
                //* DEBUG-DIE: */ die(sprintf('[%s:%d]: resultInstance=%s', __METHOD__, __LINE__, print_r($resultInstance, TRUE)));
@@ -269,7 +273,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                $searchInstance->setLimit(1);
 
                // Run the query
-               $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance);
+               $resultInstance = $this->getFrontendInstance()->doSelectByCriteria($searchInstance);
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
@@ -277,10 +281,10 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                // Is there already an entry?
                if ($resultInstance->valid()) {
                        // Entry found, so update it
-                       $this->getWrapperInstance()->updateNodeByMessageInstance($messageInstance, $handlerInstance, $searchInstance);
+                       $this->getFrontendInstance()->updateNodeByMessageInstance($messageInstance, $handlerInstance, $searchInstance);
                } elseif ($forceUpdate === FALSE) {
                        // Nothing found, so register it
-                       $this->getWrapperInstance()->registerNodeByMessageInstance($messageInstance, $handlerInstance);
+                       $this->getFrontendInstance()->registerNodeByMessageInstance($messageInstance, $handlerInstance);
                } else {
                        /*
                         * Do not register non-existent nodes here. This is maybe fatal,
@@ -290,7 +294,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                }
 
                // Save last exception
-               $handlerInstance->setLastException($this->getWrapperInstance()->getLastException());
+               $handlerInstance->setLastException($this->getFrontendInstance()->getLastException());
        }
 
        /**
@@ -326,7 +330,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                $searchInstance->setLimit(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_dht_list_limit'));
 
                // Run the query
-               $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance);
+               $resultInstance = $this->getFrontendInstance()->doSelectByCriteria($searchInstance);
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
@@ -348,14 +352,14 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                        /*
                         * Remove some keys as they should not be published.
                         */
-                       unset($current[$this->getWrapperInstance()->getIndexKey()]);
+                       unset($current[$this->getFrontendInstance()->getIndexKey()]);
 
                        // Add this entry
                        array_push($nodeList, $current);
                } // END - while
 
                // Save last exception
-               $handlerInstance->setLastException($this->getWrapperInstance()->getLastException());
+               $handlerInstance->setLastException($this->getFrontendInstance()->getLastException());
 
                // Return node list (array)
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: nodeList()=%d - EXIT!', count($nodeList)));
@@ -394,8 +398,8 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
         * @return      $recipients             An indexed array with DHT recipients
         */
        public function findRecipientsByPackageInstance (DeliverablePackage $packageInstance) {
-               // Query get a result instance back from DHT database wrapper.
-               $resultInstance = $this->getWrapperInstance()->getResultFromExcludedSender($packageInstance);
+               // Query get a result instance back from DHT database frontend
+               $resultInstance = $this->getFrontendInstance()->getResultFromExcludedSender($packageInstance);
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
@@ -440,7 +444,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                }
 
                // Look for all suitable nodes
-               $resultInstance = $this->getWrapperInstance()->getResultFromKeyValue($key, $value);
+               $resultInstance = $this->getFrontendInstance()->getResultFromKeyValue($key, $value);
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
index b05911cdbde7ce57ee1822acb164769a79c2878f..b50c2f698956a3a44acfe5a1a68da7a49dcd89c1 100644 (file)
@@ -62,7 +62,7 @@ class PeerStateFactory extends ObjectFactory {
                // Is the instance null?
                if (is_null(self::$tableInstance)) {
                        // Get a new one
-                       self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_wrapper_class');
+                       self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_frontend_class');
                } // END - if
 
                // Return it
index 809c9ff4812db694c40cd41b9471d70e54b26f01..21089bf5610323a2a22c3f6552d01f0e3a8cfe1e 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Handler\Node\Announcement\Answer;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
 use Org\Shipsimu\Hub\Handler\Message\HandleableMessage;
@@ -134,7 +134,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen
                $objectList = $nodeInstance->getListFromAcceptedObjectTypes();
 
                // Add missing (temporary) configuration 'accepted_object_types'
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
+               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
        }
 
        /**
@@ -146,7 +146,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen
         */
        protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
                // Remove temporay configuration
-               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS);
+               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ACCEPTED_OBJECTS);
        }
 
 }
index 4da7d4b78bec8db13853dc650e1986fc5bf28caa..2cfd2a8e12e89f36f292134adef7eb8baef6e030 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Handler\Node\Message\Announcement;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler;
@@ -182,7 +182,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                $statusCode = $this->getTranslatedStatusFromLastException();
 
                // Set it in configuration (temporarily)
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
+               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS, $statusCode);
        }
 
        /**
@@ -205,8 +205,8 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl
                        FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey);
                } // END - foreach
 
-               // Remove NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS as well
-               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
+               // Remove NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS as well
+               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS);
        }
 
 }
index e7c3da706dec971a839a425fe9b4f8ef9dddb1a6..f4b55509e9da8a417b1e0b008e8e69f236b468c8 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Handler\Node\Answer\Dht\Bootstrap;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
 use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler;
@@ -170,14 +170,14 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl
                $statusCode = $this->getTranslatedStatusFromLastException();
 
                // Set it in configuration (temporarily)
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
+               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS, $statusCode);
 
                /*
                 * Use the DHT instance to get a list of recipients. This means that all
                 * DHT nodes that accept bootstrap requests are read from the DHT
                 * database.
                 */
-               $nodeList = DhtObjectFactory::createDhtInstance('node')->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y');
+               $nodeList = DhtObjectFactory::createDhtInstance('node')->findRecipientsByKey(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y');
 
                // Make sure it is an array and has at least one entry
                assert(is_array($nodeList));
@@ -208,7 +208,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl
                } // END - foreach
 
                // Remove temporary "special" values as well
-               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
+               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS);
                FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry('dht_nodes');
        }
 
index 45f89edea98d6718040a974c8ee8e5c6d1479b68..936a9dea0ba9df4c5ffffd1702d8a1596ddd046d 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Handler\Node\Message\Request\NodeList;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
 use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler;
@@ -169,7 +169,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
                $statusCode = $this->getTranslatedStatusFromLastException();
 
                // Set it in configuration (temporarily)
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
+               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS, $statusCode);
        }
 
        /**
@@ -187,7 +187,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
                } // END - foreach
 
                // Remove answer status/node list as well
-               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
+               FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS);
                FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry('node_list');
        }
 
index be6c3ad6c7a36526e20ec201a6265cf5e1901d30..a338aecaa8a1eb6752148f299f5dc8b52d7f4f8a 100644 (file)
@@ -4,7 +4,7 @@ namespace Org\Shipsimu\Hub\Handler\Package;
 
 // Import application-specific stuff
 use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Assembler\Package\PackageAssemblerFactory;
 use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
 use Org\Shipsimu\Hub\Factory\Discovery\Package\PackageDiscoveryFactory;
@@ -471,10 +471,10 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                // Is an entry found?
                /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: senderData()=%d', count($senderData)));
                //* DEBUG-DIE: */ die(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE)));
-               if (count($senderData) > 0 || !empty($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])) {
+               if (count($senderData) > 0 || !empty($senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH])) {
                        // Return it
-                       /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Returning senderData[%s]=%s', NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
-                       return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH];
+                       /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Returning senderData[%s]=%s', NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, $senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH]));
+                       return $senderData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH];
                }
 
                // There is no DHT entry so, accept the hash from decoded data
index c2141c444c4b4968992bee53425f61dc372bdd4e..db0302bd0904693fa3656ef94875df7eecce0113 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Locator\Node;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseFrontend;
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Locator\Node\Tools\NodeLocatorUtils;
 use Org\Shipsimu\Hub\Tools\HubTools;
@@ -139,12 +139,12 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                        LocateableNode::UNL_PART_PROTOCOL,
                        LocateableNode::UNL_PART_ADDRESS,
                        LocateableNode::UNL_PART_EXTRA,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
+                       NodeInformationDatabaseFrontend::DB_COLUMN_NODE_ID,
+                       NodeInformationDatabaseFrontend::DB_COLUMN_SESSION_ID,
+                       NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH,
+                       NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE,
+                       NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL,
+                       NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL) as $key) {
                                // Init entry
                                $this->unlData[$key] = NULL;
 
@@ -170,16 +170,16 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                $unlData = $this->getUnlData();
 
                // Is the element there?
-               if (!isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL])) {
+               if (!isset($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL])) {
                        // Is not there
-                       throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING);
-               } elseif ($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] == 'invalid') {
+                       throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING);
+               } elseif ($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL] == 'invalid') {
                        // Is not valid/method to early used
-                       throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL));
+                       throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL));
                }
 
                // Return it
-               return $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL];
+               return $unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL];
        }
 
        /**
@@ -193,16 +193,16 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                $unlData = $this->getUnlData();
 
                // Is the element there?
-               if (!isset($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL])) {
+               if (!isset($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL])) {
                        // Is not there
-                       throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING);
-               } elseif ($unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL] == 'invalid') {
+                       throw new MissingArrayElementsException(array($this, 'unlData', array(NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL)), self::EXCEPTION_ARRAY_ELEMENTS_MISSING);
+               } elseif ($unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL] == 'invalid') {
                        // Is not valid/method to early used
-                       throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL));
+                       throw new BadMethodCallException(sprintf('unlData[%s] is invalid. Maybe called this method to early?', NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL));
                }
 
                // Return it
-               return $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL];
+               return $unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL];
        }
 
        /**
@@ -295,14 +295,14 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                if (HubTools::determineOwnInternalAddress() == $unl) {
                        // Yes, then set it here
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=%s matches own internal address, setting ...', $unl));
-                       $this->unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL] = $unl;
+                       $this->unlData[NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL] = $unl;
                }
 
                // Is it matching own external UNL?
                if (HubTools::determineOwnExternalAddress() == $unl) {
                        // Yes, then set it here
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=%s matches own external address, setting ...', $unl));
-                       $this->unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] = $unl;
+                       $this->unlData[NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL] = $unl;
                }
        }
 
index 79024c1de34dd20f74180b867f61e0fd9c466ca7..e37275f7eafbb2189101de6fa7839972d754ade7 100644 (file)
@@ -3,8 +3,8 @@
 namespace Org\Shipsimu\Hub\Node;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
-use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Registry\Object\ObjectTypeRegistryFactory;
 use Org\Shipsimu\Hub\Factory\State\Node\NodeStateFactory;
 use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
@@ -23,7 +23,7 @@ use Org\Mxchange\CoreFramework\Criteria\Add\AddableCriteria;
 use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
 use Org\Mxchange\CoreFramework\Database\Updateable;
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
@@ -31,6 +31,7 @@ use Org\Mxchange\CoreFramework\Request\Requestable;
 use Org\Mxchange\CoreFramework\Response\Responseable;
 use Org\Mxchange\CoreFramework\Task\Taskable;
 use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait;
+use Org\Mxchange\CoreFramework\Traits\Database\Frontend\DatabaseFrontendTrait;
 
 /**
  * A general hub node class
@@ -57,6 +58,7 @@ use Org\Mxchange\CoreFramework\Traits\Crypto\CryptoTrait;
 abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
        // Load traits
        use CryptoTrait;
+       use DatabaseFrontendTrait;
 
        /**
         * Node types
@@ -118,11 +120,11 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                // Call parent constructor
                parent::__construct($className);
 
-               // Get a wrapper instance
-               $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_info_db_wrapper_class');
+               // Get a frontend instance
+               $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('node_info_db_frontend_class');
 
                // Set it here
-               $this->setWrapperInstance($wrapperInstance);
+               $this->setFrontendInstance($frontendInstance);
 
                // Get a crypto instance
                $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
@@ -164,8 +166,8 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                $this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString));
                $this->setNodePrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey()));
 
-               // Register the node id with our wrapper
-               $this->getWrapperInstance()->registerPrivateKey($this, $searchInstance);
+               // Register the node id with our frontend
+               $this->getFrontendInstance()->registerPrivateKey($this, $searchInstance);
 
                // Output message
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getNodePrivateKeyHash() . '');
@@ -312,9 +314,9 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
         */
        public function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance) {
                // Is there a node id?
-               if ($this->getWrapperInstance()->ifNodeDataIsFound($this)) {
+               if ($this->getFrontendInstance()->ifNodeDataIsFound($this)) {
                        // Get the node id from result and set it
-                       $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID));
+                       $this->setNodeId($this->getField(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_ID));
 
                        // Output message
                        self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . '');
@@ -328,8 +330,8 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                        // Hash and encrypt the string so we become a node id (also documented as "hub id")
                        $this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
 
-                       // Register the node id with our wrapper
-                       $this->getWrapperInstance()->registerNodeId($this);
+                       // Register the node id with our frontend
+                       $this->getFrontendInstance()->registerNodeId($this);
 
                        // Output message
                        self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . '');
@@ -346,9 +348,9 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                // Search for the node number one which is hard-coded the default
-               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR  , 1);
-               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, FrameworkBootstrap::getRequestInstance()->getRequestElement('mode'));
-               $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID  , $this->getNodeId());
+               $searchInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_NR  , 1);
+               $searchInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE, FrameworkBootstrap::getRequestInstance()->getRequestElement('mode'));
+               $searchInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_ID  , $this->getNodeId());
                $searchInstance->setLimit(1);
 
                // Remember it for later usage
@@ -360,8 +362,8 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                // Hash and encrypt the string so we become a "node id" aka Hub-Id
                $this->setSessionId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
 
-               // Register the node id with our wrapper
-               $this->getWrapperInstance()->registerSessionId($this, $searchInstance);
+               // Register the node id with our frontend
+               $this->getFrontendInstance()->registerSessionId($this, $searchInstance);
 
                // Output message
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
@@ -377,9 +379,9 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
         */
        public function bootstrapGeneratePrivateKey () {
                // Is it valid?
-               if ($this->getWrapperInstance()->ifNodeDataIsFound($this)) {
+               if ($this->getFrontendInstance()->ifNodeDataIsFound($this)) {
                        // Is the element set?
-                       if (is_null($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY))) {
+                       if (is_null($this->getField(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY))) {
                                /*
                                 * Auto-generate the private key for e.g. out-dated database
                                 * "tables". This allows a smooth update for the underlaying
@@ -388,8 +390,8 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                                $this->generatePrivateKeyAndHash($this->getSearchInstance());
                        } else {
                                // Get the node id from result and set it
-                               $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY)));
-                               $this->setNodePrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH));
+                               $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY)));
+                               $this->setNodePrivateKeyHash($this->getField(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH));
 
                                // Output message
                                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getNodePrivateKeyHash() . '');
@@ -414,26 +416,26 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                $requestInstance = FrameworkBootstrap::getRequestInstance();
 
                // Add node number and type
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR  , 1);
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE, $requestInstance->getRequestElement('mode'));
+               $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_NR  , 1);
+               $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE, $requestInstance->getRequestElement('mode'));
 
                // Add the node id
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId());
+               $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_ID, $this->getNodeId());
 
                // Add the session id if acquired
                if ($this->getSessionId() != '') {
-                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
+                       $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_SESSION_ID, $this->getSessionId());
                } // END - if
 
                // Add the private key if acquired
                if ($this->getPrivateKey() != '') {
-                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
-                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getNodePrivateKeyHash());
+                       $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
+                       $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH, $this->getNodePrivateKeyHash());
                } // END - if
 
                // Add own external and internal addresses as UNLs
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL, HubTools::determineOwnInternalAddress());
-               $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL, HubTools::determineOwnExternalAddress());
+               $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL, HubTools::determineOwnInternalAddress());
+               $criteriaInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL, HubTools::determineOwnExternalAddress());
        }
 
        /**
@@ -454,7 +456,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                // Add search criteria
-               $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+               $searchInstance->addCriteria(UserDatabaseFrontend::DB_COLUMN_USERNAME, $this->getUserName());
                $searchInstance->setLimit(1);
 
                // Now get another criteria
@@ -466,8 +468,8 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                // Add the search criteria for searching for the right entry
                $updateInstance->setSearchInstance($searchInstance);
 
-               // Set wrapper class name
-               $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
+               // Set frontend class name
+               $updateInstance->setFrontendConfigEntry('user_db_frontend_class');
 
                // Remember the update in database result
                $this->getResultInstance()->add2UpdateQueue($updateInstance);
@@ -856,7 +858,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
         */
        public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $nodeData) {
                // Add all data the array provides
-               foreach (NodeDistributedHashTableDatabaseWrapper::getAllElements() as $element) {
+               foreach (NodeDistributedHashTableDatabaseFrontend::getAllElements() as $element) {
                        // Is the element there?
                        if (isset($nodeData[$element])) {
                                // Add it
@@ -879,22 +881,22 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
 
                // Create array with all available data
                $nodeData = array(
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR => NULL,
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE => $requestInstance->getRequestElement('mode'),
-                       NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID => $this->getNodeId(),
-                       NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL => HubTools::determineOwnInternalAddress(),
-                       NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL => HubTools::determineOwnExternalAddress(),
+                       NodeInformationDatabaseFrontend::DB_COLUMN_NODE_NR => NULL,
+                       NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE => $requestInstance->getRequestElement('mode'),
+                       NodeInformationDatabaseFrontend::DB_COLUMN_NODE_ID => $this->getNodeId(),
+                       NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL => HubTools::determineOwnInternalAddress(),
+                       NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL => HubTools::determineOwnExternalAddress(),
                );
 
                // Add the session id if acquired
                if ($this->getSessionId() != '') {
-                       $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID] = $this->getSessionId();
+                       $nodeData[NodeInformationDatabaseFrontend::DB_COLUMN_SESSION_ID] = $this->getSessionId();
                } // END - if
 
                // Add the private key if acquired
                if ($this->getPrivateKey() != '') {
-                       $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY] = base64_encode($this->getPrivateKey());
-                       $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH] = $this->getNodePrivateKeyHash();
+                       $nodeData[NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY] = base64_encode($this->getPrivateKey());
+                       $nodeData[NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH] = $this->getNodePrivateKeyHash();
                } // END - if
 
                // Debugging:
index 45cf0b017e0806cb23d330842559fc5d6a9997a5..b02d24a3418d1959aa7cfee77b355ea1bb1db83b 100644 (file)
@@ -7,7 +7,7 @@ use Org\Shipsimu\Hub\Producer\Cruncher\Unit\BaseUnitProducer;
 use Org\Shipsimu\Hub\Producer\Unit\UnitProducer;
 
 // Import framework stuff
-use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
+use Org\Mxchange\CoreFramework\Factory\Database\Frontend\DatabaseFrontendFactory;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory;
 use Org\Mxchange\CoreFramework\Registry\Registerable;
@@ -93,11 +93,11 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer,
         * @todo        ~60% done
         */
        public function initUnitProduction (Stateable $stateInstance) {
-               // First get a database wrapper because we want to permanently store test units
-               $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('cruncher_unit_db_wrapper_class');
+               // First get a database frontend because we want to permanently store test units
+               $frontendInstance = DatabaseFrontendFactory::createFrontendByConfiguredName('cruncher_unit_db_frontend_class');
 
                // Do we have some entries?
-               if ($wrapperInstance->isTestUnitProduced()) {
+               if ($frontendInstance->isTestUnitProduced()) {
                        // Entries found
                        // @TODO Unfinished work here
                        $this->debugInstance(sprintf('[%s:%d]: stateInstance=%s - Unfinished!', __METHOD__, __LINE__, $stateInstance->__toString()));
index edfae077490e05199fda9e70effaf8af85530f0a..026cf496113d1612c425916e0cb6052285cb23e1 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Network\Recipient\Dht;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler;
 use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
 use Org\Shipsimu\Hub\Network\Recipient\BaseRecipient;
@@ -94,14 +94,14 @@ class DhtRecipient extends BaseRecipient implements Recipient {
                        // These array elements must exist for this loop:
                        //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-RECIPIENT: recipient=%s', print_r($recipient, TRUE)));
                        //* DEBUG-DIE: */ die(sprintf('[%s:%d]: recipient=%s', __METHOD__, __LINE__, print_r($recipient, TRUE)));
-                       if (empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) {
+                       if (empty($recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS])) {
                                // External UNL needs to be set
-                               throw new LogicException(sprintf('recipient[%s] is not set', NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS));
+                               throw new LogicException(sprintf('recipient[%s] is not set', NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS));
                        }
 
                        // Add it to the list
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-RECIPIENT: Calling listInstance->addEntry(%s) ...', $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]));
-                       $listInstance->addEntry('unl', $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]);
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-RECIPIENT: Calling listInstance->addEntry(%s) ...', $recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS]));
+                       $listInstance->addEntry('unl', $recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS]);
                }
 
                // Trace message
index 705da89215e450f54dbe4f417c4bf7118693eec3..2867f4d5f42854f384af3a1ce406ccbb7f93c2f9 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Resolver\Protocol\Tcp;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
 use Org\Shipsimu\Hub\Node\Node;
 use Org\Shipsimu\Hub\Resolver\Protocol\BaseProtocolResolver;
@@ -80,7 +80,7 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv
                assert($searchInstance instanceof SearchCriteria);
 
                // Refetch and rewind iterator
-               $resultInstance = $nodeInstance->getWrapperInstance()->doSelectByCriteria($searchInstance);
+               $resultInstance = $nodeInstance->getFrontendInstance()->doSelectByCriteria($searchInstance);
 
                // Is the result valid?
                if ((!$resultInstance->valid()) || (!$resultInstance->next())) {
@@ -96,7 +96,7 @@ class TcpProtocolResolver extends BaseProtocolResolver implements ProtocolResolv
 
                // This should always be the case, if not your database file might be damaged.
                assert(is_array($current));
-               assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]);
+               assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseFrontend::DB_COLUMN_NODE_ID]);
 
                // Get UNL instance and handle over all data
                $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromArray($current);
index 733de785c537473d35ae6145f29cf5a7aa0344bc..bbbbffde3072a2b17c66b3d5b0178a20a462df05 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Tools;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
@@ -121,9 +121,9 @@ class HubTools extends BaseHubSystem {
                //* DEBUG-DIE: */ die(__METHOD__ . ': UNFINISHED: recipient[' . gettype($recipient) . ']=' . print_r($recipient, TRUE) . ',sessionId=' . $sessionId . PHP_EOL);
 
                // Is the recipient valid?
-               if (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) {
+               if (isset($recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS])) {
                        // Then use this
-                       $recipientUnl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS];
+                       $recipientUnl = $recipient[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS];
                } else {
                        // Get the instance, this might throw a NPE
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Creating node instance ...');
@@ -164,11 +164,11 @@ class HubTools extends BaseHubSystem {
 
                // Make sure the node id is there
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE));
-               assert(isset($nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]));
+               assert(isset($nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID]));
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: nodeId=%s - EXIT!', $nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]));
-               return $nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID];
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: nodeId=%s - EXIT!', $nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID]));
+               return $nodeData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_NODE_ID];
        }
 
        /**
@@ -194,7 +194,7 @@ class HubTools extends BaseHubSystem {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: recipientData()=%d', count($recipientData)));
                if (count($recipientData) > 0) {
                        // Get session id
-                       $sessionId = $recipientData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID];
+                       $sessionId = $recipientData[NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_SESSION_ID];
                }
 
                // Return result
index 7559cde75a271f216a78efd28bde18f71ed0b82f..d93a7199a046d85ffbca3ec000bf45fe34bd966a 100644 (file)
@@ -46,16 +46,16 @@ $cfg->setConfigEntry('enable_feature_hubcoin_reward', 'Y');
 $cfg->setConfigEntry('feature_hubcoin_reward_class', 'Org\Shipsimu\Hub\Feature\CoinReward\HubcoinRewardFeature');
 
 // CFG: NODE-INFO-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('node_info_db_wrapper_class', 'Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper');
+$cfg->setConfigEntry('node_info_db_frontend_class', 'Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseFrontend');
 
 // CFG: NODE-DHT-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('node_dht_db_wrapper_class', 'Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper');
+$cfg->setConfigEntry('node_dht_db_frontend_class', 'Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend');
 
 // CFG: NODE-DHT-LIST-LIMIT
 $cfg->setConfigEntry('node_dht_list_limit', 20);
 
 // CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'Org\Shipsimu\Hub\Database\Frontend\Node\PeerState\PeerStateLookupDatabaseWrapper');
+$cfg->setConfigEntry('peer_state_lookup_db_frontend_class', 'Org\Shipsimu\Hub\Database\Frontend\Node\PeerState\PeerStateLookupDatabaseFrontend');
 
 // CFG: WEB-CONTENT-TYPE
 $cfg->setConfigEntry('web_content_type', '');
@@ -1177,7 +1177,7 @@ $cfg->setConfigEntry('stacker_outgoing_queue_max_size', 2000);
 $cfg->setConfigEntry('cruncher_test_unit_max_count', 1000);
 
 // CFG: CRUNCHER-UNIT-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('cruncher_unit_db_wrapper_class', 'Org\Shipsimu\Hub\Database\Frontend\Cruncher\Unit\CruncherUnitDatabaseWrapper');
+$cfg->setConfigEntry('cruncher_unit_db_frontend_class', 'Org\Shipsimu\Hub\Database\Frontend\Cruncher\Unit\CruncherUnitDatabaseFrontend');
 
 // CFG: CRUNCHER-RANDOM-SECRET-MESSAGE-LENGTH
 $cfg->setConfigEntry('random_secret_message_length', 100);
index 172f566817cfd05d70136099fd8c5b1f74f005ee..a419832a1d87648b1a01875b529a7fd51577e32a 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Node\Registering;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
@@ -43,14 +43,12 @@ class NodeAlreadyRegisteredException extends FrameworkException {
                $message = sprintf('[%s:%d] Node already registered: session-id=%s, external-address=%s',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
-                       $messageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID],
-                       $messageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]
+                       $messageArray[1][NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_SESSION_ID],
+                       $messageArray[1][NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS]
                );
 
                // Call parent exception constructor
                parent::__construct($message, $code);
        }
-}
 
-// [EOF]
-?>
+}
index 27ed1f45704fe886edeac85345042ae4c0e47f02..2d86e34d5a78c04c504f51eb140f0b7a2aee916c 100644 (file)
@@ -3,7 +3,7 @@
 namespace Org\Shipsimu\Hub\Node\Data;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
@@ -43,14 +43,12 @@ class NodeDataMissingException extends FrameworkException {
                $message = sprintf('[%s:%d] Node not registered/missing: session-id=%s, external-address=%s',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
-                       $messageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_SESSION_ID],
-                       $messageArray[1][NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS]
+                       $messageArray[1][NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_SESSION_ID],
+                       $messageArray[1][NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_EXTERNAL_ADDRESS]
                );
 
                // Call parent exception constructor
                parent::__construct($message, $code);
        }
-}
 
-// [EOF]
-?>
+}
diff --git a/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php b/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php
deleted file mode 100644 (file)
index 4447fd2..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
-use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
-use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
-use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
-
-/**
- * An interface for distributed hash tables for nodes
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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/>.
- */
-interface NodeDhtWrapper extends DatabaseWrapper {
-       /**
-        * Getter for result instance for unpublished entries
-        *
-        * @return      $unpublishedEntriesInstance             Result instance
-        */
-       function getUnpublishedEntriesInstance ();
-
-       /**
-        * Checks whether the local (*this*) node is registered in the DHT by
-        * checking if the external address is found.
-        *
-        * @return      $isRegistered   Whether *this* node is registered in the DHT
-        */
-       function isLocalNodeRegistered ();
-
-       /**
-        * Registeres the local (*this*) node with its data in the DHT.
-        *
-        * @return      void
-        */
-       function registerLocalNode ();
-
-       /**
-        * Updates local (*this*) node's data in DHT, this is but not limited to the
-        * session id, ip number (and/or hostname) and port number.
-        *
-        * @return      void
-        */
-       function updateLocalNode ();
-
-       /**
-        * Finds a node locally by given session id
-        *
-        * @param       $sessionId      Session id to lookup
-        * @return      $resultInstance         An instance of a SearchableResult class
-        * @throws      InvalidArgumentException        If parameter $sessionId is not valid
-        */
-       function findNodeLocalBySessionId ($sessionId);
-
-       /**
-        * Finds a node locally by given UNL instance
-        *
-        * @param       $locatorInstance        An instance of a LocateableNode class
-        * @return      $resultInstance         An instance of a SearchableResult class
-        */
-       function findNodeLocalByLocatorInstance (LocateableNode $locatorInstance);
-
-       /**
-        * Registeres a node by given message data.
-        *
-        * @param       $messageInstance        An instance of a DeliverableMessage class
-        * @param       $handlerInstance        An instance of a HandleableDataSet class
-        * @return      void
-        */
-       function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance);
-
-       /**
-        * Updates an existing entry in node list
-        *
-        * @param       $messageInstance        An instance of a DeliverableMessage class
-        * @param       $handlerInstance        An instance of a HandleableDataSet class
-        * @param       $searchInstance         An instance of LocalSearchCriteria class
-        * @return      void
-        */
-       function updateNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance);
-
-       /**
-        * Determines whether the given node data is already inserted in the DHT
-        *
-        * @param       $nodeData               An array with valid node data
-        * @return      $isRegistered   Whether the given node data is already inserted
-        */
-       function isNodeRegistered (array $nodeData);
-
-       /**
-        * Registers a node with given data in the DHT. If the node is already
-        * registered this method shall throw an exception.
-        *
-        * @param       $nodeData       An array with valid node data
-        * @return      void
-        * @throws      NodeAlreadyRegisteredException  If the node is already registered
-        */
-       function registerNode (array $nodeData);
-
-       /**
-        * Updates a node's entry in the DHT with given data. This will enrich or
-        * just update already exsiting data. If the node is not found this method
-        * shall throw an exception.
-        *
-        * @param       $nodeData       An array with valid node data
-        * @return      void
-        * @throws      NodeDataMissingException        If the node's data is missing
-        */
-       function updateNode (array $nodeData);
-
-       /**
-        * Checks whether there are unpublished entries
-        *
-        * @return      $hasUnpublished         Whether there are unpublished entries
-        * @todo        Add minimum/maximum age limitations
-        */
-       function hasUnpublishedEntries ();
-
-       /**
-        * Initializes publication of DHT entries. This does only prepare
-        * publication. The next step is to pickup such prepared entries and publish
-        * them by uploading to other (recently appeared) DHT members.
-        *
-        * @return      void
-        * @todo        Add timestamp to dataset instance
-        */
-       function initEntryPublication ();
-
-       /**
-        * Removes non-public data from given array.
-        *
-        * @param       $data   An array with possible non-public data that needs to be removed.
-        * @return      $data   A cleaned up array with only public data.
-        */
-       function removeNonPublicDataFromArray(array $data);
-
-       /**
-        * Find recipients for given package data and exclude the sender
-        *
-        * @param       $packageInstance        An instance of a DeliverablePackage class
-        * @return      $recipients                     An indexed array with DHT recipients
-        */
-       function getResultFromExcludedSender (DeliverablePackage $packageInstance);
-
-       /**
-        * Find recopients by given key/value pair. First look for the key and if it
-        * matches, compare the value.
-        *
-        * @param       $key                    Key to look for
-        * @param       $value                  Value to compare if key matches
-        * @return      $recipients             An indexed array with DHT recipients
-        */
-       function getResultFromKeyValue (string $key, $value);
-
-       /**
-        * Enable DHT bootstrap request acceptance for local node
-        *
-        * @return      void
-        */
-       function enableAcceptDhtBootstrap ();
-
-}
diff --git a/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php b/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php
deleted file mode 100644 (file)
index 86dc982..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Node;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Node\BaseHubNode;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
-
-/**
- * An interface for node-information (database) wrapper
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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/>.
- */
-interface NodeInformationWrapper extends DatabaseWrapper {
-       /**
-        * 'Registers' a new node id along with data provided in the node instance.
-        * This may sound confusing but avoids double code very nicely...
-        *
-        * @param       $nodeInstance           A node instance
-        * @return      void
-        */
-       function registerNodeId (BaseHubNode $nodeInstance);
-
-       /**
-        * 'Registers' a new session id along with data provided in the node instance.
-        * This may sound confusing but avoids double code very nicely...
-        *
-        * @param       $nodeInstance           An instance of a BaseHubNode class
-        * @param       $searchInstance         An instance of a LocalSearchCriteria class
-        * @return      void
-        */
-       function registerSessionId (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance);
-
-       /**
-        * 'Registers' a private key  along with data provided in the node instance.
-        * This may sound confusing but avoids double code very nicely...
-        *
-        * @param       $nodeInstance           An instance of a BaseHubNode class
-        * @param       $requestInstance        An instance of a Requestable class
-        * @param       $searchInstance         An instance of a LocalSearchCriteria class
-        * @return      void
-        */
-       function registerPrivateKey (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance);
-
-}
diff --git a/application/hub/interfaces/database/frontend/class_UnitDatabaseWrapper.php b/application/hub/interfaces/database/frontend/class_UnitDatabaseWrapper.php
deleted file mode 100644 (file)
index 9a7a45a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Database\Frontend\Unit;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
-
-/**
- * An interface for cruncher unit database wrappers
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.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/>.
- */
-interface UnitDatabaseWrapper extends DatabaseWrapper {
-       /**
-        * Checks whether a test unit has been produced
-        *
-        * @return      $isProduced             Whether a test unit has already been produced
-        */
-       function isTestUnitProduced ();
-
-}
diff --git a/application/hub/interfaces/database/frontend/node_dht/class_NodeDhtFrontend.php b/application/hub/interfaces/database/frontend/node_dht/class_NodeDhtFrontend.php
new file mode 100644 (file)
index 0000000..def6db8
--- /dev/null
@@ -0,0 +1,184 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
+use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
+use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
+use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
+
+/**
+ * An interface for distributed hash tables for nodes
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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/>.
+ */
+interface NodeDhtFrontend extends DatabaseFrontend {
+       /**
+        * Getter for result instance for unpublished entries
+        *
+        * @return      $unpublishedEntriesInstance             Result instance
+        */
+       function getUnpublishedEntriesInstance ();
+
+       /**
+        * Checks whether the local (*this*) node is registered in the DHT by
+        * checking if the external address is found.
+        *
+        * @return      $isRegistered   Whether *this* node is registered in the DHT
+        */
+       function isLocalNodeRegistered ();
+
+       /**
+        * Registeres the local (*this*) node with its data in the DHT.
+        *
+        * @return      void
+        */
+       function registerLocalNode ();
+
+       /**
+        * Updates local (*this*) node's data in DHT, this is but not limited to the
+        * session id, ip number (and/or hostname) and port number.
+        *
+        * @return      void
+        */
+       function updateLocalNode ();
+
+       /**
+        * Finds a node locally by given session id
+        *
+        * @param       $sessionId      Session id to lookup
+        * @return      $resultInstance         An instance of a SearchableResult class
+        * @throws      InvalidArgumentException        If parameter $sessionId is not valid
+        */
+       function findNodeLocalBySessionId ($sessionId);
+
+       /**
+        * Finds a node locally by given UNL instance
+        *
+        * @param       $locatorInstance        An instance of a LocateableNode class
+        * @return      $resultInstance         An instance of a SearchableResult class
+        */
+       function findNodeLocalByLocatorInstance (LocateableNode $locatorInstance);
+
+       /**
+        * Registeres a node by given message data.
+        *
+        * @param       $messageInstance        An instance of a DeliverableMessage class
+        * @param       $handlerInstance        An instance of a HandleableDataSet class
+        * @return      void
+        */
+       function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance);
+
+       /**
+        * Updates an existing entry in node list
+        *
+        * @param       $messageInstance        An instance of a DeliverableMessage class
+        * @param       $handlerInstance        An instance of a HandleableDataSet class
+        * @param       $searchInstance         An instance of LocalSearchCriteria class
+        * @return      void
+        */
+       function updateNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance);
+
+       /**
+        * Determines whether the given node data is already inserted in the DHT
+        *
+        * @param       $nodeData               An array with valid node data
+        * @return      $isRegistered   Whether the given node data is already inserted
+        */
+       function isNodeRegistered (array $nodeData);
+
+       /**
+        * Registers a node with given data in the DHT. If the node is already
+        * registered this method shall throw an exception.
+        *
+        * @param       $nodeData       An array with valid node data
+        * @return      void
+        * @throws      NodeAlreadyRegisteredException  If the node is already registered
+        */
+       function registerNode (array $nodeData);
+
+       /**
+        * Updates a node's entry in the DHT with given data. This will enrich or
+        * just update already exsiting data. If the node is not found this method
+        * shall throw an exception.
+        *
+        * @param       $nodeData       An array with valid node data
+        * @return      void
+        * @throws      NodeDataMissingException        If the node's data is missing
+        */
+       function updateNode (array $nodeData);
+
+       /**
+        * Checks whether there are unpublished entries
+        *
+        * @return      $hasUnpublished         Whether there are unpublished entries
+        * @todo        Add minimum/maximum age limitations
+        */
+       function hasUnpublishedEntries ();
+
+       /**
+        * Initializes publication of DHT entries. This does only prepare
+        * publication. The next step is to pickup such prepared entries and publish
+        * them by uploading to other (recently appeared) DHT members.
+        *
+        * @return      void
+        * @todo        Add timestamp to dataset instance
+        */
+       function initEntryPublication ();
+
+       /**
+        * Removes non-public data from given array.
+        *
+        * @param       $data   An array with possible non-public data that needs to be removed.
+        * @return      $data   A cleaned up array with only public data.
+        */
+       function removeNonPublicDataFromArray(array $data);
+
+       /**
+        * Find recipients for given package data and exclude the sender
+        *
+        * @param       $packageInstance        An instance of a DeliverablePackage class
+        * @return      $recipients                     An indexed array with DHT recipients
+        */
+       function getResultFromExcludedSender (DeliverablePackage $packageInstance);
+
+       /**
+        * Find recopients by given key/value pair. First look for the key and if it
+        * matches, compare the value.
+        *
+        * @param       $key                    Key to look for
+        * @param       $value                  Value to compare if key matches
+        * @return      $recipients             An indexed array with DHT recipients
+        */
+       function getResultFromKeyValue (string $key, $value);
+
+       /**
+        * Enable DHT bootstrap request acceptance for local node
+        *
+        * @return      void
+        */
+       function enableAcceptDhtBootstrap ();
+
+}
diff --git a/application/hub/interfaces/database/frontend/node_information/class_NodeInformationFrontend.php b/application/hub/interfaces/database/frontend/node_information/class_NodeInformationFrontend.php
new file mode 100644 (file)
index 0000000..b03d171
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Node;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Node\BaseHubNode;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
+
+/**
+ * An interface for node-information (database) frontend
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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/>.
+ */
+interface NodeInformationFrontend extends DatabaseFrontend {
+       /**
+        * 'Registers' a new node id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           A node instance
+        * @return      void
+        */
+       function registerNodeId (BaseHubNode $nodeInstance);
+
+       /**
+        * 'Registers' a new session id along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           An instance of a BaseHubNode class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return      void
+        */
+       function registerSessionId (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance);
+
+       /**
+        * 'Registers' a private key  along with data provided in the node instance.
+        * This may sound confusing but avoids double code very nicely...
+        *
+        * @param       $nodeInstance           An instance of a BaseHubNode class
+        * @param       $requestInstance        An instance of a Requestable class
+        * @param       $searchInstance         An instance of a LocalSearchCriteria class
+        * @return      void
+        */
+       function registerPrivateKey (BaseHubNode $nodeInstance, LocalSearchCriteria $searchInstance);
+
+}
diff --git a/application/hub/interfaces/database/frontend/work_unit/class_UnitDatabaseFrontend.php b/application/hub/interfaces/database/frontend/work_unit/class_UnitDatabaseFrontend.php
new file mode 100644 (file)
index 0000000..6f33eec
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Database\Frontend\Unit;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend;
+
+/**
+ * An interface for cruncher unit database frontends
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.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/>.
+ */
+interface UnitDatabaseFrontend extends DatabaseFrontend {
+       /**
+        * Checks whether a test unit has been produced
+        *
+        * @return      $isProduced             Whether a test unit has already been produced
+        */
+       function isTestUnitProduced ();
+
+}
index d3e839fb244b5d12482e31b875c19e7ae5154905..9305d77b18e5c15917308df1bae7ddd4df579a2c 100644 (file)
@@ -13,7 +13,7 @@ use Org\Shipsimu\Hub\State\Peer\PeerStateable;
 use Org\Mxchange\CoreFramework\State\Stateable;
 
 /**
- * An interface for peer-state lookup table wrappers
+ * An interface for peer-state lookup table frontends
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
diff --git a/core b/core
index 9a7a272f04e54537aaf30c282598c1742fe0ad88..303d853c3d98734f9d7a1a0445c98b6d6c444945 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 9a7a272f04e54537aaf30c282598c1742fe0ad88
+Subproject commit 303d853c3d98734f9d7a1a0445c98b6d6c444945