// Is the instance there?
if (is_null(self::getApplicationInstance())) {
self::setApplicationInstance(new ApplicationHelper());
- } // END - if
+ }
// Return the instance
return self::getApplicationInstance();
// Set it in request
$requestInstance->setRequestElement('command', $commandName);
- } // END - if
+ }
// Is the request type 'html' ?
if (FrameworkBootstrap::getRequestTypeFromSystem() == 'html') {
// And set it here
$this->setLanguageInstance($languageInstance);
- } // END - if
+ }
// Configuration entry key
$configEntry = sprintf(
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown in progress, main loop exited.');
$this->getControllerInstance()->executeShutdownFilters($requestInstance, $responseInstance);
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: Shutdown completed. (This is the last line.)');
- } // END - if
+ }
}
/**
// Walk through all messages
foreach ($messageList as $message) {
exit(__METHOD__ . ':MSG:' . $message);
- } // END - foreach
+ }
}
/**
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage());
break;
}
- } // END - foreach
+ }
}
/**
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage());
break;
}
- } // END - foreach
+ }
}
}
FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_port') > 0
)
);
- } // END - if
+ }
// Return cache
return $GLOBALS[__METHOD__];
if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
// Response code is not 200
return $response;
- } // END - if
+ }
// All fine!
return $respArray;
// Add it as well
$encodedAuth = base64_encode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_username') . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('proxy_password'));
$rawRequest .= 'Proxy-Authorization: Basic ' . $encodedAuth . self::HTTP_EOL;
- } // END - if
+ }
// Add last new-line
$rawRequest .= self::HTTP_EOL;
if (feof($this->getSocketInstance())) {
// No response received
return $response;
- } // END - if
+ }
// Read the first line
$resp = trim(fgets($this->getSocketInstance(), 10240));
while (($proxyInstance->isActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
while (($chatInstance->isActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
while (($crawlerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
while (($cruncherInstance->isActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
while (($nodeInstance->isNodeActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
while (($minerInstance->isActive()) && ($handlerInstance->hasTasksLeft())) {
// Handle all tasks here
$handlerInstance->handleTasks();
- } // END - while
+ }
// Debug message
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MAIN: --- Leaving main loop. ---');
// Bail out
exit();
- } // END - if
+ }
/*
* This is a generic HTML request, this means that a regular page with
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'activation', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
parent::__construct(__CLASS__);
// Init additional filter chains
- foreach (array('bootstrap','shutdown') as $filterChain) {
+ foreach (['bootstrap', 'shutdown'] as $filterChain) {
$this->initFilterChain($filterChain);
- } // END - foreach
+ }
}
/**
if ((!$this->isInBufferQueueFilled()) && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) {
// Then fill the in-buffer with (one) test-unit(s)
$this->fillInBufferQueueWithTestUnits();
- } // END - if
- } // END - if
+ }
+ }
}
/**
// ... and finally queue it to the in-buffer queue
$this->queueUnitInstanceToInBuffer($unitInstance);
- } // END - for
+ }
}
/**
if ($this->getStateInstance()->isCruncherStateVirgin()) {
// We can silently skip here, until the generation is finished
return;
- } // END - if
+ }
// @TODO Implement this method
$this->partialStub('Please implement this method.');
use Org\Mxchange\CoreFramework\Result\Search\SearchableResult;
// Import SPL stuff
+use \BadMethodCallException;
use \InvalidArgumentException;
/**
* session id, ip number (and/or hostname) and port number.
*
* @return void
+ * @throws BadMethodCallException If node is not locally registered
*/
public function updateLocalNode () {
- // Debug message
+ // Check condition
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-FRONTEND: CALLED!');
-
- // Assert to make sure this method is called with one record in DB (the actual backend of the DHT)
- assert($this->isLocalNodeRegistered());
+ if (!$this->isLocalNodeRegistered()) {
+ // Not registered but methoded invoked
+ throw new BadMethodCallException('Node is not locally registered but method called');
+ }
// Get search criteria
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
if ($this->isNodeRegistered($nodeData)) {
// Throw an exception
throw new NodeAlreadyRegisteredException(array($this, $nodeData), self::EXCEPTION_NODE_ALREADY_REGISTERED);
- } // END - if
+ }
// @TODO Unimplemented part
$this->partialStub('nodeData=' . print_r($nodeData, TRUE));
if (!$this->isNodeRegistered($nodeData)) {
// No, then throw an exception
throw new NodeDataMissingException(array($this, $nodeData), self::EXCEPTION_NODE_NOT_REGISTERED);
- } // END - if
+ }
// Get a search instance
$searchInstance = $this->prepareSearchInstance($nodeData);
// Import framework stuff
use Org\Mxchange\CoreFramework\Registry\Registerable;
+// Import SPL stuff
+use \BadMethodCallException;
+
/**
* A Package decoder class
*
* Handles raw package data by decoding it
*
* @return void
+ * @throws BadMethodCallException If no unhandled package data is pending
*/
public function handleRawPackageData () {
// Assert on it to make sure the next popNamed() call won't throw an exception
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: CALLED!');
- assert($this->ifUnhandledRawPackageDataLeft());
+ if (!$this->ifUnhandledRawPackageDataLeft()) {
+ // No unhandled package data pending
+ throw new BadMethodCallException('No unhandled package data is pending but method called');
+ }
// "Pop" the next raw package content
$rawPackageContent = $this->getHandlerInstance()->getStackInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA);
* Handles received decoded packages internally (recipient is this node)
*
* @return void
+ * @throws BadMethodCallException If no decoded packages are left
*/
public function handleDecodedPackage () {
- // Assert on amount
- assert($this->ifDeocedPackagesLeft());
+ // Check condition
+ if (!$this->ifDeocedPackagesLeft()) {
+ // No decoded packages left
+ throw new BadMethodCallException('No decoded packages pending but method called');
+ }
// Get the next entry (assoziative array)
$packageInstance = $this->getHandlerInstance()->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE);
if (!$this->publishHelperInstance instanceof HelpableDht) {
// Get a helper instance
$this->publishHelperInstance = ObjectFactory::createObjectByConfiguredName('dht_publish_entry_helper_class');
- } // END - if
+ }
// Load the announcement descriptor
$this->publishHelperInstance->loadDescriptorXml($this);
if (is_null($locatorInstance)) {
// Throw NPE here
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ }
// ... and return it
return $locatorInstance;
// Get back the full UNL
$GLOBALS[__METHOD__][$configKey] = $resolverInstance->resolveUniversalNodeLocatorFromConfigKey($configKey);
- } // END - if
+ }
// Return cached value
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNL-DISCOVERY:configKey=' . $configKey . ',unl=' . $GLOBALS[__METHOD__][$configKey] . ' - EXIT!');
// This listener likes our package data, so abort here
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString()));
break;
- } // END - if
+ }
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Listener is NOT accepting package data.');
- } // END - foreach
+ }
// Return it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!');
// Add this filter to the chain
$chainInstance->addFilter($filterInstance);
- } // END - foreach
+ }
// Add the finished chain to the registry
GenericRegistry::getRegistry()->addInstance($registryKey, $chainInstance);
if ($socketInstance instanceof StorableSocket) {
// Set socket instance
$clientInstance->setSocketInstance($socketInstance);
- } // END - if
+ }
} else {
// Generate object instance
$clientInstance = self::createObjectByConfiguredName($registryKey, array($socketInstance));
// Get node instance from registry
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NOTE-STATE-FACTORY: Creating node instance ...');
$nodeInstance = NodeObjectFactory::createNodeInstance();
- } // END - if
+ }
// Get a class from that configuration entry
$stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance));
if (is_null(self::$tableInstance)) {
// Get a new one
self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_frontend_class');
- } // END - if
+ }
// Return it
return self::$tableInstance;
if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
- } // END - if
+ }
}
-}
-// [EOF]
-?>
+}
if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
- } // END - if
+ }
}
-}
-// [EOF]
-?>
+}
// Skip this part, don't write NULLs to the array
continue;
- } // END - if
+ }
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
// Set it now
$this->dataXmlNodes[$key] = $value;
- } // END - foreach
+ }
// Construct an array for pushing it on next stack
$messageArray = array(
if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
- } // END - if
+ }
}
-}
-// [EOF]
-?>
+}
if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
- } // END - if
+ }
}
-}
-// [EOF]
-?>
+}
if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::FILTER_CHAIN_INTERCEPTED);
- } // END - if
+ }
}
}
// Test failed
$checkPassed = FALSE;
$checksFailed++;
- } // END - if
+ }
// If scrypt() is not found (ext-scrypt) then the "Hubcoins reward" is not working
if ((extension_loaded('scrypt')) && (is_callable('scrypt'))) {
if ($checkPassed === FALSE) {
// Throw an exception
throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } // END - if
+ }
}
}
// And register it
$handlerInstance->registerTask('crawler_url_source_' . $stack, $taskInstance);
- } // END - foreach
+ }
// Put the task handler in registry
GenericRegistry::getRegistry()->addInstance('task_handler', $handlerInstance);
default: // Invalid step found
self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: Invalid step %d detected.', $this->finalPackageChunks['assemble_steps']));
break;
- } // END - switch
+ }
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: EXIT!');
* announce his node to a non-bootstrap and non-master node.
*/
throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageInstance), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED);
- } // END - if
+ }
// Register the announcing node with this node
$this->registerNodeByMessageInstance($messageInstance);
// Add it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Adding messageData[' . $key . ']=' . $messageData[$key] . ' ...');
$dataSetInstance->addCriteria($key, $messageData[$key]);
- } // END - foreach
+ }
}
}
* announcement answer messages.
*/
throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
- } // END - if
+ }
// Register the announcing node with this node
$this->registerNodeByMessageInstance($messageInstance);
* database layer.
*/
$dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
- } // END - foreach
+ }
}
}
* announcement answer messages.
*/
throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED);
- } // END - if
+ }
// Unfinished
$this->partialStub('UNHANDLED: messageInstance=' . print_r($messageInstance, TRUE));
* database layer.
*/
$dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
- } // END - foreach
+ }
}
}
* request-node-list answer messages.
*/
throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
- } // END - if
+ }
// Register the announcing node with this node
$this->registerNodeByMessageInstance($messageInstance);
* database layer.
*/
$dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
- } // END - foreach
+ }
}
}
if ($this->getLastException() instanceof FrameworkException) {
// "Determine" the right status code (may differ from exception to exception)
$this->debugInstance(sprintf('[%s:%d]: lastException=%s,message=%s is unfinished.', __METHOD__, __LINE__, $this->getLastException()->__toString(), $this->getLastException()->getMessage()));
- } // END - if
+ }
// Return the status code
return $statusCode;
* This node is not accepting DHT bootstrap requests.
*/
throw new DhtBootstrapNotAcceptedException(array($this, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED);
- } // END - if
+ }
// Register the DHT bootstrap requesting node with this node
$this->registerNodeByMessageInstance($messageInstance);
// Add it
$dataSetInstance->addCriteria($key, $messageData[$key]);
- } // END - foreach
+ }
}
}
* exception to abort any further processing.
*/
throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_REQUEST_NOT_ACCEPTED);
- } // END - if
+ }
// Register the announcing node with this node
$this->registerNodeByMessageInstance($messageInstance);
// Add it
$dataSetInstance->addCriteria($key, $messageData[$key]);
- } // END - foreach
+ }
}
}
* @return void
*/
public function sendEncodedData () {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
-
// Make sure there is pending encoded data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
assert($this->isEncodedDataPending());
// Pop current data from stack
$socketInstance = $encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE];
$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = NULL;
- // Trace message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
-
// And deliver it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
if (!$socketInstance->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) {
// Something bad happened while writing to socket
$socketInstance->handleSocketError(__METHOD__, __LINE__);
}
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
-
// If there was an error, don't continue here
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) {
// Nothing sent means all data has been sent
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All sent! (LINE=' . __LINE__ . ')');
// Set it back
$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = $socketInstance;
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing raw data back to stacker, as still some data is pending delivery.');
-
// Push array back in stack
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing raw data back to stacker, as still some data is pending delivery.');
$this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
- // Debug message
+ // Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
}
* @return $isPending Whether decoded raw data is pending
*/
private function isRawDataPending () {
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
-
// Just return whether the stack is not empty
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
$isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
-
// Return the status
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
return $isPending;
}
* @return $hasArrived Whether new raw package data has arrived for processing
*/
public function isNewRawDataPending () {
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
-
// Visit the pool. This monitors the pool for incoming raw data.
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
$this->getListenerPoolInstance()->accept($this->getVisitorInstance());
// Check for new data arrival
$hasArrived = $this->isRawDataPending();
- // Trace message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
-
// Return the status
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
return $hasArrived;
}
// Set port
$this->setPort($locatorInstance->getUnlPort());
- } // END - if
+ }
// Return result
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('IPV4-PROTOCOL-HANDLER: isValid=%d - EXIT!', intval($isValid)));
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: Adding %d(%s) bytes to stacker ...', strlen($rawData), $rawData));
$this->addRawDataToStacker($rawData);
}
- } // END - while
+ }
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-RAW-DATA-HANDLER: EXIT!');
if (strpos($packageInstance->getRecipientUnl(), ':') === FALSE) {
// No ip:port!
$helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s does not contain ":". Please fix this.', __METHOD__, __LINE__, $packageInstance->getRecipientUnl()));
- } // END - if
+ }
// "explode" the ip:port, so index 1 will be the port number
// @TODO Rewrite this test for UNLs
if (!$socketInstance->determineSocketPeerName($socketAddress, $socketPort)) {
// Did not work
throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
- } // END - if
+ }
// Fill the generic array with several data from the listener:
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketAddress=%s,socketPort=%d', $socketAddress, $socketPort));
if (!$this->valid()) {
// Throw an exception here
throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- } // END - if
+ }
// Now get the entry
$current = $this->getListInstance()->getEntry($this->key());
if (!$this->valid()) {
// Throw an exception here
throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- } // END - if
+ }
// Now get the entry
$current = $this->getListInstance()->getEntry($this->key());
if (!$this->valid()) {
// Throw an exception here
throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- } // END - if
+ }
// Now get the entry
$current = $this->getListInstance()->getEntry($this->key());
if (!$this->valid()) {
// Throw an exception here
throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- } // END - if
+ }
// Now get the entry
$current = $this->getListInstance()->getEntry($this->key());
if (!$this->valid()) {
// Throw an exception here
throw new IndexOutOfBoundsException($this->key(), self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- } // END - if
+ }
// Now get the entry
$current = $this->getListInstance()->getEntry($this->key());
if ($this->isServerSocketRegistered($socketInstance)) {
// Already registered
throw new SocketAlreadyRegisteredException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_SOCKET_ALREADY_REGISTERED);
- } // END - if
+ }
// Get a connection info instance
$infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), StorableSocket::CONNECTION_TYPE_SERVER);
if (!($infoInstance instanceof ShareableInfo)) {
// Should not happen
throw new LogicException(sprintf('infoInstance[]=%s does not implement ShareableInfo', gettype($infoInstance)));
- } // END - if
+ }
// Will the info instance with listener data
$infoInstance->fillWithListenerInformation($this);
if ($this->getPoolInstance() instanceof Poolable) {
// Visit pool instance
$this->getPoolInstance()->accept($visitorInstance);
- } // END - if
+ }
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!');
if (is_null($iteratorInstance)) {
// Throw NPE
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ }
// Is it valid?
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: iteratorInstance->valid()=%d', strtoupper($this->getProtocolName()), intval($iteratorInstance->valid())));
// Then rewind it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Rewinding iterator ...', strtoupper($this->getProtocolName())));
$iteratorInstance->rewind();
- } // END - if
+ }
// Get current instance
$socketInstance = $iteratorInstance->current();
// Nothing has changed on the listener
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: No new connection on listener ... - EXIT!', strtoupper($this->getProtocolName())));
return;
- } // END - if
+ }
// Get a connection info instance
$infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), StorableSocket::CONNECTION_TYPE_INCOMING);
if (!($infoInstance instanceof ShareableInfo)) {
// Should not happen
throw new LogicException(sprintf('infoInstance[]=%s does not implement ShareableInfo', gettype($infoInstance)));
- } // END - if
+ }
// Will the info instance with listener data
$infoInstance->fillWithSocketPeerInformation($socketInstance);
if (!$socketInstance->determineSocketPeerName($peerAddress, $peerPort)) {
// Handle this socket error
$socketInstance->handleSocketError(__METHOD__, __LINE__);
- } // END - if
+ }
// Set all required data
//* DEBUG-DIE: */ $infoInstance->debugInstance();
// No data is pending so skip further code silently
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER-DECORATOR: No data pending on handlerInstance=' . $handlerInstance->__toString() . ' - EXIT!');
return;
- } // END - if
+ }
// Get receiver (network package) instance
$receiverInstance = NetworkPackageHandlerFactory::createNetworkPackageHandlerInstance();
// Is already different protocol
return FALSE;
- } // END - if
+ }
// Debugging
/* DEBUG-DIE: */ die(__METHOD__.':packageInstance='.print_r($packageInstance, TRUE));
// Is already different protocol
return FALSE;
- } // END - if
+ }
// Debugging
/* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE));
// Is already different protocol
return FALSE;
- } // END - if
+ }
// Debugging
//* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE));
// Is already different protocol
return FALSE;
- } // END - if
+ }
// Debugging
/* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE));
// Is already different protocol
return FALSE;
- } // END - if
+ }
// Debugging
/* DEBUG-DIE: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE));
$this->unlData = [];
// Copy all found entries
- foreach (array(
+ foreach ([
LocateableNode::UNL_PART_PROTOCOL,
LocateableNode::UNL_PART_ADDRESS,
LocateableNode::UNL_PART_EXTRA,
NodeInformationDatabaseFrontend::DB_COLUMN_PRIVATE_KEY_HASH,
NodeInformationDatabaseFrontend::DB_COLUMN_NODE_MODE,
NodeInformationDatabaseFrontend::DB_COLUMN_INTERNAL_UNL,
- NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL) as $key) {
+ NodeInformationDatabaseFrontend::DB_COLUMN_EXTERNAL_UNL] as $key) {
// Init entry
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: key=%s', $key));
$this->unlData[$key] = NULL;
// ... and finally queue it to the in-buffer queue
$this->queueUnitInstanceToInBuffer($unitInstance);
- } // END - for
+ }
}
/**
if ($this->getStateInstance()->isMinerStateVirgin()) {
// We can silently skip here, until the generation is finished
return;
- } // END - if
+ }
// @TODO Implement this method
$this->partialStub('Please implement this method.');
if ((!$this->isInBufferQueueFilled()) && (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('miner_test_units_enabled') == 'Y')) {
// Then fill the in-buffer with (one) test-unit(s)
$this->fillInBufferQueueWithTestUnits();
- } // END - if
- } // END - if
+ }
+ }
}
/**
if (count($this->producersInitialized) == self::MAX_PRODUCERS) {
// Change it to 'booting'
MinerStateFactory::createMinerStateInstanceByName('booting');
- } // END - if
+ }
}
}
// Push it on stack
$this->getStackInstance()->pushNamed(self::STACKER_NAME_MULTIPLE_MESSAGE, $message);
- } // END - foreach
+ }
// Clear pending data
$this->clearPendingData();
if (substr($packageInstance->getRawData(), -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
// Remove it
$packageInstance->setRawData(substr($packageInstance->getRawData(), 0, -1));
- } // END - if
+ }
/*
* "explode" the string from 'raw_data' with chunk separator to get an
* Handles multiple messages.
*
* @return void
+ * @throws BadMethodCallException If some bad method invocation has happened
*/
public function handleMultipleMessages () {
- // Assert on condition
- assert($this->ifMultipleMessagesPending());
- assert($this->isPendingDataEmpty());
+ // Validate conditions
+ if (!$this->ifMultipleMessagesPending()) {
+ // Opps?
+ throw new BadMethodCallException('No multiple messages are pending but method called');
+ } elseif (!$this->isPendingDataEmpty()) {
+ // Pending data is not empty but invoked
+ throw new BadMethodCallException(sprintf('this->pendingData()=%d still filled but method called', strlen($this->pendingData)));
+ }
// "Pop" next entry from stack and set it as new pending data
$this->pendingData = $this->getStackInstance()->popNamed(self::STACKER_NAME_MULTIPLE_MESSAGE);
// Add the chunk to the propper array and do all the stuff there
$this->addChunkData($finalHash, $chunkData);
- } // END - for
+ }
// Debug output
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).');
// Then initialize it
$this->chunks[$finalHash] = [];
$this->chunkHashes[$finalHash] = [];
- } // END - if
+ }
// Add both
array_push($this->chunks[$finalHash] , $rawData);
if (!$this->getPoolEntriesInstance()->isGroupSet($group)) {
// Create the missing pool group
$this->getPoolEntriesInstance()->addGroup($group);
- } // END - if
+ }
// Add it to given pool group
$this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance);
// Rewind it
$iteratorInstance->rewind();
- } // END - if
+ }
// Get current entry
$poolEntry = $iteratorInstance->current();
// At last re-init the stack
$this->initOutgoingQueue();
- } // END - if
+ }
// Continue with next one
$this->getIteratorInstance()->next();
// Add it as recipient
$listInstance->addEntry('unl', $unlData);
- } // END - foreach
+ }
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DIRECT-RECIPIENT: EXIT!');
if (!empty($unl)) {
// Add it to the list
$listInstance->addEntry('unl', $unl);
- } // END - if
+ }
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SELF-RECIPIENT: EXIT!');
// Then stop adding more
/* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: Going to abort at maximum of ' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('package_recipient_max_count') . ' recipients!');
break;
- } // END - if
+ }
// Debug message
/* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: Adding node ' . print_r($unlData, TRUE) . ' as recipient.');
// Add the entry
$listInstance->addEntry('unl', $unlData);
- } // END - foreach
+ }
// Trace message
/* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UPPER-RECIPIENT: EXIT!');
if (is_null(self::$registryInstance)) {
// Not yet, so create one
self::$registryInstance = new ObjectTypeRegistry();
- } // END - if
+ }
// Return the instance
return self::$registryInstance;
if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
// This command has an invalid instance!
throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- } // END - if
+ }
// Set last controller
$this->setResolvedInstance($controllerInstance);
if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
// This command has an invalid instance!
throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- } // END - if
+ }
// Set last controller
$this->setResolvedInstance($controllerInstance);
case 'internal': // Internal IP
$address = ConsoleTools::acquireSelfIPAddress();
break;
- } // END - switch
- } // END - if
+ }
+ }
// Put all together
$unl = sprintf('%s://%s:%s',
if (!class_exists($this->getClassName())) {
// Throw an exception here
throw new UnresolveableStateException(array($this, $stateName), self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
// Initialize the state
$stateInstance = ObjectFactory::createObjectByName(
if (empty($stateName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($this, 'stateName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } // END - if
+ }
// Create class name
$className = $this->statePrefix . StringUtils::convertToClassName($stateName) . 'State';
// All is tried, give it up here
throw new DefaultStateException($this, self::EXCEPTION_DEFAULT_STATE_GONE);
}
- } // END - while
+ }
// Return the result
return $isValid;
if (!$socketInstance->isValidSocket()) {
// Then abort here with an exception (may happen after socket_shutdown())
throw new InvalidSocketException(array($helperInstance, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
- } // END - if
- } // END - if
+ }
+ }
// Translate the error code to an own name
$errorName = $socketInstance->translateLastSocketErrorCodeToName();
// Rewind to start
$this->getDirectoryInstance()->getDirectoryIteratorInstance()->rewind();
- } // END - if
+ }
// Read next entry
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: this->csvFileImported=' . print_r($this->csvFileImported, TRUE));
// Skip further processing
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-UPLOADED-LIST-URL-SOURCE: directoryEntry(' . strlen($directoryEntry) . ')=' . $directoryEntry . ' - SKIPPED!');
return FALSE;
- } // END - if
+ }
// Init SPL file instance
$infoInstance = new SplFileInfo($this->csvFilePath . '/' . $directoryEntry);
// This file as been fully read, so don't push it back on stack.
return;
- } // END - if
+ }
// ... with a fixed amount of elements, later enhancements may accept more
assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
if (!$this instanceof CommunicatorActiveState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if (!$this instanceof CrawlerActiveState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
}
if (!$this instanceof CruncherActiveState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if ((!$this instanceof DhtVirginState) && (!$this instanceof DhtInitState)) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if (isset($this->bootedProducer[$executorInstance->__toString()])) {
// Then silently skip this
return;
- } // END - if
+ }
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MINER-STATE: Calling prepareBlockProduction() on ' . $executorInstance->__toString() . ' ...');
if (!$this instanceof MinerActiveState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if (!$this instanceof MinerInitState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if (!$this instanceof MinerBootingState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if (!$this instanceof NodeActiveState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeAnnouncingState)) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeReachableState)) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
if (!$this instanceof NodeAnnouncementCompletedState) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
}
if (!$this->isPeerStateConnected()) {
// Throw the exception
throw new UnexpectedStateException($this, self::EXCEPTION_INVALID_STATE);
- } // END - if
+ }
}
/**
use Org\Mxchange\CoreFramework\Stream\BaseStream;
use Org\Mxchange\CoreFramework\Stream\Input\InputStream;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A class for handling incoming (encoded) raw data with start and end markers.
* The "stream" is being verified by its length (if modulo 4 of it is always
* @param $data The data (string mostly) to "stream"
* @return $data The data (string mostly) to "stream"
* @todo Do we need to do something more here?
+ * @throws InvalidArgumentException If $data is empty or does not contain start/end marker
* @throws Base64EncodingModuloException If the data's length modulo 4 is not zero
* @throws Base64EncodingBadException If the data contains characters which are not in the "alphabet" of BASE64 messages.
* @throws MultipleMessageSentException If the sender has sent two messages and both end up here
*/
public function streamData (string $data) {
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-INPUT-STREAM: data(' . strlen($data) . ')=' . $data . ' - CALLED!');
-
// Do we have start and end marker again?
- assert($this->ifStartEndMarkersSet($data));
-
- // Count of start and end markers must be the same
- assert(substr_count($data, HandleableRawData::STREAM_START_MARKER) == substr_count($data, HandleableRawData::STREAM_END_MARKER));
-
- // Check if more than two start markers exist and if so, split it.
- if (substr_count($data, HandleableRawData::STREAM_START_MARKER) > 1) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-INPUT-STREAM: data(%d)=%s - CALLED!', strlen($data), $data));
+ if (empty($data)) {
+ // Throw exception
+ throw new InvalidArgumentException('Parameter "data" is empty');
+ } elseif (!$this->ifStartEndMarkersSet($data)) {
+ // No start/end marker set
+ throw new InvalidArgumentException(sprintf('data=%s has no start/end marker set', $data));
+ } elseif (substr_count($data, HandleableRawData::STREAM_START_MARKER) !== substr_count($data, HandleableRawData::STREAM_END_MARKER)) {
+ // Start/end marker count not matching
+ throw new InvalidArgumentException(sprintf('data=%s has different count of start/end markers set', $data));
+ } elseif (substr_count($data, HandleableRawData::STREAM_START_MARKER) > 1) {
// Please do it outside this method
throw new MultipleMessageSentException(array($this, $data), BaseHubSystem::EXCEPTION_MULTIPLE_MESSAGE_SENT);
- } // END - if
+ }
// Remove both
$data = substr($data, strlen(HandleableRawData::STREAM_START_MARKER), -1 * strlen(HandleableRawData::STREAM_END_MARKER));
$data = base64_decode($data);
}
- // Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-INPUT-STREAM: Length of data is now ' . strlen($data) . ' Bytes.');
-
// Return it
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-INPUT-STREAM: data(%d)=%s - EXIT!', strlen($data), $data));
return $data;
}
if ((!is_array($entry)) || (count($entry) == 0) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL])) || (!isset($entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE]))) {
// Invalid entry found
throw new InvalidTagException(array($this, $tag), self::EXCEPTION_INVALID_TAG);
- } // END - if
+ }
// Now save the last discovered protocol/recipient type
$this->lastProtocol = ProtocolHandlerFactory::createProtocolHandlerFromPackageInstance($packageInstance);
$this->lastRecipientType = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE];
- } // END - foreach
+ }
// Trace message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-TAGS: EXIT!');
// And re-get it
$sourceInstance = $this->getUrlSourceInstance();
- } // END - if
+ }
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance));
// And re-get it
$sourceInstance = $this->getUrlSourceInstance();
- } // END - if
+ }
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance));
// And re-get it
$sourceInstance = $this->getUrlSourceInstance();
- } // END - if
+ }
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance));
// And re-get it
$sourceInstance = $this->getUrlSourceInstance();
- } // END - if
+ }
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CRAWLER-URL-SOURCE-UPLOADED-LIST-TASK: sourceInstance[]=' . gettype($sourceInstance));
if (($dhtInstance->hasFullyBootstrapped()) && ($dhtInstance->hasUnpublishedEntries())) {
// Then initiate publishing them
$dhtInstance->initEntryPublication();
- } // END - if
+ }
}
/**
if ($dhtInstance->hasEntriesPendingPublication()) {
// Then publish next entry
$dhtInstance->publishEntry();
- } // END - if
+ }
}
/**
if ($dhtInstance->ifInsertNodeDataPending()) {
// Then insert a single entry
$dhtInstance->insertSingleNodeData();
- } // END - if
+ }
}
/**
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
/*
* Assign the found characters to variable and use the last entry from
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
/*
* Assign the found characters to variable and use the last entry from
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
/*
* Assign the found characters to variable and use the last entry from
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
/*
* Assign the found characters to variable and use the last entry from
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
/*
* Assign the found characters to variable and use the last entry from
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
/*
* Assign the found characters to variable and use the last entry from
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
// Assign data with matching variable here
parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_entry'), $characters);
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
// Get current XML node name as an array index
$nodeName = $this->getStackInstance()->getNamed('node_object_registry');
if ($nodeName == self::OBJECT_TYPE_DATA_NAME) {
// Output debug message
/* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: Adding object type ' . $characters . ' to registry.');
- } // END - if
+ }
// Add it to the registry
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('XML-OBJECT-REGISTRY-TEMPLATE-ENGINE: EXIT!');
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
// Assign the found characters to variable and use the last entry from
// stack as the name
if (empty($characters)) {
// Then skip it silently
return;
- } // END - if
+ }
// Assign data with matching variable here
parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list'), $characters);
if (is_null(self::$selfInstance)) {
// Then set it
self::$selfInstance = new HubTools();
- } // END - if
+ }
// Return own instance
return self::$selfInstance;
if ($nodeInstance->getSessionId() == $sessionId) {
// Then get an instance of a LocateableNode class from it, assume TCP by default
$recipientUnl = self::determineOwnExternalAddress() . ':' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_listen_port');
- } // END - if
+ }
}
// Return result
// Make sure it is valid
// @TODO Find a better validation than empty()
assert(!empty($GLOBALS[__METHOD__]));
- } // END - if
+ }
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
// Make sure it is valid
// @TODO Find a better validation than empty()
assert(!empty($GLOBALS[__METHOD__]));
- } // END - if
+ }
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!');
// Convert arguments type into human-readable
foreach ($traceArray['args'] as $arg) {
$argsString .= ', ' . gettype($arg);
- } // END - foreach
+ }
$argsString = substr($argsString, 2);
}
basename($traceArray['file']),
$traceArray['line']
);
- } // END - foreach
+ }
// Construct the message
$message = sprintf("--------------------------------------------------------------------------------
// Throw an exception here
throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR);
-} // END - function
+}
// Assertion handler
function hub_assert_handler ($file, $line, $code) {
// Empty code?
if ($code === '') {
$code = '<em>Unknown</em>';
- } // END - if
+ }
// Create message
$message = sprintf('File: %s, Line: %s, Code: %s',
// Throw an exception here
throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED);
-} // END - function
+}
// Set error handler
//set_error_handler('hub_error_handler');
if (!is_int($hash)) {
$timers[str_replace('MHASH_', '', $hash)] = '- unavailable -';
continue;
- } // END - if
+ }
$time = microtime(true);
for ($idx = 0; $idx <= $count; $idx++) {
$dummy = bin2hex(mhash($hash, 'mhash-test-abc-123-foo-bar'));
- } // END - for
+ }
$timers[mhash_get_hash_name($hash)] = (microtime(true) - $time);
print '.';
-} // END - foreach
+}
print "\r\n\r\n";
asort($timers);
if ($read == 'BYE') {
// Okay
$replied = true;
- } // END - if
- } // END - if
+ }
+ }
// Sleep a little
if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
- } // END - while
+ }
}
$data = array();
if ($failed == constant('MAX_FAILURES')) {
//*DEBUG: */ out(__FILE__, __LINE__, "Too many failures! (failed={$failed})");
break;
- } // END - if
+ }
// Is the peer the same?
if (empty($peer)) {
out(__FILE__, __LINE__, "Invalid packet {$read} received. count=".count($rec));
$invalid++;
continue;
- } // END - if
+ }
$time = trim($rec[0]);
$right = explode('=', trim($rec[1]));
out(__FILE__, __LINE__, "Invalid: ({$time}/{$hash}/{$hasher})");
$invalid++;
continue;
- } // END - if
+ }
if (!isset($data[$rec[0]])) {
if (count($data) > 0) {
// Sleep a little
if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
-} // END - while
+}
array_shift($data);
$min = $cnt;
}
$avg += $cnt;
-} // END - foreach
+}
if (count($data) > 0) {
$avg = round($avg / count($data));
-} // END - if
+}
out(__FILE__, __LINE__, 'MIN/AVG/MAX=' . $min . '/' . $avg . '/' . $max . '');
out(__FILE__, __LINE__, 'INVALID=' . $invalid . '');
-Subproject commit ac256a664aa490665d37705439807ab6d62a7e3a
+Subproject commit a0f090cd1474ae446e0a480e22738cfa7b48412f