From 77c4dd80014f65257334f04602ef46aba4eaf823 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 2 Dec 2020 01:54:27 +0100 Subject: [PATCH] Continued: - renamed "Wrapper" to "Frontend" (was pending anyway) - added missing trait for above instance - updated core framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ....php => class_BaseHubDatabaseFrontend.php} | 6 +- ...=> class_CruncherUnitDatabaseFrontend.php} | 20 ++--- ...eDistributedHashTableDatabaseFrontend.php} | 28 +++---- ...class_NodeInformationDatabaseFrontend.php} | 24 +++--- ...class_PeerStateLookupDatabaseFrontend.php} | 18 ++-- application/hub/classes/dht/class_BaseDht.php | 18 ++-- .../classes/dht/node/class_NodeDhtFacade.php | 52 ++++++------ .../states/peer/class_PeerStateFactory.php | 2 +- ...lass_NodeAnnouncementAnswerOkayHandler.php | 6 +- .../class_NodeMessageAnnouncementHandler.php | 8 +- .../class_NodeMessageDhtBootstrapHandler.php | 8 +- ...lass_NodeMessageRequestNodeListHandler.php | 6 +- .../package/class_NetworkPackageHandler.php | 8 +- .../locator/class_UniversalNodeLocator.php | 38 ++++----- .../hub/classes/nodes/class_BaseHubNode.php | 84 ++++++++++--------- .../class_CruncherTestUnitProducer.php | 8 +- .../recipient/dht/class_DhtRecipient.php | 10 +-- .../tcp/class_TcpProtocolResolver.php | 6 +- .../hub/classes/tools/hub/class_HubTools.php | 14 ++-- application/hub/config.php | 8 +- .../class_NodeAlreadyRegisteredException.php | 10 +-- .../class_NodeDataMissingException.php | 10 +-- .../class_NodeDhtFrontend.php} | 4 +- .../class_NodeInformationFrontend.php} | 6 +- .../class_UnitDatabaseFrontend.php} | 6 +- .../peer_states/class_LookupablePeerState.php | 2 +- core | 2 +- 27 files changed, 207 insertions(+), 205 deletions(-) rename application/hub/classes/database/frontend/{class_BaseHubDatabaseWrapper.php => class_BaseHubDatabaseFrontend.php} (96%) rename application/hub/classes/database/frontend/cruncher/{class_CruncherUnitDatabaseWrapper.php => class_CruncherUnitDatabaseFrontend.php} (79%) rename application/hub/classes/database/frontend/{node/class_NodeDistributedHashTableDatabaseWrapper.php => node_dht/class_NodeDistributedHashTableDatabaseFrontend.php} (96%) rename application/hub/classes/database/frontend/{node/class_NodeInformationDatabaseWrapper.php => node_information/class_NodeInformationDatabaseFrontend.php} (86%) rename application/hub/classes/database/frontend/states/{class_PeerStateLookupDatabaseWrapper.php => class_PeerStateLookupDatabaseFrontend.php} (95%) rename application/hub/interfaces/database/frontend/{class_NodeDhtWrapper.php => node_dht/class_NodeDhtFrontend.php} (98%) rename application/hub/interfaces/database/frontend/{class_NodeInformationWrapper.php => node_information/class_NodeInformationFrontend.php} (92%) rename application/hub/interfaces/database/frontend/{class_UnitDatabaseWrapper.php => work_unit/class_UnitDatabaseFrontend.php} (86%) diff --git a/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php b/application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php similarity index 96% rename from application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php rename to application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php index 67373b655..ef72ac266 100644 --- a/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php @@ -10,11 +10,11 @@ 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\Database\Frontend\BaseDatabaseFrontend; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; /** - * A general hub database wrapper + * A general hub database frontend * * @author Roland Haeder * @version 0.0.0 @@ -35,7 +35,7 @@ use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -abstract class BaseHubDatabaseWrapper extends BaseDatabaseWrapper implements HubInterface { +abstract class BaseHubDatabaseFrontend extends BaseDatabaseFrontend implements HubInterface { /** * Listener instance */ diff --git a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseFrontend.php similarity index 79% rename from application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php rename to application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseFrontend.php index fcffd06fe..7e94017f3 100644 --- a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseFrontend.php @@ -3,8 +3,8 @@ 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\Database\Frontend\BaseHubDatabaseFrontend; +use Org\Shipsimu\Hub\Database\Frontend\Unit\UnitDatabaseFrontend; use Org\Shipsimu\Hub\Producer\Cruncher\Unit\BaseUnitProducer; // Import framework stuff @@ -12,7 +12,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; /** - * A database wrapper for cruncher work/test units + * A database frontend for cruncher work/test units * * @author Roland Haeder * @version 0.0.0 @@ -33,7 +33,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class CruncherUnitDatabaseWrapper extends BaseHubDatabaseWrapper implements UnitDatabaseWrapper, Registerable { +class CruncherUnitDatabaseFrontend extends BaseHubDatabaseFrontend implements UnitDatabaseFrontend, Registerable { // Constants for database table names const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units'; @@ -52,19 +52,19 @@ class CruncherUnitDatabaseWrapper extends BaseHubDatabaseWrapper implements Unit } /** - * Creates an instance of this database wrapper by a provided user class + * Creates an instance of this database frontend by a provided user class * - * @return $wrapperInstance An instance of the created wrapper class + * @return $frontendInstance An instance of the created frontend class */ - public static final function createCruncherUnitDatabaseWrapper () { + public static final function createCruncherUnitDatabaseFrontend () { // Get a new instance - $wrapperInstance = new CruncherUnitDatabaseWrapper(); + $frontendInstance = new CruncherUnitDatabaseFrontend(); // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS); + $frontendInstance->setTableName(self::DB_TABLE_CRUNCHER_UNITS); // Return the instance - return $wrapperInstance; + return $frontendInstance; } /** diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php similarity index 96% rename from application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php rename to application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php index 353786137..b4c63f919 100644 --- a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node_dht/class_NodeDistributedHashTableDatabaseFrontend.php @@ -3,7 +3,7 @@ namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht; // Import application-specific stuff -use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseWrapper; +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; @@ -23,7 +23,7 @@ use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; use \InvalidArgumentException; /** - * A database wrapper for distributed hash tables + * A database frontend for distributed hash tables * * @author Roland Haeder * @version 0.0.0 @@ -44,7 +44,7 @@ use \InvalidArgumentException; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeDhtWrapper, Registerable { +class NodeDistributedHashTableDatabaseFrontend extends BaseHubDatabaseFrontend implements NodeDhtFrontend, Registerable { /** * "Cached" results for dabase for looking for unpublished entries */ @@ -83,26 +83,26 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp } /** - * Creates an instance of this database wrapper by a provided user class + * Creates an instance of this database frontend by a provided user class * - * @return $wrapperInstance An instance of the created wrapper class + * @return $frontendInstance An instance of the created frontend class */ - public static final function createNodeDistributedHashTableDatabaseWrapper () { + public static final function createNodeDistributedHashTableDatabaseFrontend () { // Get a new instance - $wrapperInstance = new NodeDistributedHashTableDatabaseWrapper(); + $frontendInstance = new NodeDistributedHashTableDatabaseFrontend(); // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_NODE_DHT); + $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 - $wrapperInstance->setNodeInstance($nodeInstance); + $frontendInstance->setNodeInstance($nodeInstance); // Return the instance - return $wrapperInstance; + return $frontendInstance; } /** @@ -553,7 +553,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $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); + $searchInstance->addExcludeCriteria(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_PUBLICATION_STATUS, NodeDistributedHashTableDatabaseFrontend::PUBLICATION_STATUS_PENDING); // Remember search instance $this->setSearchInstance($searchInstance); @@ -649,12 +649,12 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $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()); + $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 wrapper. + // Get a result instance back from DHT database frontend. $resultInstance = $this->doSelectByCriteria($searchInstance); // Debug message @@ -690,7 +690,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp // Find the key/value pair $searchInstance->addCriteria($key, $value); - // Get a result instance back from DHT database wrapper. + // Get a result instance back from DHT database frontend. $resultInstance = $this->doSelectByCriteria($searchInstance); // Return result instance diff --git a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php b/application/hub/classes/database/frontend/node_information/class_NodeInformationDatabaseFrontend.php similarity index 86% rename from application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php rename to application/hub/classes/database/frontend/node_information/class_NodeInformationDatabaseFrontend.php index 702a228e3..51945050b 100644 --- a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node_information/class_NodeInformationDatabaseFrontend.php @@ -3,8 +3,8 @@ 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\Database\Frontend\BaseHubDatabaseFrontend; +use Org\Shipsimu\Hub\Database\Frontend\Node\NodeInformationFrontend; use Org\Shipsimu\Hub\Node\BaseHubNode; use Org\Shipsimu\Hub\Node\Node; @@ -15,7 +15,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Registry\Registerable; /** - * A database wrapper for node informations + * A database frontend for node informations * * @author Roland Haeder * @version 0.0.0 @@ -36,7 +36,7 @@ use Org\Mxchange\CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeInformationWrapper, Registerable { +class NodeInformationDatabaseFrontend extends BaseHubDatabaseFrontend implements NodeInformationFrontend, Registerable { // Constants for database table names const DB_TABLE_NODE_INFORMATION = 'node_data'; @@ -61,19 +61,19 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N } /** - * Creates an instance of this database wrapper by a provided user class + * Creates an instance of this database frontend by a provided user class * - * @return $wrapperInstance An instance of the created wrapper class + * @return $frontendInstance An instance of the created frontend class */ - public static final function createNodeInformationDatabaseWrapper () { + public static final function createNodeInformationDatabaseFrontend () { // Get a new instance - $wrapperInstance = new NodeInformationDatabaseWrapper(); + $frontendInstance = new NodeInformationDatabaseFrontend(); // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_NODE_INFORMATION); + $frontendInstance->setTableName(self::DB_TABLE_NODE_INFORMATION); // Return the instance - return $wrapperInstance; + return $frontendInstance; } /** @@ -89,8 +89,8 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N $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(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_NR , 1); + $searchInstance->addCriteria(NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE, FrameworkBootstrap::getRequestInstance()->getRequestElement('mode')); $searchInstance->setLimit(1); // Get a result back diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php similarity index 95% rename from application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php rename to application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php index 594de0a5f..bd4b101a5 100644 --- a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseFrontend.php @@ -4,7 +4,7 @@ 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\Database\Frontend\BaseHubDatabaseFrontend; use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\LookupTable\Lookupable; @@ -18,7 +18,7 @@ use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; /** - * A database wrapper for peer state lookups + * A database frontend for peer state lookups * * @author Roland Haeder * @version 0.0.0 @@ -39,7 +39,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements LookupablePeerState { +class PeerStateLookupDatabaseFrontend extends BaseHubDatabaseFrontend implements LookupablePeerState { // Exception constants const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300; @@ -65,19 +65,19 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L } /** - * Creates an instance of this database wrapper by a provided user class + * Creates an instance of this database frontend by a provided user class * - * @return $wrapperInstance An instance of the created wrapper class + * @return $frontendInstance An instance of the created frontend class */ - public static final function createPeerStateLookupDatabaseWrapper () { + public static final function createPeerStateLookupDatabaseFrontend () { // Get a new instance - $wrapperInstance = new PeerStateLookupDatabaseWrapper(); + $frontendInstance = new PeerStateLookupDatabaseFrontend(); // Set (primary!) table name - $wrapperInstance->setTableName(self::DB_TABLE_PEER_LOOKUP); + $frontendInstance->setTableName(self::DB_TABLE_PEER_LOOKUP); // Return the instance - return $wrapperInstance; + return $frontendInstance; } /** diff --git a/application/hub/classes/dht/class_BaseDht.php b/application/hub/classes/dht/class_BaseDht.php index 8dea3537a..fda923cc6 100644 --- a/application/hub/classes/dht/class_BaseDht.php +++ b/application/hub/classes/dht/class_BaseDht.php @@ -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(); } } diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php index 97a635f7e..9f6e1d3ba 100644 --- a/application/hub/classes/dht/node/class_NodeDhtFacade.php +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -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 . */ 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); diff --git a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php index b05911cdb..b50c2f698 100644 --- a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php +++ b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php @@ -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 diff --git a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php index 809c9ff48..21089bf56 100644 --- a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php +++ b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php @@ -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); } } diff --git a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php index 4da7d4b78..2cfd2a8e1 100644 --- a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -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); } } diff --git a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index e7c3da706..f4b55509e 100644 --- a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -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'); } diff --git a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php index 45f89edea..936a9dea0 100644 --- a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -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'); } diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index be6c3ad6c..a338aecaa 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -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 diff --git a/application/hub/classes/locator/class_UniversalNodeLocator.php b/application/hub/classes/locator/class_UniversalNodeLocator.php index c2141c444..db0302bd0 100644 --- a/application/hub/classes/locator/class_UniversalNodeLocator.php +++ b/application/hub/classes/locator/class_UniversalNodeLocator.php @@ -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; } } diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 79024c1de..e37275f7e 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -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: diff --git a/application/hub/classes/producer/cruncher/work_units/cruncher/class_CruncherTestUnitProducer.php b/application/hub/classes/producer/cruncher/work_units/cruncher/class_CruncherTestUnitProducer.php index 45cf0b017..b02d24a34 100644 --- a/application/hub/classes/producer/cruncher/work_units/cruncher/class_CruncherTestUnitProducer.php +++ b/application/hub/classes/producer/cruncher/work_units/cruncher/class_CruncherTestUnitProducer.php @@ -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())); diff --git a/application/hub/classes/recipient/dht/class_DhtRecipient.php b/application/hub/classes/recipient/dht/class_DhtRecipient.php index edfae0774..026cf4961 100644 --- a/application/hub/classes/recipient/dht/class_DhtRecipient.php +++ b/application/hub/classes/recipient/dht/class_DhtRecipient.php @@ -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 diff --git a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php index 705da8921..2867f4d5f 100644 --- a/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php +++ b/application/hub/classes/resolver/protocol/tcp/class_TcpProtocolResolver.php @@ -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); diff --git a/application/hub/classes/tools/hub/class_HubTools.php b/application/hub/classes/tools/hub/class_HubTools.php index 733de785c..bbbbffde3 100644 --- a/application/hub/classes/tools/hub/class_HubTools.php +++ b/application/hub/classes/tools/hub/class_HubTools.php @@ -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 diff --git a/application/hub/config.php b/application/hub/config.php index 7559cde75..d93a7199a 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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); diff --git a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php index 172f56681..a419832a1 100644 --- a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php +++ b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php @@ -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] -?> +} diff --git a/application/hub/exceptions/wrapper/class_NodeDataMissingException.php b/application/hub/exceptions/wrapper/class_NodeDataMissingException.php index 27ed1f457..2d86e34d5 100644 --- a/application/hub/exceptions/wrapper/class_NodeDataMissingException.php +++ b/application/hub/exceptions/wrapper/class_NodeDataMissingException.php @@ -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/node_dht/class_NodeDhtFrontend.php similarity index 98% rename from application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php rename to application/hub/interfaces/database/frontend/node_dht/class_NodeDhtFrontend.php index 4447fd20f..def6db848 100644 --- a/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php +++ b/application/hub/interfaces/database/frontend/node_dht/class_NodeDhtFrontend.php @@ -9,7 +9,7 @@ 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\Database\Frontend\DatabaseFrontend; use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet; /** @@ -34,7 +34,7 @@ use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface NodeDhtWrapper extends DatabaseWrapper { +interface NodeDhtFrontend extends DatabaseFrontend { /** * Getter for result instance for unpublished entries * diff --git a/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php b/application/hub/interfaces/database/frontend/node_information/class_NodeInformationFrontend.php similarity index 92% rename from application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php rename to application/hub/interfaces/database/frontend/node_information/class_NodeInformationFrontend.php index 86dc982c2..b03d17188 100644 --- a/application/hub/interfaces/database/frontend/class_NodeInformationWrapper.php +++ b/application/hub/interfaces/database/frontend/node_information/class_NodeInformationFrontend.php @@ -7,10 +7,10 @@ use Org\Shipsimu\Hub\Node\BaseHubNode; // Import framework stuff use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria; -use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend; /** - * An interface for node-information (database) wrapper + * An interface for node-information (database) frontend * * @author Roland Haeder * @version 0.0.0 @@ -31,7 +31,7 @@ use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface NodeInformationWrapper extends DatabaseWrapper { +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... diff --git a/application/hub/interfaces/database/frontend/class_UnitDatabaseWrapper.php b/application/hub/interfaces/database/frontend/work_unit/class_UnitDatabaseFrontend.php similarity index 86% rename from application/hub/interfaces/database/frontend/class_UnitDatabaseWrapper.php rename to application/hub/interfaces/database/frontend/work_unit/class_UnitDatabaseFrontend.php index 9a7a45a68..6f33eec82 100644 --- a/application/hub/interfaces/database/frontend/class_UnitDatabaseWrapper.php +++ b/application/hub/interfaces/database/frontend/work_unit/class_UnitDatabaseFrontend.php @@ -3,10 +3,10 @@ namespace Org\Shipsimu\Hub\Database\Frontend\Unit; // Import framework stuff -use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; +use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseFrontend; /** - * An interface for cruncher unit database wrappers + * An interface for cruncher unit database frontends * * @author Roland Haeder * @version 0.0.0 @@ -27,7 +27,7 @@ use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface UnitDatabaseWrapper extends DatabaseWrapper { +interface UnitDatabaseFrontend extends DatabaseFrontend { /** * Checks whether a test unit has been produced * diff --git a/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php b/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php index d3e839fb2..9305d77b1 100644 --- a/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php +++ b/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php @@ -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 * @version 0.0.0 diff --git a/core b/core index 9a7a272f0..303d853c3 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9a7a272f04e54537aaf30c282598c1742fe0ad88 +Subproject commit 303d853c3d98734f9d7a1a0445c98b6d6c444945 -- 2.39.5