/**
* Setter for UNL instance
*
- * @para $unlInstance An instance of a LocateableNode class
+ * @para $locatorInstance An instance of a LocateableNode class
* @return void
*/
- protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+ protected final function setUniversalNodeLocatorInstance (LocateableNode $locatorInstance) {
// Set new UNL data array
- $this->universalNodeLocatorInstance = $unlInstance;
+ $this->universalNodeLocatorInstance = $locatorInstance;
}
/**
/**
* Setter for UNL instance
*
- * @para $unlInstance An instance of a LocateableNode class
+ * @para $locatorInstance An instance of a LocateableNode class
* @return void
*/
- protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+ protected final function setUniversalNodeLocatorInstance (LocateableNode $locatorInstance) {
// Set new UNL data array
- $this->universalNodeLocatorInstance = $unlInstance;
+ $this->universalNodeLocatorInstance = $locatorInstance;
}
/**
$recipient = $this->getSocketRecipient();
// Generate UNL instance for it
- $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($recipient);
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($recipient);
// Get address part
- $recipientAddress = $unlInstance->getUnlAddress();
+ $recipientAddress = $locatorInstance->getUnlAddress();
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress));
$recipient = $this->getSocketRecipient();
// Generate UNL instance for it
- $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($recipient);
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($recipient);
// Get port part
- $recipientPort = $unlInstance->getUnlPort();
+ $recipientPort = $locatorInstance->getUnlPort();
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort)));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient));
// Create UNL instance from it. This will validate the connection
- $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($unlRecipient);
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($unlRecipient);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $locatorInstance->getUnlAddress(), $locatorInstance->getUnlPort()));
// Try to connect to it
- $result = socket_connect($this->getSocketResource(), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort());
+ $result = socket_connect($this->getSocketResource(), $locatorInstance->getUnlAddress(), $locatorInstance->getUnlPort());
// Trace message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
/**
* Setter for UNL instance
*
- * @para $unlInstance An instance of a LocateableNode class
+ * @para $locatorInstance An instance of a LocateableNode class
* @return void
*/
- protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+ protected final function setUniversalNodeLocatorInstance (LocateableNode $locatorInstance) {
// Set new UNL data array
- $this->universalNodeLocatorInstance = $unlInstance;
+ $this->universalNodeLocatorInstance = $locatorInstance;
}
/**
$dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID);
// Get Universal Node Locator and "explode" it
- $unlInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
+ $locatorInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
// Get external UNL
- $externalUnl = $unlInstance->getExternalUnl();
+ $externalUnl = $locatorInstance->getExternalUnl();
// Make sure both is valid
// @TODO Bad check on UNL, better use a proper validator
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Get Universal Node Locator and "explode" it
- $unlInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
+ $locatorInstance = $this->getNodeInstance()->determineUniversalNodeLocator();
// Make sure the external address is set and not invalid
// @TODO Bad check on UNL, better use a proper validator
- $externalUnl = $unlInstance->getExternalUnl();
+ $externalUnl = $locatorInstance->getExternalUnl();
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: externalUnl=' . $externalUnl);
assert($externalUnl != 'invalid');
$dataSetInstance->addCriteria(self::DB_COLUMN_PEER_STATE , $stateInstance->getStateName());
// Try to resolve sender's session id
- $senderData = explode(':', HubTools::resolveSessionId($packageInstance->getSenderAddress()));
+ $senderData = explode(':', HubTools::resolveSessionIdToUnl($packageInstance->getSenderAddress()));
// Just make sure that 'invalid:invalid' is not being processed
assert(($senderData[0] != 'invalid') && ($senderData[1] != 'invalid') && ($senderData[2] != 'invalid'));
use Org\Shipsimu\Hub\Dht\BaseDht;
use Org\Shipsimu\Hub\Dht\Distributable;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
+use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
// Import framework stuff
return $nodeData;
}
+ /**
+ * Finds a node locally by given UNL instance
+ *
+ * @param $locatorInstance An instance of a LocateableNode class
+ * @return $nodeData Node-data array
+ */
+ public function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance) {
+ // Default is empty data array
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: locatorInstance=%s - CALLED!', $locatorInstance->__toString()));
+ //* DEBUG-DIE: */ die(sprintf('[%s:%d]: locatorInstance=%s', __METHOD__, __LINE__, print_r($locatorInstance, TRUE)));
+ $nodeData = array();
+
+ // Query database
+ $resultInstance = $this->getWrapperInstance()->findNodeLocalByUnlInstance($locatorInstance);
+
+ // Make sure the result instance is valid
+ assert($resultInstance instanceof SearchableResult);
+
+ // Return node data
+ /* DEBUG-DIE: */ die(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: nodeData()=%d - EXIT!', count($nodeData)));
+ return $nodeData;
+ }
+
/**
* Registers an other node with this node by given message data. The
* following data must always be present:
* "Discovers" an instance of a LocateableNode class for given Node class
*
* @param $nodeInstance An instance of a Node class
- * @return $unlInstance An instance of a LocateableNode class
- * @throws NullPointerException If $unlInstance is NULL
+ * @return $locatorInstance An instance of a LocateableNode class
+ * @throws NullPointerException If $locatorInstance is NULL
*/
public function discoverUniversalNodeLocatorByNode (Node $nodeInstance) {
/*
$resolverInstance = ProtocolResolverFactory::createResolverFromConfiguredProtocol();
// Then resolve the node instance into an UNL instance
- $unlInstance = $resolverInstance->resolveUniversalNodeLocatorFromNode($nodeInstance);
+ $locatorInstance = $resolverInstance->resolveUniversalNodeLocatorFromNode($nodeInstance);
// Is the instance given?
- if (is_null($unlInstance)) {
+ if (is_null($locatorInstance)) {
// Throw NPE here
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
} // END - if
// ... and return it
- return $unlInstance;
+ return $locatorInstance;
}
/**
} elseif ($packageInstance->getRecipientUnl() == '' && $packageInstance->getRecipientId() != '') {
// Id is set, this might be resolved to an UNL
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RECIPIENT-DISCOVERY: Resolving recipientId=%s to UNL ...', $packageInstance->getRecipientId()));
- $recipientUnl = HubTools::resolveSessionId($packageInstance->getRecipientId());
+ $recipientUnl = HubTools::resolveSessionIdToUnl($packageInstance->getRecipientId());
// And set it in package instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RECIPIENT-DISCOVERY: recipientUnl=%s', $recipientUnl));
* Returns a singleton (registry-based) LocateableNode instance
*
* @param $unl UNL address
- * @return $unlInstance An instance of a LocateableNode class
+ * @return $locatorInstance An instance of a LocateableNode class
*/
public static final function createUnlInstanceFromString ($unl) {
// Trace message
// If there is no handler?
if (GenericRegistry::getRegistry()->instanceExists('unl_' . $unl)) {
// Get handler from registry
- $unlInstance = GenericRegistry::getRegistry()->getInstance('unl_' . $unl);
+ $locatorInstance = GenericRegistry::getRegistry()->getInstance('unl_' . $unl);
} else {
// Get the handler instance
- $unlInstance = self::createObjectByConfiguredName('universal_node_locator_class');
+ $locatorInstance = self::createObjectByConfiguredName('universal_node_locator_class');
// Parse UNL string
- $unlInstance->parseStringAsUnl($unl);
+ $locatorInstance->parseStringAsUnl($unl);
// Add it to the registry
- GenericRegistry::getRegistry()->addInstance('unl_' . $unl, $unlInstance);
+ GenericRegistry::getRegistry()->addInstance('unl_' . $unl, $locatorInstance);
}
// Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unlInstance[]=%s - EXIT!', gettype($unlInstance)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: locatorInstance[]=%s - EXIT!', gettype($locatorInstance)));
// Return the instance
- return $unlInstance;
+ return $locatorInstance;
}
/**
* Creates a UNL instance from given array
*
* @param $unlData Array with valid UNL data
- * @return $unlInstance An instance of a LocateableNode class
+ * @return $locatorInstance An instance of a LocateableNode class
*/
public static final function createUnlInstanceFromArray (array $unlData) {
// No "caching" for now
- $unlInstance = self::createObjectByConfiguredName('universal_node_locator_class', array($unlData));
+ $locatorInstance = self::createObjectByConfiguredName('universal_node_locator_class', array($unlData));
// Return it
- return $unlInstance;
+ return $locatorInstance;
}
}
/**
* Setter for UNL instance
*
- * @para $unlInstance An instance of a LocateableNode class
+ * @para $locatorInstance An instance of a LocateableNode class
* @return void
*/
- protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+ protected final function setUniversalNodeLocatorInstance (LocateableNode $locatorInstance) {
// Set new UNL data array
- $this->universalNodeLocatorInstance = $unlInstance;
+ $this->universalNodeLocatorInstance = $locatorInstance;
}
/**
use Org\Shipsimu\Hub\Factory\FilterChain\Package\PackageFilterChainFactory;
use Org\Shipsimu\Hub\Factory\Handler\Message\MessageTypeHandlerFactory;
use Org\Shipsimu\Hub\Factory\Information\Connection\ConnectionInfoFactory;
+use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Handler\BaseHubHandler;
/**
* Size of the decoded data array
*/
- const DECODED_DATA_ARRAY_SIZE = 6;
+ const DECODED_DATA_ARRAY_SIZE = 7;
/**
* Named array elements for decoded package content
// Get the package
$packageInstance = $this->getStackInstance()->getNamed(self::STACKER_NAME_OUTGOING);
+ // The UNL should be set but not recipientId
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: recipientUnl(%d)=%s,recipientId(%d)=%s', strlen($packageInstance->getRecipientUnl()), $packageInstance->getRecipientUnl(), strlen($packageInstance->getRecipientId()), $packageInstance->getRecipientId()));
+ if ($packageInstance->getRecipientUnl() != '' && $packageInstance->getRecipientId() == '') {
+ // Need to resolve UNL -> session id ("recipient id"), so prepare UNL instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: recipientUnl=%s is being solved into session id ...', $packageInstance->getRecipientUnl()));
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientUnl());
+
+ // Get session id and set it back
+ $sessionId = HubTools::resolveSessionIdByUniversalNodeLocator($locatorInstance);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sessionId=%s found, setting ...', $sessionId));
+ $packageInstance->setRecipientId($sessionId);
+ }
+
try {
// Now try to send it
$this->sendOutgoingRawPackageData($packageInstance);
// Assert on count (should be always 6)
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: decodedArray()=%d', count($decodedArray)));
- /* DEBUG-DIE: */ die(sprintf('[%s:%d] decodedArray=%s', __METHOD__, __LINE__, print_r($decodedArray, TRUE)));
+ /* DEBUG-DIE: */ die(sprintf('[%s:%d]: decodedArray=%s', __METHOD__, __LINE__, print_r($decodedArray, TRUE)));
if (count($decodedArray) != self::DECODED_DATA_ARRAY_SIZE) {
// Count of array elements not expected
throw new InvalidArgumentException(sprintf('decodedArray()=%d does not match expected size %d. rawPackageContent=%s',
*/
public function getAddressPart () {
// Get UNL instance
- $unlInstance = $this->getUniversalNodeLocatorInstance();
- die(__METHOD__.':'.print_r($unlInstance, TRUE));
+ $locatorInstance = $this->getUniversalNodeLocatorInstance();
+ die(__METHOD__.':'.print_r($locatorInstance, TRUE));
}
/**
// If this doesn't fail, continue validating the IP:port combination
if ($isValid === TRUE) {
// ... and validate IP:port, first "parse" the UNL
- $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientUnl());
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientUnl());
// Set whole UNL instance
// @TODO don't do this in a isValidFoo() method
- $this->setUniversalNodeLocatorInstance($unlInstance);
+ $this->setUniversalNodeLocatorInstance($locatorInstance);
// Set port
- $this->setPort($unlInstance->getUnlPort());
+ $this->setPort($locatorInstance->getUnlPort());
} // END - if
// Return result
// @TODO The whole resolving part should be moved out and made more configurable
// Init recipient data
- $unlInstance = NULL;
+ $locatorInstance = NULL;
// Try to solve the recipient
try {
$handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageInstance($packageInstance);
// Get UNL instance
- $unlInstance = $handlerInstance->getUniversalNodeLocatorInstance();
+ $locatorInstance = $handlerInstance->getUniversalNodeLocatorInstance();
// Set handler instance
$helperInstance->setHandlerInstance($handlerInstance);
// Create UNL instance
$this->partialStub('Please rewrite this part.');
- //$unlInstance =;
+ //$locatorInstance =;
} else {
// It doesn't match, we need to take care of this later
$helperInstance->debugInstance(sprintf(
// Now connect to it
if (!$helperInstance->connectToPeerBySocketRecipient()) {
// Debug message
- self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-CONNECTION-HELPER: helperInstance=%s,unlInstance.unlData=%s', $helperInstance->__toString(), print_r($unlInstance->getUnlData(), TRUE)));
+ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-CONNECTION-HELPER: helperInstance=%s,locatorInstance.unlData=%s', $helperInstance->__toString(), print_r($locatorInstance->getUnlData(), TRUE)));
// Handle socket error
$socketInstance->handleSocketError(__METHOD__, __LINE__);
$socketProtocol = $this->getSocketInstance()->getSocketProtocol();
// Get UNL instance
- $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientUnl());
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientUnl());
// Get protocol from it
- $unlProtocol = $unlInstance->getUnlProtocol();
+ $unlProtocol = $locatorInstance->getUnlProtocol();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: unlInstance.unlProtocol=%s,socketProtocol=%s', strtoupper($this->getProtocolName()), $unlProtocol, $socketProtocol));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: locatorInstance.unlProtocol=%s,socketProtocol=%s', strtoupper($this->getProtocolName()), $unlProtocol, $socketProtocol));
// Is same protocol?
$accepts = ($unlProtocol == $socketProtocol);
/**
* Setter for UNL instance
*
- * @param $unlInstance An instance of a LocateableNode class
+ * @param $locatorInstance An instance of a LocateableNode class
* @return void
*/
- protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+ protected final function setUniversalNodeLocatorInstance (LocateableNode $locatorInstance) {
throw new UnsupportedOperationException('This method should not be called.');
}
use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Locator\Node\Tools\NodeLocatorUtils;
+use Org\Shipsimu\Hub\Tools\HubTools;
// Import framework stuff
use Org\Mxchange\CoreFramework\Registry\Registerable;
* Creates an instance of this class
*
* @param $current An array with "raw" data from the database layer for the UNL. This parameter is optional.
- * @return $unlInstance An instance of a LocateableNode class
+ * @return $locatorInstance An instance of a LocateableNode class
*/
public final static function createUniversalNodeLocator (array $current = array()) {
// Get new instance
- $unlInstance = new UniversalNodeLocator();
+ $locatorInstance = new UniversalNodeLocator();
// Init instance
- $unlInstance->initUniversalNodeLocator($current);
+ $locatorInstance->initUniversalNodeLocator($current);
// Return the prepared instance
- return $unlInstance;
+ return $locatorInstance;
+ }
+
+ /**
+ * Parses the given UNL by splitting it up in its components. The UNL ...
+ *
+ * protocol://address[:port]
+ *
+ * ... becomes:
+ *
+ * array(
+ * 'protocol' => 'value',
+ * 'address' => 'value',
+ * 'extra' => 'port'
+ * )
+ *
+ * The value for 'extra' then must be handled by the overwriting
+ * parseUniversalNodeLocator() method of the individual protocol handler as
+ * this is protocol-specific.
+ *
+ * @param $unl Universal Node Locator (UNL) to "parse"
+ * @throws InvalidArgumentException If given UNL is not valid
+ */
+ private function parseUniversalNodeLocator ($unl) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
+
+ // Make sure the UNL is valid
+ if (!NodeLocatorUtils::isValidUniversalNodeLocator($unl)) {
+ // UNL is not valid
+ throw new InvalidArgumentException(sprintf('unl[%s]=%s is not valid.', gettype($unl), $unl));
+ } // END - if
+
+ /*
+ * "Parse" the UNL "generically", sadly this cannot be done by using preg_match() :-(
+ * @TODO If you know why, please fix and explain it to me.
+ */
+ $unlParts = explode('://', $unl);
+
+ // Split again the last part as: address:port
+ $unlParts[1] = explode(':', $unlParts[1]);
+
+ // Now there is an almost useable array which then can be copied to the "real" array.
+ $unlData = array(
+ LocateableNode::UNL_PART_PROTOCOL => $unlParts[0],
+ LocateableNode::UNL_PART_ADDRESS => $unlParts[1][0],
+ LocateableNode::UNL_PART_EXTRA => $unlParts[1][1],
+ );
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unlData=' . print_r($unlData, TRUE) . ' - EXIT!');
+
+ // Call init method
+ $this->initUniversalNodeLocator($unlData);
+ }
+
+ /**
+ * Initializes the UNL instance by givena array. If an entry is found, it
+ * will be copied, otherwise the entry is set empty.
+ *
+ * @param $unlData An array with "raw" data from the database layer for the UNL. This parameter is optional.
+ * @return void
+ */
+ private function initUniversalNodeLocator (array $unlData = array()) {
+ // Init UNL array
+ $this->unlData = array();
+
+ // Copy all found entries
+ foreach (array(
+ LocateableNode::UNL_PART_PROTOCOL,
+ LocateableNode::UNL_PART_ADDRESS,
+ LocateableNode::UNL_PART_EXTRA,
+ NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
+ NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
+ NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
+ NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
+ NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
+ NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
+ // Init entry
+ $this->unlData[$key] = NULL;
+
+ // Is the key found?
+ if (isset($unlData[$key])) {
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: Copying unlData[' . $key . ']=' . $unlData[$key] . ' ...');
+
+ // The copy the entry
+ $this->unlData[$key] = $unlData[$key];
+ } // END - if
+ } // END - foreach
}
/**
*/
public function parseStringAsUnl ($unl) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
// Is it basically valid?
if (!is_string($unl)) {
// Parse it
$this->parseUniversalNodeLocator($unl);
+
+ // Is it matching own internal UNL?
+ if (HubTools::determineOwnInternalAddress() == $unl) {
+ // Yes, then set it here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=%s matches own internal address, setting ...', $unl));
+ $this->unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL] = $unl;
+ }
+
+ // Is it matching own external UNL?
+ if (HubTools::determineOwnExternalAddress() == $unl) {
+ // Yes, then set it here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=%s matches own external address, setting ...', $unl));
+ $this->unlData[NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL] = $unl;
+ }
}
/**
return $this->unlData;
}
- /**
- * Parses the given UNL by splitting it up in its components. The UNL ...
- *
- * protocol://address[:port]
- *
- * ... becomes:
- *
- * array(
- * 'protocol' => 'value',
- * 'address' => 'value',
- * 'extra' => 'port'
- * )
- *
- * The value for 'extra' then must be handled by the overwriting
- * parseUniversalNodeLocator() method of the individual protocol handler as
- * this is protocol-specific.
- *
- * @param $unl Universal Node Locator (UNL) to "parse"
- * @throws InvalidArgumentException If given UNL is not valid
- */
- private function parseUniversalNodeLocator ($unl) {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl));
-
- // Make sure the UNL is valid
- if (!NodeLocatorUtils::isValidUniversalNodeLocator($unl)) {
- // UNL is not valid
- throw new InvalidArgumentException(sprintf('unl[%s]=%s is not valid.', gettype($unl), $unl));
- } // END - if
-
- /*
- * "Parse" the UNL "generically", sadly this cannot be done by using preg_match() :-(
- * @TODO If you know why, please fix and explain it to me.
- */
- $unlParts = explode('://', $unl);
-
- // Split again the last part as: address:port
- $unlParts[1] = explode(':', $unlParts[1]);
-
- // Now there is an almost useable array which then can be copied to the "real" array.
- $unlData = array(
- LocateableNode::UNL_PART_PROTOCOL => $unlParts[0],
- LocateableNode::UNL_PART_ADDRESS => $unlParts[1][0],
- LocateableNode::UNL_PART_EXTRA => $unlParts[1][1],
- );
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unlData=' . print_r($unlData, TRUE) . ' - EXIT!');
-
- // Call init method
- $this->initUniversalNodeLocator($unlData);
- }
-
- /**
- * Initializes the UNL instance by givena array. If an entry is found, it
- * will be copied, otherwise the entry is set empty.
- *
- * @param $unlData An array with "raw" data from the database layer for the UNL. This parameter is optional.
- * @return void
- */
- private function initUniversalNodeLocator (array $unlData = array()) {
- // Init UNL array
- $this->unlData = array();
-
- // Copy all found entries
- foreach (array(
- LocateableNode::UNL_PART_PROTOCOL,
- LocateableNode::UNL_PART_ADDRESS,
- LocateableNode::UNL_PART_EXTRA,
- NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID,
- NodeInformationDatabaseWrapper::DB_COLUMN_SESSION_ID,
- NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH,
- NodeInformationDatabaseWrapper::DB_COLUMN_NODE_MODE,
- NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL,
- NodeInformationDatabaseWrapper::DB_COLUMN_EXTERNAL_UNL) as $key) {
- // Init entry
- $this->unlData[$key] = NULL;
-
- // Is the key found?
- if (isset($unlData[$key])) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: Copying unlData[' . $key . ']=' . $unlData[$key] . ' ...');
-
- // The copy the entry
- $this->unlData[$key] = $unlData[$key];
- } // END - if
- } // END - foreach
- }
-
}
// Is "cache" set?
if (!isset($GLOBALS[__METHOD__])) {
// Get the UNL array back
- $unlInstance = $this->determineUniversalNodeLocator();
+ $locatorInstance = $this->determineUniversalNodeLocator();
// Is the instance valid?
- if (NULL == $unlInstance) {
+ if (NULL == $locatorInstance) {
// Throw NPE
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
} // END - if
// There are 2 UNLs, internal and external.
if ($this->getConfigInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
// Public "external" UNL address
- $GLOBALS[__METHOD__] = $unlInstance->getExternalUnl();
+ $GLOBALS[__METHOD__] = $locatorInstance->getExternalUnl();
} else {
// Non-public "internal" UNL address
- $GLOBALS[__METHOD__] = $unlInstance->getInternalUnl();
+ $GLOBALS[__METHOD__] = $locatorInstance->getInternalUnl();
}
} // END - if
/**
* Determines an instance of a LocateableNode class
*
- * @return $unlInstance An instance of a LocateableNode class for this node
+ * @return $locatorInstance An instance of a LocateableNode class for this node
*/
public function determineUniversalNodeLocator () {
// Debug message
} // END - if
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unlInstance= ' . $GLOBALS[__METHOD__]->__toString() . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: locatorInstance= ' . $GLOBALS[__METHOD__]->__toString() . ' - EXIT!');
return $GLOBALS[__METHOD__];
}
/**
* Setter for private key hash
*
- * @param $senderPrivateKeyHash The new private key hash
+ * @param $senderPrivateKeyHash The new private key hash
* @return void
*/
public final function setSenderPrivateKeyHash ($senderPrivateKeyHash) {
/**
* Getter for private key hash
*
- * @return $senderPrivateKeyHash Current private key hash
+ * @return $senderPrivateKeyHash Current private key hash
*/
public final function getSenderPrivateKeyHash () {
return $this->senderPrivateKeyHash;
* to all chunks and prepends a chunk with all hashes only in it. It will
* return the final hash for faster processing of packages.
*
- * @param $packageInstance An instance of a DeliverablePackage class array
+ * @param $packageInstance An instance of a DeliverablePackage class array
* @param $helperInstance An instance of a ConnectionHelper class
* @return $finalHash Final hash for faster processing
* @todo $helperInstance is unused
// Is this package already fragmented?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-FRAGMENTER: packageInstance=%s,helperInstance=%s - CALLED!', $packageInstance->__toString(), $helperInstance->__toString()));
if (!$this->isPackageProcessed($packageInstance)) {
- // First get all fields as array from PackageData class, implode() doesn't work as expected here.
+ // First put it the right way together again, implode on getAllAsArray() won't work!
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Package is not processed., getting all raw data ...');
- $packageData = $packageInstance->getAllAsArray();
-
- // Then put it the right way together again
- /* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageData=%s', __METHOD__, __LINE__, print_r($packageData, TRUE)));
- //$rawData = sprintf(
+ /* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance->allAsArray=%s', __METHOD__, __LINE__, print_r($packageInstance->getAllAsArray(), TRUE)));
+ $rawData = sprintf('%s%s%d%s%s%s%s%s%s%s%s%s%s',
+ $packageInstance->getSenderAddress(),
+ NetworkPackageHandler::PACKAGE_DATA_SEPARATOR,
+ $packageInstance->getSenderPort(),
+ NetworkPackageHandler::PACKAGE_DATA_SEPARATOR,
+ $packageInstance->getRecipientId(),
+ NetworkPackageHandler::PACKAGE_DATA_SEPARATOR,
+ $packageInstance->getPackageContent(),
+ NetworkPackageHandler::PACKAGE_DATA_SEPARATOR,
+ $packageInstance->getStatus(),
+ NetworkPackageHandler::PACKAGE_DATA_SEPARATOR,
+ $packageInstance->getContentHash(),
+ NetworkPackageHandler::PACKAGE_DATA_SEPARATOR,
+ $packageInstance->getSenderPrivateKeyHash()
+ );
// Generate the final hash from the raw data (not encoded!)
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-FRAGMENTER: rawData(%d)=%s', strlen($rawData), $rawData));
$handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageInstance($packageInstance);
// Get UNL data
- $unlInstance = $handlerInstance->getUniversalNodeLocatorInstance();
+ $locatorInstance = $handlerInstance->getUniversalNodeLocatorInstance();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),locatorInstance.unl=' . $locatorInstance->generateUnl() . ' ...');
// Default is all sockets
$sockets = $this->getAllSockets();
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,locatorInstance.addressPart=%s', $peerAddress, $peerPort, $locatorInstance->getAddressPart()));
// If the "peer" IP and recipient is same, use it
- if ($peerAddress == $unlInstance->getAddressPart()) {
+ if ($peerAddress == $locatorInstance->getAddressPart()) {
// IPs match, so take the socket and quit this loop
$socketInstance = $socketArray[Poolable::SOCKET_ARRAY_INSTANCE];
foreach ($recipients as $recipient) {
// Try to sole a single recipient
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECT-RECIPIENT: recipient=' . $recipient);
- $unlData = HubTools::resolveSessionId($recipient);
+ $unlData = HubTools::resolveSessionIdToUnl($recipient);
// Add it as recipient
$listInstance->addEntry('unl', $unlData);
* instance or null if it was not found.
*
* @param $nodeInstance An instance of a Node class
- * @return $unlInstance An instance of a LocateableNode class
+ * @return $locatorInstance An instance of a LocateableNode class
*/
public function resolveUniversalNodeLocatorFromNode (Node $nodeInstance) {
// Get search instance (to lookup database result)
assert($nodeInstance->getNodeId() == $current[NodeInformationDatabaseWrapper::DB_COLUMN_NODE_ID]);
// Get UNL instance and handle over all data
- $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromArray($current);
+ $locatorInstance = UniversalNodeLocatorFactory::createUnlInstanceFromArray($current);
// Return resolved instance
- return $unlInstance;
+ return $locatorInstance;
}
/**
* Resolves a session id into an instance of a LocateableNode class. The opposite method
* is resolveSessionIdByUniversalNodeLocator()
*
- * @param $sessionId A valid session id
+ * @param $sessionId A valid session id
* @return $recipientUniversalNodeLocator Recipient as Universal Node Locator
*/
protected function resolveUniversalNodeLocatorBySessionId ($sessionId) {
// Init variable
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId));
$recipientUniversalNodeLocator = 'invalid://invalid:invalid';
// And ask it for Universal Node Locator by given session id
// Is the recipient valid?
if (isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS])) {
// Then use this
- $recipientUniversalNodeLocator = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS];
+ $recipientUnl = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_ADDRESS];
} else {
// Get the instance, this might throw a NPE
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Creating node instance ...');
// Is the session id the same?
if ($nodeInstance->getSessionId() == $sessionId) {
// Then get an instance of a LocateableNode class from it, assume TCP by default
- $recipientUniversalNodeLocator = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port');
+ $recipientUnl = self::determineOwnExternalAddress() . ':' . $nodeInstance->getConfigInstance()->getConfigEntry('node_listen_port');
} // END - if
}
// Return result
- return $recipientUniversalNodeLocator;
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: recipientUnl=%s - EXIT!', $recipientUnl));
+ return $recipientUnl;
}
/**
*/
public static function resolveNodeIdBySessionId ($sessionId) {
// Get an own instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - CALLED!', $sessionId));
$selfInstance = self::getSelfInstance();
// And ask it for session id by given Universal Node Locator
assert(isset($nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]));
// Return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: nodeId=%s - EXIT!', $nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID]));
return $nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID];
}
* Resolves a Universal Node Locator into a session id. The "opposite" method
* is resolveUniversalNodeLocatorBySessionId().
*
- * @param $unlInstance Universal Node Locator
+ * @param $locatorInstance An instance of a LocateableNode class
* @return $sessionId Valid session id
*/
- public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $unlInstance) {
+ public static function resolveSessionIdByUniversalNodeLocator (LocateableNode $locatorInstance) {
// Get an own instance
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: locatorInstance=%s - CALLED!', $locatorInstance->__toString()));
$selfInstance = self::getSelfInstance();
// And ask it for session id by given Universal Node Locator
- $recipient = DhtObjectFactory::createDhtInstance('node')->findNodeByUniversalNodeLocator($unlInstance);
+ $recipient = DhtObjectFactory::createDhtInstance('node')->findNodeByUniversalNodeLocator($locatorInstance);
die(__METHOD__.':recipient='.print_r($recipient, TRUE));
// Return result
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: sessionId=%s - EXIT!', $sessionId));
return $sessionId;
}
* @throws InvalidSessionIdException If the provided session id is invalid (and no Universal Node Locator)
* @throws NoValidHostnameException If the provided hostname cannot be resolved into an IP address
*/
- public static function resolveSessionId ($address) {
+ public static function resolveSessionIdToUnl ($address) {
// Get an own instance
$selfInstance = self::getSelfInstance();
*/
public static function determineOwnInternalAddress () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
// Is the internal_address config entry set?
if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
// Not allowed to publish internal address, so use external
$unl = self::determineOwnExternalAddress();
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('internal_address') != '') {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Getting config entry internal_address ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting config entry internal_address ...');
// Use it as internal address
$unl = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('internal_address');
} else {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineInternalUniversalNodeLocator() ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Calling self::determineInternalUniversalNodeLocator() ...');
// Determine own internal address
$unl = self::determineInternalUniversalNodeLocator();
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $unl . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
// Return it
return $unl;
*/
public static function determineInternalUniversalNodeLocator () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
// Is there cache? (This shortens a lot calls)
if (!isset($GLOBALS[__METHOD__])) {
} // END - if
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
return $GLOBALS[__METHOD__];
}
*/
public static function determineExternalUniversalNodeLocator () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
// Is there cache? (This shortens a lot calls)
if (!isset($GLOBALS[__METHOD__])) {
} // END - if
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
return $GLOBALS[__METHOD__];
}
/**
* Getter for UNL instance
*
- * @return $unlInstance An instance of a LocateableNode class
+ * @return $locatorInstance An instance of a LocateableNode class
*/
function getUniversalNodeLocatorInstance ();
+++ /dev/null
-Deny from all
* "Discovers" an instance of a LocateableNode class for given Node class
*
* @param $nodeInstance An instance of a Node class
- * @return $unlInstance An instance of a LocateableNode class
- * @throws NullPointerException If $unlInstance is NULL
+ * @return $locatorInstance An instance of a LocateableNode class
+ * @throws NullPointerException If $locatorInstance is NULL
*/
function discoverUniversalNodeLocatorByNode (Node $nodeInstance);
// Import application-specific stuff
use Org\Shipsimu\Hub\Dht\Distributable;
+use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
// Import framework stuff
use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
*/
function findNodeLocalBySessionId ($sessionId);
+ /**
+ * Finds a node locally by given UNL instance
+ *
+ * @param $locatorInstance An instance of a LocateableNode class
+ * @return $nodeData Node-data array
+ */
+ function findNodeByUniversalNodeLocator (LocateableNode $locatorInstance);
+
/**
* Registers an other node with this node by given message data. The
* following data must always be present:
/**
* Determines an instance of a LocateableNode class
*
- * @return $unlInstance An instance of a LocateableNode class for this node
+ * @return $locatorInstance An instance of a LocateableNode class for this node
*/
function determineUniversalNodeLocator ();
* instance or null if it was not found.
*
* @param $nodeInstance An instance of a Node class
- * @return $unlInstance An instance of a LocateableNode class
+ * @return $locatorInstance An instance of a LocateableNode class
*/
function resolveUniversalNodeLocatorFromNode (Node $nodeInstance);