namenode = new ServiceComponent($clusterName, "namenode", "hdfs", State::UNINSTALLED, $this, $puppet, FALSE); $this->secondary_namenode = new ServiceComponent($clusterName, "secondary_namenode", "hdfs", State::UNINSTALLED, $this, $puppet, FALSE); $this->datanode = new ServiceComponent($clusterName, "datanode", "hdfs", State::UNINSTALLED, $this, $puppet, FALSE); $this->hdfs = new Service($clusterName, "hdfs", State::UNINSTALLED, $this, $puppet); $this->jobtracker= new ServiceComponent($clusterName, "jobtracker", "mapreduce", State::UNINSTALLED, $this, $puppet, FALSE); $this->tasktracker = new ServiceComponent($clusterName, "tasktracker", "mapreduce", State::UNINSTALLED, $this, $puppet, FALSE); $this->mapreduce = new Service($clusterName, "mapreduce", State::UNINSTALLED, $this, $puppet); $this->zookeeper_node = new ServiceComponent($clusterName, "zookeeper_node", "zookeeper", State::UNINSTALLED, $this, $puppet, FALSE); $this->zookeeper = new Service($clusterName, "zookeeper", State::UNINSTALLED, $this, $puppet); $this->hbase_master = new ServiceComponent($clusterName, "hbase_master", "hbase", State::UNINSTALLED, $this, $puppet, FALSE); $this->hbase_regionserver = new ServiceComponent($clusterName, "hbase_regionserver", "hbase", State::UNINSTALLED, $this, $puppet, FALSE); $this->hbase = new Service($clusterName, "hbase", State::UNINSTALLED, $this, $puppet); } public function getClusterServices() { return array($this->hdfs, $this->zookeeper, $this->mapreduce, $this->hbase); } public function getServiceDependencies($serviceName) { switch ($serviceName) { case "hdfs": case "zookeeper": return array(); case "mapreduce": return array($this->hdfs); case "hbase": return array($this->hdfs, $this->zookeeper); default: return "Unknown service $serviceName"; } } public function getServiceDependents($serviceName) { switch ($serviceName) { case "hdfs": return array($this->mapreduce, $this->hbase); case "zookeeper": return array($this->hbase); case "mapreduce": case "hbase": return array(); default: return "Unknown service $serviceName"; } } public function getServiceComponents($serviceName) { switch ($serviceName) { case "hdfs": return array($this->namenode, $this->secondary_namenode, $this->datanode); case "zookeeper": return array($this->zookeeper_node); case "mapreduce": return array($this->jobtracker, $this->tasktracker); case "hbase": return array($this->hbase_master, $this->hbase_regionserver); default: return "Unknown service $serviceName"; } } public function getComponentDependencies($serviceName, $componentName) { switch ($componentName) { case "namenode": return array(); case "secondary_namenode": return array($this->namenode); case "datanode": return array($this->secondary_namenode); case "zookeeper_node": return array(); case "jobtracker": return array(); case "tasktracker": return array($this->jobtracker); case "hbase_master": return array(); case "hbase_regionserver": return array($this->hbase_master); default: return "Unknown component $componentName"; } } public function reset($state) { $this->hdfs->state = $state; $this->namenode->state = $state; $this->secondary_namenode->state = $state; $this->datanode->state = $state; $this->mapreduce->state = $state; $this->jobtracker->state = $state; $this->tasktracker->state = $state; $this->zookeeper->state = $state; $this->zookeeper_node->state = $state; $this->hbase->state = $state; $this->hbase_master->state = $state; $this->hbase_regionserver->state = $state; } } class MockPuppetInvoker extends PuppetInvoker { function __construct() { parent::__construct("test", 100); } public function install($txid) { print("MockPuppetInvoker::install\n"); return array("result" => 0, "error" => 0); } public function kickPuppet($nodes, $transaction, $clusterName) { $trace = debug_backtrace(); print("MockPuppetInvoker::kickPuppet from " . $trace[1]["function"] . " with " . $transaction->toString() . "\n"); return array("result" => 0, "error" => 0, KICKSENT => array(), KICKFAILED => array(), FAILEDNODES => array(), SUCCESSFULLNODES => array()); } public function kickServiceCheck($nodes, $transaction, $clusterName) { $trace = debug_backtrace(); print("MockPuppetInvoker::kickServiceCheck from " . $trace[1]["function"] . " with " . $transaction->toString() . "\n"); return array("result" => 0, "error" => 0, KICKSENT => array(), KICKFAILED => array(), FAILEDNODES => array(), SUCCESSFULLNODES => array()); } } /* print_r($hdfs->install()); print_r($hdfs->start()); print_r($mapreduce->install()); print_r($mapreduce->start()); print_r($hbase->install()); print_r($hbase->start()); print_r($hdfs->stop()); print_r($zookeeper->stop()); */ $puppet = new MockPuppetInvoker(); $db = new OrchestratorDB("/homes/hortonmu/HMC/src/php/db/test.db", "DataCluster", $puppet); $cluster = new Cluster($clusterName, $db, $puppet); $t0 = new Transaction(0, 0, 0); print_r($cluster->deployHDP($t0)); $cluster->resetSubTxnId(); $t1 = new Transaction(1, 0, 0); print_r($cluster->reconfigureServices($t1, array("MAPREDUCE"))); $t2 = new Transaction(2, 0, 0); print_r($cluster->smokeServices($t2, array("HDFS", "MAPREDUCE"))); $cluster->resetSubTxnId(); $t20 = new Transaction(20, 0, 0); print_r($cluster->stopAllServices($t20)); $cluster->resetSubTxnId(); ?>