From 916e2f10ba8e34f2f762fa746f1041aa99c921b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 22 May 2017 19:05:37 +0200 Subject: [PATCH] Continued: - imported Distributable - imported FiLoStacker - imported BaseState - imported NodeDistributedHashTableDatabaseWrapper - created/added namespaces - setter/getter for DHT instance is no longer working and maybe okay to use DhtObjectFactory instead. Okay, a few more calls then, but well. - renamed HubPingIterator -> NodePingIterator - updated core framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- application/hub/classes/dht/class_ | 7 +++ application/hub/classes/dht/class_BaseDht.php | 2 + .../classes/dht/node/class_NodeDhtFacade.php | 4 +- .../dht/class_DhtRecipientDiscovery.php | 12 +---- .../states/dht/class_DhtStateFactory.php | 8 +-- ...lass_NodeAnnouncementAnswerOkayHandler.php | 3 +- ...class_RequestNodeListAnswerOkayHandler.php | 4 +- .../class_NodeMessageAnnouncementHandler.php | 1 + .../class_BaseMessageHandler.php | 2 +- .../class_NodeMessageDhtBootstrapHandler.php | 9 +--- ...lass_NodeMessageRequestNodeListHandler.php | 3 +- .../raw_data/class_BaseDataHandler.php | 6 --- .../helper/dht/class_DhtBootstrapHelper.php | 3 +- .../dht/class_DhtPublishEntryHelper.php | 3 +- .../classes/iterator/{hub => node}/.htaccess | 0 .../class_NodePingIterator.php} | 8 +-- .../hub/classes/nodes/class_BaseHubNode.php | 1 + .../classes/package/class_NetworkPackage.php | 1 + .../recipient/dht/class_DhtRecipient.php | 1 + .../class_BaseCommunicatorState.php | 6 +++ .../states/crawler/class_BaseCrawlerState.php | 6 +++ .../cruncher/class_BaseCruncherState.php | 6 +++ .../dht/active/class_DhtActiveState.php | 10 ++-- .../dht/booting/class_DhtBootingState.php | 10 ++-- .../classes/states/dht/class_BaseDhtState.php | 6 +++ application/hub/classes/states/dht/class_Dht | 10 ++-- .../states/dht/init/class_DhtInitState.php | 13 +++-- .../dht/virgin/class_DhtVirginState.php | 13 +++-- .../states/miner/class_BaseMinerState.php | 6 +++ .../states/peer/class_BasePeerState.php | 6 +++ .../node/dht/class_NodeDhtBootstrapTask.php | 12 +---- .../dht/class_NodeDhtInitializationTask.php | 12 +---- .../dht/class_NodeDhtLateBootstrapTask.php | 12 +---- .../dht/class_NodeDhtPublicationCheckTask.php | 12 +---- .../node/dht/class_NodeDhtPublicationTask.php | 12 +---- .../tasks/node/dht/class_NodeDhtQueryTask.php | 12 +---- .../hub/classes/tools/class_HubTools.php | 13 ++--- application/hub/config.php | 50 +++++++++---------- .../class_NodeAlreadyRegisteredException.php | 3 ++ .../class_NodeDataMissingException.php | 3 ++ .../node/class_DistributableNode.php | 7 +-- .../helper/dht/class_HelpableDht.php | 1 + core | 2 +- 43 files changed, 153 insertions(+), 168 deletions(-) rename application/hub/classes/iterator/{hub => node}/.htaccess (100%) rename application/hub/classes/iterator/{hub/class_HubPingIterator.php => node/class_NodePingIterator.php} (92%) diff --git a/application/hub/classes/dht/class_ b/application/hub/classes/dht/class_ index 92d40c8f5..cf2444172 100644 --- a/application/hub/classes/dht/class_ +++ b/application/hub/classes/dht/class_ @@ -1,4 +1,11 @@ setDhtInstance($dhtInstance); - // Return the prepared instance return $discoveryInstance; } @@ -68,12 +62,10 @@ class DhtRecipientDiscovery extends BaseRecipientDiscovery implements Discoverab */ public function resolveRecipientsByPackageData (array $packageData) { // Use facade to get recipients back - $recipients = $this->getDhtInstance()->findRecipientsByPackageData($packageData); + $recipients = DhtObjectFactory::createDhtInstance('node')->findRecipientsByPackageData($packageData); // Return it return $recipients; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/dht/class_DhtStateFactory.php b/application/hub/classes/factories/states/dht/class_DhtStateFactory.php index 9085cd3fc..03ebd954d 100644 --- a/application/hub/classes/factories/states/dht/class_DhtStateFactory.php +++ b/application/hub/classes/factories/states/dht/class_DhtStateFactory.php @@ -2,6 +2,10 @@ // Own namespace namespace Hub\Factory\State\Dht; +// Import application-specific stuff +use Hub\Dht\Distributable; +use Hub\Factory\State\Dht\DhtStateFactory; + // Import framework stuff use CoreFramework\Factory\ObjectFactory; @@ -65,7 +69,5 @@ class DhtStateFactory extends ObjectFactory { // For any purposes, return the state instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php index 3494284e7..a55714d15 100644 --- a/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php +++ b/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php @@ -3,6 +3,7 @@ namespace Hub\Handler\Node\Announcement\Answer; // Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Node\NodeObjectFactory; use Hub\Network\Receive\Receivable; use Hub\Node\BaseHubNode; @@ -79,7 +80,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implement * Query DHT and force update (which will throw an exception if the * node is not found). */ - $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); + DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this, TRUE); // Get handler instance $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); diff --git a/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php index 0ea6e20b5..3199bb5d2 100644 --- a/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php +++ b/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php @@ -85,13 +85,13 @@ class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements unset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]); // Write node list to DHT - $this->getDhtInstance()->insertNodeList($nodeList); + DhtObjectFactory::createDhtInstance('node')->insertNodeList($nodeList); /* * Query DHT and force update (which will throw an exception if the * node is not found). */ - $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE); + DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this, TRUE); // Prepare next message ("hello" message to all returned nodes) //$this->prepareNextMessage($messageData, $packageInstance); diff --git a/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php index 2931e81fa..1882fb2e3 100644 --- a/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ b/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -3,6 +3,7 @@ namespace Hub\Handler\Node\Message\Announcement; // Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Node\NodeObjectFactory; use Hub\Generic\BaseHubSystem; use Hub\Network\Receive\Receivable; diff --git a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php index e502920a4..f9038c8ff 100644 --- a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php +++ b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php @@ -79,7 +79,7 @@ abstract class BaseMessageHandler extends BaseDataHandler { assert(count($this->getSearchData()) > 0); // Let the DHT facade do the work - $this->getDhtInstance()->registerNodeByMessageData($messageData, $this); + DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this); } /** diff --git a/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index c431f3a97..bcffb8394 100644 --- a/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -3,6 +3,7 @@ namespace Hub\Handler\Node\Answer\Dht\Bootstrap; // Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Dht\DhtObjectFactory; use Hub\Factory\Node\NodeObjectFactory; use Hub\Network\Receive\Receivable; @@ -85,12 +86,6 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl // Get new instance $handlerInstance = new NodeMessageDhtBootstrapHandler(); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $handlerInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $handlerInstance; } @@ -179,7 +174,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl * DHT nodes that accept bootstrap requests are read from the DHT * database. */ - $nodeList = $this->getDhtInstance()->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y'); + $nodeList = DhtObjectFactory::createDhtInstance('node')->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y'); // Make sure it is an array and has at least one entry assert(is_array($nodeList)); diff --git a/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php index a9ca0bf3f..1cefd96e5 100644 --- a/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -3,6 +3,7 @@ namespace Hub\Handler\Node\Message\Request\NodeList; // Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Node\NodeObjectFactory; use Hub\Network\Receive\Receivable; use Hub\Node\BaseHubNode; @@ -143,7 +144,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha } // END - foreach // Query local DHT for nodes except given session id - $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData( + $nodeList = DhtObjectFactory::createDhtInstance('node')->queryLocalNodeListExceptByMessageData( $messageData, $this, XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, diff --git a/application/hub/classes/handler/raw_data/class_BaseDataHandler.php b/application/hub/classes/handler/raw_data/class_BaseDataHandler.php index dcc7896e1..b6a47f15a 100644 --- a/application/hub/classes/handler/raw_data/class_BaseDataHandler.php +++ b/application/hub/classes/handler/raw_data/class_BaseDataHandler.php @@ -68,12 +68,6 @@ abstract class BaseDataHandler extends BaseHandler { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set it here - $this->setDhtInstance($dhtInstance); } /** diff --git a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php index 5c296512a..29fdc3477 100644 --- a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php +++ b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php @@ -2,7 +2,8 @@ // Own namespace namespace Hub\Helper\Dht\Bootstrap; -// Import hub-specific stuff +// Import application-specific stuff +use Hub\Dht\Distributable; use Hub\Generic\BaseHubSystem; use Hub\Helper\BaseHubSystemHelper; use Hub\Network\Package\NetworkPackage; diff --git a/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php b/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php index c3099dda1..174f3e9dc 100644 --- a/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php +++ b/application/hub/classes/helper/dht/class_DhtPublishEntryHelper.php @@ -2,7 +2,8 @@ // Own namespace namespace Hub\Helper\Dht\Publish; -// Import hub-specific stuff +// Import application-specific stuff +use Hub\Dht\Distributable; use Hub\Generic\BaseHubSystem; use Hub\Helper\BaseHubSystemHelper; use Hub\Network\Package\NetworkPackage; diff --git a/application/hub/classes/iterator/hub/.htaccess b/application/hub/classes/iterator/node/.htaccess similarity index 100% rename from application/hub/classes/iterator/hub/.htaccess rename to application/hub/classes/iterator/node/.htaccess diff --git a/application/hub/classes/iterator/hub/class_HubPingIterator.php b/application/hub/classes/iterator/node/class_NodePingIterator.php similarity index 92% rename from application/hub/classes/iterator/hub/class_HubPingIterator.php rename to application/hub/classes/iterator/node/class_NodePingIterator.php index 4600d0ef9..905e4f0fd 100644 --- a/application/hub/classes/iterator/hub/class_HubPingIterator.php +++ b/application/hub/classes/iterator/node/class_NodePingIterator.php @@ -1,6 +1,6 @@ . */ -class HubPingIterator extends BaseIterator implements Iterator { +class NodePingIterator extends BaseIterator implements Iterator { /** * Protected constructor * @@ -46,9 +46,9 @@ class HubPingIterator extends BaseIterator implements Iterator { * * @return $iteratorInstance An instance of a Iterator class */ - public static final function createHubPingIterator () { + public static final function createNodePingIterator () { // Get new instance - $iteratorInstance = new HubPingIterator(); + $iteratorInstance = new NodePingIterator(); // Return the prepared instance return $iteratorInstance; diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 7d653a786..e57002eb6 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -3,6 +3,7 @@ namespace Hub\Node; // Import hub-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper; use Hub\Factory\State\Node\NodeStateFactory; use Hub\Locator\Node\LocateableNode; diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php index 5a218e6b3..feeca4db2 100644 --- a/application/hub/classes/package/class_NetworkPackage.php +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -4,6 +4,7 @@ namespace Hub\Network\Package; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Assembler\Package\PackageAssemblerFactory; use Hub\Factory\Dht\DhtObjectFactory; use Hub\Factory\Information\Connection\ConnectionInfoFactory; diff --git a/application/hub/classes/recipient/dht/class_DhtRecipient.php b/application/hub/classes/recipient/dht/class_DhtRecipient.php index 2d4511fed..2e3e2a78d 100644 --- a/application/hub/classes/recipient/dht/class_DhtRecipient.php +++ b/application/hub/classes/recipient/dht/class_DhtRecipient.php @@ -3,6 +3,7 @@ namespace Hub\Recipient\Dht; // Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Network\Package\NetworkPackage; // Import framework stuff diff --git a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php index 32a055406..bfb80130b 100644 --- a/application/hub/classes/states/communicator/class_BaseCommunicatorState.php +++ b/application/hub/classes/states/communicator/class_BaseCommunicatorState.php @@ -1,4 +1,10 @@ debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/dht/booting/class_DhtBootingState.php b/application/hub/classes/states/dht/booting/class_DhtBootingState.php index 51f864cda..1059659cf 100644 --- a/application/hub/classes/states/dht/booting/class_DhtBootingState.php +++ b/application/hub/classes/states/dht/booting/class_DhtBootingState.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\State\Dht; +// Import application-specific stuff +use Hub\Dht\Distributable; + // Import application-specific stuff use Hub\Factory\Node\NodeObjectFactory; @@ -57,9 +60,6 @@ class DhtBootingState extends BaseDhtState implements Stateable { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - // Get node instance and enable DHT bootstrap requests NodeObjectFactory::createNodeInstance()->enableAcceptDhtBootstrap(); @@ -69,7 +69,5 @@ class DhtBootingState extends BaseDhtState implements Stateable { // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/dht/class_BaseDhtState.php b/application/hub/classes/states/dht/class_BaseDhtState.php index 44e0b5584..f6051285e 100644 --- a/application/hub/classes/states/dht/class_BaseDhtState.php +++ b/application/hub/classes/states/dht/class_BaseDhtState.php @@ -1,4 +1,10 @@ debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/dht/init/class_DhtInitState.php b/application/hub/classes/states/dht/init/class_DhtInitState.php index e08a84c9d..02a0690ac 100644 --- a/application/hub/classes/states/dht/init/class_DhtInitState.php +++ b/application/hub/classes/states/dht/init/class_DhtInitState.php @@ -2,6 +2,10 @@ // Own namespace namespace Hub\State\Dht; +// Import application-specific stuff +use Hub\Dht\Distributable; +use Hub\Factory\State\Dht\DhtStateFactory; + // Import framework stuff use CoreFramework\State\Stateable; @@ -54,9 +58,6 @@ class DhtInitState extends BaseDhtState implements Stateable { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $stateInstance; } @@ -69,9 +70,7 @@ class DhtInitState extends BaseDhtState implements Stateable { */ public function dhtHasInitialized () { // Create a new instance - DhtStateFactory::createDhtStateInstanceByName('virgin', $this->getDhtInstance()); + DhtStateFactory::createDhtStateInstanceByName('virgin', DhtObjectFactory::createDhtInstance('node')); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/dht/virgin/class_DhtVirginState.php b/application/hub/classes/states/dht/virgin/class_DhtVirginState.php index 3dc2b82e7..322c17f79 100644 --- a/application/hub/classes/states/dht/virgin/class_DhtVirginState.php +++ b/application/hub/classes/states/dht/virgin/class_DhtVirginState.php @@ -2,6 +2,10 @@ // Own namespace namespace Hub\State\Dht; +// Import application-specific stuff +use Hub\Dht\Distributable; +use Hub\Factory\State\Dht\DhtStateFactory; + // Import framework stuff use CoreFramework\State\Stateable; @@ -54,9 +58,6 @@ class DhtVirginState extends BaseDhtState implements Stateable { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); - // Set the dht instance - $stateInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $stateInstance; } @@ -69,9 +70,7 @@ class DhtVirginState extends BaseDhtState implements Stateable { */ public function dhtIsBooting () { // Get new instance and set it - DhtStateFactory::createDhtStateInstanceByName('booting', $this->getDhtInstance()); + DhtStateFactory::createDhtStateInstanceByName('booting', DhtObjectFactory::createDhtInstance('node')); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/miner/class_BaseMinerState.php b/application/hub/classes/states/miner/class_BaseMinerState.php index cf53991ee..3b1a13693 100644 --- a/application/hub/classes/states/miner/class_BaseMinerState.php +++ b/application/hub/classes/states/miner/class_BaseMinerState.php @@ -1,4 +1,10 @@ setDhtInstance($dhtInstance); - // Return the prepared instance return $taskInstance; } @@ -81,7 +75,7 @@ class NodeDhtBootstrapTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Let the DHT class do the work for us - $this->getDhtInstance()->bootstrapDht(); + DhtObjectFactory::createDhtInstance('node')->bootstrapDht(); } /** @@ -93,7 +87,5 @@ class NodeDhtBootstrapTask extends BaseTask implements Taskable, Visitable { public function doShutdown () { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php index e49052654..e9c0df869 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtInitializationTask.php @@ -53,12 +53,6 @@ class NodeDhtInitializationTask extends BaseTask implements Taskable, Visitable // Get new instance $taskInstance = new NodeDhtInitializationTask(); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $taskInstance; } @@ -81,7 +75,7 @@ class NodeDhtInitializationTask extends BaseTask implements Taskable, Visitable */ public function executeTask () { // Intiailize the DHT - $this->getDhtInstance()->initDht(); + DhtObjectFactory::createDhtInstance('node')->initDht(); } /** @@ -93,7 +87,5 @@ class NodeDhtInitializationTask extends BaseTask implements Taskable, Visitable public function doShutdown () { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php index 265aff2c4..625e8e532 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtLateBootstrapTask.php @@ -53,12 +53,6 @@ class NodeDhtLateBootstrapTask extends BaseTask implements Taskable, Visitable { // Get new instance $taskInstance = new NodeDhtLateBootstrapTask(); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $taskInstance; } @@ -81,7 +75,7 @@ class NodeDhtLateBootstrapTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Let the DHT class do the work for us - $this->getDhtInstance()->bootstrapDht(); + DhtObjectFactory::createDhtInstance('node')->bootstrapDht(); } /** @@ -93,7 +87,5 @@ class NodeDhtLateBootstrapTask extends BaseTask implements Taskable, Visitable { public function doShutdown () { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php index baa6b52ec..01bbf446d 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationCheckTask.php @@ -53,12 +53,6 @@ class NodeDhtPublicationCheckTask extends BaseTask implements Taskable, Visitabl // Get new instance $taskInstance = new NodeDhtPublicationCheckTask(); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $taskInstance; } @@ -82,7 +76,7 @@ class NodeDhtPublicationCheckTask extends BaseTask implements Taskable, Visitabl */ public function executeTask () { // Get DHT instance - $dhtInstance = $this->getDhtInstance(); + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); // Has the DHT some unpublished entries? if (($dhtInstance->hasFullyBootstrapped()) && ($dhtInstance->hasUnpublishedEntries())) { @@ -100,7 +94,5 @@ class NodeDhtPublicationCheckTask extends BaseTask implements Taskable, Visitabl public function doShutdown () { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php index 0dbddb906..268df7827 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtPublicationTask.php @@ -53,12 +53,6 @@ class NodeDhtPublicationTask extends BaseTask implements Taskable, Visitable { // Get new instance $taskInstance = new NodeDhtPublicationTask(); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $taskInstance; } @@ -82,7 +76,7 @@ class NodeDhtPublicationTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Get DHT instance - $dhtInstance = $this->getDhtInstance(); + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); // Has the DHT some entries pending publication? if ($dhtInstance->hasEntriesPendingPublication()) { @@ -100,7 +94,5 @@ class NodeDhtPublicationTask extends BaseTask implements Taskable, Visitable { public function doShutdown () { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php b/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php index 0d59c59be..cd9ddadac 100644 --- a/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php +++ b/application/hub/classes/tasks/node/dht/class_NodeDhtQueryTask.php @@ -53,12 +53,6 @@ class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { // Get new instance $taskInstance = new NodeDhtQueryTask(); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set the DHT instance here - $taskInstance->setDhtInstance($dhtInstance); - // Return the prepared instance return $taskInstance; } @@ -82,7 +76,7 @@ class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Get DHT instance - $dhtInstance = $this->getDhtInstance(); + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); // Are there "INSERT" node data entries? if ($dhtInstance->ifInsertNodeDataPending()) { @@ -100,7 +94,5 @@ class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable { public function doShutdown () { self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK: Shutting down...'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/tools/class_HubTools.php b/application/hub/classes/tools/class_HubTools.php index 5f4d5023d..bbac60895 100644 --- a/application/hub/classes/tools/class_HubTools.php +++ b/application/hub/classes/tools/class_HubTools.php @@ -3,6 +3,7 @@ namespace Hub\Tools; // Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; use Hub\Factory\Dht\DhtObjectFactory; use Hub\Factory\Node\NodeObjectFactory; use Hub\Generic\BaseHubSystem; @@ -63,12 +64,6 @@ class HubTools extends BaseHubSystem { // Call parent constructor parent::__construct(__CLASS__); - // Get a DHT instance - $dhtInstance = DhtObjectFactory::createDhtInstance('node'); - - // Set it here - $this->setDhtInstance($dhtInstance); - // Init salt length $this->sessionIdLength = 32 + $this->getConfigInstance()->getConfigEntry('salt_length'); } @@ -110,7 +105,7 @@ class HubTools extends BaseHubSystem { $recipientUniversalNodeLocator = 'invalid://invalid:invalid'; // And ask it for Universal Node Locator by given session id - $recipient = $this->getDhtInstance()->findNodeLocalBySessionId($sessionId); + $recipient = DhtObjectFactory::createDhtInstance('node')->findNodeLocalBySessionId($sessionId); //* DEBUG-DIE: */ die(__METHOD__ . ': UNFINISHED: recipient[' . gettype($recipient) . ']=' . print_r($recipient, TRUE) . ',sessionId=' . $sessionId . PHP_EOL); // Is the recipient valid? @@ -143,7 +138,7 @@ class HubTools extends BaseHubSystem { $selfInstance = self::getSelfInstance(); // And ask it for session id by given Universal Node Locator - $nodeData = $selfInstance->getDhtInstance()->findNodeLocalBySessionId($sessionId); + $nodeData = DhtObjectFactory::createDhtInstance('node')->findNodeLocalBySessionId($sessionId); // 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)); @@ -165,7 +160,7 @@ class HubTools extends BaseHubSystem { $selfInstance = self::getSelfInstance(); // And ask it for session id by given Universal Node Locator - $recipient = $selfInstance->getDhtInstance()->findNodeByUniversalNodeLocator($unlInstance); + $recipient = DhtObjectFactory::createDhtInstance('node')->findNodeByUniversalNodeLocator($unlInstance); die(__METHOD__.':recipient='.print_r($recipient, TRUE)); // Return result diff --git a/application/hub/config.php b/application/hub/config.php index 1a276bb9a..5f27fd1f0 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -55,7 +55,7 @@ $cfg->setConfigEntry('output_class', 'DebugConsoleOutput'); $cfg->setConfigEntry('node_info_db_wrapper_class', 'Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper'); // CFG: NODE-DHT-DB-WRAPPER-CLASS -$cfg->setConfigEntry('node_dht_db_wrapper_class', 'NodeDistributedHashTableDatabaseWrapper'); +$cfg->setConfigEntry('node_dht_db_wrapper_class', 'Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper'); // CFG: NODE-DHT-LIST-LIMIT $cfg->setConfigEntry('node_dht_list_limit', 20); @@ -307,28 +307,28 @@ $cfg->setConfigEntry('node_announcement_answer_template_extension', '.xml'); $cfg->setConfigEntry('node_announcement_template_type', 'xml/announcement'); // CFG: NODE-ANNOUNCEMENT-STACKER-CLASS -$cfg->setConfigEntry('node_announcement_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_announcement_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-ANNOUNCEMENT-ANSWER-STACKER-CLASS -$cfg->setConfigEntry('node_announcement_answer_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_announcement_answer_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-DHT-BOOTSTRAP-STACKER-CLASS -$cfg->setConfigEntry('node_dht_bootstrap_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_dht_bootstrap_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-DHT-BOOTSTRAP-ANSWER-STACKER-CLASS -$cfg->setConfigEntry('node_dht_bootstrap_answer_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_dht_bootstrap_answer_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-REQUEST-NODE-LIST-ANSWER-STACKER-CLASS -$cfg->setConfigEntry('node_request_node_list_answer_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_request_node_list_answer_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-REQUEST-NODE-LIST-ENTRY-STACKER-CLASS -$cfg->setConfigEntry('node_request_node_list_entry_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_request_node_list_entry_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: DHT-STACKER-CLASS -$cfg->setConfigEntry('dht_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('dht_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: RAW-DATA-STACKER-CLASS -$cfg->setConfigEntry('raw_data_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('raw_data_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: MULTIPLE-MESSAGE-STACKER-CLASS $cfg->setConfigEntry('multiple_message_stacker_class', 'CoreFramework\Stacker\FiFoStacker'); @@ -352,10 +352,10 @@ $cfg->setConfigEntry('node_self_connect_template_type', 'xml/self_connect'); $cfg->setConfigEntry('node_request_node_list_template_type', 'xml/requests'); // CFG: NODE-SELF-CONNECT-STACKER-CLASS -$cfg->setConfigEntry('node_self_connect_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_self_connect_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-REQUEST-NODE_LIST-STACKER-CLASS -$cfg->setConfigEntry('node_request_node_list_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_request_node_list_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-OBJECT-REGISTRY-TEMPLATE-CLASS $cfg->setConfigEntry('node_object_registry_template_class', 'XmlObjectRegistryTemplateEngine'); @@ -367,7 +367,7 @@ $cfg->setConfigEntry('node_object_registry_template_extension', '.xml'); $cfg->setConfigEntry('node_object_registry_template_type', 'xml/object_registry'); // CFG: NODE-OBJECT-REGISTRY-STACKER-CLASS -$cfg->setConfigEntry('node_object_registry_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('node_object_registry_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: NODE-OBJECT-TYPE-REGISTRY-CLASS $cfg->setConfigEntry('node_object_type_registry_class', 'ObjectTypeRegistry'); @@ -541,13 +541,13 @@ $cfg->setConfigEntry('task_ping_max_runs', 0); $cfg->setConfigEntry('node_package_tags_init_task_class', 'Hub\Node\Task\Initialization\Tag\NodePackageTagsInitTask'); // CFG: NODE-SELFCONNECT-TASK-CLASS -$cfg->setConfigEntry('node_selfconnect_task_class', 'NodeSelfConnectTask'); +$cfg->setConfigEntry('node_selfconnect_task_class', 'Hub\Node\Task\SelfConnect\NodeSelfConnectTask'); // CFG: NODE-UPDATE-CHECK-TASK-CLASS -$cfg->setConfigEntry('node_update_check_task_class', 'NodeUpdateCheckTask'); +$cfg->setConfigEntry('node_update_check_task_class', 'Hub\Node\Check\Update\NodeUpdateCheckTask'); // CFG: NODE-PING-TASK-CLASS -$cfg->setConfigEntry('node_ping_task_class', 'NodePingTask'); +$cfg->setConfigEntry('node_ping_task_class', 'Hub\Node\Ping\NodePingTask'); // CFG: NODE-ANNOUNCEMENT-TASK-CLASS $cfg->setConfigEntry('node_announcement_task_class', 'NodeAnnouncementTask'); @@ -571,19 +571,19 @@ $cfg->setConfigEntry('node_package_decoder_task_class', 'Hub\Node\Task\Decoder\N $cfg->setConfigEntry('node_dht_init_task_class', 'Hub\Node\Task\Dht\Initialization\NodeDhtInitializationTask'); // CFG: NODE-DHT-BOOTSTRAP-TASK-CLASS -$cfg->setConfigEntry('node_dht_bootstrap_task_class', 'NodeDhtBootstrapTask'); +$cfg->setConfigEntry('node_dht_bootstrap_task_class', 'Hub\Node\Task\Dht\Bootstrap\NodeDhtBootstrapTask'); // CFG: NODE-DHT-LATE-BOOTSTRAP-TASK-CLASS $cfg->setConfigEntry('node_dht_late_bootstrap_task_class', 'NodeDhtLateBootstrapTask'); // CFG: NODE-DHT-QUERY-TASK-CLASS -$cfg->setConfigEntry('node_dht_query_task_class', 'NodeDhtQueryTask'); +$cfg->setConfigEntry('node_dht_query_task_class', 'Hub\Node\Task\Dht\Query\NodeDhtQueryTask'); // CFG: NODE-DHT-PUBLICATION-CHECK-TASK-CLASS -$cfg->setConfigEntry('node_dht_publication_check_task_class', 'NodeDhtPublicationCheckTask'); +$cfg->setConfigEntry('node_dht_publication_check_task_class', 'Hub\Node\Task\Dht\Check\Publication\NodeDhtPublicationCheckTask'); // CFG: NODE-DHT-PUBLICATION-TASK-CLASS -$cfg->setConfigEntry('node_dht_publication_task_class', 'NodeDhtPublicationTask'); +$cfg->setConfigEntry('node_dht_publication_task_class', 'Hub\Node\Task\Dht\Publication\NodeDhtPublicationTask'); // CFG: TASK-NETWORK-PACKAGE-WRITER-STARTUP-DELAY $cfg->setConfigEntry('task_network_package_writer_startup_delay', 2500); @@ -694,7 +694,7 @@ $cfg->setConfigEntry('monitor_pool_iterator_class', 'MonitorPoolIterator'); $cfg->setConfigEntry('query_iterator_class', 'CoreFramework\Iterator\DefaultIterator'); // CFG: NODE-PING-ITERATOR-CLASS -$cfg->setConfigEntry('node_ping_iterator_class', 'HubPingIterator'); +$cfg->setConfigEntry('node_ping_iterator_class', 'Hub\Iterator\Node\Ping\NodePingIterator'); // CFG: WEB-TEMPLATE-CLASS @OVERRIDE $cfg->setConfigEntry('web_template_class', 'ConsoleTemplateEngine'); @@ -897,16 +897,16 @@ $cfg->setConfigEntry('peer_no_route_to_host_state_class', 'NoRouteToHostPeerStat /////////////////////////////////////////////////////////////////////////////// // CFG: DHT-INIT-STATE-CLASS -$cfg->setConfigEntry('dht_init_state_class', 'DhtInitState'); +$cfg->setConfigEntry('dht_init_state_class', 'Hub\State\Dht\DhtInitState'); // CFG: DHT-VIRGIN-STATE-CLASS -$cfg->setConfigEntry('dht_virgin_state_class', 'DhtVirginState'); +$cfg->setConfigEntry('dht_virgin_state_class', 'Hub\State\Dht\DhtVirginState'); // CFG: DHT-BOOTING-STATE-CLASS -$cfg->setConfigEntry('dht_booting_state_class', 'DhtBootingState'); +$cfg->setConfigEntry('dht_booting_state_class', 'Hub\State\Dht\DhtBootingState'); // CFG: DHT-ACTIVE-STATE-CLASS -$cfg->setConfigEntry('dht_active_state_class', 'DhtActiveState'); +$cfg->setConfigEntry('dht_active_state_class', 'Hub\State\Dht\DhtActiveState'); /////////////////////////////////////////////////////////////////////////////// // Message answer-status handler @@ -1141,7 +1141,7 @@ $cfg->setConfigEntry('cruncher_message_template_extension', '.xml'); $cfg->setConfigEntry('cruncher_test_unit_template_extension', '.xml'); // CFG: CRUNCHER-TEST-UNIT-STACKER-CLASS -$cfg->setConfigEntry('cruncher_test_unit_stacker_class', 'FiLoStacker'); +$cfg->setConfigEntry('cruncher_test_unit_stacker_class', 'CoreFramework\Stacker\FiLoStacker'); // CFG: CRUNCHER-TEST-UNIT-TEMPLATE-TYPE $cfg->setConfigEntry('cruncher_test_unit_template_type', 'xml/cruncher/producer'); diff --git a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php index 6d7baf54b..e8e12a566 100644 --- a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php +++ b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\Node\Registering; +// Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; + // Import framework stuff use CoreFramework\Generic\FrameworkException; diff --git a/application/hub/exceptions/wrapper/class_NodeDataMissingException.php b/application/hub/exceptions/wrapper/class_NodeDataMissingException.php index 4e6b8041e..45786eccc 100644 --- a/application/hub/exceptions/wrapper/class_NodeDataMissingException.php +++ b/application/hub/exceptions/wrapper/class_NodeDataMissingException.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\Node\Data; +// Import application-specific stuff +use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper; + // Import framework stuff use CoreFramework\Generic\FrameworkException; diff --git a/application/hub/interfaces/distributable/node/class_DistributableNode.php b/application/hub/interfaces/distributable/node/class_DistributableNode.php index 6f5177e5c..8629f4d13 100644 --- a/application/hub/interfaces/distributable/node/class_DistributableNode.php +++ b/application/hub/interfaces/distributable/node/class_DistributableNode.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\Dht\Node; +// Import application-specific stuff +use Hub\Dht\Distributable; + // Import framework stuff use CoreFramework\Handler\DataSet\HandleableDataSet; @@ -111,7 +114,5 @@ interface DistributableNode extends Distributable { * @return void */ function publishEntry (); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/helper/dht/class_HelpableDht.php b/application/hub/interfaces/helper/dht/class_HelpableDht.php index b208b74bf..cb48498c3 100644 --- a/application/hub/interfaces/helper/dht/class_HelpableDht.php +++ b/application/hub/interfaces/helper/dht/class_HelpableDht.php @@ -3,6 +3,7 @@ namespace Hub\Helper\Dht; // Import application-specific stuff +use Hub\Dht\Distributable; use Hub\Helper\HubHelper; /** diff --git a/core b/core index d506014f8..8180df965 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit d506014f84d8e6a76ea67ef59537fc56f5f1c364 +Subproject commit 8180df9650994694ac2db841d91b6bfa2d83d36f -- 2.39.5