$current = $resultInstance->current();
// Add instance to recipient list
- /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: current=%s', print_r($current, TRUE)));
+ //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: current=%s', print_r($current, TRUE)));
array_push($recipients, $current);
// Advanced to next entry
$current = $resultInstance->current();
// Add instance to recipient list
- /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: current=%s', print_r($current, TRUE)));
+ //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: current=%s', print_r($current, TRUE)));
array_push($recipients, $current);
// Advanced to next entry
* @return $isValid Whether the final (last) chunk is valid
* @throws UnexpectedValueException If some unexpected value was found
*/
- private function isValidFinalChunk (array $chunks) {
+ private function isFinalChunkValid (array $chunks) {
// Default is all fine
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: chunks()=%d - CALLED!', count($chunks)));
$isValid = TRUE;
$chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunk);
// Make sure chunks with only 3 elements are parsed (for details see ChunkHandler)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: eopChunk=%s,chunkSplits=%s', $chunks[count($chunks) - 1], print_r($chunkSplits, TRUE)));
+ //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: eopChunk=%s,chunkSplits=%s', $chunks[count($chunks) - 1], print_r($chunkSplits, TRUE)));
if (count($chunkSplits) != 3) {
// Must be 3 elements exact
throw new UnexpectedValueException(sprintf('chunk=%s has %d splits, must be exact 3.', $chunk, count($chunkSplits)));
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: chunks()=%d - CALLED!', count($chunks)));
try {
// Validate final chunk
- $this->isValidFinalChunk($chunks);
+ $this->isFinalChunkValid($chunks);
} catch (AssertionException $e) {
// Last chunk is not valid
throw new FinalChunkVerificationException(array($this, $chunks, $e), self::EXCEPTION_FINAL_CHUNK_VERIFICATION);
$this->prepareNextMessage($messageInstance, $handlerInstance);
}
- /**
- * Initializes configuration data from given message data array
- *
- * The following array is being handled over:
- *
- * my-external-address => 1.2.3.4
- * my-internal-address => 5.6.7.8
- * my-status => reachable
- * my-node-id => aaabbbcccdddeeefff123456789
- * my-session-id => aaabbbcccdddeeefff123456789
- * my-tcp-port => 9060
- * my-udp-port => 9060
- * answer-status => OKAY
- * message_type => announcement_answer
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Get node instance
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-MESSAGE-HANDLER: Creating node instance ...');
- $nodeInstance = NodeObjectFactory::createNodeInstance();
-
- // Get an array of all accepted object types
- $objectList = $nodeInstance->getListFromAcceptedObjectTypes();
-
- // Add missing (temporary) configuration 'accepted_object_types'
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration. For content of $messageInstance see method comment above.
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Remove temporay configuration
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ACCEPTED_OBJECTS);
- }
-
}
// @TODO $this->prepareNextMessage($messageInstance, $handlerInstance);
}
- /**
- * Initializes configuration data from given message data array
- *
- * The following array is being handled over:
- *
- * session-id => aaabbbcccdddeeefff123456789
- * node-list => aabb:ccdd:eeff
- * answer-status => OKAY
- * message_type => request_node_list_answer
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @todo 0% done
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- $this->partialStub('Please implement this method.');
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration. For content of $messageInstance see method comment above.
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @todo 0% done
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- $this->partialStub('Please implement this method.');
- }
}
-
-// [EOF]
-?>
*/
protected $messageDataElements = [];
- /**
- * Array for translating message data elements (other node's data mostly)
- * into configuration elements.
- */
- protected $messageToConfig = [];
-
- /**
- * Array for copying configuration entries
- */
- protected $configCopy = [];
-
/**
* Protected constructor
*
// Load descriptor XML
$helperInstance->loadDescriptorXml($nodeInstance);
- /*
- * Set missing (temporary) configuration data, mostly it needs to be
- * copied from message data array.
- */
- $this->initMessageConfigurationData($messageInstance);
-
// Compile any configuration variables
$helperInstance->getTemplateInstance()->compileConfigInVariables();
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-DATA-HANDLER: Calling helperInstance->sendPackage(%s) ...', $nodeInstance->__toString()));
$helperInstance->sendPackage($nodeInstance);
- /*
- * Remove temporary configuration
- */
- $this->removeMessageConfigurationData($messageInstance);
-
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER: Answer message has been prepared.');
}
// Load descriptor XML
$helperInstance->loadDescriptorXml($nodeInstance);
- /*
- * Set missing (temporary) configuration data, mostly it needs to be
- * copied from message data array.
- */
- $this->initMessageConfigurationData($messageInstance);
-
// Compile any configuration variables
$helperInstance->getTemplateInstance()->compileConfigInVariables();
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: Calling helperInstance->sendPackage(%s) ...', $nodeInstance->__toString()));
$helperInstance->sendPackage($nodeInstance);
- /*
- * Remove temporary configuration
- */
- $this->removeMessageConfigurationData($messageInstance);
-
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER:Next message has been prepared.');
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- abstract protected function initMessageConfigurationData (DeliverableMessage $messageInstance);
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- abstract protected function removeMessageConfigurationData (DeliverableMessage $messageInstance);
-
}
$this->setHandlerName('message_announcement');
// Init message data array
- $this->messageDataElements = array(
+ $this->messageDataElements = [
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
- );
+ ];
// Init message-data->configuration translation array
- $this->messageToConfig = array(
+ /*
+ $this->messageToConfig = [
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID => 'your_node_id',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash',
- );
-
- // Init config-copy array
- $this->configCopy = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
- );
+ ];
+ */
// Init array
- $this->searchData = array(
+ $this->searchData = [
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS
- );
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
+ ];
}
/**
} // END - foreach
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // "Walk" throught the translation array
- /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: messageInstance=' . print_r($messageInstance, TRUE));
- foreach ($this->messageToConfig as $messageKey => $configKey) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
-
- // Set the element in configuration
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
- } // END - foreach
-
- // "Walk" throught the config-copy array
- foreach ($this->configCopy as $targetKey => $sourceKey) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
-
- // Copy from source to targetKey
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($targetKey, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($sourceKey));
- } // END - foreach
-
- // Translate last exception into a status code
- $statusCode = $this->getTranslatedStatusFromLastException();
-
- // Set it in configuration (temporarily)
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS, $statusCode);
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageData An instance of a DeliverableMessage class
- * @return void
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // "Walk" throught the translation array again
- foreach ($this->messageToConfig as $dummy => $configKey) {
- // Now unset this configuration entry (to save some memory)
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey);
- } // END - foreach
-
- // "Walk" throught the config-copy array again
- foreach ($this->configCopy as $configKey => $dummy) {
- // Now unset this configuration entry (to save some memory again)
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey);
- } // END - foreach
-
- // Remove NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS as well
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS);
- }
-
}
$this->setHandlerName('message_announcement_answer');
// Init message data array
- $this->messageDataElements = array(
+ $this->messageDataElements = [
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
- );
+ ];
// Init message-data->configuration translation array
- $this->messageToConfig = array(
/*
+ $this->messageToConfig = [
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'your_session_id'
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash'
+ ];
*/
- );
-
- // Init config-copy array
- $this->configCopy = array(
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS => 'node_status',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID => 'session_id',
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
- );
// Init array
- $this->searchData = array(
+ $this->searchData = [
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
- );
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
+ ];
}
/**
} // END - foreach
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
}
];
// Init message-data->configuration translation array
- $this->messageToConfig = [
/*
+ $this->messageToConfig = [
@TODO Why commented out?
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id'
- */
- ];
-
- // Init config-copy array
- $this->configCopy = [
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id',
];
+ */
// Init array
$this->searchData = [
XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
+ XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
];
}
} // END - foreach
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
}
-
-// [EOF]
-?>
$this->setHandlerName('message_request_node_list_answer');
// Init message data array
- $this->messageDataElements = array(
+ $this->messageDataElements = [
XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST,
BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
- );
+ ];
// Init message-data->configuration translation array
- $this->messageToConfig = array(
/*
+ $this->messageToConfig = [
XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID => 'your_session_id'
+ ];
*/
- );
// Init search data array
- $this->searchData = array(
+ $this->searchData = [
XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
- );
+ ];
}
/**
} // END - foreach
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
}
];
// Init message-data->configuration translation array
+ /*
$this->messageToConfig = [
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'your_session_id'
];
-
- // Init config-copy array
- $this->configCopy = [
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS => 'node_status',
- XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID => 'session_id',
- ];
+ */
// Init array
- $this->searchData = array(
+ $this->searchData = [
XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
- );
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
+ XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
+ ];
}
/**
} // END - foreach
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // "Walk" throught the translation array
- /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: messageInstance=' . print_r($messageInstance, TRUE));
- foreach ($this->messageToConfig as $messageKey => $configKey) {
- // Set the element in configuration
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
- } // END - foreach
-
- // "Walk" throught the config-copy array
- foreach ($this->configCopy as $targetKey => $sourceKey) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
-
- // Copy from source to target key
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($targetKey, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($sourceKey));
- } // END - foreach
-
- // Translate last exception into a status code
- $statusCode = $this->getTranslatedStatusFromLastException();
-
- // Set it in configuration (temporarily)
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS, $statusCode);
-
- /*
- * Use the DHT instance to get a list of recipients. This means that all
- * DHT nodes that accept bootstrap requests are read from the DHT
- * database.
- */
- $nodeList = DhtObjectFactory::createDhtInstance('node')->findRecipientsByKey(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y');
-
- // Make sure it is an array and has at least one entry
- assert(is_array($nodeList));
- assert(count($nodeList) > 0);
-
- // Set it in configuration
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList)));
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // "Walk" throught the translation array again
- foreach ($this->messageToConfig as $dummy => $configKey) {
- // Now unset this configuration entry (to save some memory)
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey);
- } // END - foreach
-
- // "Walk" throught the config-copy array again
- foreach ($this->configCopy as $configKey => $dummy) {
- // Now unset this configuration entry (to save some memory again)
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey);
- } // END - foreach
-
- // Remove temporary "special" values as well
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS);
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry('dht_nodes');
- }
-
}
$this->setHandlerName('message_request_node_list');
// Init message data array
- $this->messageDataElements = array(
+ $this->messageDataElements = [
XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
- );
-
- // Init config-copy array
- $this->configCopy = array(
- );
+ ];
// Init search data array
- $this->searchData = array(
+ $this->searchData = [
XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
- );
+ ];
}
/**
} // END - foreach
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: messageInstance=' . print_r($messageInstance, TRUE));
-
- // "Walk" throught the config-copy array
- foreach ($this->configCopy as $targetKey => $sourceKey) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
-
- // Copy from source to targetKey
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry($targetKey, FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($sourceKey));
- } // END - foreach
-
- // Query local DHT for nodes except given session id
- $nodeList = DhtObjectFactory::createDhtInstance('node')->queryLocalNodeListExceptByMessageInstance(
- $messageInstance,
- $this,
- XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
- XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
- BaseHubNode::OBJECT_LIST_SEPARATOR
- );
-
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
-
- // Set it serialized in configuration (temporarily)
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList)));
-
- // Translate last exception into a status code
- $statusCode = $this->getTranslatedStatusFromLastException();
-
- // Set it in configuration (temporarily)
- FrameworkBootstrap::getConfigurationInstance()->setConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS, $statusCode);
- }
-
- /**
- * Removes configuration data with given message data array from global
- * configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // "Walk" throught the config-copy array again
- foreach ($this->configCopy as $configKey => $dummy) {
- // Now unset this configuration entry (to save some memory again)
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry($configKey);
- } // END - foreach
-
- // Remove answer status/node list as well
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseFrontend::DB_COLUMN_ANSWER_STATUS);
- FrameworkBootstrap::getConfigurationInstance()->unsetConfigEntry('node_list');
- }
-
}
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
- /**
- * Initializes configuration data from given message data array
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function initMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method!
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
-
- /**
- * Removes configuration data with given message data array from global configuration
- *
- * @param $messageInstance An instance of a DeliverableMessage class
- * @return void
- * @throws UnsupportedOperationException If this method is called
- */
- protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) {
- // Please don't call this method!
- throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
- }
}
-
-// [EOF]
-?>
// Generate the hash of comparing it
//* DEBUG-DIE: */ ApplicationEntryPoint::exitApplication(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $packageInstance->__toString(), $packageInstance->getSenderId(), $packageInstance->getSenderPrivateKeyHash()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s,senderId=%s,senderPrivateKeyHash=%s', $packageInstance->__toString(), $packageInstance->getSenderId(), $packageInstance->getSenderPrivateKeyHash()));
if (empty($packageInstance->getSenderId())) {
// Invalid $packageInstance
throw new InvalidArgumentException('packageInstance does not contain senderId');
*/
public function clearList () {
// Clear both groups
- $this->clearGroups(array('unl', 'session_id'));
+ $this->clearGroups(['unl', 'session_id']);
}
-}
-// [EOF]
-?>
+}