]> git.mxchange.org Git - hub.git/blob - application/hub/interfaces/wrapper/class_NodeDhtWrapper.php
d2b21e337f91135b6062ba82e5fee6b2c2584a75
[hub.git] / application / hub / interfaces / wrapper / class_NodeDhtWrapper.php
1 <?php
2 /**
3  * An interface for distributed hash tables for nodes
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.org
10  *
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.
15  *
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.
20  *
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/>.
23  */
24 interface NodeDhtWrapper extends DatabaseWrapper {
25         /**
26          * Static getter for an array of all DHT database entries
27          *
28          * @return      $elements       All elements for the DHT dabase
29          */
30         static function getAllElements ();
31
32         /**
33          * Getter for result instance for unpublished entries
34          *
35          * @return      $unpublishedEntriesInstance             Result instance
36          */
37         function getUnpublishedEntriesInstance ();
38
39         /**
40          * Checks whether the local (*this*) node is registered in the DHT by
41          * checking if the external address is found.
42          *
43          * @return      $isRegistered   Whether *this* node is registered in the DHT
44          */
45         function isLocalNodeRegistered ();
46
47         /**
48          * Registeres the local (*this*) node with its data in the DHT.
49          *
50          * @return      void
51          */
52         function registerLocalNode ();
53
54         /**
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.
57          *
58          * @return      void
59          */
60         function updateLocalNode ();
61
62         /**
63          * Finds a node locally by given session id
64          *
65          * @param       $sessionId      Session id to lookup
66          * @return      $nodeData       Node data array
67          */
68         function findNodeLocalBySessionId ($sessionId);
69
70         /**
71          * Registeres a node by given message data.
72          *
73          * @param       $messageData            An array of all message data
74          * @param       $handlerInstance        An instance of a HandleableDataSet class
75          * @return      void
76          */
77         function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance);
78
79         /**
80          * Updates an existing entry in node list
81          *
82          * @param       $messageData            An array of all message data
83          * @param       $handlerInstance        An instance of a HandleableDataSet class
84          * @param       $searchInstance         An instance of LocalSearchCriteria class
85          * @return      void
86          */
87         function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance);
88
89         /**
90          * Determines whether the given node data is already inserted in the DHT
91          *
92          * @param       $nodeData               An array with valid node data
93          * @return      $isRegistered   Whether the given node data is already inserted
94          */
95         function isNodeRegistered (array $nodeData);
96
97         /**
98          * Registers a node with given data in the DHT. If the node is already
99          * registered this method shall throw an exception.
100          *
101          * @param       $nodeData       An array with valid node data
102          * @return      void
103          * @throws      NodeAlreadyRegisteredException  If the node is already registered
104          */
105         function registerNode (array $nodeData);
106
107         /**
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.
111          *
112          * @param       $nodeData       An array with valid node data
113          * @return      void
114          * @throws      NodeDataMissingException        If the node's data is missing
115          */
116         function updateNode (array $nodeData);
117
118         /**
119          * Checks whether there are unpublished entries
120          *
121          * @return      $hasUnpublished         Whether there are unpublished entries
122          * @todo        Add minimum/maximum age limitations
123          */
124         function hasUnpublishedEntries ();
125
126         /**
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.
130          *
131          * @return      void
132          * @todo        Add timestamp to dataset instance
133          */
134         function initEntryPublication ();
135
136         /**
137          * Removes non-data from given array.
138          *
139          * @param       $data   An array with possible non-data that needs to be removed.
140          * @return      $data   A cleaned up array with only data.
141          */
142         function removeNonPublicDataFromArray(array $data);
143
144         /**
145          * Find recipients for given package data and returns it as a result instance
146          *
147          * @param       $packageData    An array of valid package data
148          * @return      $recipients             An indexed array with DHT recipients
149          */
150         function getResultFromExcludedSender (array $packageData);
151
152         /**
153          * Find recopients by given key/value pair. First look for the key and if it
154          * matches, compare the value.
155          *
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
159          */
160         function getResultFromKeyValue ($key, $value);
161
162         /**
163          * Enable DHT bootstrap request acceptance for local node
164          *
165          * @return      void
166          */
167         function enableAcceptDhtBootstrap ();
168 }
169
170 // [EOF]
171 ?>