application/hub/interfaces/executor/.htaccess svneol=native#text/plain
application/hub/interfaces/executor/class_Executor.php svneol=native#text/plain
application/hub/interfaces/handler/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/handler/chunks/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/handler/chunks/class_HandleableChunks.php svneol=native#text/plain
application/hub/interfaces/handler/class_Handleable.php svneol=native#text/plain
application/hub/interfaces/handler/network/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/handler/network/class_Networkable.php svneol=native#text/plain
application/hub/main/tasks/hub/.htaccess -text svneol=unset#text/plain
application/hub/main/tasks/hub/announcement/.htaccess -text svneol=unset#text/plain
application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php svneol=native#text/plain
+application/hub/main/tasks/hub/chunks/.htaccess -text svneol=unset#text/plain
+application/hub/main/tasks/hub/chunks/class_HubChunkAssemblerTask.php svneol=native#text/plain
+application/hub/main/tasks/hub/class_Hub svneol=native#text/plain
application/hub/main/tasks/hub/class_HubSelfConnectTask.php svneol=native#text/plain
application/hub/main/tasks/hub/ping/.htaccess -text svneol=unset#text/plain
application/hub/main/tasks/hub/ping/class_HubPingTask.php svneol=native#text/plain
// CFG: STACKER-PACKAGE-OUTGOING-MAX-SIZE
$cfg->setConfigEntry('stacker_package_outgoing_max_size', 100);
+// CFG: STACKER-PACKAGE-DECODED-DATA-MAX-SIZE
+$cfg->setConfigEntry('stacker_package_decoded_data_max_size', 200);
+
+// CFG: STACKER-PACKAGE-HANDLED-DECODED-MAX-SIZE
+$cfg->setConfigEntry('stacker_package_handled_decoded_max_size', 200);
+
+// CFG: STACKER-PACKAGE-CHUNKED-DECODED-MAX-SIZE
+$cfg->setConfigEntry('stacker_package_chunked_decoded_max_size', 800);
+
// CFG: STACKER-PACKAGE-BACKBUFFER-MAX-SIZE
$cfg->setConfigEntry('stacker_package_backbuffer_max_size', 1000);
// CFG: STACKER-DECODED-DATA-MAX-SIZE
$cfg->setConfigEntry('stacker_decoded_data_max_size', 100);
-// CFG: STACKER-PACKAGE-DECODED-DATA-MAX-SIZE
-$cfg->setConfigEntry('stacker_package_decoded_data_max_size', 200);
-
-// CFG: STACKER-PACKAGE-HANDLED-DECODED-MAX-SIZE
-$cfg->setConfigEntry('stacker_package_handled_decoded_max_size', 200);
-
// CFG: STACKER-FINAL-CHUNKS-MAX-SIZE
$cfg->setConfigEntry('stacker_final_chunks_max_size', 100);
// CFG: HUB-SOCKET-LISTENER-TASK-CLASS
$cfg->setConfigEntry('hub_socket_listener_task_class', 'HubSocketListenerTask');
+// CFG: HUB-CHUNK-ASSEMBLER-TASK-CLASS
+$cfg->setConfigEntry('hub_chunk_assembler_task_class', 'HubChunkAssemblerTask');
+
// CFG: TASK-NETWORK-PACKAGE-WRITER-STARTUP-DELAY
$cfg->setConfigEntry('task_network_package_writer_startup_delay', 2500);
// CFG: TASK-SOCKET-LISTENER-MAX-RUNS
$cfg->setConfigEntry('task_socket_listener_max_runs', 0);
+// CFG: TASK-CHUNK-ASSEMBLER-STATUP-DELAY
+$cfg->setConfigEntry('task_chunk_assembler_startup_delay', 1500);
+
+// CFG: TASK-CHUNK-ASSEMBLER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_chunk_assembler_interval_delay', 10);
+
+// CFG: TASK-CHUNK-ASSEMBLER-MAX-RUNS
+$cfg->setConfigEntry('task_chunk_assembler_max_runs', 0);
+
// CFG: TASK-LIST-CLASS
$cfg->setConfigEntry('task_list_class', 'TaskList');
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * Handleable chunks interface
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface HandleableChunks extends Handleable {
+ /**
+ * Adds all chunks if the last one verifies as a 'final chunk'.
+ *
+ * @param $chunks An array with chunks, the last one should be a 'final'
+ * @return void
+ * @throws FinalChunkVerificationException If the final chunk does not start with 'EOP:'
+ */
+ function addAllChunksWithFinal (array $chunks);
+}
+
+// [EOF]
+?>
/**
* Setter for network package handler instance
*
- * @param $packageInstance The network package handler instance we shall set
+ * @param $packageInstance The network package instance we shall set
* @return void
*/
- protected final function setPackageInstance (Networkable $packageInstance) {
+ protected final function setPackageInstance (Deliverable $packageInstance) {
$this->packageInstance = $packageInstance;
}
// Register it as well
$handlerInstance->registerTask('network_package_writer', $taskInstance);
+ // Generate chunk assembler task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_chunk_assembler_task_class');
+
+ // Register it as well
+ $handlerInstance->registerTask('chunk_assembler', $taskInstance);
+
// Query handler instance
$handlerInstance->registerTask('query_handler', $nodeInstance->getQueryConnectorInstance());
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class ChunkHandler extends BaseHandler implements Registerable {
+class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable {
/**
* Stacker for chunks with final EOP
*/
// Set handler name
$this->setHandlerName('chunk');
-
- // Get a FIFO stacker
- $stackerInstance = ObjectFactory::createObjectByConfiguredName('chunk_handler_stacker_class');
-
- // Init all stacker
- $stackerInstance->initStacker(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP);
-
- // Set the stacker in this handler
- $this->setStackerInstance($stackerInstance);
}
/**
// Get new instance
$handlerInstance = new ChunkHandler();
+ // Get a FIFO stacker
+ $stackerInstance = ObjectFactory::createObjectByConfiguredName('chunk_handler_stacker_class');
+
+ // Init all stacker
+ $stackerInstance->initStacker(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP);
+
+ // Set the stacker in this handler
+ $handlerInstance->setStackerInstance($stackerInstance);
+
// Return the prepared instance
return $handlerInstance;
}
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, $chunk);
} // END - foreach
}
+
+ /**
+ * Checks whether unhandled chunks are available
+ *
+ * @return $unhandledChunks Whether unhandled chunks are left
+ */
+ public function ifUnhandledChunksAvailable () {
+ // Simply check if the stacker is not empty
+ $unhandledChunks = $this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP) === false;
+
+ // Return result
+ return $unhandledChunks;
+ }
}
// [EOF]
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class ???Handler extends BaseHandler {
+class ???Handler extends BaseHandler implements Handleable {
/**
* Protected constructor
*
*/
const STACKER_NAME_DECODED_HANDLED = 'package_handled_decoded';
+ /**
+ * Stacker name for "chunked" decoded raw data
+ */
+ const STACKER_NAME_DECODED_CHUNKED = 'package_chunked_decoded';
+
/**
* Stacker name for "back-buffered" packages
*/
/**
* Initialize all stackers
*
+ * @param $forceReInit Whether to force reinitialization of all stacks
* @return void
*/
- protected function initStackers () {
+ protected function initStackers ($forceReInit = false) {
// Initialize all
foreach (
array(
self::STACKER_NAME_OUTGOING,
self::STACKER_NAME_DECODED_INCOMING,
self::STACKER_NAME_DECODED_HANDLED,
+ self::STACKER_NAME_DECODED_CHUNKED,
self::STACKER_NAME_BACK_BUFFER
) as $stackerName) {
// Init this stacker
- $this->getStackerInstance()->initStacker($stackerName);
+ $this->getStackerInstance()->initStacker($stackerName, $forceReInit);
} // END - foreach
}
// Get current package content (an array with two elements; see handleIncomingDecodedData() for details)
$packageContent = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED);
- // Get a package assembler instance from factory
+ // Get a singleton package assembler instance from factory
$assemblerInstance = PackageAssemblerFactory::createAssemblerInstance();
// Start assembling the raw package data array by chunking it
$assemblerInstance->chunkPackageContent($packageContent);
- die(__METHOD__.': BACK!' . chr(10));
+
+ // Remove the package from 'handled_decoded' stack ...
+ $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED);
+
+ // ... and push it on the 'chunked' stacker
+ $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent);
}
/**
* @return void
*/
public function clearAllStacker () {
- // Do the cleanup (no flushing)
- foreach (
- array(
- self::STACKER_NAME_UNDECLARED,
- self::STACKER_NAME_DECLARED,
- self::STACKER_NAME_OUTGOING,
- self::STACKER_NAME_DECODED_INCOMING,
- self::STACKER_NAME_DECODED_HANDLED,
- self::STACKER_NAME_BACK_BUFFER
- ) as $stackerName) {
- // Clear this stacker by forcing an init
- $this->getStackerInstance()->initStacker($stackerName, true);
- } // END - foreach
+ // Call the init method to force re-initialization
+ $this->initStackers(true);
// Debug message
/* DEBUG: */ $this->debugOutput('PACKAGE: All stacker have been re-initialized.');
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ChunkAssembler hub-task
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class HubChunkAssemblerTask extends BaseTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createHubChunkAssemblerTask () {
+ // Get new instance
+ $taskInstance = new HubChunkAssemblerTask();
+
+ // Get a chunk handler instance
+ $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
+
+ // And add it to this task instance
+ $taskInstance->setHandlerInstance($handlerInstance);
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visit "request"
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Also visit some sub-objects?
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ */
+ public function executeTask () {
+ // Are there chunks to handle?
+ if ($this->getHandlerInstance()->ifUnhandledChunksAvailable()) {
+ // Then handle them (not all!)
+ $this->getHandlerInstance()->handleAvailableChunks();
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ??? hub-task
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Hub???Task extends BaseTask implements Taskable, Visitable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $taskInstance An instance of a Visitable class
+ */
+ public final static function createHub???Task () {
+ // Get new instance
+ $taskInstance = new Hub???Task();
+
+ // Return the prepared instance
+ return $taskInstance;
+ }
+
+ /**
+ * Accepts the visitor to process the visit "request"
+ *
+ * @param $visitorInstance An instance of a Visitor class
+ * @return void
+ * @todo Maybe visit some sub-objects
+ */
+ public function accept (Visitor $visitorInstance) {
+ // Visit this task
+ $visitorInstance->visitTask($this);
+ }
+
+ /**
+ * Executes the task
+ *
+ * @return void
+ * @todo 0%
+ */
+ public function executeTask () {
+ $this->partialStub('Unimplemented task.');
+ }
+}
+
+// [EOF]
+?>
*
* @param $visitorInstance An instance of a Visitor class
* @return void
+ * @todo Also visit some sub-objects?
*/
public function accept (Visitor $visitorInstance) {
// Visit this task
// Set the listener instance here
$taskInstance->setListenerPoolInstance($poolInstance);
+ // Get a singleton network package instance
+ $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
+
+ // And set it in this task
+ $taskInstance->setPackageInstance($packageInstance);
+
// Return the prepared instance
return $taskInstance;
}
*
* @param $visitorInstance An instance of a Visitor class
* @return void
+ * @todo Also visit some sub-objects?
*/
public function accept (Visitor $visitorInstance) {
// Visit this task
* @return void
*/
public function executeTask () {
- // Get a singleton network package instance
- $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
-
// Do we have something to handle?
- if ($packageInstance->isNewRawDataPending($this->getListenerPoolInstance())) {
+ if ($this->getPackageInstance()->isNewRawDataPending($this->getListenerPoolInstance())) {
// We have to handle raw data from the socket
- $packageInstance->handleIncomingDecodedData();
- } elseif ($packageInstance->isIncomingDecodedDataHandled()) {
+ $this->getPackageInstance()->handleIncomingDecodedData();
+ } elseif ($this->getPackageInstance()->isIncomingDecodedDataHandled()) {
/*
* We have handled decoded data so we should validate it, if we have
* all chunks/fragments together, and assemble it into an abstract
* network package.
*/
- $packageInstance->assembleDecodedDataToPackage();
- } elseif ($packageInstance->isNewPackageArrived()) {
+ $this->getPackageInstance()->assembleDecodedDataToPackage();
+ } elseif ($this->getPackageInstance()->isNewPackageArrived()) {
// Okay, then handle newly arrived package
- $packageInstance->handleNewlyArrivedPackage();
+ $this->getPackageInstance()->handleNewlyArrivedPackage();
} // END - if
}
}
// Get new instance
$taskInstance = new NetworkPackageWriterTask();
+ // Get a singleton network package instance
+ $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
+
+ // And set it in this task
+ $taskInstance->setPackageInstance($packageInstance);
+
// Return the prepared instance
return $taskInstance;
}
*
* @param $visitorInstance An instance of a Visitor class
* @return void
+ * @todo Also visit some sub-objects?
*/
public function accept (Visitor $visitorInstance) {
// Visit this task
* @return void
*/
public function executeTask () {
- // Get a singleton network package instance
- $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
-
// Do we have something to deliver?
- if ($packageInstance->isPackageEnqueued()) {
+ if ($this->getPackageInstance()->isPackageEnqueued()) {
// Okay, then deliver (better discover its recipients) this package
- $packageInstance->declareEnqueuedPackage();
- } elseif ($packageInstance->isPackageDeclared()) {
+ $this->getPackageInstance()->declareEnqueuedPackage();
+ } elseif ($this->getPackageInstance()->isPackageDeclared()) {
// Prepare package for delivery
- $packageInstance->deliverDeclaredPackage();
- } elseif ($packageInstance->isPackageWaitingForDelivery()) {
+ $this->getPackageInstance()->deliverDeclaredPackage();
+ } elseif ($this->getPackageInstance()->isPackageWaitingForDelivery()) {
// Sent it finally out
- $packageInstance->sendWaitingPackage();
+ $this->getPackageInstance()->sendWaitingPackage();
}
}
}
./application/hub/main/nodes/regular/class_HubRegularNode.php:58: * @todo Implement this method
./application/hub/main/nodes/regular/class_HubRegularNode.php:68: * @todo Unfinished method
./application/hub/main/nodes/regular/class_HubRegularNode.php:91: // @TODO Add some filters here
-./application/hub/main/package/class_NetworkPackage.php:218: * @todo $helperInstance is unused
-./application/hub/main/package/class_NetworkPackage.php:222: // @TODO crc32() is very weak, but it needs to be fast
+./application/hub/main/package/class_NetworkPackage.php:225: * @todo $helperInstance is unused
+./application/hub/main/package/class_NetworkPackage.php:229: // @TODO crc32() is very weak, but it needs to be fast
./application/hub/main/package/class_NetworkPackage.php:23: * @todo Needs to add functionality for handling the object's type
-./application/hub/main/package/class_NetworkPackage.php:386: // @TODO We may want to do somthing more here?
-./application/hub/main/package/class_NetworkPackage.php:492: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:518: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:622: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:716: // @TODO Add some content here
-./application/hub/main/package/class_NetworkPackage.php:766: * @todo This may be enchanced for outgoing packages?
+./application/hub/main/package/class_NetworkPackage.php:393: // @TODO We may want to do somthing more here?
+./application/hub/main/package/class_NetworkPackage.php:499: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:525: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:629: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:728: // @TODO Add some content here
+./application/hub/main/package/class_NetworkPackage.php:767: * @todo This may be enchanced for outgoing packages?
./application/hub/main/package/fragmenter/class_PackageFragmenter.php:427: * @todo $helperInstance is unused
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106: // @TODO Do something with it
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:62: * @todo Find something for init phase of this key producer
./application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php:53: * @todo Maybe visit some sub-objects
./application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php:54: * @todo Maybe visit some sub-objects
./application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php:53: * @todo 0%
+./application/hub/main/tasks/hub/chunks/class_HubChunkAssemblerTask.php:59: * @todo Also visit some sub-objects?
./application/hub/main/tasks/hub/class_HubSelfConnectTask.php:53: * @todo 0%
./application/hub/main/tasks/hub/class_HubSocketListenerTask.php:63: // @TODO Do we need to visit this task? $visitorInstance->visitTask($this);
./application/hub/main/tasks/hub/class_HubSocketListenerTask.php:70: * @todo 0% done
-./application/hub/main/tasks/hub/ping/class_HubPingTask.php:73: * @todo 0% done
+./application/hub/main/tasks/hub/ping/class_HubPingTask.php:63: * @todo Also visit some sub-objects?
+./application/hub/main/tasks/hub/ping/class_HubPingTask.php:74: * @todo 0% done
./application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php:53: * @todo 0%
+./application/hub/main/tasks/network/class_NetworkPackageReaderTask.php:63: * @todo Also visit some sub-objects?
+./application/hub/main/tasks/network/class_NetworkPackageWriterTask.php:59: * @todo Also visit some sub-objects?
./application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType()
./application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType()
./application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php:240: * @todo Find something useful with this!