]> git.mxchange.org Git - hub.git/commitdiff
TCP/UDP listener config entries added, some more stub calls added
authorRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 17:33:28 +0000 (17:33 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Jul 2009 17:33:28 +0000 (17:33 +0000)
application/hub/class_ApplicationHelper.php
application/hub/config.php
application/hub/main/nodes/class_BaseHubNode.php

index 0e8fc55c7c60dc507955f8f4108f10a708fa92fa..121f58f88a08d3024bb42d820567c23b0feebfa5 100644 (file)
@@ -202,6 +202,11 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica
                // will help us to communicate between the "tasks" a hub needs to do.
                $nodeInstance->initQueues();
 
+               // -------------------------- Hub activation --------------------------
+               // Activates the hub by doing some final preparation steps and setting
+               // the attribute $hubIsActive to true
+               $nodeInstance->activateHub();
+
                // ----------------------------- Main loop ----------------------------
                // This is the main loop. Queried calls should come back here very fast
                // so the whole application runs on nice speed. This while-loop goes
index 6c7bc5c99a6e53c514d5d75ee534e6c4715077cd..ce9a200012cabc486e8770cfdd099253da640ffc 100644 (file)
@@ -27,8 +27,11 @@ $cfg = FrameworkConfiguration::getInstance();
 // CFG: NODE-LISTEN-ADDR
 $cfg->setConfigEntry('node_listen_addr', "0.0.0.0");
 
-// CFG: NODE-LISTEN-PORT
-$cfg->setConfigEntry('node_listen_port', 9060);
+// CFG: NODE-TCP-LISTEN-PORT
+$cfg->setConfigEntry('node_tcp_listen_port', 9060);
+
+// CFG: NODE-UDP-LISTEN-PORT
+$cfg->setConfigEntry('node_udp_listen_port', 9060);
 
 // CFG: NODE-MODE (can be 'regular', 'list', 'master' or 'boot', default is 'regular')
 $cfg->setConfigEntry('node_mode', "regular");
@@ -48,11 +51,17 @@ $cfg->setConfigEntry('node_info_db_wrapper_class', "NodeInformationDatabaseWrapp
 // CFG: WEB-CONTENT-TYPE
 $cfg->setConfigEntry('web_content_type', "");
 
-// CFG: QUERY-CONNECTOR
+// CFG: QUERY-CONNECTOR-CLASS
 $cfg->setConfigEntry('query_connector_class', "LocalQueryConnector");
 
-// CFG: QUEUE-CONNECTOR
+// CFG: QUEUE-CONNECTOR-CLASS
 $cfg->setConfigEntry('queue_connector_class', "LocalQueueConnector");
 
+// CFG: TCP-LISTENER-CLASS
+$cfg->setConfigEntry('tcp_listener_class', "TcpListener");
+
+// CFG: UDP-LISTENER-CLASS
+$cfg->setConfigEntry('udp_listener_class', "UdpListener");
+
 // [EOF]
 ?>
index d2755f21f7fa4e8d6554207c49e764bf0d78d2bb..590aaa8fed363865a74d7855d7287bd0808da376 100644 (file)
@@ -37,6 +37,16 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
         */
        private $queryInstance = null;
 
+       /**
+        * Listener pool instance
+        */
+       private $listenerPoolInstance = null;
+
+       /**
+        * Wether the hub is active (true/false)
+        */
+       private $hubIsActive = false;
+
        /**
         * Protected constructor
         *
@@ -156,15 +166,13 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
                $this->bootstrapAcquireHubId();
 
                // ------------------- More generic bootstrap steps -------------------
-               // Generate the session id which will only be stored in RAM
+               // Generate the session id which will only be stored in RAM and kept for
+               // the whole "session".
                $this->bootstrapGenerateSessionId();
 
-               // Restore a previously downloaded bootstrap-node list
+               // Restore a previously downloaded bootstrap-node list.
                $this->bootstrapRestoreNodeList();
 
-               // Download or update the bootstrap-node list
-               $this->bootstrapDownloadNodeList();
-
                // @TODO Add some generic bootstrap steps
                $this->partialStub('Add some generic bootstrap steps here.');
        }
@@ -284,6 +292,39 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable {
                // Remember the update in database result
                $this->getResultInstance()->add2UpdateQueue($updateInstance);
        }
+
+       /**
+        * Getter for $hubIsActive attribute
+        *
+        * @return      $hubIsActive    Wether the hub is activer
+        */
+       public final function isHubActive () {
+               return $this->hubIsActive;
+       }
+
+       /**
+        * Activates the hub by doing some final preparation and setting
+        * $hubIsActive to true
+        */
+       public function activateHub () {
+               // Checks wether a listener is still active and shuts it down if one
+               // is still listening
+               if (($this->checkIfListenerIsActive()) && ($this->isHubActive())) {
+                       // Shutdown them down before they can hurt anything
+                       $this->shutdownListenerPool();
+               } // END - if
+
+               // Initialize the TCP/UDP listener pool
+               $this->initializeListenerPool();
+
+               // @TODO Do some final preparation
+               $this->partialStub('Do some final preparation before the hub gots activated.');
+
+               // ----------------------- Last step from here ------------------------
+               // Activate the hub. This is ALWAYS the last step in this method
+               $this->hubIsActive = true;
+               // ---------------------- Last step until here ------------------------
+       }
 }
 
 // [EOF]