// No, so register it
$this->getWrapperInstance()->registerLocalNode();
}
+
+ // Change state
+ $this->getStateInstance()->dhtHasInitialized();
}
/**
* @return void
*/
public function bootstrapDht () {
+ // Get a helper instance
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('dht_bootstrap_helper_class');
+
+ // Load the announcement descriptor
+ $helperInstance->loadDescriptorXml($this);
+
+ // Compile all variables
+ $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+ // "Publish" the descriptor by sending it to the bootstrap/list nodes
+ $helperInstance->sendPackage($this);
+
+ // Change state
+ $this->getStateInstance()->dhtHasBooted();
}
/**
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData=' . print_r($messageData, true));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, true) . ',handlerInstance=' . $handlerInstance->__toString() . ',forceUpdate=' . intval($forceUpdate) . ',count(getSearchData())=' . count($handlerInstance->getSearchData()));
// Search for the node's session id and external IP/hostname + TCP/UDP listen port
foreach ($handlerInstance->getSearchData() as $key) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData[' . $key . ']=' . $messageData[$key]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData[' . $key . ']=' . $messageData[$key]);
// Is it there?
assert(isset($messageData[$key]));
assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey])));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData=' . print_r($messageData, true));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, true));
// Get a search criteria class
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add all keys
foreach (explode($separator, $messageData[$andKey]) as $criteria) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: andKey=' . $andKey . ',criteria=' . $criteria);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: andKey=' . $andKey . ',criteria=' . $criteria);
// Add it and leave any 'my-' prefix out
$searchInstance->addChoiceCriteria(str_replace('my-', '', $andKey), $criteria);
// Get node list
$nodeList = array();
while ($resultInstance->next()) {
+ // Get current element (it should be an array, and have at least 1 entry)
+ $current = $resultInstance->current();
+ assert(is_array($current));
+ assert(count($current) > 0);
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: current(' . count($current) . ')[' . gettype($current) . ']=' . print_r($current, TRUE));
+
// Add this entry
- array_push($nodeList, $resultInstance->current());
+ array_push($nodeList, $current);
} // END - while
// Save last exception
*
* @param $nodeList An array from an earlier database result instance
* @return void
+ * @todo ~10% done
*/
public function insertNodeList (array $nodeList) {
- // If no node is in the list (array), skip the rest of this method silently
+ // If no node is in the list (array), skip the rest of this method
if (count($nodeList) == 0) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: No node record has been returned.');
+ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: No node record has been returned.');
// Abort here
return;