application/hub/interfaces/discovery/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/discovery/class_DiscoverableRecipient.php svneol=native#text/plain
application/hub/interfaces/discovery/class_DiscoverableSocket.php svneol=native#text/plain
+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/class_Handleable.php -text svneol=unset#text/plain
application/hub/interfaces/handler/network/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/pool/peer/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/pool/peer/class_PoolablePeer.php -text svneol=unset#text/plain
application/hub/interfaces/producer/.htaccess svneol=native#text/plain
+application/hub/interfaces/producer/class_ -text
application/hub/interfaces/producer/class_Producer.php svneol=native#text/plain
+application/hub/interfaces/producer/keys/.htaccess svneol=native#text/plain
+application/hub/interfaces/producer/keys/class_KeyProducer.php svneol=native#text/plain
application/hub/interfaces/producer/work_units/.htaccess svneol=native#text/plain
application/hub/interfaces/producer/work_units/class_UnitProducer.php svneol=native#text/plain
application/hub/interfaces/protocol/.htaccess -text svneol=unset#text/plain
application/hub/main/factories/source/units/class_UnitSourceFactory.php svneol=native#text/plain
application/hub/main/factories/states/.htaccess -text svneol=unset#text/plain
application/hub/main/factories/states/class_StateFactory.php -text svneol=unset#text/plain
+application/hub/main/factories/states/cruncher/.htaccess svneol=native#text/plain
+application/hub/main/factories/states/cruncher/class_CruncherStateFactory.php svneol=native#text/plain
+application/hub/main/factories/states/node/.htaccess svneol=native#text/plain
+application/hub/main/factories/states/node/class_NodeStateFactory.php svneol=native#text/plain
application/hub/main/factories/states/peer/.htaccess -text svneol=unset#text/plain
application/hub/main/factories/states/peer/class_PeerStateFactory.php svneol=native#text/plain
application/hub/main/factories/tags/.htaccess -text svneol=unset#text/plain
application/hub/main/producer/class_ -text
application/hub/main/producer/class_BaseProducer.php svneol=native#text/plain
application/hub/main/producer/cruncher/.htaccess svneol=native#text/plain
+application/hub/main/producer/cruncher/class_BaseKeyProducer.php svneol=native#text/plain
application/hub/main/producer/cruncher/class_BaseUnitProducer.php svneol=native#text/plain
+application/hub/main/producer/cruncher/keys/.htaccess svneol=native#text/plain
+application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php svneol=native#text/plain
application/hub/main/producer/cruncher/work_units/.htaccess svneol=native#text/plain
application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php svneol=native#text/plain
application/hub/main/queries/.htaccess -text svneol=unset#text/plain
application/hub/main/states/.htaccess -text svneol=unset#text/plain
application/hub/main/states/class_ -text svneol=unset#text/plain
application/hub/main/states/class_BaseState.php -text svneol=unset#text/plain
+application/hub/main/states/cruncher/.htaccess svneol=native#text/plain
+application/hub/main/states/cruncher/class_ -text
+application/hub/main/states/cruncher/class_BaseCruncherState.php svneol=native#text/plain
+application/hub/main/states/cruncher/init/.htaccess svneol=native#text/plain
+application/hub/main/states/cruncher/init/class_CruncherInitState.php svneol=native#text/plain
+application/hub/main/states/cruncher/virgin/.htaccess svneol=native#text/plain
+application/hub/main/states/cruncher/virgin/class_CruncherVirginState.php svneol=native#text/plain
application/hub/main/states/generic/.htaccess -text svneol=unset#text/plain
application/hub/main/states/hub/.htaccess -text svneol=unset#text/plain
application/hub/main/states/hub/class_BaseHubState.php -text svneol=unset#text/plain
application/hub/main/tasks/class_BaseTask.php -text svneol=unset#text/plain
application/hub/main/tasks/cruncher/.htaccess svneol=native#text/plain
application/hub/main/tasks/cruncher/class_ -text
+application/hub/main/tasks/cruncher/class_CruncherKeyProducerTask.php svneol=native#text/plain
application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php svneol=native#text/plain
application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php svneol=native#text/plain
application/hub/main/tasks/hub/.htaccess -text svneol=unset#text/plain
// CFG: CRUNCHER-BUFFER-STACKER-CLASS
$cfg->setConfigEntry('cruncher_buffer_stacker_class', 'FiFoStacker');
-// CFG: PRODUCER-OUTGOING-WORK-QUEUE
-$cfg->setConfigEntry('producer_outgoing_work_queue', 'FiFoStacker');
+// CFG: PRODUCER-OUTGOING-QUEUE
+$cfg->setConfigEntry('producer_outgoing_queue', 'FiFoStacker');
+
+// CFG: PRODUCER-INCOMING-QUEUE
+$cfg->setConfigEntry('producer_incoming_queue', 'FiFoStacker');
// CFG: STACKER-ANNOUNCEMENT-MAX-SIZE
$cfg->setConfigEntry('stacker_announcement_max_size', 20);
// CFG: STACKER-OBJECT-REGISTRY-MAX-SIZE
$cfg->setConfigEntry('stacker_object_registry_max_size', 100);
-// CFG: STACKER-WORK-QUEUE-MAX-SIZE
-$cfg->setConfigEntry('stacker_work_queue_max_size', 1000);
+// CFG: STACKER-OUTGOING-QUEUE-MAX-SIZE
+$cfg->setConfigEntry('stacker_outgoing_queue_max_size', 1000);
+
+// CFG: STACKER-INCOMING-QUEUE-MAX-SIZE
+$cfg->setConfigEntry('stacker_incoming_queue_max_size', 1000);
// CFG: NEWS-MAIN-LIMIT
$cfg->setConfigEntry('news_main_limit', 5);
// CFG: CRUNCHER-TEST-UNIT-PRODUCER-TASK-CLASS
$cfg->setConfigEntry('cruncher_test_unit_producer_task_class', 'CruncherTestUnitProducerTask');
+// CFG: CRUNCHER-KEY-PRODUCER-TASK-CLASS
+$cfg->setConfigEntry('cruncher_key_producer_task_class', 'CruncherKeyProducerTask');
+
// CFG: TASK-NETWORK-PACKAGE-WRITER-STARTUP-DELAY
$cfg->setConfigEntry('task_network_package_writer_startup_delay', 2500);
// CFG: TASK-CRUNCHER-TEST-UNIT-PRODUCER-MAX-RUNS
$cfg->setConfigEntry('task_cruncher_test_unit_producer_max_runs', 0);
+// CFG: TASK-CRUNCHER-KEY-PRODUCER-STARTUP-DELAY
+$cfg->setConfigEntry('task_cruncher_key_producer_startup_delay', 750);
+
+// CFG: TASK-CRUNCHER-KEY-PRODUCER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_cruncher_key_producer_interval_delay', 10);
+
+// CFG: TASK-CRUNCHER-KEY-PRODUCER-MAX-RUNS
+$cfg->setConfigEntry('task_cruncher_key_producer_max_runs', 0);
+
// CFG: TASK-LIST-CLASS
$cfg->setConfigEntry('task_list_class', 'TaskList');
// CFG: CRUNCHER-TEST-UNIT-PRODUCER-CLASS
$cfg->setConfigEntry('cruncher_test_unit_producer_class', 'CruncherTestUnitProducer');
+// CFG: CRUNCHER-KEY-PRODUCER-CLASS
+$cfg->setConfigEntry('cruncher_key_producer_class', 'CruncherKeyProducer');
+
// CFG: CRUNCHER-TEST-UNIT-PRODUCER-TEMPLATE-CLASS
$cfg->setConfigEntry('cruncher_test_unit_producer_template_class', 'XmlCruncherTestUnitTemplateEngine');
// CFG: CRUNCHER-RANDOM-SECRET-MESSAGE-LENGTH
$cfg->setConfigEntry('random_secret_message_length', 100);
-// CFG: CRUNCHER-RANDOM-SECRET-KEY-LENGTH
-$cfg->setConfigEntry('random_secret_key_length', 8);
+// CFG: TEST-UNIT-RANDOM-SECRET-KEY-LENGTH
+$cfg->setConfigEntry('test_unit_random_secret_key_length', 8*4);
// CFG: TEST-UNIT-SOURCE-CLASS
$cfg->setConfigEntry('test_unit_source_class', 'TestUnitSource');
// CFG: CRYPTO-RANDOM-MESSAGE-HELPER-CLASS
$cfg->setConfigEntry('crypto_random_message_helper_class', 'CryptoRandomUnitMessageHelper');
+// CFG: CRUNCHER-INIT-STATE-CLASS
+$cfg->setConfigEntry('cruncher_init_state_class', 'CruncherInitState');
+
+// CFG: CRUNCHER-VIRGIN-STATE-CLASS
+$cfg->setConfigEntry('cruncher_virgin_state_class', 'CruncherVirginState');
+
// [EOF]
?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Executor 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 Executor extends FrameworkInterface {
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An interface for a ??? producer of the producer/consumer implementation
+ *
+ * @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 ???Producer extends Producer {
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for the producer/consumer implementation, especially for key
+ * producers.
+ *
+ * @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 KeyProducer extends Producer, Executor {
+ /**
+ * Produces some keys and pushes them onto the queue
+ *
+ * @param $stateInstance An instance of a Stateable instance
+ * @return void
+ */
+ function produceKeys (Stateable $stateInstance);
+}
+
+// [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/>.
*/
-interface UnitProducer extends Producer {
+interface UnitProducer extends Producer, Executor {
/**
- * Produces some work/test units and pushes them onto the queue
+ * Prepares the produces of some work/test units and pushes them onto the queue
*
+ * @param $stateInstance An instance of a Stateable instance
* @return void
*/
- function produceUnits ();
+ function prepareUnitProduction (Stateable $stateInstance);
}
// [EOF]
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface Stateable extends FrameworkInterface {
+ /**
+ * Executes the state with given Executor instance
+ *
+ * @param $executorInstance An instance of a Executor class
+ * @return void
+ */
+ function executeState (Executor $executorInstance);
}
// [EOF]
*/
private $nodeInstance = null;
+ /**
+ * An instance of a cruncher
+ */
+ private $cruncherInstance = null;
+
/**
* Listener instance
*/
*/
private $packageInstance = null;
+ /**
+ * State instance
+ */
+ private $stateInstance = null;
+
/**
* Protected constructor
*
}
/**
- * Setter for listener instance
+ * Getter for node instance
*
- * @param $listenerInstance A Listenable instance
+ * @return $nodeInstance An instance of a node node
+ */
+ public final function getNodeInstance () {
+ return $this->nodeInstance;
+ }
+
+ /**
+ * Setter for node instance
+ *
+ * @param $nodeInstance An instance of a node node
* @return void
*/
- protected final function setListenerInstance (Listenable $listenerInstance) {
- $this->listenerInstance = $listenerInstance;
+ protected final function setNodeInstance (NodeHelper $nodeInstance) {
+ $this->nodeInstance = $nodeInstance;
}
/**
- * Getter for listener instance
+ * Getter for cruncher instance
*
- * @return $listenerInstance A Listenable instance
+ * @return $cruncherInstance An instance of a cruncher cruncher
*/
- protected final function getListenerInstance () {
- return $this->listenerInstance;
+ public final function getCruncherInstance () {
+ return $this->cruncherInstance;
}
/**
- * Setter for node instance
+ * Setter for cruncher instance
*
- * @param $nodeInstance An instance of a node node
+ * @param $cruncherInstance An instance of a cruncher cruncher
* @return void
*/
- protected final function setNodeInstance (NodeHelper $nodeInstance) {
- $this->nodeInstance = $nodeInstance;
+ protected final function setCruncherInstance (CruncherHelper $cruncherInstance) {
+ $this->cruncherInstance = $cruncherInstance;
}
/**
- * Getter for node instance
+ * Setter for listener instance
*
- * @return $nodeInstance An instance of a node node
+ * @param $listenerInstance A Listenable instance
+ * @return void
*/
- public final function getNodeInstance () {
- return $this->nodeInstance;
+ protected final function setListenerInstance (Listenable $listenerInstance) {
+ $this->listenerInstance = $listenerInstance;
+ }
+
+ /**
+ * Getter for listener instance
+ *
+ * @return $listenerInstance A Listenable instance
+ */
+ protected final function getListenerInstance () {
+ return $this->listenerInstance;
}
/**
return $this->packageInstance;
}
+ /**
+ * Setter for state instance
+ *
+ * @param $stateInstance A Stateable instance
+ * @return void
+ */
+ public final function setStateInstance (Stateable $stateInstance) {
+ $this->stateInstance = $stateInstance;
+ }
+
+ /**
+ * Getter for state instance
+ *
+ * @return $stateInstance A Stateable instance
+ */
+ public final function getStateInstance () {
+ return $this->stateInstance;
+ }
+
/**
* Shuts down a given socket resource. This method does only ease calling
* the right visitor.
// Call the visitor
$this->accept($visitorInstance);
}
+
+ /**
+ * "Getter" for a printable state name
+ *
+ * @return $stateName Name of the node's state in a printable format
+ */
+ public final function getPrintableState () {
+ // Default is 'null'
+ $stateName = 'null';
+
+ // Get the state instance
+ $stateInstance = $this->getStateInstance();
+
+ // Is it an instance of Stateable?
+ if ($stateInstance instanceof Stateable) {
+ // Then use that state name
+ $stateName = $stateInstance->getStateName();
+ } // END - if
+
+ // Return result
+ return $stateName;
+ }
}
// [EOF]
protected function __construct ($className) {
// Call parent constructor
parent::__construct($className);
+
+ // Init this cruncher
+ $this->initCruncher();
+ }
+
+ /**
+ * Initialize the cruncher generically
+ *
+ * @return void
+ */
+ private function initCruncher () {
+ // Init the state
+ CruncherStateFactory::createCruncherStateInstanceByName('init', $this);
}
/**
if ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') {
// They are disabled, so skip any further steps
return;
- } // END - if
+ } elseif ($this->getStateInstance()->isCruncherStateVirgin()) {
+ // No virgin crunchers please, because they usually have no test units ready for crunching
+ return;
+ }
// Get a test-unit generator instance
$generatorInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_generator_class');
* @return void
*/
protected function fillInBufferQueueWithWorkUnits () {
+ // This cruncher's state must not be one of these: 'virgin'
+ 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.');
}
<?php
-/**
- * A factory class for states
- *
- * @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 StateFactory extends ObjectFactory {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of a configurable node state and sets it in the
- * given node instance.
- *
- * @param $stateName Name of the state
- * @param $nodeInstance A NodeHelper class instance
- * @return $stateInstance A Stateable class instance
- */
- public static final function createStateInstanceByName ($stateName, NodeHelper $nodeInstance) {
- // Then construct the class' configuraton entry
- $className = 'node_' . $stateName . '_state_class';
-
- // Get a class from that configuration entry
- $stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance));
-
- // Once we have that state, set it in the node instance
- $nodeInstance->setStateInstance($stateInstance);
-
- // For any purposes, return the state instance
- return $stateInstance;
- }
-}
-
-// [EOF]
+// @DEPRECATED
?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for cruncher states
+ *
+ * @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 CruncherStateFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of a configurable cruncher state and sets it in the
+ * given cruncher instance.
+ *
+ * @param $stateName Name of the state
+ * @param $cruncherInstance A CruncherHelper class instance
+ * @return $stateInstance A Stateable class instance
+ */
+ public static final function createCruncherStateInstanceByName ($stateName, CruncherHelper $cruncherInstance) {
+ // Then construct the class' configuraton entry
+ $className = 'cruncher_' . $stateName . '_state_class';
+
+ // Get a class from that configuration entry
+ $stateInstance = self::createObjectByConfiguredName($className, array($cruncherInstance));
+
+ // Once we have that state, set it in the cruncher instance
+ $cruncherInstance->setStateInstance($stateInstance);
+
+ // For any purposes, return the state instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for node states
+ *
+ * @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 NodeStateFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of a configurable node state and sets it in the
+ * given node instance.
+ *
+ * @param $stateName Name of the state
+ * @param $nodeInstance A NodeHelper class instance
+ * @return $stateInstance A Stateable class instance
+ */
+ public static final function createNodeStateInstanceByName ($stateName, NodeHelper $nodeInstance) {
+ // Then construct the class' configuraton entry
+ $className = 'node_' . $stateName . '_state_class';
+
+ // Get a class from that configuration entry
+ $stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance));
+
+ // Once we have that state, set it in the node instance
+ $nodeInstance->setStateInstance($stateInstance);
+
+ // For any purposes, return the state instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
$taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_producer_task_class');
$handlerInstance->registerTask('cruncher_test_unit_producer', $taskInstance);
+ /*
+ * 3) A task for generating keys based on the generated test unit. This
+ * task will only be executed if the state of the cruncher is one of
+ * these: 'virgin'.
+ */
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('cruncher_key_producer_task_class');
+ $handlerInstance->registerTask('cruncher_key_producer', $taskInstance);
+
// Put the task handler in registry
Registry::getRegistry()->addInstance('task', $handlerInstance);
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class TestUnitKeyProducerIterator extends BaseIterator implements Iterator {
+ /**
+ * Maximum different bit combinations
+ */
+ private $maxBits = 0;
+
+ /**
+ * Key length
+ */
+ private $keyLength = 0;
+
+ /**
+ * Current iteration
+ */
+ private $currentIteration = 0;
+
/**
* Protected constructor
*
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Get key length
+ $this->keyLength = $this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length');
+
+ // Make sure the key length isn't getting to big (32 byte = 256 bit is really a lot)
+ assert($this->keyLength <= (8 * 32));
+
+ // Set max bits entry
+ $this->maxBits = pow(2, $this->keyLength);
+
+ // Debug message
+ $this->debugOutput('ITERATOR: maxBits=' . $this->maxBits . ',keyLength=' . $this->keyLength);
}
/**
}
/**
- * Getter for current value from group or generic
+ * Getter for current value
*
* @return $current Current value in iteration
*/
public function current () {
- // Default is null
- $current = null;
+ // Calculate ASCII string representation of the key number
+ $current = $this->dec2asc($this->currentIteration);
- $this->partialStub('Please implement this method.');
+ // Prepend more zeros
+ $current = $this->prependStringToString($current, chr(0), ($this->keyLength / 8));
// Return it
return $current;
* @return void
*/
public function next () {
- $this->partialStub('Please implement this method.');
+ /*
+ * This is of course a very ineffective key generation iterator because
+ * it will create a lot of keys that will never decode an encrypted
+ * message. If you know a better algorithm which is freely available and
+ * can be implemented as an itertator please contact me.
+ */
+ $this->currentIteration++;
}
/**
* @return void
*/
public function valid () {
- $this->partialStub('Please implement this method.');
+ return ($this->currentIteration <= $this->maxBits);
}
}
*/
private $hubIsAnnounced = false;
- /**
- * State instance
- */
- private $stateInstance = null;
-
/**
* Wether this hub is active
*/
private function initState() {
// Get the state factory and create the initial state, we don't need
// the state instance here
- StateFactory::createStateInstanceByName('init', $this);
+ NodeStateFactory::createNodeStateInstanceByName('init', $this);
}
/**
return $this->listenerPoolInstance;
}
- /**
- * Setter for state instance
- *
- * @param $stateInstance Node's current state instance
- * @return void
- */
- public final function setStateInstance (Stateable $stateInstance) {
- $this->stateInstance = $stateInstance;
- }
-
- /**
- * Getter for state instance
- *
- * @return $stateInstance Node's current state instance
- */
- public final function getStateInstance () {
- return $this->stateInstance;
- }
-
/**
* Setter for session id
*
/**
* "Getter" for a printable state name
*
- * @return $stateName Name of the node's state in a printable format
+ * @return $stateName Name of the node's state in a printable format
*/
public final function getPrintableState () {
// Default is 'null'
*/
abstract class BaseProducer extends BaseFrameworkSystem {
/**
- * Out-going work-queue
+ * Outgoing work-queue
*/
private $outgoingQueueInstance = null;
+ /**
+ * Incoming raw data/items queue
+ */
+ private $incomingQueueInstance = null;
+
/**
* Protected constructor
*
}
/**
- * Setter for out-going work queue
+ * Getter for outgoing work queue
*
- * @param $outgoingQueueInstance The out-going work queue instance
+ * @param $outgoingQueueInstance The outgoing work queue instance
+ */
+ protected final function getOutgoingQueueInstance () {
+ return $this->outgoingQueueInstance;
+ }
+
+ /**
+ * Setter for outgoing work queue
+ *
+ * @param $outgoingQueueInstance The outgoing work queue instance
* @return void
*/
private final function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) {
}
/**
- * Getter for out-going work queue
+ * Getter for incoming raw data/items queue
*
- * @param $outgoingQueueInstance The out-going work queue instance
+ * @param $incomingQueueInstance The incoming raw data/items queue instance
*/
- protected final function getOutgoingQueueInstance () {
- return $this->outgoingQueueInstance;
+ protected final function getIncomingQueueInstance () {
+ return $this->incomingQueueInstance;
+ }
+
+ /**
+ * Setter for incoming raw data/items queue
+ *
+ * @param $incomingQueueInstance The incoming raw data/items queue instance
+ * @return void
+ */
+ private final function setIncomingQueueInstance (Stackable $incomingQueueInstance) {
+ $this->incomingQueueInstance = $incomingQueueInstance;
}
/**
abstract protected function initProducer();
/**
- * Initializes the work queue which is being used for out-going, produced
+ * Initializes the work queue which is being used for outgoing, produced
* items.
*
* @return void
*/
protected function initWorkQueue () {
// Get an instance and set it in this producer
- $this->setOutgoingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_outgoing_work_queue'));
+ $this->setOutgoingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_outgoing_queue'));
+
+ // Init the queue
+ $this->getOutgoingQueueInstance()->initStacker('outgoing_queue');
+
+ // Get an instance and set it in this producer
+ $this->setOutgoingQueueInstance(ObjectFactory::createObjectByConfiguredName('producer_incoming_queue'));
// Init the queue
- $this->getOutgoingQueueInstance()->initStacker('work_queue');
+ $this->getOutgoingQueueInstance()->initStacker('incoming_queue');
// Debug message
- $this->debugOutput('PRODUCER: Out-going work queue initialized.');
+ $this->debugOutput('PRODUCER: All queues have been initialized.');
}
}
--- /dev/null
+<?php
+/**
+ * A general KeyProducer class
+ *
+ * @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/>.
+ */
+abstract class BaseKeyProducer extends BaseProducer {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
<?php
/**
- * A general Producer class
+ * A general UnitProducer class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A CruncherKey producer class
+ *
+ * @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 CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $producerInstance An instance of a Producer class
+ */
+ public final static function createCruncherKeyProducer () {
+ // Get new instance
+ $producerInstance = new CruncherKeyProducer();
+
+ // Get a helper instance, we now only need this for the key iterator
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('crypto_random_message_helper_class', array('test'));
+
+ // Next get an iterator, again the helper will do that for us
+ $iteratorInstance = $helperInstance->getKeyIterator();
+
+ // Set it in the producer
+ $producerInstance->setIteratorInstance($iteratorInstance);
+
+ // Return the prepared instance
+ return $producerInstance;
+ }
+
+ /**
+ * Initializes the producer. This method satisfies the abstract BaseProducer
+ * class.
+ *
+ * @return void
+ * @todo Find something for init phase of this key producer
+ */
+ protected function initProducer () {
+ }
+
+ /**
+ * Produces some keys and pushes them onto the queue
+ *
+ * @param $stateInstance An instance of a Stateable instance
+ * @return void
+ * @todo ~30% done
+ */
+ public function produceKeys (Stateable $stateInstance) {
+ // Is this cruncher virgin?
+ if (!$stateInstance->isCruncherStateVirgin()) {
+ // This cruncher is not virgin, so skip it
+ $this->debugOutput('ITERATOR: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . '.');
+ return;
+ } elseif (!$this->getIteratorInstance()->valid()) {
+ // This iterator has finished his assignment
+ $this->debugOutput('ITERATOR: Finished creating keys.');
+ return;
+ }
+
+ /*
+ * Now we need to create an iterator, just as for the work units,
+ * to create new keys from the encrypted message. The iterator will
+ * not iterate over an object nor a collection. It will instead
+ * encapsulate the "key production" into a class and not in a simple
+ * for() loop. These keys then needs to be bundled into test units
+ * and stored to database for later re-usage.
+ */
+
+ // Get current key (which is not the key of the iterator)
+ // This is always an ASCII string.
+ $currentKey = $this->getIteratorInstance()->current();
+
+ // @TODO Do something with it
+ $this->debugOutput('currentKey(b64)="' . base64_encode($currentKey) . '" needs to be processed.');
+
+ // Continue with next one
+ $this->getIteratorInstance()->next();
+ }
+}
+
+// [EOF]
+?>
}
/**
- * Produces some test units and pushes them onto the queue
+ * Prepares the produces of some test units and pushes them onto the queue
*
+ * @param $stateInstance An instance of a Stateable instance
* @return void
- * @todo ~30% done
+ * @todo ~60% done
*/
- public function produceUnits () {
+ public function prepareUnitProduction (Stateable $stateInstance) {
// First get a database wrapper because we want to permanently store test units
$wrapperInstance = ObjectFactory::createObjectByConfiguredName('cruncher_unit_db_wrapper_class');
// Entries found
// @TODO Unfinished work here
$this->debugInstance();
+
+ // The state must be changed because ...
+ $stateInstance->someFooStateChange();
} else {
// Get an encrypted, random message from our source
$encryptedMessage = $this->getHelperInstance()->generateRandomMessage();
// Set the encrypted message in the template instance
$this->getTemplateInstance()->assignVariable('encrypted_message', $encryptedMessage);
- /*
- * Now we need to create an iterator, just as for the work units,
- * to create new keys from the encrypted message. The iterator will
- * not iterate over an object nor a collection. It will instead
- * encapsulate the "key production" into a class and not in a simple
- * for() loop. These keys then needs to be bundled into test units
- * and stored to database for later re-usage.
- */
-
- // First get an iterator, again the helper will do that for us
- $iteratorInstance = $this->getHelperInstance()->getKeyIterator();
-
- // Begin the "key production"
- while ($iteratorInstance->valid()) {
- // Get current key (which is not the key of the iterator)
- $currentKey = $iteratorInstance->current();
-
- // @TODO Do something with it
- $this->debugOutput('currentKey=' . $currentKey . ' needs to be processed.');
-
- // Continue with next one
- $iteratorInstance->next();
- } // END - while
-
- die(__METHOD__ . ": Ended the key production.\n");
+ // The state must be changed because we have a new message
+ $stateInstance->encryptedMessageGenerated();
}
}
}
$secretMessage = base64_encode($this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_message_length')));
// Get a random, secret key
- $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('random_secret_key_length'));
+ $secretKey = $this->getRngInstance()->randomString($this->getConfigInstance()->getConfigEntry('test_unit_random_secret_key_length') / 8);
// Now encrypt the message with our key and a good (strong) cipher
$encryptedMessage = base64_encode($this->getCryptoInstance()->encryptString($secretMessage, $secretKey));
protected final function setStateName ($stateName) {
$this->stateName = $stateName;
}
+
+ /**
+ * Executes the state with given Executor instance
+ *
+ * @param $executorInstance An instance of a Executor class
+ * @return void
+ * @throws UnsupportedOperationException This method should be overwritten
+ */
+ public function executeState (Executor $executorInstance) {
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? cruncher state class
+ *
+ * @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 Cruncher???State extends BaseCruncherState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('!!!');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $cruncherInstance An instance of a CruncherHelper class
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public final static function createCruncher???State (CruncherHelper $cruncherInstance) {
+ // Get new instance
+ $stateInstance = new Cruncher???State();
+
+ // Debug message
+ $stateInstance->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Set the cruncher instance
+ $stateInstance->setCruncherInstance($cruncherInstance);
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+
+ /**
+ * Executes the state with given Executor instance
+ *
+ * @param $executorInstance An instance of a Executor class
+ * @return void
+ */
+ public function executeState (Executor $executorInstance) {
+ $this->partialStub('This state needs implementation. executorInstance=' . $executorInstance->__toString());
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general cruncher state class
+ *
+ * @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 BaseCruncherState extends BaseState {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Validates wether the state is 'active' or throws an exception if
+ * it is every other state.
+ *
+ * @return void
+ * @throws InvalidStateException If the state is not 'active'
+ */
+ public function validateCruncherStateIsActive () {
+ // Just compare it...
+ if (!$this instanceof CruncherActiveState) {
+ // Throw the exception
+ throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+ } // END - if
+ }
+
+ /**
+ * Checks if this state is 'virgin'
+ *
+ * @return $isVirgin Wether this state is 'virgin'
+ */
+ public function isCruncherStateVirgin () {
+ // Just compare it...
+ return ($this instanceof CruncherVirginState);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Init cruncher state class
+ *
+ * @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 CruncherInitState extends BaseCruncherState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('init');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $cruncherInstance An instance of a CruncherHelper class
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public final static function createCruncherInitState (CruncherHelper $cruncherInstance) {
+ // Get new instance
+ $stateInstance = new CruncherInitState();
+
+ // Debug message
+ $stateInstance->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Set the cruncher instance
+ $stateInstance->setCruncherInstance($cruncherInstance);
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+
+ /**
+ * Executes the state with given Executor instance
+ *
+ * @param $executorInstance An instance of a Executor class
+ * @return void
+ */
+ public function executeState (Executor $executorInstance) {
+ // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there
+ $executorInstance->prepareUnitProduction($this);
+ }
+
+ /**
+ * An encrypted message has been generated so we change the state to
+ * 'virgin'.
+ *
+ * @return void
+ */
+ public function encryptedMessageGenerated () {
+ // Change the state now to 'virgin'
+ CruncherStateFactory::createCruncherStateInstanceByName('virgin', $this->getCruncherInstance());
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Virgin cruncher state class
+ *
+ * @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 CruncherVirginState extends BaseCruncherState implements Stateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('virgin');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $cruncherInstance An instance of a CruncherHelper class
+ * @return $stateInstance An instance of a Stateable class
+ */
+ public final static function createCruncherVirginState (CruncherHelper $cruncherInstance) {
+ // Get new instance
+ $stateInstance = new CruncherVirginState();
+
+ // Debug message
+ $stateInstance->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Set the cruncher instance
+ $stateInstance->setCruncherInstance($cruncherInstance);
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+
+ /**
+ * Executes the state with given Executor instance
+ *
+ * @param $executorInstance An instance of a Executor class
+ * @return void
+ */
+ public function executeState (Executor $executorInstance) {
+ // Produce some keys now
+ $executorInstance->produceKeys($this);
+ }
+}
+
+// [EOF]
+?>
*/
public function nodeAnnouncedToUpperHubs () {
// Create the new state instance
- StateFactory::createStateInstanceByName('announced', $this->getNodeInstance());
+ NodeStateFactory::createNodeStateInstanceByName('announced', $this->getNodeInstance());
}
}
* 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 NodeAnnouncedState extends BaseState implements Stateable {
+class NodeAnnouncedState extends BaseNodeState implements Stateable {
/**
* Protected constructor
*
* 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 Node???State extends BaseState implements Stateable {
+class Node???State extends BaseNodeState implements Stateable {
/**
* Protected constructor
*
* nodes with current state 'init' now 'virgin'.
*
* @return void
+ * @todo We might want to move some calls to this method to fill it with life
*/
public function nodeGeneratedSessionId () {
// Create the new state instance
- StateFactory::createStateInstanceByName('virgin', $this->getNodeInstance());
+ NodeStateFactory::createNodeStateInstanceByName('virgin', $this->getNodeInstance());
}
}
*/
public function nodeIsActivated () {
// Create the new state instance
- StateFactory::createStateInstanceByName('active', $this->getNodeInstance());
+ NodeStateFactory::createNodeStateInstanceByName('active', $this->getNodeInstance());
}
}
--- /dev/null
+<?php
+/**
+ * A KeyProducer task for crunchers
+ *
+ * @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 CruncherKeyProducerTask 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 createCruncherKeyProducerTask () {
+ // Get new instance
+ $taskInstance = new CruncherKeyProducerTask();
+
+ // 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
+ */
+ public function executeTask () {
+ // First we check if we already have an instance (which will happen at any later cyclus)
+ if (!Registry::getRegistry()->instanceExists('key_producer')) {
+ // No instance found, so we need to create a producer instance
+ $producerInstance = ObjectFactory::createObjectByConfiguredName('cruncher_key_producer_class');
+
+ // ... and add it to the registry
+ Registry::getRegistry()->addInstance('key_producer', $producerInstance);
+ } else {
+ // Get the producer instance from registry
+ $producerInstance = Registry::getRegistry()->getInstance('key_producer');
+ }
+
+ // Get the current cruncher state from registry
+ $stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance();
+
+ // Debug message
+ //* DEBUG: */ $this->debugOutput('TASK: Executing stateInstance=' . $stateInstance->__toString());
+
+ // We can now invoke that state instance and pass our producer instance for generating some test units
+ $stateInstance->executeState($producerInstance);
+ }
+}
+
+// [EOF]
+?>
* Executes the task
*
* @return void
- * @todo 0%
*/
public function executeTask () {
// First we check if we already have an instance (which will happen at any later cyclus)
$producerInstance = Registry::getRegistry()->getInstance('test_unit_producer');
}
- // We can now use that producer instance for generating some test units
- $producerInstance->produceUnits();
+ // Get the current cruncher state from registry
+ $stateInstance = Registry::getRegistry()->getInstance('cruncher')->getStateInstance();
+
+ // Debug message
+ //* DEBUG: */ $this->debugOutput('TASK: Executing stateInstance=' . $stateInstance->__toString());
+
+ // We can now invoke that state instance and pass our producer instance for generating some test units
+ $stateInstance->executeState($producerInstance);
}
}
./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:10: * @todo Find an interface for: handleAllQueries()
./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:78: * @TODO 0% done: Unfinished work here
./application/hub/main/connectors/queues/local/class_LocalQueueConnector.php:58: * @TODO 0% done: Unfinished work here
-./application/hub/main/cruncher/class_BaseHubCruncher.php:175: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
-./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:128: * @todo 0% done
-./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:98: * @todo Implement this method
+./application/hub/main/cruncher/class_BaseHubCruncher.php:188: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
+./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:108: * @todo Implement this method
+./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:138: * @todo 0% done
+./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:98: // @TODO Implement this method
./application/hub/main/discovery/socket/class_PackageSocketDiscovery.php:102: // @TODO We may need some locking here
./application/hub/main/factories/socket/class_SocketFactory.php:10: * @todo Find an interface for hub helper
./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php:54: * @todo 0% done
./application/hub/main/nodes/boot/class_HubBootNode.php:119: // @TODO Add some filters here
./application/hub/main/nodes/boot/class_HubBootNode.php:58: * @todo add some more special bootstrap things for this boot node
./application/hub/main/nodes/boot/class_HubBootNode.php:99: * @todo Unfinished method
-./application/hub/main/nodes/class_BaseHubNode.php:452: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
-./application/hub/main/nodes/class_BaseHubNode.php:492: * @todo Change the first if() block to check for a specific state
-./application/hub/main/nodes/class_BaseHubNode.php:667: // @TODO Add some criteria, e.g. if the node is active or so
+./application/hub/main/nodes/class_BaseHubNode.php:428: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
+./application/hub/main/nodes/class_BaseHubNode.php:468: * @todo Change the first if() block to check for a specific state
+./application/hub/main/nodes/class_BaseHubNode.php:643: // @TODO Add some criteria, e.g. if the node is active or so
./application/hub/main/nodes/list/class_HubListNode.php:58: * @todo Implement more bootstrap steps
./application/hub/main/nodes/list/class_HubListNode.php:68: * @todo Unfinished method
./application/hub/main/nodes/list/class_HubListNode.php:91: // @TODO Add some filters here
./application/hub/main/package/class_NetworkPackage.php:383: // @TODO Add some logging here
./application/hub/main/package/class_NetworkPackage.php:409: // @TODO Add some logging here
./application/hub/main/pools/peer/class_DefaultPeerPool.php:148: // @TODO Check for IP
-./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:127: // @TODO Do something with it
-./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:78: * @todo ~30% done
-./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:98: // @TODO Unfinished work here
+./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:62: * @todo Find something for init phase of this key producer
+./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:72: * @todo ~30% done
+./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:99: // @TODO Do something with it
+./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:79: * @todo ~60% done
+./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:99: // @TODO Unfinished work here
./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:68: * @todo ~30% done
./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:80: // @TODO On some systems it is 134, on some 107?
+./application/hub/main/states/node/init/class_NodeInitState.php:63: * @todo We might want to move some calls to this method to fill it with life
+./application/hub/main/tasks/cruncher/class_CruncherKeyProducerTask.php:53: * @todo Maybe visit some sub-objects
./application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php:53: * @todo Maybe visit some sub-objects
-./application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php:64: * @todo 0%
./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/class_HubSelfConnectTask.php:53: * @todo 0%
./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo Try to rewrite user/guest login classes and mark this exception as deprecated
./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo Rename this class to NoFoundEntryException
./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo Find a better name for this interface
-./inc/classes/main/class_BaseFrameworkSystem.php:1197: * @todo Write a logging mechanism for productive mode
-./inc/classes/main/class_BaseFrameworkSystem.php:1211: // @TODO Finish this part!
+./inc/classes/main/class_BaseFrameworkSystem.php:1237: * @todo Write a logging mechanism for productive mode
+./inc/classes/main/class_BaseFrameworkSystem.php:1251: // @TODO Finish this part!
./inc/classes/main/class_BaseFrameworkSystem.php:169: // @todo Try to clean these constants up
-./inc/classes/main/class_BaseFrameworkSystem.php:368: * @todo SearchableResult and UpdateableResult shall have a super interface to use here
+./inc/classes/main/class_BaseFrameworkSystem.php:408: * @todo SearchableResult and UpdateableResult shall have a super interface to use here
./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64: * @todo Add some stuff here: Some personal data, app/game related data
./inc/classes/main/commands/web/class_WebProblemCommand.php:58: * @todo 0% done
./inc/classes/main/commands/web/class_WebStatusCommand.php:58: * @todo 0% done
./inc/classes/main/response/image/class_ImageResponse.php:91: * @todo this will send only one cookie out, the first one.
./inc/classes/main/result/class_DatabaseResult.php:226: * @todo 0% done
./inc/classes/main/result/class_DatabaseResult.php:379:4 * @todo Find a caching way without modifying the result array
-./inc/classes/main/rng/class_RandomNumberGenerator.php:152: * @todo I had a better random number generator here but now it is somewhere lost :(
+./inc/classes/main/rng/class_RandomNumberGenerator.php:161: * @todo I had a better random number generator here but now it is somewhere lost :(
./inc/classes/main/rng/class_RandomNumberGenerator.php:83: * @todo Add site key for stronger salt!
./inc/classes/main/template/class_BaseTemplateEngine.php:1055: // @TODO This silent abort should be logged, maybe.
./inc/classes/main/template/class_BaseTemplateEngine.php:1063: // @TODO Old behaviour, will become obsolete!
./application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php:2:// @DEPRECATED
./application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php:2:// @DEPRECATED
./application/hub/main/database/wrapper/class_PeerStateLookupDatabaseWrapper.php:2:// @DEPRECATED
+./application/hub/main/factories/states/class_StateFactory.php:2:// @DEPRECATED
./application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php:2:// @DEPRECATED
./application/hub/main/filter/bootstrap/class_HubBootstrapAquireHubIdFilter.php:2:// @DEPRECATED
./application/hub/main/filter/bootstrap/class_HubBootstrapExtraBootstrappingFilter.php:2:// @DEPRECATED
./inc/classes/exceptions/language/class_MissingLanguageHandlerException.php:2:// @DEPRECATED
./inc/classes/exceptions/main/class_ClassNotFoundException.php:2:// @DEPRECATED
./inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php:2:// @DEPRECATED
+./inc/classes/exceptions/main/class_MissingMethodException.php:14: * @deprecated Please do no longer use this exception
./inc/classes/interfaces/helper/class_HelpableLogin.php:2:// @DEPRECATED
./inc/classes/interfaces/helper/class_HelpableTemplate.php:2:// @DEPRECATED
./inc/classes.php:9: * @deprecated