]> git.mxchange.org Git - hub.git/blob - application/hub/main/nodes/class_BaseHubNode.php
Cruncher continued and rewritten to use states:
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
1 <?php
2 /**
3  * A general hub node class
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.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 class BaseHubNode extends BaseHubSystem implements Updateable {
25         /**
26          * Node types
27          */
28         const NODE_TYPE_BOOT    = 'boot';
29         const NODE_TYPE_MASTER  = 'master';
30         const NODE_TYPE_LIST    = 'list';
31         const NODE_TYPE_REGULAR = 'regular';
32
33         // Exception constants
34         const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00;
35
36         /**
37          * IP/port number of bootstrapping node
38          */
39         private $bootIpPort = '';
40
41         /**
42          * Query connector instance
43          */
44         private $queryConnectorInstance = null;
45
46         /**
47          * Queue connector instance
48          */
49         private $queueConnectorInstance = null;
50
51         /**
52          * Listener pool instance
53          */
54         private $listenerPoolInstance = null;
55
56         /**
57          * Wether this node is anncounced (KEEP ON false!)
58          * @deprecated
59          */
60         private $hubIsAnnounced = false;
61
62         /**
63          * Wether this hub is active
64          */
65         private $isActive = false;
66
67         /**
68          * Protected constructor
69          *
70          * @param       $className      Name of the class
71          * @return      void
72          */
73         protected function __construct ($className) {
74                 // Call parent constructor
75                 parent::__construct($className);
76
77                 // Init state which sets the state to 'init'
78                 $this->initState();
79         }
80
81         /**
82          * Initializes the node's state which sets it to 'init'
83          *
84          * @return      void
85          */
86         private function initState() {
87                 // Get the state factory and create the initial state, we don't need
88                 // the state instance here
89                 NodeStateFactory::createNodeStateInstanceByName('init', $this);
90         }
91
92         /**
93          * Setter for node id
94          *
95          * @param       $nodeId         Our new node id
96          * @return      void
97          */
98         private final function setNodeId ($nodeId) {
99                 // Set it config now
100                 $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId);
101         }
102
103         /**
104          * Getter for node id
105          *
106          * @return      $nodeId         Current node id
107          */
108         private final function getNodeId () {
109                 // Get it from config
110                 return $this->getConfigInstance()->getConfigEntry('node_id');
111         }
112
113         /**
114          * Setter for listener pool instance
115          *
116          * @param       $listenerPoolInstance   Our new listener pool instance
117          * @return      void
118          */
119         private final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) {
120                 $this->listenerPoolInstance = $listenerPoolInstance;
121         }
122
123         /**
124          * Getter for listener pool instance
125          *
126          * @return      $listenerPoolInstance   Our current listener pool instance
127          */
128         public final function getListenerPoolInstance () {
129                 return $this->listenerPoolInstance;
130         }
131
132         /**
133          * Setter for session id
134          *
135          * @param       $sessionId              Our new session id
136          * @return      void
137          */
138         private final function setSessionId ($sessionId) {
139                 $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId);
140         }
141
142         /**
143          * Getter for session id
144          *
145          * @return      $sessionId              Current session id
146          */
147         public final function getSessionId () {
148                 return $this->getConfigInstance()->getConfigEntry('session_id');
149         }
150
151         /**
152          * Setter for query instance
153          *
154          * @param       $connectorInstance              Our new query instance
155          * @return      void
156          */
157         private final function setQueryConnectorInstance (Connectable $connectorInstance) {
158                 $this->queryConnectorInstance = $connectorInstance;
159         }
160
161         /**
162          * Getter for query instance
163          *
164          * @return      $connectorInstance              Our new query instance
165          */
166         public final function getQueryConnectorInstance () {
167                 return $this->queryConnectorInstance;
168         }
169
170         /**
171          * Setter for queue instance
172          *
173          * @param       $connectorInstance              Our new queue instance
174          * @return      void
175          */
176         private final function setQueueConnectorInstance (Connectable $connectorInstance) {
177                 $this->queueConnectorInstance = $connectorInstance;
178         }
179
180         /**
181          * Getter for queue instance
182          *
183          * @return      $connectorInstance              Our new queue instance
184          */
185         public final function getQueueConnectorInstance () {
186                 return $this->queueConnectorInstance;
187         }
188
189         /**
190          * Getter for boot IP/port combination
191          *
192          * @return      $bootIpPort             The IP/port combination of the boot node
193          */
194         protected final function getBootIpPort () {
195                 return $this->bootIpPort;
196         }
197
198         /**
199          * "Getter" for a printable state name
200          *
201          * @return      $stateName      Name of the node's state in a printable format
202          */
203         public final function getPrintableState () {
204                 // Default is 'null'
205                 $stateName = 'null';
206
207                 // Get the state instance
208                 $stateInstance = $this->getStateInstance();
209
210                 // Is it an instance of Stateable?
211                 if ($stateInstance instanceof Stateable) {
212                         // Then use that state name
213                         $stateName = $stateInstance->getStateName();
214                 } // END - if
215
216                 // Return result
217                 return $stateName;
218         }
219
220         /**
221          * Checks wether the given IP address matches one of the bootstrapping nodes
222          *
223          * @param       $remoteAddr             IP address to checkout against our bootstrapping list
224          * @return      $isFound                Wether the IP is found
225          */
226         protected function ifAddressMatchesBootstrappingNodes ($remoteAddr) {
227                 // By default nothing is found
228                 $isFound = false;
229
230                 // Run through all configured IPs
231                 foreach (explode(',', $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $ipPort) {
232                         // Split it up in IP/port
233                         $ipPortArray = explode(':', $ipPort);
234
235                         // Does it match?
236                         if ($ipPortArray[0] == $remoteAddr) {
237                                 // Found it!
238                                 $isFound = true;
239
240                                 // Remember the port number
241                                 $this->bootIpPort = $ipPort;
242
243                                 // Output message
244                                 $this->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __LINE__ . ']: IP matches remote address ' . $ipPort . '.');
245
246                                 // Stop further searching
247                                 break;
248                         } elseif ($ipPortArray[0] == $this->getConfigInstance()->getConfigEntry('node_listen_addr')) {
249                                 // IP matches listen address. At this point we really don't care
250                                 // if we can really listen on that address
251                                 $isFound = true;
252
253                                 // Remember the port number
254                                 $this->bootIpPort = $ipPort;
255
256                                 // Output message
257                                 $this->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __LINE__ . ']: IP matches listen address ' . $ipPort . '.');
258
259                                 // Stop further searching
260                                 break;
261                         }
262                 } // END - foreach
263
264                 // Return the result
265                 return $isFound;
266         }
267
268         /**
269          * Outputs the console teaser. This should only be executed on startup or
270          * full restarts. This method generates some space around the teaser.
271          *
272          * @return      void
273          */
274         public function outputConsoleTeaser () {
275                 // Get the app instance (for shortening our code)
276                 $app = $this->getApplicationInstance();
277
278                 // Output all lines
279                 $this->debugOutput(' ');
280                 $this->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - ' . $this->getRequestInstance()->getRequestElement('mode') . ' mode active');
281                 $this->debugOutput('Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2011 Hub Developer Team');
282                 $this->debugOutput(' ');
283                 $this->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
284                 $this->debugOutput('This is free software, and you are welcome to redistribute it under certain');
285                 $this->debugOutput('conditions; see docs/COPYING for details.');
286                 $this->debugOutput(' ');
287         }
288
289         /**
290          * Generic method to acquire a hub-id. On first run this generates a new one
291          * based on many pseudo-random data. On any later run, unless the id
292          * got not removed from database, it will be restored from the database.
293          *
294          * @param       $requestInstance        A Requestable class
295          * @param       $responseInstance       A Responseable class
296          * @return      void
297          */
298         public function bootstrapAcquireNodeId (Requestable $requestInstance, Responseable $responseInstance) {
299                 // Get a wrapper instance
300                 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
301
302                 // Now get a search criteria instance
303                 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
304
305                 // Search for the node number zero which is hard-coded the default
306                 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
307                 $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
308                 $searchInstance->setLimit(1);
309
310                 // Get a result back
311                 $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
312
313                 // Is it valid?
314                 if ($resultInstance->next()) {
315                         // Save the result instance in this class
316                         $this->setResultInstance($resultInstance);
317
318                         // Get the node id from result and set it
319                         $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID));
320
321                         // Output message
322                         $this->debugOutput('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . '');
323                 } else {
324                         // Get an RNG instance (Random Number Generator)
325                         $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
326
327                         // Generate a pseudo-random string
328                         $randomString = $rngInstance->randomString(255) . ':' . $this->getBootIpPort()  . ':' . $this->getRequestInstance()->getRequestElement('mode');
329
330                         // Get a crypto instance
331                         $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
332
333                         // Hash and encrypt the string so we become a node id (also documented as "hub id")
334                         $this->setNodeId($cryptoInstance->hashString($cryptoInstance->encryptString($randomString)));
335
336                         // Register the node id with our wrapper
337                         $wrapperInstance->registerNodeId($this, $this->getRequestInstance());
338
339                         // Output message
340                         $this->debugOutput('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . '');
341                 }
342         }
343
344         /**
345          * Generates a session id which will be sent to the other hubs and peers
346          *
347          * @return      void
348          */
349         public function bootstrapGenerateSessionId () {
350                 // Get an RNG instance
351                 $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
352
353                 // Generate a pseudo-random string
354                 $randomString = $rngInstance->randomString(255) . ':' . $this->getBootIpPort() . ':' . $this->getRequestInstance()->getRequestElement('mode');
355
356                 // Get a crypto instance
357                 $cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
358
359                 // Hash and encrypt the string so we become a "node id" aka Hub-Id
360                 $this->setSessionId($cryptoInstance->hashString($cryptoInstance->encryptString($randomString)));
361
362                 // Get a wrapper instance
363                 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
364
365                 // Register the node id with our wrapper
366                 $wrapperInstance->registerSessionId($this, $this->getRequestInstance());
367
368                 // Output message
369                 $this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
370
371                 // Change the state because the node has auired a hub id
372                 $this->getStateInstance()->nodeGeneratedSessionId();
373         }
374
375         /**
376          * Initializes queues which every node needs
377          *
378          * @return      void
379          */
380         protected function initGenericQueues () {
381                 // Debug message
382                 $this->debugOutput('BOOTSTRAP: Initialize queues: START');
383
384                 // Set the query connector instance
385                 $this->setQueryConnectorInstance(ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this)));
386
387                 // Run a test query
388                 $this->getQueryConnectorInstance()->doTestQuery();
389
390                 // Set the queue connector instance
391                 $this->setQueueConnectorInstance(ObjectFactory::createObjectByConfiguredName('queue_connector_class', array($this)));
392
393                 // Run a test queue
394                 $this->getQueueConnectorInstance()->doTestQueue();
395
396                 // Debug message
397                 $this->debugOutput('BOOTSTRAP: Initialize queues: FINISHED');
398         }
399
400         /**
401          * Adds hub data elements to a given dataset instance
402          *
403          * @param       $criteriaInstance       An instance of a storeable criteria
404          * @param       $requestInstance        An instance of a Requestable class
405          * @return      void
406          */
407         public function addElementsToDataSet (StoreableCriteria $criteriaInstance, Requestable $requestInstance) {
408                 // Add node number and type
409                 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
410                 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
411
412                 // Add the node id
413                 $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID, $this->getNodeId());
414
415                 // Add the session id if acquired
416                 if ($this->getSessionId() != '') {
417                         $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID, $this->getSessionId());
418                 } // END - if
419         }
420
421         /**
422          * Updates a given field with new value
423          *
424          * @param       $fieldName              Field to update
425          * @param       $fieldValue             New value to store
426          * @return      void
427          * @throws      DatabaseUpdateSupportException  If this class does not support database updates
428          * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
429          */
430         public function updateDatabaseField ($fieldName, $fieldValue) {
431                 // Unfinished
432                 $this->partialStub('Unfinished!');
433                 return;
434
435                 // Get a critieria instance
436                 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
437
438                 // Add search criteria
439                 $searchInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
440                 $searchInstance->setLimit(1);
441
442                 // Now get another criteria
443                 $updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
444
445                 // Add criteria entry which we shall update
446                 $updateInstance->addCriteria($fieldName, $fieldValue);
447
448                 // Add the search criteria for searching for the right entry
449                 $updateInstance->setSearchInstance($searchInstance);
450
451                 // Set wrapper class name
452                 $updateInstance->setWrapperConfigEntry('user_db_wrapper_class');
453
454                 // Remember the update in database result
455                 $this->getResultInstance()->add2UpdateQueue($updateInstance);
456         }
457
458         /**
459          * Announces this hub to the upper (bootstrap or list) hubs. After this is
460          * successfully done the given task is unregistered from the handler. This
461          * might look a bit overloaded here but the announcement phase isn't a
462          * simple "Hello there" message, it may later on also contain more
463          * informations like the object list.
464          *
465          * @param       $taskInstance   The task instance running this announcement
466          * @return      void
467          * @throws      HubAlreadyAnnouncedException    If this hub is already announced
468          * @todo        Change the first if() block to check for a specific state
469          */
470         public function announceSelfToUpperNodes (Taskable $taskInstance) {
471                 // Is this hub node announced?
472                 if ($this->hubIsAnnounced === true) {
473                         // Already announced!
474                         throw new HubAlreadyAnnouncedException($this, self::EXCEPTION_HUB_ALREADY_ANNOUNCED);
475                 } // END - if
476
477                 // Debug output
478                 $this->debugOutput('HUB: Announcement: START (taskInstance=' . $taskInstance->__toString(). ')');
479
480                 // Get a helper instance
481                 $helperInstance = ObjectFactory::createObjectByConfiguredName('hub_announcement_helper_class', array($this));
482
483                 // Load the announcement descriptor
484                 $helperInstance->loadDescriptorXml();
485
486                 // Set some dummy configuration entries, e.g. node_status
487                 $this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName());
488
489                 // Compile all variables
490                 $helperInstance->getTemplateInstance()->compileConfigInVariables();
491
492                 // "Publish" the descriptor by sending it to the bootstrap/list nodes
493                 $helperInstance->sendPackage();
494
495                 // Change the state, this should be the last line except debug output
496                 $this->getStateInstance()->nodeAnnouncedToUpperHubs();
497
498                 // Debug output
499                 $this->debugOutput('HUB: Announcement: FINISHED');
500         }
501
502         /**
503          * Does a self-connect attempt on the public IP address. This should make
504          * it sure, we are reachable from outside world. For this kind of package we
505          * don't need that overload we have in the announcement phase.
506          *
507          * @param       $taskInstance   The task instance running this announcement
508          * @return      void
509          */
510         public function doSelfConnection (Taskable $taskInstance) {
511                 // Debug output
512                 $this->debugOutput('HUB: Self Connection: START (taskInstance=' . $taskInstance->__toString(). ')');
513
514                 // Get a helper instance
515                 $helperInstance = ObjectFactory::createObjectByConfiguredName('hub_self_connect_helper_class', array($this));
516
517                 // Load the descriptor (XML) file
518                 $helperInstance->loadDescriptorXml();
519
520                 // And send the package away
521                 $helperInstance->sendPackage();
522
523                 // Debug output
524                 $this->debugOutput('HUB: Self Connection: FINISHED');
525         }
526
527         /**
528          * Activates the hub by doing some final preparation and setting
529          * $hubIsActive to true
530          *
531          * @param       $requestInstance        A Requestable class
532          * @param       $responseInstance       A Responseable class
533          * @return      void
534          */
535         public function activateNode (Requestable $requestInstance, Responseable $responseInstance) {
536                 // Checks wether a listener is still active and shuts it down if one
537                 // is still listening.
538                 if (($this->determineIfListenerIsActive()) && ($this->getIsActive())) {
539                         // Shutdown them down before they can hurt anything
540                         $this->shutdownListenerPool();
541                 } // END - if
542
543                 // Get the controller here
544                 $controllerInstance = Registry::getRegistry()->getInstance('controller');
545
546                 // Run all filters for the hub activation
547                 $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
548
549                 // ----------------------- Last step from here ------------------------
550                 // Activate the hub. This is ALWAYS the last step in this method
551                 $this->getStateInstance()->nodeIsActivated();
552                 // ---------------------- Last step until here ------------------------
553         }
554
555         /**
556          * Initializes the listener pool (class)
557          *
558          * @return      void
559          */
560         public function initializeListenerPool () {
561                 // Debug output
562                 $this->debugOutput('HUB: Initialize listener: START');
563
564                 // Get a new pool instance
565                 $this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)));
566
567                 // Get an instance of the low-level listener
568                 $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
569
570                 // Setup address and port
571                 $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
572                 if ($this instanceof HubBootNode) {
573                         // Bootstrap have different listening port
574                         $listenerInstance->setListenPortByConfiguration('boot_node_tcp_listen_port');
575                 } else {
576                         // All other nodes use the default port
577                         $listenerInstance->setListenPortByConfiguration('node_tcp_listen_port');
578                 }
579
580                 // Initialize the listener
581                 $listenerInstance->initListener();
582
583                 // Get a decorator class
584                 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_tcp_listener_class', array($listenerInstance));
585
586                 // Add this listener to the pool
587                 $this->getListenerPoolInstance()->addListener($decoratorInstance);
588
589                 // Get a decorator class
590                 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('peer_tcp_listener_class', array($listenerInstance));
591
592                 // Add this listener to the pool
593                 $this->getListenerPoolInstance()->addListener($decoratorInstance);
594
595                 // Get an instance of the low-level listener
596                 $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
597
598                 // Setup address and port
599                 $listenerInstance->setListenAddressByConfiguration('node_listen_addr');
600                 if ($this instanceof HubBootNode) {
601                         // Bootstrap have different listening port
602                         $listenerInstance->setListenPortByConfiguration('boot_node_udp_listen_port');
603                 } else {
604                         // All other nodes use the default port
605                         $listenerInstance->setListenPortByConfiguration('node_udp_listen_port');
606                 }
607
608                 // Initialize the listener
609                 $listenerInstance->initListener();
610
611                 // Get a decorator class
612                 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_udp_listener_class', array($listenerInstance));
613
614                 // Add this listener to the pool
615                 $this->getListenerPoolInstance()->addListener($decoratorInstance);
616
617                 // Get a decorator class
618                 $decoratorInstance = ObjectFactory::createObjectByConfiguredName('peer_udp_listener_class', array($listenerInstance));
619
620                 // Add this listener to the pool
621                 $this->getListenerPoolInstance()->addListener($decoratorInstance);
622
623                 // Debug output
624                 $this->debugOutput('HUB: Initialize listener: FINISHED.');
625         }
626
627         /**
628          * Restores a previously stored node list from database
629          *
630          * @return      void
631          */
632         public function bootstrapRestoreNodeList () {
633                 // Debug output
634                 $this->debugOutput('HUB: Restore node list: START');
635
636                 // Get a wrapper instance
637                 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_list_db_wrapper_class');
638
639                 // Now get a search criteria instance
640                 $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
641
642                 // Search for the node number zero which is hard-coded the default
643                 // @TODO Add some criteria, e.g. if the node is active or so
644                 //$searchInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
645                 //$searchInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
646                 //$searchInstance->setLimit(1);
647
648                 // Get a result back
649                 $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
650
651                 // Is it valid?
652                 if ($resultInstance->next()) {
653                         $this->partialStub('Do something for restoring the list.');
654                         // Output message
655                         //$this->debugOutput('HUB: ');
656                 } else {
657                         // No previously saved node list found!
658                         $this->debugOutput('HUB: No previously saved node list found. This is fine.');
659                 }
660
661                 // Debug output
662                 $this->debugOutput('HUB: Restore node list: FINISHED.');
663         }
664
665         /**
666          * Getter for isActive attribute
667          *
668          * @return      $isActive       Wether the hub is active
669          */
670         public final function getIsActive () {
671                 return $this->isActive;
672         }
673
674         /**
675          * Enables (default) or disables isActive flag
676          *
677          * @param       $isActive       Wether the hub is active
678          * @return      void
679          */
680         public final function enableIsActive ($isActive = true) {
681                 $this->isActive = (bool) $isActive;
682         }
683
684         /**
685          * "Getter for address:port combination
686          *
687          * @param       $handlerInstance        A valid Networkable instance
688          * @return      $addressPort            A address:port combination for this node
689          */
690         public final function getAddressPort (Networkable $handlerInstance) {
691                 // Construct config entry
692                 $configEntry = 'node_' . $handlerInstance->getHandlerName() . '_listen_port';
693
694                 // Get IP and port
695                 $addressPort = $this->getConfigInstance()->detectServerAddress() . ':' . $this->getConfigInstance()->getConfigEntry($configEntry);
696
697                 // Return it
698                 return $addressPort;
699         }
700 }
701
702 // [EOF]
703 ?>