From fe4b8ec8891325eb8534f3dd6b85376ac644e43b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 6 Dec 2020 06:38:05 +0100 Subject: [PATCH] Continued: - moved BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR to Node interface as this is a node-related only constant - moved BaseHubNode::NODE_TYPE_* to Node interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- application/hub/classes/class_BaseHubSystem.php | 5 ----- .../hub/classes/nodes/boot/class_HubBootNode.php | 2 +- application/hub/classes/nodes/class_BaseHubNode.php | 13 +++---------- .../recipient/upper/class_UpperRecipient.php | 4 ++-- application/hub/interfaces/nodes/class_Node.php | 13 +++++++++++++ 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index b1af3fa71..79b86824b 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -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 * diff --git a/application/hub/classes/nodes/boot/class_HubBootNode.php b/application/hub/classes/nodes/boot/class_HubBootNode.php index a61697b5e..22e01fa17 100644 --- a/application/hub/classes/nodes/boot/class_HubBootNode.php +++ b/application/hub/classes/nodes/boot/class_HubBootNode.php @@ -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 { diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 961eb1806..89a08ce2a 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -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))); diff --git a/application/hub/classes/recipient/upper/class_UpperRecipient.php b/application/hub/classes/recipient/upper/class_UpperRecipient.php index 75d4831cb..bd436b139 100644 --- a/application/hub/classes/recipient/upper/class_UpperRecipient.php +++ b/application/hub/classes/recipient/upper/class_UpperRecipient.php @@ -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 diff --git a/application/hub/interfaces/nodes/class_Node.php b/application/hub/interfaces/nodes/class_Node.php index 9d6af7613..d2e142e90 100644 --- a/application/hub/interfaces/nodes/class_Node.php +++ b/application/hub/interfaces/nodes/class_Node.php @@ -38,6 +38,19 @@ use Org\Mxchange\CoreFramework\Task\Taskable; * along with this program. If not, see . */ 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 -- 2.39.5