From 6c9f7d411356871244a6a95b9b4742e116e14f57 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 21 Nov 2011 19:52:45 +0000 Subject: [PATCH] Hub project continued: - Added a telnet listener for the 'chat' console - Some minor cleanups/improvements --- .gitattributes | 3 + application/hub/config.php | 12 ++++ ...class_ChatTaskHandlerInitializerFilter.php | 12 ++-- ...class_NodeTaskHandlerInitializerFilter.php | 6 +- .../main/listener/tcp/class_TcpListener.php | 2 +- application/hub/main/pools/class_BasePool.php | 3 +- .../class_ConnectionStatisticsHelper.php | 3 +- application/hub/main/tasks/chat/.htaccess | 1 + application/hub/main/tasks/chat/class_ | 72 +++++++++++++++++++ .../chat/class_ChatTelnetListenerTask.php | 72 +++++++++++++++++++ application/hub/main/tasks/class_ | 8 +-- .../tasks/hub/class_HubSocketListenerTask.php | 1 + .../class_RawDataPoolMonitorVisitor.php | 4 +- .../xml/cruncher/producer/work_unit.xml | 4 +- 14 files changed, 184 insertions(+), 19 deletions(-) create mode 100644 application/hub/main/tasks/chat/.htaccess create mode 100644 application/hub/main/tasks/chat/class_ create mode 100644 application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php diff --git a/.gitattributes b/.gitattributes index 2ccd8ddc2..8108bb226 100644 --- a/.gitattributes +++ b/.gitattributes @@ -500,6 +500,9 @@ application/hub/main/tags/class_BaseTags.php svneol=native#text/plain application/hub/main/tags/package/.htaccess -text svneol=unset#text/plain application/hub/main/tags/package/class_PackageTags.php svneol=native#text/plain application/hub/main/tasks/.htaccess -text svneol=unset#text/plain +application/hub/main/tasks/chat/.htaccess -text svneol=unset#text/plain +application/hub/main/tasks/chat/class_ svneol=native#text/plain +application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php svneol=native#text/plain application/hub/main/tasks/class_ svneol=native#text/plain application/hub/main/tasks/class_BaseTask.php svneol=native#text/plain application/hub/main/tasks/cruncher/.htaccess svneol=native#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index 6d5263127..ff8e966b4 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -705,6 +705,18 @@ $cfg->setConfigEntry('chat_bootstrap_generic_activation_filter', 'ChatBootstrapG // CFG: CHAT-SHUTDOWN-FILTER $cfg->setConfigEntry('chat_shutdown_filter', 'ChatShutdownFilter'); +// CFG: CHAT-TELNET-LISTENER-TASK-CLASS +$cfg->setConfigEntry('chat_telnet_listener_task_class', 'ChatTelnetListenerTask'); + +// CFG: TASK-CHAT-TELNET-LISTENER-STARTUP-DELAY +$cfg->setConfigEntry('task_chat_telnet_listener_startup_delay', 2500); + +// CFG: TASK-CHAT-TELNET-LISTENER-INTERVAL-DELAY +$cfg->setConfigEntry('task_chat_telnet_listener_interval_delay', 10); + +// CFG: TASK-CHAT-TELNET-LISTENER-MAX-RUNS +$cfg->setConfigEntry('task_chat_telnet_listener_max_runs', 0); + /////////////////////////////////////////////////////////////////////////////// // HTTP Configuration /////////////////////////////////////////////////////////////////////////////// diff --git a/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php index 5d984d75c..e386bb470 100644 --- a/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php @@ -61,11 +61,13 @@ class ChatTaskHandlerInitializerFilter extends BaseFilter implements Filterable // Get a new task handler instance $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - // Register all tasks: - // - // 1) A task for fetching WUs (work units) or test units - //$taskInstance = ObjectFactory::createObjectByConfiguredName('chat_work_unit_fetcher_task_class'); - //$handlerInstance->registerTask('chat_work_unit_fetcher', $taskInstance); + /* + * Register all tasks: + * + * 1) Telnet session listener + */ + $taskInstance = ObjectFactory::createObjectByConfiguredName('chat_telnet_listener_task_class'); + $handlerInstance->registerTask('chat_telnet_listener', $taskInstance); // Put the task handler in registry Registry::getRegistry()->addInstance('task', $handlerInstance); diff --git a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php index 34dff9338..620135ba8 100644 --- a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php @@ -58,9 +58,6 @@ class NodeTaskHandlerInitializerFilter extends BaseFilter implements Filterable // Get node instance $nodeInstance = Registry::getRegistry()->getInstance('node'); - // Get the list instance here - $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); - // Get a new task handler instance $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); @@ -100,6 +97,9 @@ class NodeTaskHandlerInitializerFilter extends BaseFilter implements Filterable // Register it $handlerInstance->registerTask('update_check', $taskInstance); + // Get the list instance here + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); + // Prepare a ping task $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_ping_task_class', array($listInstance)); diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php index a1f87a766..6554016d3 100644 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ b/application/hub/main/listener/tcp/class_TcpListener.php @@ -250,7 +250,7 @@ class TcpListener extends BaseListener implements Listenable { * @return $accepts Wether this listener does accept */ public function ifListenerAcceptsPackageData (array $packageData) { - $this->partialStub('This call should not happen. Please report it.'); + $this->debugBackTrace('This call should not happen. Please report it.'); } } diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php index 0e58c98ba..648277d4c 100644 --- a/application/hub/main/pools/class_BasePool.php +++ b/application/hub/main/pools/class_BasePool.php @@ -115,10 +115,11 @@ class BasePool extends BaseHubSystem implements Visitable { // Is this entry visitable? if ($poolEntry instanceof Visitable) { // Visit this entry as well + //* NOISY-DEBUG: */ $this->debugOutput('BASE-POOL: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...'); $poolEntry->accept($visitorInstance); } else { // Cannot visit this entry - $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . '.'); + $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.'); } // Advance to next entry diff --git a/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php b/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php index f125081ed..8ff6d0225 100644 --- a/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php +++ b/application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php @@ -30,11 +30,12 @@ class ConnectionStatisticsHelper extends BaseHubSystem { private static $connectionStatistics = array( // Statistics for TCP connections 'tcp' => array( - // Tried connection attempts + // Tried TCP connection attempts 'retry_count' => array(), ), // Statistics for UDP connections 'udp' => array( + // Tried UDP connection attempts 'retry_count' => array(), ) ); diff --git a/application/hub/main/tasks/chat/.htaccess b/application/hub/main/tasks/chat/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/tasks/chat/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/tasks/chat/class_ b/application/hub/main/tasks/chat/class_ new file mode 100644 index 000000000..2501e2249 --- /dev/null +++ b/application/hub/main/tasks/chat/class_ @@ -0,0 +1,72 @@ + + * @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 . + */ +class Chat???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 createChat???Task () { + // Get new instance + $taskInstance = new Chat???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] +?> diff --git a/application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php b/application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php new file mode 100644 index 000000000..c245f506f --- /dev/null +++ b/application/hub/main/tasks/chat/class_ChatTelnetListenerTask.php @@ -0,0 +1,72 @@ + + * @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 . + */ +class ChatTelnetListenerTask 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 createChatTelnetListenerTask () { + // Get new instance + $taskInstance = new ChatTelnetListenerTask(); + + // 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] +?> diff --git a/application/hub/main/tasks/class_ b/application/hub/main/tasks/class_ index ca9549023..a5936c9a2 100644 --- a/application/hub/main/tasks/class_ +++ b/application/hub/main/tasks/class_ @@ -1,6 +1,6 @@ * @version 0.0.0 @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Cruncher???Task extends BaseTask implements Taskable, Visitable { +class !!!???Task extends BaseTask implements Taskable, Visitable { /** * Protected constructor * @@ -37,9 +37,9 @@ class Cruncher???Task extends BaseTask implements Taskable, Visitable { * * @return $taskInstance An instance of a Visitable class */ - public final static function createCruncher???Task () { + public final static function create!!!???Task () { // Get new instance - $taskInstance = new Cruncher???Task(); + $taskInstance = new !!!???Task(); // Return the prepared instance return $taskInstance; diff --git a/application/hub/main/tasks/hub/class_HubSocketListenerTask.php b/application/hub/main/tasks/hub/class_HubSocketListenerTask.php index 139a2b4b2..9eff3b15f 100644 --- a/application/hub/main/tasks/hub/class_HubSocketListenerTask.php +++ b/application/hub/main/tasks/hub/class_HubSocketListenerTask.php @@ -56,6 +56,7 @@ class HubSocketListenerTask extends BaseTask implements Taskable, Visitable { $nodeInstance = Registry::getRegistry()->getInstance('node'); // Visit the pool listener task + //* NOISY-DEBUG: */ $this->debugOutput('LISTENER-TASK: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...'); $nodeInstance->getListenerPoolInstance()->accept($visitorInstance); // Visit this task diff --git a/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php b/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php index 51eccab2e..45228dcc6 100644 --- a/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php +++ b/application/hub/main/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php @@ -84,9 +84,9 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List */ public function visitDecorator (BaseDecorator $decoratorInstance) { // Do monitor here - //* DEBUG: */ $this->debugOutput('VISITOR: Visiting ' . $listenerInstance->__toString() . ' - START'); + //* NOISY-DEBUG: */ $this->debugOutput('VISITOR: Visiting ' . $listenerInstance->__toString() . ' - START'); $decoratorInstance->monitorIncomingRawData($this->getReceiverInstance()); - //* DEBUG: */ $this->debugOutput('VISITOR: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); + //* NOISY-DEBUG: */ $this->debugOutput('VISITOR: Visiting ' . $listenerInstance->__toString() . ' - FINISH'); } } diff --git a/application/hub/templates/xml/cruncher/producer/work_unit.xml b/application/hub/templates/xml/cruncher/producer/work_unit.xml index 956095913..ed80f189b 100644 --- a/application/hub/templates/xml/cruncher/producer/work_unit.xml +++ b/application/hub/templates/xml/cruncher/producer/work_unit.xml @@ -42,10 +42,10 @@ along with this program. If not, see {?cipher_name?} - {?test_unit_created + {?work_unit_created -- 2.39.5