]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/nodes/class_BaseHubNode.php
publishHubDescriptor() added, TODOs.txt updated
[hub.git] / application / hub / main / nodes / class_BaseHubNode.php
index 4e903bddcb6aef99247c93358f35145a5b042a1d..cebc45bdeb2078bd100a07397de70a9310b1e275 100644 (file)
@@ -40,7 +40,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
        /**
         * Query connector instance
         */
-       private $queryInstance = null;
+       private $connectorInstance = null;
 
        /**
         * Listener pool instance
@@ -82,6 +82,25 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                return $this->nodeId;
        }
 
+       /**
+        * Setter for listener pool instance
+        *
+        * @param       $listenerPoolInstance   Our new listener pool instance
+        * @return      void
+        */
+       private final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) {
+               $this->listenerPoolInstance = $listenerPoolInstance;
+       }
+
+       /**
+        * Getter for listener pool instance
+        *
+        * @return      $listenerPoolInstance   Our current listener pool instance
+        */
+       public final function getListenerPoolInstance () {
+               return $this->listenerPoolInstance;
+       }
+
        /**
         * Setter for session id
         *
@@ -97,27 +116,36 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
         *
         * @return      $sessionId              Our new session id
         */
-       private final function getSessionId () {
+       public final function getSessionId () {
                return $this->sessionId;
        }
 
        /**
         * Setter for query instance
         *
-        * @param       $queryInstance          Our new query instance
+        * @param       $connectorInstance              Our new query instance
         * @return      void
         */
-       private final function setQueryInstance (Queryable $queryInstance) {
-               $this->queryInstance = $queryInstance;
+       private final function setQueryConnectorInstance (Connectable $connectorInstance) {
+               $this->connectorInstance = $connectorInstance;
        }
 
        /**
         * Getter for query instance
         *
-        * @return      $queryInstance          Our new query instance
+        * @return      $connectorInstance              Our new query instance
+        */
+       public final function getQueryConnectorInstance () {
+               return $this->connectorInstance;
+       }
+
+       /**
+        * Getter for boot IP/port combination
+        *
+        * @return      $bootIpPort             The IP/port combination of the boot node
         */
-       protected final function getQueryInstance () {
-               return $this->queryInstance;
+       protected final function getBootIpPort () {
+               return $this->bootIpPort;
        }
 
        /**
@@ -270,15 +298,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->debugOutput('BOOTSTRAP: Created new session-id: ' . $this->getSessionId() . '');
        }
 
-       /**
-        * Getter for boot IP/port combination
-        *
-        * @return      $bootIpPort             The IP/port combination of the boot node
-        */
-       protected final function getBootIpPort () {
-               return $this->bootIpPort;
-       }
-
        /**
         * Initializes queues which every node needs
         *
@@ -289,15 +308,25 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->debugOutput('BOOTSTRAP: Initialize queues: START');
 
                // Set the query connector instance
-               $this->setQueryInstance(ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this)));
+               $this->setQueryConnectorInstance(ObjectFactory::createObjectByConfiguredName('query_connector_class', array($this)));
 
                // Run a test query
-               $this->getQueryInstance()->doTestQuery();
+               $this->getQueryConnectorInstance()->doTestQuery();
 
                // Debug message
                $this->debugOutput('BOOTSTRAP: Initialize queues: FINISHED');
        }
-       
+
+       /**
+        * Publish our hub descriptor to the upper hub(s)
+        *
+        * @return      void
+        * @todo        This should be implemented in a generic way to keep things easy.
+        */
+       protected function publishHubDescriptor () {
+               $this->partialStub('Unfinished method.');
+       }
+
        /**
         * Adds hub data elements to a given dataset instance
         *
@@ -394,7 +423,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $controllerInstance = Registry::getRegistry()->getInstance('controller');
 
                // Run all filters for the hub activation
-               $controllerInstance->executeHubActivationFilters($requestInstance, $responseInstance);
+               $controllerInstance->executeActivationFilters($requestInstance, $responseInstance);
 
                // ----------------------- Last step from here ------------------------
                // Activate the hub. This is ALWAYS the last step in this method
@@ -412,7 +441,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->debugOutput('HUB: Initialize listener: START');
 
                // Get a new pool instance
-               $this->listenerPoolInstance = ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this));
+               $this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)));
 
                // Get an instance of the low-level listener
                $listenerInstance = ObjectFactory::createObjectByConfiguredName('tcp_listener_class', array($this));
@@ -428,13 +457,13 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_tcp_listener_class', array($listenerInstance));
 
                // Add this listener to the pool
-               $this->listenerPoolInstance->addListener($decoratorInstance);
+               $this->getListenerPoolInstance()->addListener($decoratorInstance);
 
                // Get a decorator class
                $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance));
 
                // Add this listener to the pool
-               $this->listenerPoolInstance->addListener($decoratorInstance);
+               $this->getListenerPoolInstance()->addListener($decoratorInstance);
 
                // Get an instance of the low-level listener
                $listenerInstance = ObjectFactory::createObjectByConfiguredName('udp_listener_class', array($this));
@@ -450,13 +479,13 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $decoratorInstance = ObjectFactory::createObjectByConfiguredName('hub_udp_listener_class', array($listenerInstance));
 
                // Add this listener to the pool
-               $this->listenerPoolInstance->addListener($decoratorInstance);
+               $this->getListenerPoolInstance()->addListener($decoratorInstance);
 
                // Get a decorator class
                $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance));
 
                // Add this listener to the pool
-               $this->listenerPoolInstance->addListener($decoratorInstance);
+               $this->getListenerPoolInstance()->addListener($decoratorInstance);
 
                // Debug output
                $this->debugOutput('HUB: Initialize listener: FINISHED.');
@@ -490,8 +519,11 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                if ($resultInstance->next()) {
                        $this->partialStub('Do something for restoring the list.');
                        // Output message
-                       //$this->debugOutput('BOOTSTRAP: ');
-               } // END - if
+                       //$this->debugOutput('HUB: ');
+               } else {
+                       // No previously saved node list found!
+                       $this->debugOutput('HUB: No previously saved node list found. This is fine.');
+               }
 
                // Debug output
                $this->debugOutput('HUB: Restore node list: FINISHED.');