3 * An interface for distributed hash tables for nodes
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 interface NodeDhtWrapper extends DatabaseWrapper {
26 * Static getter for an array of all DHT database entries
28 * @return $elements All elements for the DHT dabase
30 static function getAllElements ();
33 * Getter for result instance for unpublished entries
35 * @return $unpublishedEntriesInstance Result instance
37 function getUnpublishedEntriesInstance ();
40 * Checks whether the local (*this*) node is registered in the DHT by
41 * checking if the external ip/port is found.
43 * @return $isRegistered Whether *this* node is registered in the DHT
45 function isLocalNodeRegistered ();
48 * Registeres the local (*this*) node with its data in the DHT.
52 function registerLocalNode ();
55 * Updates local (*this*) node data in DHT, this is but not limited to the
56 * session id, ip number (and/or hostname) and port number.
60 function updateLocalNode ();
63 * Finds a node locally by given session id
65 * @param $sessionId Session id to lookup
66 * @return $nodeData Node data array
68 function findNodeLocalBySessionId ($sessionId);
71 * Registeres a node by given message data.
73 * @param $messageData An array of all message data
74 * @param $handlerInstance An instance of a Handleable class
77 function registerNodeByMessageData (array $messageData, Handleable $handlerInstance);
80 * Updates an existing entry in node list
82 * @param $messageData An array of all message data
83 * @param $handlerInstance An instance of a Handleable class
84 * @param $searchInstance An instance of LocalSearchCriteria class
87 function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance);
90 * Determines whether the given node data is already inserted in the DHT
92 * @param $nodeData An array with valid node data
93 * @return $isRegistered Whether the given node data is already inserted
95 function isNodeRegistered (array $nodeData);
98 * Registers a node with given data in the DHT. If the node is already
99 * registered this method shall throw an exception.
101 * @param $nodeData An array with valid node data
103 * @throws NodeAlreadyRegisteredException If the node is already registered
105 function registerNode (array $nodeData);
108 * Updates a node's entry in the DHT with given data. This will enrich or
109 * just update already exsiting data. If the node is not found this method
110 * shall throw an exception.
112 * @param $nodeData An array with valid node data
114 * @throws NodeDataMissingException If the node's data is missing
116 function updateNode (array $nodeData);
119 * Checks whether there are unpublished entries
121 * @return $hasUnpublished Whether there are unpublished entries
122 * @todo Add minimum/maximum age limitations
124 function hasUnpublishedEntries ();
127 * Initializes publication of DHT entries. This does only prepare
128 * publication. The next step is to pickup such prepared entries and publish
129 * them by uploading to other (recently appeared) DHT members.
132 * @todo Add timestamp to dataset instance
134 function initEntryPublication ();
137 * Removes non-data from given array.
139 * @param $data An array with possible non-data that needs to be removed.
140 * @return $data A cleaned up array with only data.
142 function removeNonPublicDataFromArray(array $data);
145 * Find recipients for given package data and returns it as a result instance
147 * @param $packageData An array of valid package data
148 * @return $recipients An indexed array with DHT recipients
150 function getResultFromExcludedSender (array $packageData);
153 * Find recopients by given key/value pair. First look for the key and if it
154 * matches, compare the value.
156 * @param $key Key to look for
157 * @param $value Value to compare if key matches
158 * @return $recipients An indexed array with DHT recipients
160 function getResultFromKeyValue ($key, $value);
163 * Enable DHT bootstrap request acceptance for local node
167 function enableAcceptDhtBootstrap ();