From: Roland Häder Date: Sun, 6 Dec 2020 05:38:05 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fe4b8ec8891325eb8534f3dd6b85376ac644e43b;p=hub.git Continued: - 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 --- 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