From a77f201606b892fe1d18d12e0803a11af2124d05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 6 Jul 2009 19:16:00 +0000 Subject: [PATCH] More debug lines added, bootstrap method stubs added --- application/hub/class_ApplicationHelper.php | 6 +++++ .../hub/main/nodes/boot/class_HubBootNode.php | 13 +++++----- .../hub/main/nodes/class_BaseHubNode.php | 26 ++++++++++++++----- .../hub/main/nodes/list/class_HubListNode.php | 13 +++++----- .../main/nodes/master/class_HubMasterNode.php | 13 +++++----- .../nodes/regular/class_HubRegularNode.php | 14 +++++----- 6 files changed, 50 insertions(+), 35 deletions(-) diff --git a/application/hub/class_ApplicationHelper.php b/application/hub/class_ApplicationHelper.php index 23ad957ac..0e8fc55c7 100644 --- a/application/hub/class_ApplicationHelper.php +++ b/application/hub/class_ApplicationHelper.php @@ -185,6 +185,12 @@ class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplica die('Node mode ' . $nodeMode . ' is invalid.' . "\n"); } + // ----------------------- Output teaser lines ------------------------ + // Output some introducing lines to the console. This should be later + // be switched off if this is a productive release because it would be + // only visible to the logfile. + $nodeInstance->outputConsoleTeaser(); + // ----------------------- Bootstrapping phase ------------------------ // Try to bootstrap the node and pass the request instance to it for // extra arguments which mostly override config entries or enable special diff --git a/application/hub/main/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php index e3d294aaa..b984b5ce8 100644 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ b/application/hub/main/nodes/boot/class_HubBootNode.php @@ -45,13 +45,6 @@ class HubBootNode extends BaseHubNode implements NodeHelper { // Set the request instance $nodeInstance->setRequestInstance($requestInstance); - // --------------------- Hub-id acquirement phase --------------------- - // Acquire a hub-id. This step generates on first launch a new one and - // on any later launches it will restore the hub-id from the database. - // A passed 'nickname=xxx' argument will be used to add some - // 'personality' to the hub. - $nodeInstance->acquireHubId(); - // Return the instance return $nodeInstance; } @@ -65,6 +58,9 @@ class HubBootNode extends BaseHubNode implements NodeHelper { * @todo add some more special bootstrap things for this boot node */ public function doBootstrapping () { + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Beginning with bootstrap...'); + // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); @@ -91,6 +87,9 @@ class HubBootNode extends BaseHubNode implements NodeHelper { // This might not be all... $this->partialStub('Please implement more bootsrapping steps.'); + + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Bootstrap finished.'); } /** diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index a47136f62..d2755f21f 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -125,7 +125,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * * @return void */ - protected function outputConsoleTeaser () { + public function outputConsoleTeaser () { // Get the app instance (for shortening our code) $app = $this->getApplicationInstance(); @@ -148,8 +148,22 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * @todo This method is maybe not yet finished. */ protected function doGenericBootstrapping () { - // This should be the last line: output teaser - $this->outputConsoleTeaser(); + // --------------------- Hub-id acquirement phase --------------------- + // Acquire a hub-id. This step generates on first launch a new one and + // on any later launches it will restore the hub-id from the database. + // A passed 'nickname=xxx' argument will be used to add some + // 'personality' to the hub. + $this->bootstrapAcquireHubId(); + + // ------------------- More generic bootstrap steps ------------------- + // Generate the session id which will only be stored in RAM + $this->bootstrapGenerateSessionId(); + + // 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.'); @@ -162,7 +176,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { * * @return void */ - protected function acquireHubId () { + private function bootstrapAcquireHubId () { // Get a wrapper instance $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class'); @@ -186,7 +200,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { $this->setNodeId($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID)); // Output message - $this->getDebugInstance()->output('Re-using found node-id: ' . $this->getNodeId() . ''); + $this->getDebugInstance()->output('BOOTSTRAP: Re-using found node-id: ' . $this->getNodeId() . ''); } else { // Get an RNG instance (Random Number Generator) $rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class'); @@ -204,7 +218,7 @@ class BaseHubNode extends BaseFrameworkSystem implements Updateable { $wrapperInstance->registerNodeId($this, $this->getRequestInstance()); // Output message - $this->getDebugInstance()->output('Created new node-id: ' . $this->getNodeId() . ''); + $this->getDebugInstance()->output('BOOTSTRAP: Created new node-id: ' . $this->getNodeId() . ''); } } diff --git a/application/hub/main/nodes/list/class_HubListNode.php b/application/hub/main/nodes/list/class_HubListNode.php index e1375702b..0e2fc9e9f 100644 --- a/application/hub/main/nodes/list/class_HubListNode.php +++ b/application/hub/main/nodes/list/class_HubListNode.php @@ -45,13 +45,6 @@ class HubListNode extends BaseHubNode implements NodeHelper { // Set the request instance $nodeInstance->setRequestInstance($requestInstance); - // --------------------- Hub-id acquirement phase --------------------- - // Acquire a hub-id. This step generates on first launch a new one and - // on any later launches it will restore the hub-id from the database. - // A passed 'nickname=xxx' argument will be used to add some - // 'personality' to the hub. - $nodeInstance->acquireHubId(); - // Return the instance return $nodeInstance; } @@ -65,9 +58,15 @@ class HubListNode extends BaseHubNode implements NodeHelper { * @todo Implement this method */ public function doBootstrapping () { + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Beginning with bootstrap...'); + // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); $this->partialStub('Please implement this method.'); + + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Bootstrap finished.'); } /** diff --git a/application/hub/main/nodes/master/class_HubMasterNode.php b/application/hub/main/nodes/master/class_HubMasterNode.php index 803bc8926..92b100c74 100644 --- a/application/hub/main/nodes/master/class_HubMasterNode.php +++ b/application/hub/main/nodes/master/class_HubMasterNode.php @@ -45,13 +45,6 @@ class HubMasterNode extends BaseHubNode implements NodeHelper { // Set the request instance $nodeInstance->setRequestInstance($requestInstance); - // --------------------- Hub-id acquirement phase --------------------- - // Acquire a hub-id. This step generates on first launch a new one and - // on any later launches it will restore the hub-id from the database. - // A passed 'nickname=xxx' argument will be used to add some - // 'personality' to the hub. - $nodeInstance->acquireHubId(); - // Return the instance return $nodeInstance; } @@ -65,9 +58,15 @@ class HubMasterNode extends BaseHubNode implements NodeHelper { * @todo Implement this method */ public function doBootstrapping () { + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Beginning with bootstrap...'); + // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); $this->partialStub('Please implement this method.'); + + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Bootstrap finished.'); } /** diff --git a/application/hub/main/nodes/regular/class_HubRegularNode.php b/application/hub/main/nodes/regular/class_HubRegularNode.php index b6cb2d36a..243271e6d 100644 --- a/application/hub/main/nodes/regular/class_HubRegularNode.php +++ b/application/hub/main/nodes/regular/class_HubRegularNode.php @@ -45,13 +45,6 @@ class HubRegularNode extends BaseHubNode implements NodeHelper { // Set the request instance $nodeInstance->setRequestInstance($requestInstance); - // --------------------- Hub-id acquirement phase --------------------- - // Acquire a hub-id. This step generates on first launch a new one and - // on any later launches it will restore the hub-id from the database. - // A passed 'nickname=xxx' argument will be used to add some - // 'personality' to the hub. - $nodeInstance->acquireHubId(); - // Return the instance return $nodeInstance; } @@ -61,14 +54,19 @@ class HubRegularNode extends BaseHubNode implements NodeHelper { * command-line arguments stored in the request instance. The regular node * should communicate with the bootstrap-nodes at this point. * - * @param $requestInstance A Requestable instance * @return void * @todo Implement this method */ public function doBootstrapping () { + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Beginning with bootstrap...'); + // Call generic (parent) bootstrapping method first parent::doGenericBootstrapping(); $this->partialStub('Please implement this method.'); + + // Output message + $this->getDebugInstance()->output('BOOTSTRAP: Bootstrap finished.'); } /** -- 2.39.5