From 6910fd7abeeeefc3c45d85ef0f25b55be35df746 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 29 Jul 2013 00:08:03 +0000 Subject: [PATCH] Added more required filters (some not implemented) and config entries --- .gitattributes | 9 ++ application/lfdb2/config.php | 23 +++ ...lass_ServerBootstrapListenerPoolFilter.php | 66 ++++++++ .../lfdb2/main/filter/shutdown/.htaccess | 1 + .../main/filter/shutdown/server/.htaccess | 1 + .../shutdown/server/class_ServerShutdown | 67 +++++++++ .../class_ServerShutdownServerFilter.php | 68 +++++++++ .../class_ServerShutdownTaskHandlerFilter.php | 67 +++++++++ application/lfdb2/main/filter/task/.htaccess | 1 + .../lfdb2/main/filter/task/server/.htaccess | 1 + ...ass_ServerTaskHandlerInitializerFilter.php | 142 ++++++++++++++++++ 11 files changed, 446 insertions(+) create mode 100644 application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php create mode 100644 application/lfdb2/main/filter/shutdown/.htaccess create mode 100644 application/lfdb2/main/filter/shutdown/server/.htaccess create mode 100644 application/lfdb2/main/filter/shutdown/server/class_ServerShutdown create mode 100644 application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php create mode 100644 application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php create mode 100644 application/lfdb2/main/filter/task/.htaccess create mode 100644 application/lfdb2/main/filter/task/server/.htaccess create mode 100644 application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php diff --git a/.gitattributes b/.gitattributes index eff759d..107b06f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -24,6 +24,7 @@ application/lfdb2/main/filter/bootstrap/.htaccess -text application/lfdb2/main/filter/bootstrap/server/.htaccess -text application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrap -text application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapExtraBootstrappingFilter.php -text +application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php -text application/lfdb2/main/filter/class_BaseLfdb2Filter.php -text application/lfdb2/main/filter/class_BaseServerFilter.php -text application/lfdb2/main/filter/server/.htaccess -text @@ -31,6 +32,14 @@ application/lfdb2/main/filter/server/class_Server -text application/lfdb2/main/filter/server/class_ServerInitializationFilter.php -text application/lfdb2/main/filter/server/class_ServerPhpRequirementsFilter.php -text application/lfdb2/main/filter/server/class_ServerWelcomeTeaserFilter.php -text +application/lfdb2/main/filter/shutdown/.htaccess -text +application/lfdb2/main/filter/shutdown/server/.htaccess -text +application/lfdb2/main/filter/shutdown/server/class_ServerShutdown -text +application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php -text +application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php -text +application/lfdb2/main/filter/task/.htaccess -text +application/lfdb2/main/filter/task/server/.htaccess -text +application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php -text application/lfdb2/main/resolver/.htaccess -text application/lfdb2/main/resolver/command/.htaccess -text application/lfdb2/main/resolver/command/console/.htaccess -text diff --git a/application/lfdb2/config.php b/application/lfdb2/config.php index af94b70..9457509 100644 --- a/application/lfdb2/config.php +++ b/application/lfdb2/config.php @@ -45,6 +45,12 @@ $cfg->setConfigEntry('news_download_filter', 'NewsDownloadFilter'); // CFG: NEWS-PROCESS-FILTER $cfg->setConfigEntry('news_process_filter', 'NewsProcessFilter'); +// CFG: NEWS-READER-CLASS +$cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader'); + +// CFG: NEWS-SERVER-LIMIT +$cfg->setConfigEntry('news_server_limit', 5); + // CFG: SERVER-PHP-REQUIREMENTS-FILTER $cfg->setConfigEntry('node_php_requirements_filter', 'NodePhpRequirementsFilter'); @@ -60,8 +66,25 @@ $cfg->setConfigEntry('server_php_requirements_filter', 'ServerPhpRequirementsFil // CFG: SERVER-WELCOME-TEASER-FILTER $cfg->setConfigEntry('server_welcome_teaser_filter', 'ServerWelcomeTeaserFilter'); +// ---------------------------------------------------------------------------- +// Bootstrapping filters +// ---------------------------------------------------------------------------- + // CFG: SERVER-BOOTSTRAP-EXTRA-BOOTSTRAPPING-FILTER $cfg->setConfigEntry('server_bootstrap_extra_bootstrapping_filter', 'ServerBootstrapExtraBootstrappingFilter'); +// CFG: SERVER-BOOTSTRAP-LISTENER-POOL-FILTER +$cfg->setConfigEntry('server_bootstrap_listener_pool_filter', 'ServerBootstrapListenerPoolFilter'); + +// ---------------------------------------------------------------------------- +// Shutdown filters +// ---------------------------------------------------------------------------- + +// CFG: SERVER-SHUTDOWN-TASK-HANDLER-FILTER +$cfg->setConfigEntry('server_shutdown_task_handler_filter', 'ServerShutdownTaskHandlerFilter'); + +// CFG: SERVER-SHUTDOWN-SERVER-FILTER +$cfg->setConfigEntry('server_shutdown_server_filter', 'ServerShutdownServerFilter'); + // [EOF] ?> diff --git a/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php b/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php new file mode 100644 index 0000000..5a29b9b --- /dev/null +++ b/application/lfdb2/main/filter/bootstrap/server/class_ServerBootstrapListenerPoolFilter.php @@ -0,0 +1,66 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 ServerBootstrapListenerPoolFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerBootstrapListenerPoolFilter () { + // Get a new instance + $filterInstance = new ServerBootstrapListenerPoolFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $serverInstance is null (no NullPointerException here) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Now do something + $serverInstance->initializeListenerPool(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/main/filter/shutdown/.htaccess b/application/lfdb2/main/filter/shutdown/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/main/filter/shutdown/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/main/filter/shutdown/server/.htaccess b/application/lfdb2/main/filter/shutdown/server/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/main/filter/shutdown/server/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdown b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdown new file mode 100644 index 0000000..4822e38 --- /dev/null +++ b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdown @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 ServerShutdown???Filter extends BaseNodeFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public final static function createServerShutdown???Filter () { + // Get a new instance + $filterInstance = new ServerShutdown???Filter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $serverInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Now do something + $this->partialStub('Please implement this step.'); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php new file mode 100644 index 0000000..abf49a3 --- /dev/null +++ b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownServerFilter.php @@ -0,0 +1,68 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 ServerShutdownServerFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerShutdownServerFilter () { + // Get a new instance + $filterInstance = new ServerShutdownServerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $serverInstance is null (no NullPointerException please) + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Shutdown the server. This should be the last line + $serverInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php new file mode 100644 index 0000000..cec2502 --- /dev/null +++ b/application/lfdb2/main/filter/shutdown/server/class_ServerShutdownTaskHandlerFilter.php @@ -0,0 +1,67 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 ServerShutdownTaskHandlerFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerShutdownTaskHandlerFilter () { + // Get a new instance + $filterInstance = new ServerShutdownTaskHandlerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If $nodeInstance is null (no NullPointerException here) + * @todo 0% done + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Get task handler instance + $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); + + // Shutdown the task manager and all its registered tasks + $handlerInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/application/lfdb2/main/filter/task/.htaccess b/application/lfdb2/main/filter/task/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/main/filter/task/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/main/filter/task/server/.htaccess b/application/lfdb2/main/filter/task/server/.htaccess new file mode 100644 index 0000000..3a42882 --- /dev/null +++ b/application/lfdb2/main/filter/task/server/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php b/application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php new file mode 100644 index 0000000..757bd83 --- /dev/null +++ b/application/lfdb2/main/filter/task/server/class_ServerTaskHandlerInitializerFilter.php @@ -0,0 +1,142 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2013 LFDB2 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 ServerTaskHandlerInitializerFilter extends BaseServerFilter implements Filterable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this filter class + * + * @return $filterInstance An instance of this filter class + */ + public static final function createServerTaskHandlerInitializerFilter () { + // Get a new instance + $filterInstance = new ServerTaskHandlerInitializerFilter(); + + // Return the instance + return $filterInstance; + } + + /** + * Executes the filter with given request and response objects + * + * @param $requestInstance An instance of a class with an Requestable interface + * @param $responseInstance An instance of a class with an Responseable interface + * @return void + * @throws FilterChainException If we need to interrupt the filter chain + * @todo Maybe some more tasks needs to be added? + */ + public function execute (Requestable $requestInstance, Responseable $responseInstance) { + $this->partialStub('Unported.'); + die(); + + // Get server instance + $serverInstance = Registry::getRegistry()->getInstance('server'); + + // Get a new task handler instance + $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); + + // Generate socket listener task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class'); + + // Network package reader, needs to be delayed a little + $handlerInstance->registerTask('socket_listener', $taskInstance); + + // Generate package reader task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class', array($nodeInstance->getListenerPoolInstance())); + + // Network package reader, needs to be delayed a little + $handlerInstance->registerTask('network_package_reader', $taskInstance); + + // Generate package writer task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class'); + + // Register it as well + $handlerInstance->registerTask('network_package_writer', $taskInstance); + + // Generate chunk assembler task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class'); + + // Register it as well + $handlerInstance->registerTask('chunk_assembler', $taskInstance); + + // Generate package decoder task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class'); + + // Register it as well + $handlerInstance->registerTask('package_decoder', $taskInstance); + + // Generate DHT initialization task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_init', $taskInstance); + + // Generate DHT query task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class'); + + // Register it as well + $handlerInstance->registerTask('dht_query', $taskInstance); + + // Prepare a package-tags initialization task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class'); + + // Register it + $handlerInstance->registerTask('package_tags_init', $taskInstance); + + // Prepare a self-test task for the listeners + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class'); + + // Register it + $handlerInstance->registerTask('self_connect', $taskInstance); + + // Prepare a update-check task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class'); + + // Register it + $handlerInstance->registerTask('update_check', $taskInstance); + + // Get the list instance here + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); + + // Prepare a ping task + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance)); + + // Register it + $handlerInstance->registerTask('ping', $taskInstance); + + // Put the task handler in registry + Registry::getRegistry()->addInstance('task_handler', $handlerInstance); + } +} + +// [EOF] +?> -- 2.39.5