Exemplo n.º 1
0
void StatsAggregator::UpdateTableMetrics(storage::Database *database,
                                         int64_t time_stamp,
                                         concurrency::Transaction *txn) {
  // Get the target table metrics table
  auto database_oid = database->GetOid();
  auto table_metrics_table = GetMetricTable(TABLE_METRIC_NAME);

  // Update table metrics table for each of the indices
  auto table_count = database->GetTableCount();
  for (oid_t table_offset = 0; table_offset < table_count; table_offset++) {
    auto table = database->GetTable(table_offset);
    auto table_oid = table->GetOid();
    auto table_metrics =
        aggregated_stats_.GetTableMetric(database_oid, table_oid);
    auto table_access = table_metrics->GetTableAccess();
    auto reads = table_access.GetReads();
    auto updates = table_access.GetUpdates();
    auto deletes = table_access.GetDeletes();
    auto inserts = table_access.GetInserts();

    // Generate and insert the tuple
    auto table_tuple = catalog::GetTableMetricsCatalogTuple(
        table_metrics_table->GetSchema(), database_oid, table_oid, reads,
        updates, deletes, inserts, time_stamp);
    catalog::InsertTuple(table_metrics_table, std::move(table_tuple), txn);
    LOG_TRACE("Table Metric Tuple inserted");

    UpdateIndexMetrics(database, table, time_stamp, txn);
  }
}
Exemplo n.º 2
0
void ZWaveBase::Do_Work()
{
#ifdef WIN32
	//prevent OpenZWave locale from taking over
	_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
#endif
	while (!m_stoprequested)
	{
		sleep_milliseconds(500);
		if (m_stoprequested)
			return;
		if (m_bInitState)
		{
			if (GetInitialDevices())
			{
				m_bInitState=false;
				sOnConnected(this);
			}
		}
		else
		{
			GetUpdates();
			if (m_bControllerCommandInProgress==true)
			{
				time_t atime=mytime(NULL);
				time_t tdiff=atime-m_ControllerCommandStartTime;
				if (tdiff>=CONTROLLER_COMMAND_TIMEOUT)
				{
					_log.Log(LOG_ERROR,"ZWave: Stopping Controller command (Timeout!)");
					CancelControllerCommand();
				}
			}
		}
	}
}
Exemplo n.º 3
0
void StatsAggregator::UpdateQueryMetrics(int64_t time_stamp,
                                         concurrency::Transaction *txn) {
  // Get the target query metrics table
  LOG_DEBUG("Inserting Query Metric Tuples");
  auto query_metrics_table = GetMetricTable(QUERY_METRIC_NAME);

  std::shared_ptr<QueryMetric> query_metric;
  auto &completed_query_metrics = aggregated_stats_.GetCompletedQueryMetrics();
  while (completed_query_metrics.Dequeue(query_metric)) {

    auto table_access = query_metric->GetQueryAccess();
    auto reads = table_access.GetReads();
    auto updates = table_access.GetUpdates();
    auto deletes = table_access.GetDeletes();
    auto inserts = table_access.GetInserts();
    auto latency = query_metric->GetQueryLatency().GetFirstLatencyValue();
    auto cpu_system = query_metric->GetProcessorMetric().GetSystemDuration();
    auto cpu_user = query_metric->GetProcessorMetric().GetUserDuration();

    // Generate and insert the tuple
    auto query_tuple = catalog::GetQueryMetricsCatalogTuple(
        query_metrics_table->GetSchema(), query_metric->GetName(),
        query_metric->GetDatabaseId(), reads, updates, deletes, inserts,
        (int64_t)latency, (int64_t)(cpu_system + cpu_user), time_stamp,
        pool_.get());
    catalog::InsertTuple(query_metrics_table, std::move(query_tuple), txn);
    LOG_TRACE("Query Metric Tuple inserted");
  }
}