Ejemplo n.º 1
0
 /**
  * @dataProvider realPointsProvider
  */
 public function testHeuristicWithRealPoints($jobid, $metric_x, $metric_y, $num_clusters, $num_noise = 0)
 {
     $points = $this->getRealPoints($jobid, $metric_x, $metric_y);
     $dbscan = new DBSCAN();
     list($cluster, $noise) = $dbscan->execute($points);
     $assert_error = "";
     $assert_error .= "Check the chart here:\n";
     $assert_error .= "    http://127.0.0.1:8080/dbscan?jobid={$jobid}\n";
     $assert_error .= "    Metric X: \"" . DBUtils::$TASK_METRICS[$metric_x] . "\"\n";
     $assert_error .= "    Metric Y: \"" . DBUtils::$TASK_METRICS[$metric_y] . "\"";
     $this->assertCount($num_clusters, $cluster, $assert_error);
     $this->assertCount($num_noise, $noise, $assert_error);
 }
Ejemplo n.º 2
0
 public function dbscanexecsDataAction()
 {
     //ini_set('memory_limit', '384M');
     $db = $this->container->getDBUtils();
     $this->buildFilters();
     $whereClause = $this->filters->getWhereClause(array('execs' => 'e', 'clusters' => 'c'));
     $table_name = "e";
     $jobid = Utils::get_GET_string("jobid");
     $metric_x = Utils::get_GET_int("metric_x") !== null ? Utils::get_GET_int("metric_x") : 0;
     $metric_y = Utils::get_GET_int("metric_y") !== null ? Utils::get_GET_int("metric_y") : 1;
     $task_type = $db->get_task_type(Utils::get_GET_string("task_type"));
     list($bench, $job_offset, $id_exec) = $db->get_jobid_info($jobid);
     // Calc pending dbscanexecs (if any)
     $pending = $db->get_dbscanexecs_pending($bench, $job_offset, $metric_x, $metric_y, $task_type, $whereClause);
     if (count($pending) > 0) {
         $db->get_dbscan($pending[0]['jobid'], $metric_x, $metric_y, $task_type);
     }
     // Retrieve calculated dbscanexecs from database
     $task_type_select = $db->get_task_type_query($task_type, $filter_null = true);
     $query = "\n            SELECT\n                d.`id_exec`,\n                d.`centroid_x`,\n                d.`centroid_y`\n            FROM aloja2.JOB_dbscan d, aloja2.execs e\n            JOIN aloja2.clusters c USING (id_cluster)\n            LEFT JOIN aloja_ml.predictions p USING (id_exec)\n            WHERE\n                d.`id_exec` = e.`id_exec` AND\n                d.`bench` = :bench AND\n                d.`job_offset` = :job_offset AND\n                d.`metric_x` = :metric_x AND\n                d.`metric_y` = :metric_y\n                " . $task_type_select('d') . "\n                {$whereClause}\n        ;";
     $query_params = array(":bench" => $bench, ":job_offset" => $job_offset, ":metric_x" => $metric_x, ":metric_y" => $metric_y);
     // Since we are calculating new results, we have to bypass the cache
     $_GET['NO_CACHE'] = 1;
     $rows = $db->get_rows($query, $query_params);
     $points = new Cluster();
     // Used instead of a simple array to calc x/y min/max
     foreach ($rows as $row) {
         $points[] = new Point($row['centroid_x'], $row['centroid_y'], array('id_exec' => $row['id_exec']));
     }
     $dbscan = new DBSCAN();
     list($clusters, $noise) = $dbscan->execute((array) $points);
     $seriesData = array();
     foreach ($clusters as $cluster) {
         $data = array();
         foreach ($cluster as $point) {
             $data[] = array('x' => $point->x, 'y' => $point->y, 'id_exec' => $point->info['id_exec']);
         }
         if ($data) {
             $seriesData[] = array('points' => $data, 'size' => $cluster->count(), 'x_min' => $cluster->getXMin(), 'x_max' => $cluster->getXMax(), 'y_min' => $cluster->getYMin(), 'y_max' => $cluster->getYMax());
         }
     }
     $noiseData = array();
     foreach ($noise as $point) {
         $noiseData[] = array('x' => $point->x, 'y' => $point->y, 'id_exec' => $point->info['id_exec']);
     }
     $result = ['seriesData' => $seriesData, 'noiseData' => $noiseData, 'pending' => max(0, count($pending) - 1)];
     header('Content-Type: application/json');
     ob_start('ob_gzhandler');
     echo json_encode($result, JSON_NUMERIC_CHECK);
 }
Ejemplo n.º 3
0
 public function dbscanexecsDataAction()
 {
     //ini_set('memory_limit', '384M');
     $db = $this->container->getDBUtils();
     $where_configs = '';
     $table_name = "e";
     $datefrom = Utils::read_params('datefrom', $where_configs, false, $table_name);
     $dateto = Utils::read_params('dateto', $where_configs, false, $table_name);
     $benchs = Utils::read_params('benchs', $where_configs, false, $table_name);
     $nets = Utils::read_params('nets', $where_configs, false, $table_name);
     $disks = Utils::read_params('disks', $where_configs, false, $table_name);
     $blk_sizes = Utils::read_params('blk_sizes', $where_configs, false, $table_name);
     $comps = Utils::read_params('comps', $where_configs, false, $table_name);
     $id_clusters = Utils::read_params('id_clusters', $where_configs, false, $table_name);
     $mapss = Utils::read_params('mapss', $where_configs, false, $table_name);
     $replications = Utils::read_params('replications', $where_configs, false, $table_name);
     $iosfs = Utils::read_params('iosfs', $where_configs, false, $table_name);
     $iofilebufs = Utils::read_params('iofilebufs', $where_configs, false, $table_name);
     $money = Utils::read_params('money', $where_configs, false, $table_name);
     $datanodes = Utils::read_params('datanodess', $where_configs, false, $table_name);
     $benchtype = Utils::read_params('bench_types', $where_configs, false, $table_name);
     $vm_sizes = Utils::read_params('vm_sizes', $where_configs, false, $table_name);
     $vm_coress = Utils::read_params('vm_coress', $where_configs, false, $table_name);
     $vm_RAMs = Utils::read_params('vm_RAMs', $where_configs, false, $table_name);
     $hadoop_versions = Utils::read_params('hadoop_versions', $where_configs, false, $table_name);
     $types = Utils::read_params('types', $where_configs, false, $table_name);
     $filters = Utils::read_params('filters', $where_configs, false, $table_name);
     $allunchecked = isset($_GET['allunchecked']) ? $_GET['allunchecked'] : '';
     $minexetime = Utils::read_params('minexetime', $where_configs, false, $table_name);
     $maxexetime = Utils::read_params('maxexetime', $where_configs, false, $table_name);
     $provider = Utils::read_params('providers', $where_configs, false, $table_name);
     $jobid = Utils::get_GET_string("jobid");
     $metric_x = Utils::get_GET_int("metric_x") !== null ? Utils::get_GET_int("metric_x") : 0;
     $metric_y = Utils::get_GET_int("metric_y") !== null ? Utils::get_GET_int("metric_y") : 1;
     $task_type = $db->get_task_type(Utils::get_GET_string("task_type"));
     list($bench, $job_offset, $id_exec) = $db->get_jobid_info($jobid);
     // Calc pending dbscanexecs (if any)
     $pending = $db->get_dbscanexecs_pending($bench, $job_offset, $metric_x, $metric_y, $task_type, $where_configs);
     if (count($pending) > 0) {
         $db->get_dbscan($pending[0]['jobid'], $metric_x, $metric_y, $task_type);
     }
     // Retrieve calculated dbscanexecs from database
     $task_type_select = $db->get_task_type_query($task_type, $filter_null = true);
     $query = "\n            SELECT\n                d.`id_exec`,\n                d.`centroid_x`,\n                d.`centroid_y`\n            FROM `JOB_dbscan` d, `execs` e\n            WHERE\n                d.`id_exec` = e.`id_exec` AND\n                d.`bench` = :bench AND\n                d.`job_offset` = :job_offset AND\n                d.`metric_x` = :metric_x AND\n                d.`metric_y` = :metric_y\n                " . $task_type_select('d') . "\n                {$where_configs}\n        ;";
     $query_params = array(":bench" => $bench, ":job_offset" => $job_offset, ":metric_x" => $metric_x, ":metric_y" => $metric_y);
     // Since we are calculating new results, we have to bypass the cache
     $_GET['NO_CACHE'] = 1;
     $rows = $db->get_rows($query, $query_params);
     $points = new Cluster();
     // Used instead of a simple array to calc x/y min/max
     foreach ($rows as $row) {
         $points[] = new Point($row['centroid_x'], $row['centroid_y'], array('id_exec' => $row['id_exec']));
     }
     $dbscan = new DBSCAN();
     list($clusters, $noise) = $dbscan->execute((array) $points);
     $seriesData = array();
     foreach ($clusters as $cluster) {
         $data = array();
         foreach ($cluster as $point) {
             $data[] = array('x' => $point->x, 'y' => $point->y, 'id_exec' => $point->info['id_exec']);
         }
         if ($data) {
             $seriesData[] = array('points' => $data, 'size' => $cluster->count(), 'x_min' => $cluster->getXMin(), 'x_max' => $cluster->getXMax(), 'y_min' => $cluster->getYMin(), 'y_max' => $cluster->getYMax());
         }
     }
     $noiseData = array();
     foreach ($noise as $point) {
         $noiseData[] = array('x' => $point->x, 'y' => $point->y, 'id_exec' => $point->info['id_exec']);
     }
     $result = ['seriesData' => $seriesData, 'noiseData' => $noiseData, 'pending' => max(0, count($pending) - 1)];
     header('Content-Type: application/json');
     ob_start('ob_gzhandler');
     echo json_encode($result, JSON_NUMERIC_CHECK);
 }
Ejemplo n.º 4
0
 /**
  * Calculates the DBSCAN.
  */
 public function get_dbscan($jobid, $metric_x, $metric_y, $task_type, $eps = null, $minPoints = null)
 {
     $query_select1 = $this->get_task_metric_query($this::$TASK_METRICS[$metric_x]);
     $query_select2 = $this->get_task_metric_query($this::$TASK_METRICS[$metric_y]);
     $task_type_select = $this->get_task_type_query($task_type);
     $query = "\n            SELECT\n                t.`TASKID` as TASK_ID,\n                " . $query_select1('t') . " as TASK_VALUE_X,\n                " . $query_select2('t') . " as TASK_VALUE_Y\n            FROM `JOB_tasks` t\n            WHERE t.`JOBID` = :jobid\n            " . $task_type_select('t') . "\n            ORDER BY t.`TASKID`\n        ;";
     $query_params = array(":jobid" => $jobid);
     $rows = $this->get_rows($query, $query_params);
     $points = new Cluster();
     // Used instead of a simple array to calc x/y min/max
     foreach ($rows as $row) {
         $task_id = $row['TASK_ID'];
         $task_value_x = $row['TASK_VALUE_X'] ?: 0;
         $task_value_y = $row['TASK_VALUE_Y'] ?: 0;
         // Show only task id (not the whole string)
         $task_id = substr($task_id, 23);
         $points[] = new Point($task_value_x, $task_value_y, array('task_id' => $task_id));
     }
     $dbscan = new DBSCAN($eps, $minPoints);
     $dbscan->execute((array) $points);
     // If heuristic was used, cache results in database
     if ($eps === null && $minPoints === null) {
         $this->add_dbscan($jobid, $metric_x, $metric_y, $task_type, $dbscan->getClusters());
     }
     return $dbscan;
 }