application/hub/main/states/dht/.htaccess -text svneol=unset#text/plain
application/hub/main/states/dht/active/.htaccess -text svneol=unset#text/plain
application/hub/main/states/dht/active/class_DhtActiveState.php svneol=native#text/plain
+application/hub/main/states/dht/booting/.htaccess -text svneol=unset#text/plain
+application/hub/main/states/dht/booting/class_DhtBootingState.php svneol=native#text/plain
application/hub/main/states/dht/class_ svneol=native#text/plain
application/hub/main/states/dht/class_BaseDhtState.php svneol=native#text/plain
application/hub/main/states/dht/init/.htaccess -text svneol=unset#text/plain
// CFG: WEB-TEMPLATE-CLASS @OVERRIDE
$cfg->setConfigEntry('web_template_class', 'ConsoleTemplateEngine');
-// CFG: NODE-INIT-STATE-CLASS
-$cfg->setConfigEntry('node_init_state_class', 'NodeInitState');
-
-// CFG: NODE-VIRGIN-STATE-CLASS
-$cfg->setConfigEntry('node_virgin_state_class', 'NodeVirginState');
-
-// CFG: NODE-ACTIVE-STATE-CLASS
-$cfg->setConfigEntry('node_active_state_class', 'NodeActiveState');
-
-// CFG: NODE-ANNOUNCED-STATE-CLASS
-$cfg->setConfigEntry('node_announced_state_class', 'NodeAnnouncedState');
-
-// CFG: NODE-REACHABLE-STATE-CLASS
-$cfg->setConfigEntry('node_reachable_state_class', 'NodeReachableState');
-
-// CFG: NODE-ANNOUNCEMENT-COMPLETED-STATE-CLASS
-$cfg->setConfigEntry('node_announcement_completed_state_class', 'NodeAnnouncementCompletedState');
-
-// CFG: DHT-INIT-STATE-CLASS
-$cfg->setConfigEntry('dht_init_state_class', 'DhtInitState');
-
-// CFG: DHT-VIRGIN-STATE-CLASS
-$cfg->setConfigEntry('dht_virgin_state_class', 'DhtVirginState');
-
-// CFG: DHT-ACTIVE-STATE-CLASS
-$cfg->setConfigEntry('dht_active_state_class', 'DhtActiveState');
-
// CFG: NETWORK-PACKAGE-CLASS
$cfg->setConfigEntry('network_package_class', 'NetworkPackage');
// CFG: NODE-DHT-CLASS
$cfg->setConfigEntry('node_dht_class', 'NodeDhtFacade');
+///////////////////////////////////////////////////////////////////////////////
+// Node states
+///////////////////////////////////////////////////////////////////////////////
+
+// CFG: NODE-INIT-STATE-CLASS
+$cfg->setConfigEntry('node_init_state_class', 'NodeInitState');
+
+// CFG: NODE-VIRGIN-STATE-CLASS
+$cfg->setConfigEntry('node_virgin_state_class', 'NodeVirginState');
+
+// CFG: NODE-ACTIVE-STATE-CLASS
+$cfg->setConfigEntry('node_active_state_class', 'NodeActiveState');
+
+// CFG: NODE-ANNOUNCED-STATE-CLASS
+$cfg->setConfigEntry('node_announced_state_class', 'NodeAnnouncedState');
+
+// CFG: NODE-REACHABLE-STATE-CLASS
+$cfg->setConfigEntry('node_reachable_state_class', 'NodeReachableState');
+
+// CFG: NODE-ANNOUNCEMENT-COMPLETED-STATE-CLASS
+$cfg->setConfigEntry('node_announcement_completed_state_class', 'NodeAnnouncementCompletedState');
+
///////////////////////////////////////////////////////////////////////////////
// Peer states
///////////////////////////////////////////////////////////////////////////////
// CFG: PEER-NO-ROUTE-TO-HOST-STATE-CLASS
$cfg->setConfigEntry('peer_no_route_to_host_state_class', 'NoRouteToHostPeerState');
+///////////////////////////////////////////////////////////////////////////////
+// DHT states
+///////////////////////////////////////////////////////////////////////////////
+
+// CFG: DHT-INIT-STATE-CLASS
+$cfg->setConfigEntry('dht_init_state_class', 'DhtInitState');
+
+// CFG: DHT-VIRGIN-STATE-CLASS
+$cfg->setConfigEntry('dht_virgin_state_class', 'DhtVirginState');
+
+// CFG: DHT-BOOTING-STATE-CLASS
+$cfg->setConfigEntry('dht_booting_state_class', 'DhtBootingState');
+
+// CFG: DHT-ACTIVE-STATE-CLASS
+$cfg->setConfigEntry('dht_active_state_class', 'DhtActiveState');
+
///////////////////////////////////////////////////////////////////////////////
// Message answer-status handler
///////////////////////////////////////////////////////////////////////////////
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData=' . print_r($messageData, true));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, true) . ',handlerInstance=' . $handlerInstance->__toString() . ',forceUpdate=' . intval($forceUpdate) . ',count(getSearchData())=' . count($handlerInstance->getSearchData()));
// Search for the node's session id and external IP/hostname + TCP/UDP listen port
foreach ($handlerInstance->getSearchData() as $key) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData[' . $key . ']=' . $messageData[$key]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData[' . $key . ']=' . $messageData[$key]);
// Is it there?
assert(isset($messageData[$key]));
assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey])));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData=' . print_r($messageData, true));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, true));
// Get a search criteria class
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add all keys
foreach (explode($separator, $messageData[$andKey]) as $criteria) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: andKey=' . $andKey . ',criteria=' . $criteria);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: andKey=' . $andKey . ',criteria=' . $criteria);
// Add it and leave any 'my-' prefix out
$searchInstance->addChoiceCriteria(str_replace('my-', '', $andKey), $criteria);
// Get node list
$nodeList = array();
while ($resultInstance->next()) {
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: current()=' . $resultinstance->current());
+
// Add this entry
array_push($nodeList, $resultInstance->current());
} // END - while
*
* @param $nodeList An array from an earlier database result instance
* @return void
+ * @todo ~10% done
*/
public function insertNodeList (array $nodeList) {
- // If no node is in the list (array), skip the rest of this method silently
+ // If no node is in the list (array), skip the rest of this method
if (count($nodeList) == 0) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: No node record has been returned.');
+ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: No node record has been returned.');
// Abort here
return;
} // END - if
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
// Set it now
$this->dataXmlNodes[$key] = $value;
// Call parent constructor
parent::__construct(__CLASS__);
+ // Init array
+ $this->searchData = array(
+ XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
+ );
+
// Set handler name
$this->setHandlerName('request_node_list_answer_okay');
}
*/
$this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE);
- // Get the node instance
- $nodeInstance = Registry::getRegistry()->getInstance('node');
-
- // Change state
- $nodeInstance->getStateInstance()->nodeRequestNodeListSuccessful();
-
// Prepare next message ("hello" message to all returned nodes)
$this->prepareNextMessage($messageData, $packageInstance);
}
parent::addArrayToDataSet($dataSetInstance, $messageData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER: messageData=' . print_r($messageData, true));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER: messageData=' . print_r($messageData, true));
// Add all ements
foreach ($this->messageDataElements as $key) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER: messageData[' . $key . ']=' . $messageData[$key]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER: messageData[' . $key . ']=' . $messageData[$key]);
// Is it there?
assert(isset($messageData[$key]));
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Booting dht state class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class DhtBootingState extends BaseDhtState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('booting');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $dhtInstance An instance of a Distributable class
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public final static function createDhtBootingState (Distributable $dhtInstance) {
+ // Get new instance
+ $stateInstance = new DhtBootingState();
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->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]
+?>
/**
* Called when the DHT has booted. This means that the bootstrap message
* has been sent out to other nodes. This will changed the DHT's state
- * to 'active'.
+ * to 'booting'.
*
* @return void
*/
public function dhtHasBooted () {
// Get new instance and set it
- DhtStateFactory::createDhtStateInstanceByName('active', $this->getDhtInstance());
+ DhtStateFactory::createDhtStateInstanceByName('booting', $this->getDhtInstance());
}
}