die('Node mode ' . $nodeMode . ' is invalid.' . "\n");
}
- // --------------------- Hub-id acquirement phase ---------------------
- // Acquire a hub-id. This step generates on first launch anew 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($requestInstance);
-
// --------------------- Bootstrapping phase ---------------------
// Try to bootstrap the node and pass the request instance to it for
- // extra arguments which mostly override config entries
+ // extra arguments which mostly override config entries or enable special
+ // features within the hub (none is ready at this development stage)
$nodeInstance->doBootstrapping($requestInstance);
}
// 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;
}
* @todo add some more special bootstrap things for this boot node
*/
public function doBootstrapping () {
- // Call generic (parent) bootstrapping method
+ // Call generic (parent) bootstrapping method first
parent::doGenericBootstrapping();
// Now check if the IP address matches one of the bootstrap nodes
if ($this->ifAddressMatchesBootstrappingNodes($_SERVER['REMOTE_ADDR'])) {
- // Get our port
+ // Get our port from configuration
$ourPort = $this->getConfigInstance()->readConfig('node_listen_port');
// Is the port the same?
} // END - if
// This might not be all...
- $this->partialStub("Please implement more bootsrapping steps.");
+ $this->partialStub('Please implement more bootsrapping steps.');
+
+ // This should be the last thing to do: output teaser lines
+ $this->outputConsoleTeaser();
}
}
* @todo Implement this method
*/
public function doBootstrapping () {
- // Call generic (parent) bootstrapping method
+ // Call generic (parent) bootstrapping method first
parent::doGenericBootstrapping();
- $this->partialStub("Please implement this method.");
+ $this->partialStub('Please implement this method.');
+
+ // This is the last line: output teaser
+ $this->outputTeaserLines();
}
}
*
* @return void
*/
- private function outputConsoleTeaser () {
+ protected function outputConsoleTeaser () {
// Get the app instance (for shortening our code)
$app = $this->getApplicationInstance();
* Do generic things for bootup phase. This can be e.g. checking if the
* right node mode is selected for this hub's IP number.
*
- * @todo This method is maybe not yet finished.
* @return void
+ * @todo This method is maybe not yet finished.
*/
protected function doGenericBootstrapping () {
- // Finally output our teaser. This should be the last line!
- $this->outputConsoleTeaser();
+ // @TODO Empty method
+ $this->partialStub('Add some generic bootstrap steps here.');
}
/**
* based on many pseudo-random data. On any later run, unless the id
* got not removed from database, it will be restored from the database.
*
- * @param $requestInstance An instance of a Requestable class
* @return void
*/
- public function acquireHubId (Requestable $requestInstance) {
+ protected function acquireHubId () {
// Get a wrapper instance
$wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_info_db_wrapper_class');
// Search for the node number zero which is hard-coded the default
$searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_NR, 1);
- $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $requestInstance->getRequestElement('mode'));
+ $searchInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_NODE_TYPE, $this->getRequestInstance()->getRequestElement('mode'));
$searchInstance->setLimit(1);
// Get a result back
$rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
// Generate a pseudo-random string
- $randomString = $rngInstance->randomString(255) . ':' . $requestInstance->getRequestElement('mode');
+ $randomString = $rngInstance->randomString(255) . ':' . $this->getRequestInstance()->getRequestElement('mode');
// Get a crypto instance
$cryptoInstance = ObjectFactory::createObjectByConfiguredName('crypto_class');
$this->setNodeId($cryptoInstance->hashString($cryptoInstance->encryptString($randomString)));
// Register the node id with our wrapper
- $wrapperInstance->registerNodeId($this, $requestInstance);
+ $wrapperInstance->registerNodeId($this, $this->getRequestInstance());
// Output message
$this->getDebugInstance()->output('Created new node-id: ' . $this->getNodeId() . '');
// 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;
}
* @todo Implement this method
*/
public function doBootstrapping () {
- // Call generic (parent) bootstrapping method
+ // Call generic (parent) bootstrapping method first
parent::doGenericBootstrapping();
- $this->partialStub("Please implement this method.");
+ $this->partialStub('Please implement this method.');
+
+ // This should be the last line: output teaser
+ $this->outputConsoleTeaser();
}
}
// 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;
}
* @todo Implement this method
*/
public function doBootstrapping () {
- // Call generic (parent) bootstrapping method
+ // Call generic (parent) bootstrapping method first
parent::doGenericBootstrapping();
- $this->partialStub("Please implement this method.");
+ $this->partialStub('Please implement this method.');
+
+ // This should be the last line: output teaser
+ $this->outputConsoleTeaser();
}
}
// 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;
}
* @todo Implement this method
*/
public function doBootstrapping () {
- // Call generic (parent) bootstrapping method
+ // Call generic (parent) bootstrapping method first
parent::doGenericBootstrapping();
- $this->partialStub("Please implement this method.");
+ $this->partialStub('Please implement this method.');
+
+ // This is the last line: output teaser
+ $this->outputConsoleTeaser();
}
}
}
/**
- * Determines the correct absolute path for all includes
+ * Determines the correct absolute path for all includes only once per run.
+ * Other calls of this method are being "cached".
*
* @return $basePath Base path (core) for all includes
*/