]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 05:38:05 +0000 (06:38 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 6 Dec 2020 05:43:50 +0000 (06:43 +0100)
- moved BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR to Node interface as this is a
  node-related only constant
- moved BaseHubNode::NODE_TYPE_* to Node interface

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/nodes/boot/class_HubBootNode.php
application/hub/classes/nodes/class_BaseHubNode.php
application/hub/classes/recipient/upper/class_UpperRecipient.php
application/hub/interfaces/nodes/class_Node.php

index b1af3fa71828c6f7b74304c660348dbeebb3b389..79b86824b3a6dbedd8c3ab462e456bca88a36d27 100644 (file)
@@ -50,11 +50,6 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface
        // Message status codes
        const MESSAGE_STATUS_CODE_OKAY = 'OKAY';
 
-       /**
-        * Separator for all bootstrap node entries
-        */
-       const BOOTSTRAP_NODES_SEPARATOR = ';';
-
        /**
         * Protected constructor
         *
index a61697b5ecd7087834c3634aa32038535ea5c653..22e01fa173c4f69f278f0d1a65e2871ed99d8f3a 100644 (file)
@@ -87,7 +87,7 @@ class HubBootNode extends BaseHubNode implements Node, Registerable {
                                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BOOTSTRAP: UNL matches bootstrap node "%s".', $this->getBootUniversalNodeLocator()));
 
                                // Now, does the mode match
-                               if (FrameworkBootstrap::getRequestInstance()->getRequestElement('mode') == self::NODE_TYPE_BOOT) {
+                               if (FrameworkBootstrap::getRequestInstance()->getRequestElement('mode') == Node::NODE_TYPE_BOOT) {
                                        // Output debug message
                                        self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Our node is a valid bootstrap node.');
                                } else {
index 961eb18060941cca4042df11bc56002d7609f55d..89a08ce2ad588262dc6a531208c2d3d14d31549b 100644 (file)
@@ -12,6 +12,7 @@ use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler;
 use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
 use Org\Shipsimu\Hub\Network\Receive\Receivable;
+use Org\Shipsimu\Hub\Node\Node;
 use Org\Shipsimu\Hub\Pool\Poolable;
 use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
 use Org\Shipsimu\Hub\Template\Engine\Xml\ObjectRegistry\XmlObjectRegistryTemplateEngine;
@@ -68,14 +69,6 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
        use DatabaseFrontendTrait;
        use StateableTrait;
 
-       /**
-        * Node types
-        */
-       const NODE_TYPE_BOOT    = 'boot';
-       const NODE_TYPE_MASTER  = 'master';
-       const NODE_TYPE_LIST    = 'list';
-       const NODE_TYPE_REGULAR = 'regular';
-
        // Exception constants
        const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00;
 
@@ -243,7 +236,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                $isFound = FALSE;
 
                // Run through all configured IPs
-               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) {
+               foreach (explode(Node::BOOTSTRAP_NODES_SEPARATOR, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unl) {
                        // Does it match?
                        if ($unl == $remoteAddr) {
                                // Found it!
@@ -945,7 +938,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                 * added then the next check will be TRUE.
                 */
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HUB-NODE: CALLED!');
-               $acceptsRequest = ((!$this instanceof HubRegularNode) && (FrameworkBootstrap::getRequestInstance()->getRequestElement('mode') != self::NODE_TYPE_REGULAR));
+               $acceptsRequest = ((!$this instanceof HubRegularNode) && (FrameworkBootstrap::getRequestInstance()->getRequestElement('mode') != Node::NODE_TYPE_REGULAR));
 
                // Return it
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-NODE: acceptsRequests=%d - EXIT!', intval($hasAnnouncementCompleted)));
index 75d4831cb377c4039c3751c2af1ac39efbdfa6a1..bd436b139a98917b7cd94a30cedec48bb678609e 100644 (file)
@@ -3,11 +3,11 @@
 namespace Org\Shipsimu\Hub\Network\Recipient\Upper;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler;
 use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
 use Org\Shipsimu\Hub\Network\Recipient\BaseRecipient;
 use Org\Shipsimu\Hub\Network\Recipient\Recipient;
+use Org\Shipsimu\Hub\Node\Node;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
@@ -80,7 +80,7 @@ class UpperRecipient extends BaseRecipient implements Recipient {
                assert($recipientUnl == NetworkPackageHandler::RECIPIENT_TYPE_UPPER);
 
                // Get all bootstrap nodes
-               foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) {
+               foreach (explode(Node::BOOTSTRAP_NODES_SEPARATOR, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('hub_bootstrap_nodes')) as $unlData) {
                        // Is maximum reached?
                        if ($listInstance->count() == FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_recipient_max_count')) {
                                // Then stop adding more
index 9d6af7613da0882fd69dfb33ed59ca98a61450d9..d2e142e905e7612bf6514a16b0c17c7713c6352d 100644 (file)
@@ -38,6 +38,19 @@ use Org\Mxchange\CoreFramework\Task\Taskable;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface Node extends FrameworkInterface {
+       /**
+        * Separator for all bootstrap node entries
+        */
+       const BOOTSTRAP_NODES_SEPARATOR = ';';
+
+       /**
+        * Node types
+        */
+       const NODE_TYPE_BOOT    = 'boot';
+       const NODE_TYPE_MASTER  = 'master';
+       const NODE_TYPE_LIST    = 'list';
+       const NODE_TYPE_REGULAR = 'regular';
+
        /**
         * Method to "bootstrap" the node. This step does also apply provided
         * command-line arguments stored in the request instance. You should now