default: // Everything else <> 0
// Unhandled error code detected, so first debug it because we may want to handle it like the others
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode . ', MESSAGE = ' . socket_strerror($errorCode));
+ self::createDebugInstance(__CLASS__)->debugOutput('BASE-HUB[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode . ', MESSAGE = ' . socket_strerror($errorCode));
// Change it only in this class
$errorName = BaseRawDataHandler::SOCKET_ERROR_UNKNOWN;
assert(is_array($current));
// ... and push it to the next stack
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] Pushing entry with ' . count($current) . ' elements to stack ' . self::STACKER_NAME_PENDING_PUBLISHING . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] Pushing entry with ' . count($current) . ' elements to stack ' . self::STACKER_NAME_PENDING_PUBLISHING . ' ...');
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_PENDING_PUBLISHING, $current);
} // END - while
}
$isPending = ($this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_PENDING_PUBLISHING) === FALSE);
// Return status
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] isPending=' . intval($isPending));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-DHT[' . __METHOD__ . ':' . __LINE__ . '] isPending=' . intval($isPending));
return $isPending;
}
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// The default node-mode is from our configuration
$nodeMode = $this->getConfigInstance()->getConfigEntry('node_default_mode');
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Got default node mode ' . $nodeMode . ' from configuration.');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: Got default node mode ' . $nodeMode . ' from configuration.');
// Is the node 'mode' parameter set?
if ($requestInstance->isRequestElementSet('mode')) {
// Set the node instance in registry
Registry::getRegistry()->addInstance('node', $nodeInstance);
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Node ' . $nodeMode . ' has been added to registry.');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NODE-INIT-FILTER[' . __METHOD__ . ':' . __LINE__ . ']: Node ' . $nodeMode . ' has been added to registry.');
}
}
* if the decoded data origins from a TCP or UDP connection so we can
* just pass it over to the network package receiver
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] Going to handle over some raw data to receiver instance (' . $receiverInstance->__toString() . ') ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-LISTENER-DECORATOR[' . __METHOD__ . ':' . __LINE__ . '] Going to handle over some raw data to receiver instance (' . $receiverInstance->__toString() . ') ...');
$receiverInstance->addRawDataToIncomingStack($handlerInstance);
}
}
$newSocket = socket_accept($this->getSocketResource());
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',serverSocket=' .$this->getSocketResource());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __METHOD__ . ':' . __LINE__ . ']: newSocket=' . $newSocket . ',serverSocket=' .$this->getSocketResource());
// Array for timeout settings
$options = array(
// Generate hash
$hash = $this->generateHash($groupName, $groupName, $entry);
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: groupName=' . $groupName . ', entry=' . $entry . ', hash=' . $hash);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: groupName=' . $groupName . ', entry=' . $entry . ', hash=' . $hash);
// Add the hash to the index
array_push($this->listIndex, $hash);
// Generate hash
$hash = $this->generateHash($groupName, $groupName, $entry);
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: groupName=' . $groupName . ', entry=' . $entry . ', hash=' . $hash);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: groupName=' . $groupName . ', entry=' . $entry . ', hash=' . $hash);
// Remove it from the list ...
unset($this->listEntries[$hash]);
$entry2 = crc32($entry[BasePool::SOCKET_ARRAY_RESOURCE] . ':' . $entry[BasePool::SOCKET_ARRAY_CONN_TYPE]);
} else {
// Unsupported type detected
- self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.');
+ self::createDebugInstance(__CLASS__)->debugOutput('BASE-LIST[' . __METHOD__ . ':' . __LINE__ . ']: Entry type ' . gettype($entry) . ' is unsupported.');
// @TODO Extend this somehow?
$entry2 = gettype($entry);
assert(strlen($finalHash) > 0);
// Is the pointer already initialized?
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
assert(isset($this->chunkPointers[$finalHash]));
// Return it
assert(isset($this->chunkPointers[$finalHash]));
// Count one up
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
$this->chunkPointers[$finalHash]++;
}
$this->generateHashFromRawData($lastChunk);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...');
// Add it as regular chunk
$this->addChunkData($finalHash, $chunkData);
// Calculate real (data) chunk size
$dataChunkSize = $this->getDataChunkSizeFromHash($finalHash);
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': dataChunkSize=' . $dataChunkSize);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: dataChunkSize=' . $dataChunkSize);
// Init variables
$chunkHash = '';
} // END - for
// Debug output
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).');
// Add end-of-package chunk
$this->appendEndOfPackageChunk($chunkData, $finalHash);
);
// Make sure the chunk is not larger than a TCP package can hold
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...');
// @TODO This assert broke packages where the hash chunk was very large: assert(strlen($rawData) <= NetworkPackage::TCP_PACKAGE_SIZE);
// Add it to the array
if ($prepend === TRUE) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
array_unshift($this->chunkHashes[$finalHash], $rawDataHash);
array_unshift($this->chunks[$finalHash] , $rawData);
} else {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
// Is the array there?
if (!isset($this->chunks[$finalHash])) {
assert($this->serialNumber[$finalHash] <= $this->maxSerialNumber);
// Encode the current serial number
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]);
$encodedSerialNumber = $this->dec2Hex($this->serialNumber[$finalHash], self::MAX_SERIAL_LENGTH);
// Count one up
$this->serialNumber[$finalHash]++;
// Return the encoded serial number
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': encodedSerialNumber=' . $encodedSerialNumber);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: encodedSerialNumber=' . $encodedSerialNumber);
return $encodedSerialNumber;
}
}
// Return final hash
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
return $finalHash;
}
*/
public function getNextRawDataChunk ($finalHash) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': finalHash[' . gettype($finalHash) . ']=' . $finalHash);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-FRAGMENTER[' . __METHOD__ . ':' . __LINE__ . ']: finalHash[' . gettype($finalHash) . ']=' . $finalHash);
try {
// Get current chunk index
*/
public function addPeer ($socketResource, $connectionType) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DEFAULT-PEER-POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - ENTERED!');
// Validate the socket
$this->validateSocket($socketResource);
*/
private function isProtocolRegistered (ProtocolHandler $protocolInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
// Get the key
$key = $this->getRegistryKeyFromProtocol($protocolInstance);
$isRegistered = $this->instanceExists($key);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return result
return $isRegistered;
*/
public function isSocketRegistered (ProtocolHandler $protocolInstance, $socketResource) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
// Default is not registered
$isRegistered = FALSE;
} // END - if
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
// Return the result
return $isRegistered;
*/
public function registerSocket (ProtocolHandler $protocolInstance, $socketResource, array $packageData = array()) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
// Is the socket already registered?
if ($this->isSocketRegistered($protocolInstance, $socketResource)) {
*/
public function getRegisteredSocketResource (ProtocolHandler $protocolInstance) {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
// The socket must be registered before we can return it
if (!$this->isProtocolRegistered($protocolInstance)) {
$socketResource = $registryInstance->getInstance($socketKey)->getSocketResource();
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!');
// Return the resource
return $socketResource;
* @return $isExhausted Whether the retry count has been reached
*/
public static function isConnectRetryExhausted (ConnectionHelper $helperInstance) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
// Construct config entry
$configEntry = $helperInstance->getProtocol() . '_connect_retry_max';
);
// Return it
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ',isExhausted=' . intval($isExhausted) . ' - EXIT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ',isExhausted=' . intval($isExhausted) . ' - EXIT!');
return $isExhausted;
}
* @return void
*/
public static function increaseConnectRetry (ConnectionHelper $helperInstance) {
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
// Is the counter there
if (!isset(self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'])) {
// First attempt
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - FIRST!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - FIRST!');
self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'] = 1;
} else {
// Next attempt
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - INCREMENT!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-STATISTICS[' . __METHOD__ . ':' . __LINE__ . ']: helperInstance=' . $helperInstance->__toString() . ' - INCREMENT!');
self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count']++;
}
* [[S]] - Start marker
* [[E]] - End marker
*/
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: data()=' . strlen($data) . ' - BEFORE!');
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-OUTPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ']: data()=' . strlen($data) . ' - BEFORE!');
$data = BaseRawDataHandler::STREAM_START_MARKER . base64_encode($data) . BaseRawDataHandler::STREAM_END_MARKER;
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: data(' . strlen($data) . ')=' . $data);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RAW-OUTPUT-STREAM[' . __METHOD__ . ':' . __LINE__ . ']: data(' . strlen($data) . ')=' . $data);
// Return it
return $data;
-Subproject commit 6807d3268e4f233bf224155956ef6858925b58b0
+Subproject commit 882c6e83b89e5c168812498025b9c48857edb952