From 6db6964084893cc66546e580995115746bd0965a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 14 Feb 2013 22:46:09 +0000 Subject: [PATCH] Added very basic implementation of updateDhtData() --- .gitattributes | 7 ++ application/hub/config.php | 6 ++ .../distributable/class_Distributable.php | 7 ++ application/hub/main/dht/class_BaseDht.php | 11 +++ application/hub/main/states/dht/.htaccess | 1 + application/hub/main/states/dht/class_ | 60 ++++++++++++++++ .../main/states/dht/class_BaseDhtState.php | 38 ++++++++++ .../hub/main/states/dht/init/.htaccess | 1 + .../states/dht/init/class_DhtInitState.php | 71 +++++++++++++++++++ .../hub/main/states/dht/virgin/.htaccess | 1 + .../dht/virgin/class_DhtVirginState.php | 60 ++++++++++++++++ 11 files changed, 263 insertions(+) create mode 100644 application/hub/main/states/dht/.htaccess create mode 100644 application/hub/main/states/dht/class_ create mode 100644 application/hub/main/states/dht/class_BaseDhtState.php create mode 100644 application/hub/main/states/dht/init/.htaccess create mode 100644 application/hub/main/states/dht/init/class_DhtInitState.php create mode 100644 application/hub/main/states/dht/virgin/.htaccess create mode 100644 application/hub/main/states/dht/virgin/class_DhtVirginState.php diff --git a/.gitattributes b/.gitattributes index e74efdf52..a071e24dd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -577,6 +577,13 @@ application/hub/main/states/cruncher/init/.htaccess svneol=native#text/plain application/hub/main/states/cruncher/init/class_CruncherInitState.php svneol=native#text/plain application/hub/main/states/cruncher/virgin/.htaccess svneol=native#text/plain application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php svneol=native#text/plain +application/hub/main/states/dht/.htaccess -text svneol=unset#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 +application/hub/main/states/dht/init/class_DhtInitState.php svneol=native#text/plain +application/hub/main/states/dht/virgin/.htaccess -text svneol=unset#text/plain +application/hub/main/states/dht/virgin/class_DhtVirginState.php svneol=native#text/plain application/hub/main/states/generic/.htaccess -text svneol=unset#text/plain application/hub/main/states/hub/.htaccess -text svneol=unset#text/plain application/hub/main/states/node/.htaccess -text svneol=unset#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index bdfcb0835..7de51c2a6 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -633,6 +633,12 @@ $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: NETWORK-PACKAGE-CLASS $cfg->setConfigEntry('network_package_class', 'NetworkPackage'); diff --git a/application/hub/interfaces/distributable/class_Distributable.php b/application/hub/interfaces/distributable/class_Distributable.php index acd099dd6..dc828071d 100644 --- a/application/hub/interfaces/distributable/class_Distributable.php +++ b/application/hub/interfaces/distributable/class_Distributable.php @@ -83,6 +83,13 @@ interface Distributable extends FrameworkInterface { * @return void */ function insertNodeList (array $nodeList); + + /** + * Updates/refreshes DHT data (e.g. status). + * + * @return void + */ + function updateDhtData (); } // [EOF] diff --git a/application/hub/main/dht/class_BaseDht.php b/application/hub/main/dht/class_BaseDht.php index a71c2f305..597cc209a 100644 --- a/application/hub/main/dht/class_BaseDht.php +++ b/application/hub/main/dht/class_BaseDht.php @@ -38,6 +38,17 @@ class BaseDht extends BaseHubSystem { */ DhtStateFactory::createDhtStateInstanceByName('init', $this); } + + /** + * Updates/refreshes DHT data (e.g. status). + * + * @return void + * @todo Find more to do here + */ + public function updateDhtData () { + // Set some dummy configuration entries, e.g. dht_status + $this->getConfigInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName()); + } } // [EOF] diff --git a/application/hub/main/states/dht/.htaccess b/application/hub/main/states/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/states/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/states/dht/class_ b/application/hub/main/states/dht/class_ new file mode 100644 index 000000000..0c4d1a004 --- /dev/null +++ b/application/hub/main/states/dht/class_ @@ -0,0 +1,60 @@ + + * @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 . + */ +class Dht???State extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('!!!'); + } + + /** + * 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 createDht???State (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new Dht???State(); + + // Debug message + 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] +?> diff --git a/application/hub/main/states/dht/class_BaseDhtState.php b/application/hub/main/states/dht/class_BaseDhtState.php new file mode 100644 index 000000000..e70151cbe --- /dev/null +++ b/application/hub/main/states/dht/class_BaseDhtState.php @@ -0,0 +1,38 @@ + + * @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 . + */ +class BaseDhtState extends BaseState { + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/states/dht/init/.htaccess b/application/hub/main/states/dht/init/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/states/dht/init/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/states/dht/init/class_DhtInitState.php b/application/hub/main/states/dht/init/class_DhtInitState.php new file mode 100644 index 000000000..bc2ad156e --- /dev/null +++ b/application/hub/main/states/dht/init/class_DhtInitState.php @@ -0,0 +1,71 @@ + + * @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 . + */ +class DhtInitState extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('init'); + } + + /** + * 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 createDhtInitState (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new DhtInitState(); + + // Debug message + 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; + } + + /** + * The DHT has been initialized. This means that the state can be changed + * to the next one: virgin. + * + * @return void + */ + public function dhtHasInitialized () { + // Create a new instance + DhtStateFactory::createDhtStateInstanceByName('virgin', $this->getDhtInstance()); + } +} + +// [EOF] +?> diff --git a/application/hub/main/states/dht/virgin/.htaccess b/application/hub/main/states/dht/virgin/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/states/dht/virgin/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/states/dht/virgin/class_DhtVirginState.php b/application/hub/main/states/dht/virgin/class_DhtVirginState.php new file mode 100644 index 000000000..ff461d573 --- /dev/null +++ b/application/hub/main/states/dht/virgin/class_DhtVirginState.php @@ -0,0 +1,60 @@ + + * @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 . + */ +class DhtVirginState extends BaseDhtState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('virgin'); + } + + /** + * 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 createDhtVirginState (Distributable $dhtInstance) { + // Get new instance + $stateInstance = new DhtVirginState(); + + // Debug message + 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] +?> -- 2.39.5