From: Roland Haeder Date: Tue, 25 Mar 2014 21:39:07 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=752d3e37ef6688c98094eadcd9629ab9f80e1fb7;p=hub.git Continued: - improved logging messages - added logger for enableAcceptDhtBootstrap() - moved this call from 'init' state to 'booting' as on 'init' state the DHT has no records registered. This may require reconsidering. Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/dht/class_BaseDht.php b/application/hub/main/dht/class_BaseDht.php index 64dda6e47..f4e4a0344 100644 --- a/application/hub/main/dht/class_BaseDht.php +++ b/application/hub/main/dht/class_BaseDht.php @@ -224,9 +224,9 @@ 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__)->debugOutput('DHT[' . $this->__toString() . ']: Calling this->getWrapperInstance()->removeNonPublicDataFromArray(data) ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . __METHOD__ . ':' . __LINE__ . ']: Calling this->getWrapperInstance()->removeNonPublicDataFromArray(data) ...'); $entry = $this->getWrapperInstance()->removeNonPublicDataFromArray($entry); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . $this->__toString() . ']: entry[]=' . gettype($entry)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT[' . __METHOD__ . ':' . __LINE__ . ']: entry[]=' . gettype($entry)); // Some sanity-checks again assert(is_array($entry)); diff --git a/application/hub/main/handler/class_BaseDataHandler.php b/application/hub/main/handler/class_BaseDataHandler.php index 8af671281..3b154ca84 100644 --- a/application/hub/main/handler/class_BaseDataHandler.php +++ b/application/hub/main/handler/class_BaseDataHandler.php @@ -102,7 +102,7 @@ abstract class BaseDataHandler extends BaseHandler { */ protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send an answer message ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to send an answer message ...'); // Get a helper instance based on this handler's name $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData)); @@ -131,7 +131,7 @@ abstract class BaseDataHandler extends BaseHandler { $this->removeMessageConfigurationData($messageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Answer message has been prepared.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Answer message has been prepared.'); } /** @@ -143,7 +143,7 @@ abstract class BaseDataHandler extends BaseHandler { */ protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send next message ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Going to send next message ...'); // Get a helper instance based on this handler's name $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData)); @@ -172,7 +172,7 @@ abstract class BaseDataHandler extends BaseHandler { $this->removeMessageConfigurationData($messageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Next message has been prepared.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Next message has been prepared.'); } /** diff --git a/application/hub/main/states/dht/booting/class_DhtBootingState.php b/application/hub/main/states/dht/booting/class_DhtBootingState.php index e590148a1..2cec6825d 100644 --- a/application/hub/main/states/dht/booting/class_DhtBootingState.php +++ b/application/hub/main/states/dht/booting/class_DhtBootingState.php @@ -46,11 +46,17 @@ class DhtBootingState extends BaseDhtState implements Stateable { $stateInstance = new DhtBootingState(); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE: Has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->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(); + + // Update DHT node info as well + $dhtInstance->enableAcceptDhtBootstrap(); + // Return the prepared instance return $stateInstance; } diff --git a/application/hub/main/states/dht/virgin/class_DhtVirginState.php b/application/hub/main/states/dht/virgin/class_DhtVirginState.php index 69882f367..3d42a391a 100644 --- a/application/hub/main/states/dht/virgin/class_DhtVirginState.php +++ b/application/hub/main/states/dht/virgin/class_DhtVirginState.php @@ -51,12 +51,6 @@ class DhtVirginState extends BaseDhtState implements Stateable { // Set the dht instance $stateInstance->setDhtInstance($dhtInstance); - // Get node instance and enable DHT bootstrap requests - NodeObjectFactory::createNodeInstance()->enableAcceptDhtBootstrap(); - - // Update DHT node info as well - $dhtInstance->enableAcceptDhtBootstrap(); - // Return the prepared instance return $stateInstance; } diff --git a/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php index 1dd336996..fea84caec 100644 --- a/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/main/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -230,7 +230,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem } /** - * Updates local (*this*) node data in DHT, this is but not limited to the + * Updates local (*this*) node's data in DHT, this is but not limited to the * session id, ip number (and/or hostname) and port number. * * @return void @@ -503,9 +503,9 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem */ public function removeNonPublicDataFromArray(array $data) { // Currently call only inner method - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . $this->__toString() . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); $data = parent::removeNonPublicDataFromArray($data); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . $this->__toString() . ']: data[]=' . gettype($data)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: data[]=' . gettype($data)); // Return cleaned data return $data; @@ -571,6 +571,9 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem * @return void */ public function enableAcceptDhtBootstrap () { + // Debug message + /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Enabling DHT bootstrap requests ...'); + // Just update our record $this->updateLocalNode(); } diff --git a/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php b/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php index 820102f50..79a5c701a 100644 --- a/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/main/wrapper/node/class_NodeInformationDatabaseWrapper.php @@ -172,7 +172,7 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node */ public function removeNonPublicDataFromArray(array $data) { // Currently call only inner method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-WRAPPER[' . $this->__toString() . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-WRAPPER[' . __METHOD__ . ':' . __LINE__ . ']: Calling parent::removeNonPublicDataFromArray(data) ...'); $data = parent::removeNonPublicDataFromArray($data); // Return cleaned data