application/hub/interfaces/work_units/.htaccess svneol=native#text/plain
application/hub/interfaces/work_units/class_UnitHelper.php svneol=native#text/plain
application/hub/interfaces/wrapper/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/wrapper/class_NodeDhtWrapper.php svneol=native#text/plain
application/hub/interfaces/wrapper/class_NodeInformationWrapper.php svneol=native#text/plain
application/hub/interfaces/wrapper/class_NodeListWrapper.php svneol=native#text/plain
application/hub/loader.php svneol=native#text/plain
application/hub/main/database/wrapper/cruncher/.htaccess svneol=native#text/plain
application/hub/main/database/wrapper/cruncher/class_CruncherUnitDatabaseWrapper.php svneol=native#text/plain
application/hub/main/database/wrapper/node/.htaccess svneol=native#text/plain
+application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php svneol=native#text/plain
application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php svneol=native#text/plain
application/hub/main/database/wrapper/node/class_NodeListDatabaseWrapper.php svneol=native#text/plain
application/hub/main/database/wrapper/states/.htaccess svneol=native#text/plain
// CFG: NODE-INFO-DB-WRAPPER-CLASS
$cfg->setConfigEntry('node_info_db_wrapper_class', 'NodeInformationDatabaseWrapper');
+// CFG: NODE-DHT-DB-WRAPPER-CLASS
+$cfg->setConfigEntry('node_dht_db_wrapper_class', 'NodeDistributedHashTableDatabaseWrapper');
+
// CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper');
--- /dev/null
+<?php
+/**
+ * An interface for distributed hash tables for nodes
+ *
+ * @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/>.
+ */
+interface NodeDhtWrapper extends FrameworkInterface {
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A database wrapper for distributed hash tables
+ *
+ * @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 NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implements NodeDhtWrapper, Registerable {
+ // Constants for database table names
+ const DB_TABLE_NODE_DHT = 'node_dht';
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this database wrapper by a provided user class
+ *
+ * @return $wrapperInstance An instance of the created wrapper class
+ */
+ public static final function createNodeDistributedHashTableDatabaseWrapper () {
+ // Get a new instance
+ $wrapperInstance = new NodeDistributedHashTableDatabaseWrapper();
+
+ // Set (primary!) table name
+ $wrapperInstance->setTableName(self::DB_TABLE_NODE_DHT);
+
+ // Return the instance
+ return $wrapperInstance;
+ }
+}
+
+// [EOF]
+?>
* 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 NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper {
+class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper, Registerable {
// Constants for database table names
const DB_TABLE_NODE_INFORMATION = 'node_data';
// Get new instance
$dhtInstance = new NodeDhtFacade();
+ // Get a database wrapper instance
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_dht_db_wrapper_class');
+
+ // Set it in this class
+ $dhtInstance->setWrapperInstance($wrapperInstance);
+
// Return the prepared instance
return $dhtInstance;
}
// Call parent constructor
parent::__construct($className);
+ // Get a wrapper instance
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('node_info_db_wrapper_class');
+
+ // Set it here
+ $this->setWrapperInstance($wrapperInstance);
+
// Get a crypto instance
$cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
$this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString));
$this->setPrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey()));
- // Get a wrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
-
// Register the node id with our wrapper
- $wrapperInstance->registerPrivateKey($this, $this->getRequestInstance(), $searchInstance);
+ $this->getWrapperInstance()->registerPrivateKey($this, $this->getRequestInstance(), $searchInstance);
// Output message
self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . '');
* @return void
*/
public function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance) {
- // Get a wrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
-
// Now get a search criteria instance
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
$searchInstance->setLimit(1);
// Get a result back
- $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
+ $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance);
// Is it valid?
if ($resultInstance->next()) {
$this->setNodeId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
// Register the node id with our wrapper
- $wrapperInstance->registerNodeId($this, $this->getRequestInstance());
+ $this->getWrapperInstance()->registerNodeId($this, $this->getRequestInstance());
// Output message
self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . '');
// Hash and encrypt the string so we become a "node id" aka Hub-Id
$this->setSessionId($this->getCryptoInstance()->hashString($this->getCryptoInstance()->encryptString($randomString)));
- // Get a wrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
-
// Register the node id with our wrapper
- $wrapperInstance->registerSessionId($this, $this->getRequestInstance(), $searchInstance);
+ $this->getWrapperInstance()->registerSessionId($this, $this->getRequestInstance(), $searchInstance);
// Output message
self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
* @return void
*/
public function bootstrapGeneratePrivateKey () {
- // Get a wrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
-
// Now get a search criteria instance
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
$searchInstance->setLimit(1);
// Get a result back
- $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
+ $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance);
// Is it valid?
if ($resultInstance->next()) {