Exemplo n.º 1
0
 /**
  * Fetches a set of rows from this column family.
  *
  * @param string[] $keys row keys to fetch
  * @param mixed $columnStart only fetch columns with name >= this
  * @param mixed $columnFinish only fetch columns with name <= this
  * @param bool $columnReversed fetch the columns in reverse order
  * @param int $columnCount limit the number of columns returned to this amount
  * @param mixed $superColumn return only columns in this super column
  * @param cassandra_ConsistencyLevel $readConsistencyLevel affects the guaranteed
  *        number of nodes that must respond before the operation returns
  * @param int $bufferSize the number of keys to multiget at a single time. If your
  *        rows are large, having a high buffer size gives poor performance; if your
  *        rows are small, consider increasing this value.
  *
  * @return mixed array(key => array(column_name => column_value))
  */
 public function multiget($keys, $columns = null, $columnStart = "", $columnFinish = "", $columnReversed = false, $columnCount = ColumnFamily::DEFAULT_COLUMN_COUNT, $superColumn = null, $readConsistencyLevel = null, $bufferSize = 16)
 {
     if (empty($this->_columnFamily)) {
         $this->init();
     }
     return $this->_columnFamily->multiget($keys, $columns, $columnStart, $columnFinish, $columnReversed, $columnCount, $superColumn, $readConsistencyLevel, $bufferSize);
 }
 /**
  * @param string $usuarioId
  * @return array
  */
 private function _recuperarListaDeRS($usuarioId)
 {
     try {
         $listaDeRS = array();
         $idsRS = array_keys($this->_RSPorUsuarioCF->get($usuarioId));
         $columns = $this->_RSCF->multiget($idsRS);
         foreach ($columns as $column) {
             $RS = $this->criarNovoRS();
             $RS->fromCassandra($column);
             $listaDeRS[] = $RS;
         }
         return $listaDeRS;
     } catch (cassandra_NotFoundException $e) {
         return array();
     }
 }
function get_xfer_metrics($system, $dates, $date_step) {
  $metrics = array("tx_bytes", "rx_bytes", "vnc-tx_bytes", "vnc-rx_bytes");
  $conn = cassandra_connect(KS_METRICS);
  $agg = new ColumnFamily($conn, CF_AGG);
  $keys = array();
  $totals = array();
  foreach($metrics as $metric) {
    $keys[] = "$system-$metric-$date_step";
    $totals[$metric] = array();
  }
  $result = $agg->multiget($keys, $dates);
  foreach($metrics as $metric) {
    $xfer = $result["$system-$metric-$date_step"];
    foreach($dates as $date) {
      $v = array_key_exists($date, $xfer) ? $xfer[$date] : "";
      $totals[$metric][$date] = $v;
    }
  }
  return $totals;
}
 }
 $columnfamily_name = '';
 if (isset($_GET['columnfamily_name'])) {
     $columnfamily_name = $_GET['columnfamily_name'];
 }
 $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name, $columnfamily_name);
 try {
     $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(), null, 5, 5000, 5000, 10000, $cluster_helper->getCredentialsForCurrentCluster());
     $column_family = new ColumnFamily($pool, $columnfamily_name);
     $vw_vars['results'] = '';
     $time_start = microtime(true);
     if (count($tab_keys) == 1) {
         $output = $column_family->get($tab_keys[0]);
         $output = array($tab_keys[0] => $output);
     } else {
         $output = $column_family->multiget($tab_keys);
     }
     $time_end = microtime(true);
     $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name, $columnfamily_name);
     $results = '';
     foreach ($output as $key => $value) {
         $vw_row_vars['key'] = $key;
         $vw_row_vars['value'] = $value;
         $vw_row_vars['is_super_cf'] = $cf_def->column_type == 'Super';
         $vw_row_vars['keyspace_name'] = $keyspace_name;
         $vw_row_vars['columnfamily_name'] = $columnfamily_name;
         $vw_row_vars['show_actions_link'] = true;
         $vw_row_vars['is_counter_column'] = false;
         $results .= getHTML('columnfamily_browse_data_row.php', $vw_row_vars);
     }
     $vw_vars['results'] = $results;
 $sys->read_consistency_level = cassandra_ConsistencyLevel::ONE;
 $agg->read_consistency_level = cassandra_ConsistencyLevel::ONE;
 if($_GET["load"] == "all") {
   $systems = array();
   $r = $sys->get_range("", "", $row_count=200, $columns=array("status"));
   foreach($r as $system => $info) $systems[] = $system;
 } else {
   $systems = explode(",", $_GET["load"]);
 }
 $keys = array();
 $totals = array();
 foreach($systems as $system) {
   $totals[$system] = array();
   $keys["$system-$metric-$date_step"] = $system;
 }
 $result = $agg->multiget(array_keys($keys), $dates);
 foreach($result as $key => $xfer) {
   $system = $keys[$key];
   foreach($dates as $date) {
     $totals[$system][$date] = array_key_exists($date, $xfer) ? $xfer[$date] : "";
   }
 }
 if(in_array($current, $dates) && in_array($date_step, array("monthly", "daily"))) {
   $keys = array();
   $skeymap = array();
   if($date_step == "monthly") {
     $keys["daily"] = array();
     $keys["daily"]["map"] = array();
     $keys["daily"]["columns"] = get_date_span(strtotime("first day of this month"), time(), "daily");
   }
   $keys["hourly"] = array();