$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Debug message
- //* 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()));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __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[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',key=' . $key);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',key=' . $key);
// Is it there?
assert(isset($messageData[$key]));
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData[' . $key . ']=' . $messageData[$key]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData[' . $key . ']=' . $messageData[$key]);
// Add criteria
$searchInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey])));
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __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[' . __LINE__ . ']: andKey=' . $andKey . ',criteria=' . $criteria);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: andKey=' . $andKey . ',criteria=' . $criteria);
// Add it and leave any 'my-' prefix out
$searchInstance->addChoiceCriteria(str_replace('my-', '', $andKey), $criteria);
assert(count($current) > 0);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: current(' . count($current) . ')[' . gettype($current) . ']=' . print_r($current, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: current(' . count($current) . ')[' . gettype($current) . ']=' . print_r($current, TRUE));
/*
* Remove some keys as they should not be published.
// 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[' . __LINE__ . ']: No node record has been returned.');
+ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: No node record has been returned.');
// Abort here
return;
while ($resultInstance->next()) {
// Get current entry
$current = $resultInstance->current();
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __LINE__ . ']: current=' . print_r($current, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE[' . __METHOD__ . ':' . __LINE__ . ']: current=' . print_r($current, TRUE));
// Add instance to recipient list
array_push($recipients, $current);
*/
// Debug output (may flood)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Recipient ' . $recipient[0] . ' matches own ip (' . HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $recipient[0] . ' matches own ip (' . HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
} else {
// Debug output (may flood)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Recipient ' . $recipient[0] . ' is different than own external ip (' . HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Recipient ' . $recipient[0] . ' is different than own external ip (' . HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
// This package is to be delivered to someone else, so add it
$this->getListInstance()->addEntry('ip_port', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
$discoveryInstance = new PackageSocketDiscovery();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Initialized.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Initialized.');
// Return the prepared instance
return $discoveryInstance;
*/
public function discoverListenerInstance ($protocolName, array $packageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: protocolName=' . $protocolName . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ' - ENTERED!');
/*
* Get the listener pool instance, we need to lookup the matching
*/
foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromGroup($protocolName) as $listenerInstance) {
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
// Does the listener want that package?
if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
// This listener likes our package data, so abort here
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Listener is accepting package data.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is accepting package data.');
break;
} // END - if
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Listener is NOT accepting package data.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Listener is NOT accepting package data.');
} // END - foreach
// Return it
// Try to create a new socket resource
try {
// Possibly noisy debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
// Get a socket resource from our factory (if succeeded)
$socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
} catch (SocketConnectionException $e) {
// The connection fails of being established, so log it away
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
}
} // END - if
$helperInstance = Registry::getRegistry()->getInstance('connection');
// Possibly noisy debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Going to resolve socket from peer state and given package data ...');
// Resolve the peer's state (but ignore return value)
PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource);
} catch (InvalidSocketException $e) {
// This cannot be fixed, so log it away
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage());
// Make any failed attempts to 'FALSE'
$socketResource = FALSE;
}
// And return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, TRUE));
return $socketResource;
}
}
$registryKey = 'socket_' . $protocolName . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey);
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Trying to find a socket with registryKey=' . $registryKey);
// Is the key there?
if (Registry::getRegistry()->instanceExists($registryKey)) {
$socketResource = $containerInstance->getSocketResource();
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Using socket ' . $socketResource . '(' . gettype($socketResource) . ') from registry.');
} else {
// Construct configuration entry for object factory and get it
$className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolName . '_connection_helper_class');
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Going to use class ' . $className . ' for creating a socket resource ...');
// And call the static method
$socketResource = call_user_func($className . '::createConnectionFromPackageData', $packageData);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Created socket ' . $socketResource . '(' . gettype($socketResource) . ') from class ' . $className . '.');
// Construct container class, this won't be reached if an exception is thrown
$containerInstance = self::CreateObjectByConfiguredName('socket_container_class', array($socketResource, NULL, $packageData));
Registry::getRegistry()->addInstance($registryKey, $containerInstance);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __LINE__ . ']: Socket is now registered in registry.');
+ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Socket is now registered in registry.');
}
// Return the resource
$stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance));
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE-FACTORY[' . __LINE__ . ']: Node state has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('NODE-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Node state has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
// Once we have that state, set it in the node instance
$nodeInstance->setStateInstance($stateInstance);
$stateInstance = self::createObjectByConfiguredName($className, array($dhtInstance));
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE-FACTORY[' . __LINE__ . ']: DHT state has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('DHT-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: DHT state has changed from ' . $dhtInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
// Once we have that state, set it in the DHT instance
$dhtInstance->setStateInstance($stateInstance);
$chunkHash = $this->getCryptoInstance()->hashString($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA], $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH], FALSE);
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: chunkHash=' . $chunkHash . ',chunkSplits[chunk_hash]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ',chunkSplits[serial]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',chunkSplits[raw_data]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: chunkHash=' . $chunkHash . ',chunkSplits[chunk_hash]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ',chunkSplits[serial]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',chunkSplits[raw_data]=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]);
// Check it
$isValid = ($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] === $chunkHash);
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]);
// Add the chunk data (index 2) to the final array and use the serial number as index
$this->finalPackageChunks['content'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA];
$nextSerial = $this->getFragmenterInstance()->getNextHexSerialNumber();
// Debug output
- //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
+ //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial);
// Is it not the same? Then re-request it
if ($serialNumber != $nextSerial) {
// That went well, so start assembling all chunks
foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: serialNumber=' . $serialNumber . ' - validating ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber=' . $serialNumber . ' - validating ...');
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE));
// Is this chunk valid? This should be the case
} // END - foreach
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',' . chr(10) . 'index=' . (count($this->chunkHashes) - 2) . ',' . chr(10) . 'chunkHashes='.print_r($this->chunkHashes, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: eopChunk[1]=' . $this->eopChunk[1] . ',' . chr(10) . 'index=' . (count($this->chunkHashes) - 2) . ',' . chr(10) . 'chunkHashes='.print_r($this->chunkHashes, TRUE));
// The last chunk hash must match with the one from eopChunk[1]
assert($this->eopChunk[1] == $this->chunkHashes[count($this->chunkHashes) - 2]);
// Is the generated hash from data same ("valid") as given hash?
if (!$this->isChunkHashValid($chunkSplits)) {
// Do some logging
- self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: Chunk content is not validating against given hash.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Chunk content is not validating against given hash.');
// Re-request this chunk (trust the hash in index # 0)
$this->rerequestChunkBySplitsArray($chunkSplits);
// Is the serial number valid (chars 0-9, length equals PackageFragmenter::MAX_SERIAL_LENGTH)?
if (!$this->isSerialNumberValid($chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL])) {
// Do some logging
- self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: Chunk serial number ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ' for hash ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ' is invalid.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Chunk serial number ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ' for hash ' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] . ' is invalid.');
// Re-request this chunk
$this->rerequestChunkBySplitsArray($chunkSplits);
break;
default: // Invalid step found
- self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __LINE__ . ']: Invalid step ' . $this->finalPackageChunks['assemble_steps'] . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CHUNK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Invalid step ' . $this->finalPackageChunks['assemble_steps'] . ' detected.');
break;
} // END - switch
}
*/
protected function initMessageConfigurationData (array $messageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
// "Walk" throught the translation array
foreach ($this->messageToConfig as $messageKey => $configKey) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
// Set the element in configuration
$this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
// "Walk" throught the config-copy array
foreach ($this->configCopy as $targetKey => $sourceKey) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANNOUNCEMENT-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
// Copy from source to targetKey
$this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
parent::addArrayToDataSet($dataSetInstance, $messageData);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
// Add all ements
foreach ($this->messageDataElements as $key) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __LINE__ . ']: messageData[' . $key . ']=' . $messageData[$key]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('ANSWER-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData[' . $key . ']=' . $messageData[$key]);
// Is it there?
assert(isset($messageData[$key]));
*/
protected function initMessageConfigurationData (array $messageData) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: messageData=' . print_r($messageData, TRUE));
// "Walk" throught the config-copy array
foreach ($this->configCopy as $targetKey => $sourceKey) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
// Copy from source to targetKey
$this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
// Set it serialized in configuration (temporarily)
$this->getConfigInstance()->setConfigEntry('node_list', base64_encode(serialize($nodeList)));
// Are node id and session id the same?
if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $this->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $this->getSessionId())) {
// Both are equal
- self::createDebugInstance(__CLASS__)->debugOutput('SELF-CONNECT[' . __LINE__ . ']: Have connected to myself, both node and session id are equal!');
+ self::createDebugInstance(__CLASS__)->debugOutput('SELF-CONNECT[' . __METHOD__ . ':' . __LINE__ . ']: Have connected to myself, both node and session id are equal!');
// Get node instance ...
$nodeInstance = Registry::getRegistry()->getInstance('node');
$this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError));
/*
* Read the raw data from socket. If you change PHP_BINARY_READ to
$this->lastSocketError = socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]);
// Debug output of read data length
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($this->lastSocketError));
- /* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData=' . $rawData);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($this->lastSocketError));
+ /* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: rawData=' . $rawData);
// Is it valid?
if ($this->lastSocketError == 11) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]);
/*
* Error code 11 (Resource temporary unavailable) can be safely
* well-formed BASE64-encoded message with start and markers. This
* will be checked later on.
*/
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Adding ' . strlen($rawData) . ' bytes to stacker ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($rawData) . ' bytes to stacker ...');
$this->addRawDataToStacker($rawData);
}
}
$handlerInstance = new TaskHandler();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Initializing task handler.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Initializing task handler.');
// Init the task list
$handlerInstance->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
$handlerInstance->registerTask('idle_loop', $taskInstance);
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task handler initialized.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task handler initialized.');
// Return the prepared instance
return $handlerInstance;
// Should we start now?
if ($diff < $currentTask['task_startup_delay']) {
// Skip this silently
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' not started: diff=' . $diff . ',task_startup_delay=' . $currentTask['task_startup_delay']);
return;
} // END - if
$updateTask = TRUE;
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
} // END - if
// Get time difference from interval delay
*/
private function unregisterTask (array $taskData) {
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - START');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - START');
// Remove the entry
$this->getListInstance()->removeEntry('tasks', $taskData);
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - FINISHED');
}
/**
$this->getListInstance()->addEntry('tasks', $taskEntry);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task registered: taskName=' . $taskName .
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Task registered: taskName=' . $taskName .
' (taskInstance=' . $taskInstance->__toString() . ')' .
', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' .
', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' .
$this->getListInstance()->getIterator()->rewind();
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
// Remember all tasks that has been shutdown for removal
$tasks = array();
$currentTask = $this->getListInstance()->getIterator()->current();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
// Shutdown the task
$currentTask['task_instance']->accept($this->getVisitorInstance());
} // END - while
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutdown of all tasks completed.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __METHOD__ . ':' . __LINE__ . ']: Shutdown of all tasks completed.');
// Remove all tasks
foreach ($tasks as $entry) {
$timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds');
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Trying to connect to ' . $recipientData[0] . ':' . $recipientData[1] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Trying to connect to ' . $recipientData[0] . ':' . $recipientData[1] . ' with socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' ...');
// Try to connect until it is connected
while ($isConnected = !@socket_connect($socketResource, $recipientData[0], $recipientData[1])) {
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: currentFinalHash=' . $this->currentFinalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: currentFinalHash=' . $this->currentFinalHash);
// Get the next raw data chunk from the fragmenter
$rawDataChunk = $this->getFragmenterInstance()->getNextRawDataChunk($this->currentFinalHash);
$chunkData = array_values($rawDataChunk);
// Is the required data there?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData));
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('chunkData='.print_r($chunkData, TRUE));
if ((isset($chunkHashes[0])) && (isset($chunkData[0]))) {
// Remember this chunk as queued
$this->queuedChunks[$chunkHashes[0]] = $chunkData[0];
// Return the raw data
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...');
return $chunkData[0];
} else {
// Return zero string
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Returning zero bytes from ' . __METHOD__ . '!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Returning zero bytes from ' . __METHOD__ . '!');
return '';
}
}
// Fill sending buffer with data
while (strlen($dataStream) > 0) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: packageData=' . print_r($packageData, TRUE));
// Convert the package data array to a raw data stream
$dataStream = $this->getRawDataFromPackageArray($packageData);
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...');
$rawData .= $dataStream;
} // END - while
$encodedData = $this->getOutputStreamInstance()->streamData($rawData);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: rawData()=' . strlen($rawData) . ',encodedData()=' . strlen($encodedData));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: rawData()=' . strlen($rawData) . ',encodedData()=' . strlen($encodedData));
// Calculate difference
$this->diff = $bufferSize - strlen($encodedData);
// Deliver all data
while ($sentBytes !== FALSE) {
// And deliver it
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Sending out ' . strlen($encodedData) . ' bytes,bufferSize=' . $bufferSize . ',diff=' . $this->diff);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Sending out ' . strlen($encodedData) . ' bytes,bufferSize=' . $bufferSize . ',diff=' . $this->diff);
if ($this->diff >= 0) {
// Send all out (encodedData is smaller than or equal buffer size)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: MD5=' . md5(substr($encodedData, 0, ($bufferSize - $this->diff))));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedData, 0, ($bufferSize - $this->diff))));
$sentBytes = socket_write($socketResource, $encodedData, ($bufferSize - $this->diff));
} else {
// Send buffer size out
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: MD5=' . md5(substr($encodedData, 0, $bufferSize)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: MD5=' . md5(substr($encodedData, 0, $bufferSize)));
$sentBytes = socket_write($socketResource, $encodedData, $bufferSize);
}
throw new InvalidSocketException(array($this, $socketResource, $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} elseif (($sentBytes == 0) && (strlen($encodedData) > 0)) {
// Nothing sent means we are done
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')');
break;
}
$totalSentBytes += $sentBytes;
// Cut out the last unsent bytes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Sent out ' . $sentBytes . ' of ' . strlen($encodedData) . ' bytes ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Sent out ' . $sentBytes . ' of ' . strlen($encodedData) . ' bytes ...');
$encodedData = substr($encodedData, $sentBytes);
// Calculate difference again
// Can we abort?
if (strlen($encodedData) <= 0) {
// Abort here, all sent!
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: All sent! (LINE=' . __LINE__ . ')');
break;
} // END - if
} // END - while
// Return sent bytes
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: totalSentBytes=' . $totalSentBytes . ',diff=' . $this->diff);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: totalSentBytes=' . $totalSentBytes . ',diff=' . $this->diff);
return $totalSentBytes;
}
* @return void
*/
protected final function markConnectionShuttedDown () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: ' . $this->__toString() . ' has been marked as shutted down');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $this->__toString() . ' has been marked as shutted down');
$this->shuttedDown = TRUE;
// And remove the (now invalid) socket
* @return $shuttedDown Whether this connection is shutted down
*/
public final function isShuttedDown () {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
return $this->shuttedDown;
}
* @return void
*/
protected function socketErrorOperationInProgressHandler ($socketResource, array $recipientData) {
- self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
+ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Operation is now in progress, this is usual for non-blocking connections and is no bug.');
}
}
$recipientData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
} catch (NoValidHostnameException $e) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __LINE__ . ']: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Failed to resolve ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ':' . $e->getMessage());
// Is the recipient equal as configured IP
if (substr($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_ip'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_ip')) {
*/
public function doShutdown () {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Shutting down socket resource ' . $this->getSocketResource());
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down socket resource ' . $this->getSocketResource());
// Clear any previous errors
socket_clear_error($this->getSocketResource());
*/
public function loadDescriptorXml (Distributable $dhtInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Starting with DHT boostrap ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with DHT boostrap ...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class');
*/
public function loadDescriptorXml (Distributable $dhtInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Starting with publishing an entry ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with publishing an entry ...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_publish_entry_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Starting with announcement to upper hubs...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Starting with announcement to upper hubs...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting to answer an announcement...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer an announcement...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting to answer a request: node-list...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to answer a request: node-list...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_answer_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting self-connect...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting self-connect...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class');
*/
public function loadDescriptorXml (NodeHelper $nodeInstance) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __LINE__ . ']: Attempting to request: node-list...');
+ self::createDebugInstance(__CLASS__)->debugOutput('HELPER[' . __METHOD__ . ':' . __LINE__ . ']: Attempting to request: node-list...');
// Get a XML template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class');
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
// Visit this listener
$visitorInstance->visitListener($this);
} // END - if
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
}
/**
* that all connections on this port are now our resposibility to
* send/recv data, disconnect, etc..
*/
- self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
+ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
// Handle this socket error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
} // END - if
// Start listen for connections
- self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Listening for connections.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Listening for connections.');
if (!socket_listen($mainSocket)) {
// Handle this socket error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
} // END - if
// Now, we want non-blocking mode
- self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Setting non-blocking mode.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting non-blocking mode.');
if (!socket_set_nonblock($mainSocket)) {
// Handle this socket error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
$this->setHandlerInstance($handlerInstance);
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
}
/**
// Some new peers found?
if ($left < 1) {
// Debug message
- //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE));
+ //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE));
// Nothing new found
return;
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, TRUE));
// Do we have changed peers?
if (in_array($this->getSocketResource(), $readers)) {
$currentSocket = $this->getIteratorInstance()->current();
// Handle it here, if not main server socket
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource());
if (($currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] != BaseConnectionHelper::CONNECTION_TYPE_SERVER) && ($currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] != $this->getSocketResource())) {
// ... or else it will raise warnings like 'Transport endpoint is not connected'
$this->getHandlerInstance()->processRawDataFromResource($currentSocket);
* that all connections on this port are now our resposibility to
* send/recv data, disconnect, etc..
*/
- self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
+ self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
// Handle the socket error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
} // END - if
// Now, we want non-blocking mode
- self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Setting non-blocking mode.');
+ self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting non-blocking mode.');
if (!socket_set_nonblock($mainSocket)) {
// Handle the socket error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
} // END - if
// Set the option to reuse the port
- self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Setting re-use address option.');
+ self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Setting re-use address option.');
if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) {
// Handle the socket error with a faked recipientData array
$this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
$this->setHandlerInstance($handlerInstance);
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+ self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
}
/**
return;
} elseif ($lastError > 0) {
// Other error detected
- self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Error detected: ' . socket_strerror($lastError));
+ self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Error detected: ' . socket_strerror($lastError));
// Skip further processing
return;
} // END - if
// Debug only
- self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port);
+ self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port);
}
/**
$this->bootIpPort = $ipPort;
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __LINE__ . ']: IP matches remote address ' . $ipPort . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches remote address ' . $ipPort . '.');
// Stop further searching
break;
$this->bootIpPort = $ipPort;
// Output message
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __LINE__ . ']: IP matches listen address ' . $ipPort . '.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: ' . __FUNCTION__ . '[' . __METHOD__ . ':' . __LINE__ . ']: IP matches listen address ' . $ipPort . '.');
// Stop further searching
break;
*/
public function doSelfConnection (Taskable $taskInstance) {
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: Self Connection: START (taskInstance=' . $taskInstance->__toString(). ')');
+ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Self Connection: START (taskInstance=' . $taskInstance->__toString(). ')');
// Get a helper instance
$helperInstance = ObjectFactory::createObjectByConfiguredName('node_self_connect_helper_class', array($this));
$helperInstance->sendPackage($this);
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: Self Connection: FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Self Connection: FINISHED');
}
/**
*/
public function initializeListenerPool () {
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: Initialize listener: START');
+ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Initialize listener: START');
// Get a new pool instance
$this->setListenerPoolInstance(ObjectFactory::createObjectByConfiguredName('listener_pool_class', array($this)));
$this->getListenerPoolInstance()->addListener($decoratorInstance);
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: Initialize listener: FINISHED.');
+ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: Initialize listener: FINISHED.');
}
/**
*/
public function ifNodeHasAnnounced () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: ifNodeHasAnnounced(): state=' . $this->getStateInstance()->getStateName());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnounced(): state=' . $this->getStateInstance()->getStateName());
// Simply check the state of this node
$hasAnnounced = ($this->getStateInstance() instanceof NodeAnnouncedState);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: ifNodeHasAnnounced(): hasAnnounced=' . intval($hasAnnounced));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnounced(): hasAnnounced=' . intval($hasAnnounced));
// Return it
return $hasAnnounced;
*/
public function ifNodeHasAnnouncementCompleted () {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName());
// Simply check the state of this node
$hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted));
// Return it
return $hasAnnouncementCompleted;
$dataSetInstance->addCriteria($element, $nodeData[$element]);
} else {
// Output warning message
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in nodeData array.');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE[' . __METHOD__ . ':' . __LINE__ . ']: addArrayToDataSet(): Element ' . $element . ' not found in nodeData array.');
}
} // END - foreac
}
*/
private function getHashFromContent ($content) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
// And return it
return $hash;
*/
public function getHashFromContentSessionId (array $decodedContent, $sessionId) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
// Create the hash
// @TODO md5() is very weak, but it needs to be fast
$currentRecipient = $iteratorInstance->current();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]);
// Set the recipient
$packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient;
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Package declared for recipient ' . $currentRecipient);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package declared for recipient ' . $currentRecipient);
// Skip to next entry
$iteratorInstance->next();
$socketResource = $discoveryInstance->discoverSocket($packageData, BaseConnectionHelper::CONNECTION_TYPE_OUTGOING);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
// We have to put this socket in our registry, so get an instance
$registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
$helperInstance = Registry::getRegistry()->getInstance('connection');
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: stateInstance=' . $helperInstance->getStateInstance());
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: stateInstance=' . $helperInstance->getStateInstance());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
// Is it not there?
if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($helperInstance, $socketResource))) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Registering socket ' . $socketResource . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Registering socket ' . $socketResource . ' ...');
// Then register it
$registryInstance->registerSocket($helperInstance, $socketResource, $packageData);
} elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) {
// Is not connected, then we cannot send
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
// Shutdown the socket
$this->shutdownSocket($socketResource);
}
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
// Make sure the connection is up
$helperInstance->getStateInstance()->validatePeerStateConnected();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
// Enqueue it again on the out-going queue, the connection is up and working at this point
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
}
/**
// Make sure this method isn't working if there is no package enqueued
if (!$this->isPackageEnqueued()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: No package has been declared, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No package has been declared, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
$this->getStackerInstance()->popNamed(self::STACKER_NAME_DECLARED);
} catch (InvalidStateException $e) {
// The state is not excepected (shall be 'connected')
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
// Mark the package with status failed
$this->changePackageStatus($packageData, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED);
// Sanity check if we have packages waiting for delivery
if (!$this->isPackageWaitingForDelivery()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
return;
} // END - if
$this->getStackerInstance()->popNamed(self::STACKER_NAME_OUTGOING);
} catch (InvalidSocketException $e) {
// Output exception message
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Package was not delivered: ' . $e->getMessage());
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Package was not delivered: ' . $e->getMessage());
// Mark package as failed
$this->changePackageStatus($packageData, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED);
*/
if (!$this->isRawDataPending()) {
// This is not fatal but should be avoided
- self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!');
+ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
// Very noisy debug message:
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: Stacker size is ' . $this->getStackerInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Stacker size is ' . $this->getStackerInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
// "Pop" the next entry (the same array again) from the stack
$decodedData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING);
* Also make sure the error code is SOCKET_ERROR_UNHANDLED because we
* only want to handle unhandled packages here.
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')');
assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED);
// Remove the last chunk SEPARATOR (because it is being added and we don't need it)
} // END - if
// This package is "handled" and can be pushed on the next stack
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $decodedData);
}
$decodedData = $handlerInstance->getNextRawData();
// Very noisy debug message:
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE));
// And push it on our stack
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData);
// Get current package content (an array with two elements; see handleIncomingDecodedData() for details)
$packageContent = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED);
+ // Assert on some elements
+ assert(
+ (is_array($packageContent)) &&
+ (isset($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA])) &&
+ (isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]))
+ );
+
// Start assembling the raw package data array by chunking it
$this->getAssemblerInstance()->chunkPackageContent($packageContent);
$this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED);
// ... and push it on the 'chunked' stacker
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ' ...');
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent);
}
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
// Visit the package
$visitorInstance->visitNetworkPackage($this);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
}
/**
$this->initStacks(TRUE);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: All stacker have been re-initialized.');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: All stacker have been re-initialized.');
}
/**
$messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE];
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __LINE__ . ']: messageArray=' . print_r($messageArray, TRUE));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: messageArray=' . print_r($messageArray, TRUE));
// Create a handler instance from given message type
$handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
*/
public function accept (Visitor $visitorInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - START');
// Visit this pool
$visitorInstance->visitPool($this);
// Is this entry visitable?
if ($poolEntry instanceof Visitable) {
// Visit this entry as well
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-POOL[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...');
$poolEntry->accept($visitorInstance);
} else {
// Cannot visit this entry
} // END - while
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited - FINISHED');
}
/**
// Debug message
self::createDebugInstance(__CLASS__)->debugOutput(
- 'POOL[' . __LINE__ . ']: Listener ' . $listenerInstance->__toString() .
+ 'POOL[' . __METHOD__ . ':' . __LINE__ . ']: Listener ' . $listenerInstance->__toString() .
' listening to ' . $listenerInstance->getListenAddress() . ':' .
$listenerInstance->getListenPort() . ' added to listener pool.'
);
*/
public function doShutdown () {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Shutting down listener pool - START');
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down listener pool - START');
// Get a new visitor
$visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class');
$this->accept($visitorInstance);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Shutting down listener pool - FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down listener pool - FINISHED');
}
}
} // END - if
} else {
// Server sockets won't work with socket_getpeername()
- self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Socket resource is server socket (' . $socketResource . '). This is not a bug.');
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Socket resource is server socket (' . $socketResource . '). This is not a bug.');
}
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType);
+ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Adding peer ' . $peerName . ',socketResource=' . $socketResource . ',type=' . $connectionType);
// Construct the array
$socketArray = array(
assert(count($recipientIpArray) == 2);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),recipientIpArray[0]=' . $recipientIpArray[0] . ',recipientIpArray[1]=' . $recipientIpArray[1] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),recipientIpArray[0]=' . $recipientIpArray[0] . ',recipientIpArray[1]=' . $recipientIpArray[1] . ' ...');
// Default is all sockets
$sockets = $this->getAllSockets();
// Is this a server socket?
if ($socketArray[self::SOCKET_ARRAY_RESOURCE] === $this->getListenerInstance()->getSocketResource()) {
// Skip 'server' sockets (local socket)
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: Skipping server socket ' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ' ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Skipping server socket ' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ' ...');
continue;
} // END - if
$socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[self::SOCKET_ARRAY_CONN_TYPE]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: peerIp=' . $peerIp . ' matches with recipient IP address. Taking socket=' . $socketArray[self::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[self::SOCKET_ARRAY_CONN_TYPE]);
break;
} // END - if
} // END - foreach
// Return the determined socket resource
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource);
return $socketResource;
}
}
$socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $connectionInstance, $packageData));
// We have a sub-registry, the socket key and the socket, now we need to put all together
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
$registryInstance->addInstance($socketKey, $socketInstance);
}
// This is always a SubRegistry instance
foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
// This is a ConnectionContainer instance, so does the recipient match?
if ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) {
$key = $this->getRegistryKeyFromProtocol($protocolInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
// Get the registry
$registryInstance = $this->getInstance($key);
$socketKey = $this->getSubRegistryKey($protocolInstance);
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
// Is it there?
if ($registryInstance->instanceExists($socketKey)) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey));
// Get the instance
$registeredInstance = $registryInstance->getInstance($socketKey);
$isRegistered = (($registeredInstance instanceof SocketContainer) && ($registeredInstance->ifSocketResourceMatches($socketResource)));
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: Final result: isRegistered(' . $socketResource . ')=' . intval($isRegistered));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: Final result: isRegistered(' . $socketResource . ')=' . intval($isRegistered));
} // END - if
} // END - if
$socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $protocolInstance, $packageData));
// We have a sub-registry, the socket key and the socket, now we need to put all together
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - adding socket container instance ...');
$registryInstance->addInstance($socketKey, $socketInstance);
}
// Get all keys and check them
foreach ($this->getInstanceRegistry() as $key => $registryInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',registryInstance=' . $registryInstance->__toString());
// This is always a SubRegistry instance
foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
// Is this a SocketContainer instance and is the address the same?
if (($containerInstance instanceof SocketContainer) && ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]))) {
*/
private function initObjectRegistry () {
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Initializing object registry - START');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Initializing object registry - START');
// Get the application instance
$applicationInstance = Registry::getRegistry()->getInstance('app');
$this->getTemplateInstance()->renderXmlContent();
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Initializing object registry - FINISHED');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Initializing object registry - FINISHED');
}
/**
// "Walk" over all tags
foreach ($this->getTags() as $tag) {
// Debug output
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Validating tag ' . $tag . ' ...');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Validating tag ' . $tag . ' ...');
// Get an array from this tag
$entry = $objectRegistryInstance->getArrayFromKey(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME, $tag);
$stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance();
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString());
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString());
// We can now invoke that state instance and pass our producer instance for generating some test units
$stateInstance->executeState($producerInstance);
$stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance();
// Debug message
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString());
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString());
// We can now invoke that state instance and pass our producer instance for generating some test units
$stateInstance->executeState($producerInstance);
*/
public function doShutdown () {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('IDLE-TASK[' . __LINE__ . ']: Shutting down...');
+ self::createDebugInstance(__CLASS__)->debugOutput('IDLE-TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
}
}
$nodeInstance = Registry::getRegistry()->getInstance('node');
// Visit the pool listener task
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LISTENER-TASK[' . __LINE__ . ']: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('LISTENER-TASK[' . __METHOD__ . ':' . __LINE__ . ']: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...');
$nodeInstance->getListenerPoolInstance()->accept($visitorInstance);
// Visit this task
// Is the node name self::OBJECT_TYPE_DATA_NAME?
if ($nodeName == self::OBJECT_TYPE_DATA_NAME) {
// Output debug message
- self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __LINE__ . ']: Adding object type ' . $characters . ' to registry.');
+ self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Adding object type ' . $characters . ' to registry.');
} // END - if
// Add it to the registry
// Does it match a direct ip:port? (hint: see www.regexlib.com for the regular expression)
if (preg_match('/((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])):([0-9]{3,5})/', $sessionId)) {
// Direct ip:port found
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Direct ip:port ' . $sessionId . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Direct ip:port ' . $sessionId . ' detected.');
} elseif (isset($selfInstance->sessionIdCache[$sessionId])) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Using entry from sessionIdCache[] array.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using entry from sessionIdCache[] array.');
// Found in cache!
$recipient = $selfInstance->sessionIdCache[$sessionId];
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: sessionIdCache[' . $sessionId . ']=' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: sessionIdCache[' . $sessionId . ']=' . $recipient);
} elseif (preg_match('/([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}:([0-9]{3,5})/', $sessionId)) {
// Hostname:port found
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: hostname:port ' . $sessionId . ' detected.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: hostname:port ' . $sessionId . ' detected.');
// Hostname:port found
$hostnameArray = explode(':', $sessionId);
} // END - if
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: hostname:port ' . $sessionId . ' resolved to ' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: hostname:port ' . $sessionId . ' resolved to ' . $recipient);
} elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $sessionId)) {
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Using internal session id resolver.');
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Using internal session id resolver.');
// Resolve session id into a ip:port combination
$recipient = $selfInstance->resolveIpPortBySessionId($sessionId);
// Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __LINE__ . ']: Session id ' . $sessionId . ' resolved to ' . $recipient);
+ self::createDebugInstance(__CLASS__)->debugOutput('HUB-TOOLS[' . __METHOD__ . ':' . __LINE__ . ']: Session id ' . $sessionId . ' resolved to ' . $recipient);
} else {
// Invalid session id
throw new InvalidSessionIdException($sessionId, self::EXCEPTION_SESSION_ID_IS_INVALID);
-Subproject commit f3f1e6f543b907969a12c913a69a4e51e45a5637
+Subproject commit c68ca324e84a3297fb811ae9356f41a82b3c45ab