application/hub/interfaces/wrapper/class_NodeDhtWrapper.php svneol=native#text/plain
application/hub/interfaces/wrapper/class_NodeInformationWrapper.php svneol=native#text/plain
application/hub/interfaces/wrapper/class_NodeListWrapper.php svneol=native#text/plain
+application/hub/interfaces/wrapper/class_UnitDatabaseWrapper.php svneol=native#text/plain
application/hub/loader.php svneol=native#text/plain
application/hub/main/.htaccess -text svneol=unset#text/plain
application/hub/main/apt-proxy/.htaccess svneol=native#text/plain
function isLocalNodeRegistered ();
/**
- * Updates local (*this*) node data in DHT, this is but not limited to the
- * session id, ip number (and/or hostname) and port number.
+ * Registeres the local (*this*) node with its data in the DHT.
*
* @return void
*/
- function updateLocalNode();
+ function registerLocalNode ();
/**
- * Registeres the local (*this*) node with its data in the DHT.
+ * Updates local (*this*) node data in DHT, this is but not limited to the
+ * session id, ip number (and/or hostname) and port number.
*
* @return void
*/
- function registerLocalNode();
+ function updateLocalNode ();
}
// [EOF]
--- /dev/null
+<?php
+/**
+ * An interface for cruncher unit database wrappers
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 UnitDatabaseWrapper extends DatabaseWrapper {
+ /**
+ * Checks whether a test unit has been produced
+ *
+ * @return $isProduced Whether a test unit has already been produced
+ */
+ function isTestUnitProduced ();
+}
+
+// [EOF]
+?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper {
+class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper implements UnitDatabaseWrapper {
// Constants for database table names
const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units';
// Return the instance
return $wrapperInstance;
}
+
+ /**
+ * Checks whether a test unit has been produced
+ *
+ * @return $isProduced Whether a test unit has already been produced
+ */
+ public function isTestUnitProduced () {
+ // Now get a search instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add criteria for looking up already created and available test units
+ $searchInstance->addCriteria(self::DB_COLUMN_UNIT_TYPE , BaseUnitProducer::UNIT_TYPE_TEST_UNIT);
+ $searchInstance->addCriteria(self::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE);
+ $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count');
+
+ // Search for our units
+ $resultInstance = $this->doSelectByCriteria($searchInstance);
+
+ // Do we have some entries?
+ $isProduced = $resultInstance->next();
+
+ // Return it
+ return $isProduced;
+ }
}
// [EOF]
const DB_TABLE_NODE_DHT = 'node_dht';
// Constants for database column names
+ const DB_COLUMN_NODE_ID = 'node_id';
const DB_COLUMN_SESSION_ID = 'session_id';
const DB_COLUMN_IP_PORT = 'ip_port';
* @return $isRegistered Whether *this* node is registered in the DHT
*/
public function isLocalNodeRegistered () {
+ // Get a search criteria instance
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
// Get node instance
$nodeInstance = Registry::getRegistry()->getInstance('node');
- // Get a dataset instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
// Add ip:port as criteria
$searchInstance->addCriteria(self::DB_COLUMN_IP_PORT, $nodeInstance->getAddressPort());
$searchInstance->setLimit(1);
}
/**
- * Updates local (*this*) node data in DHT, this is but not limited to the
- * session id, ip number (and/or hostname) and port number.
+ * Registeres the local (*this*) node with its data in the DHT.
*
* @return void
*/
- public function updateLocalNode () {
+ public function registerLocalNode () {
$this->partialStub('Not implemented yet.');
}
/**
- * Registeres the local (*this*) node with its data in the DHT.
+ * Updates local (*this*) node data in DHT, this is but not limited to the
+ * session id, ip number (and/or hostname) and port number.
*
* @return void
*/
- public function registerLocalNode () {
+ public function updateLocalNode () {
$this->partialStub('Not implemented yet.');
}
}
*/
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');
-
- // Now get a search instance
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
- // Add criteria for looking up already created and available test units
- $searchInstance->addCriteria(CruncherUnitDatabaseWrapper::DB_COLUMN_UNIT_TYPE , BaseUnitProducer::UNIT_TYPE_TEST_UNIT);
- $searchInstance->addCriteria(CruncherUnitDatabaseWrapper::DB_COLUMN_UNIT_STATUS, BaseUnitProducer::UNIT_STATUS_AVAILABLE);
- $searchInstance->setConfiguredLimit('cruncher_test_unit_max_count');
-
- // Search for our units
- $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
+ $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('cruncher_unit_db_wrapper_class');
// Do we have some entries?
- if ($resultInstance->next()) {
+ if ($wrapperInstance->isTestUnitProduced()) {
// Entries found
// @TODO Unfinished work here
$this->debugInstance();