Beispiel #1
0
Future<hashmap<string, double>> MetricsProcess::__snapshot(
    const Option<Duration>& timeout,
    const hashmap<string, Future<double>>& metrics,
    const hashmap<string, Option<Statistics<double>>>& statistics)
{
  hashmap<string, double> snapshot;

  foreachpair (const string& key, const Future<double>& value, metrics) {
    // TODO(dhamon): Maybe add the failure message for this metric to the
    // response if value.isFailed().
    if (value.isPending()) {
      CHECK_SOME(timeout);
      VLOG(1) << "Exceeded timeout of " << timeout.get()
              << " when attempting to get metric '" << key << "'";
    } else if (value.isReady()) {
      snapshot[key] = value.get();
    }

    Option<Statistics<double>> statistics_ = statistics.get(key).get();

    if (statistics_.isSome()) {
      snapshot[key + "/count"] = static_cast<double>(statistics_.get().count);
      snapshot[key + "/min"] = statistics_.get().min;
      snapshot[key + "/max"] = statistics_.get().max;
      snapshot[key + "/p50"] = statistics_.get().p50;
      snapshot[key + "/p90"] = statistics_.get().p90;
      snapshot[key + "/p95"] = statistics_.get().p95;
      snapshot[key + "/p99"] = statistics_.get().p99;
      snapshot[key + "/p999"] = statistics_.get().p999;
      snapshot[key + "/p9999"] = statistics_.get().p9999;
    }
  }

  return snapshot;
}
Beispiel #2
0
Future<http::Response> MetricsProcess::__snapshot(
    const http::Request& request,
    const hashmap<string, Future<double> >& metrics,
    const hashmap<string, Option<Statistics<double> > >& statistics)
{
  JSON::Object object;

  foreachpair (const string& key, const Future<double>& value, metrics) {
    // Value.
    if (value.isReady()) {
      object.values[key] = value.get();
    }

    // Statistics.
    Option<Statistics<double> > statistics_ = statistics.get(key).get();

    if (statistics_.isSome()) {
      object.values[key + "/count"] = statistics_.get().count;
      object.values[key + "/min"] = statistics_.get().min;
      object.values[key + "/max"] = statistics_.get().max;
      object.values[key + "/p50"] = statistics_.get().p50;
      object.values[key + "/p90"] = statistics_.get().p90;
      object.values[key + "/p95"] = statistics_.get().p95;
      object.values[key + "/p99"] = statistics_.get().p99;
      object.values[key + "/p999"] = statistics_.get().p999;
      object.values[key + "/p9999"] = statistics_.get().p9999;
    }
  }

  return http::OK(object, request.query.get("jsonp"));
}
  foreach (const Future<TaskStatus>& taskStatus, taskStatuses) {
    AWAIT_READY(taskStatus);

    Option<TaskState> taskState = taskStates.get(taskStatus->task_id());
    ASSERT_SOME(taskState);

    switch (taskState.get()) {
      case TASK_STAGING: {
        ASSERT_EQ(TASK_STARTING, taskStatus->state())
          << taskStatus->DebugString();

        taskStates[taskStatus->task_id()] = TASK_STARTING;
        break;
      }
      case TASK_STARTING: {
        ASSERT_EQ(TASK_RUNNING, taskStatus->state())
          << taskStatus->DebugString();

        taskStates[taskStatus->task_id()] = TASK_RUNNING;
        break;
      }
      default: {
        FAIL() << "Unexpected task update: " << taskStatus->DebugString();
        break;
      }
    }
  }
Beispiel #4
0
static void searchStock(char *symbol)
{
	unsigned int	usedIndex, hashIndex, symbolHash, chainLgth;
	stock	s;
	if (hm.get(symbol, s, symbolHash, hashIndex, usedIndex, chainLgth)) {
		cout << "found " << left << setw(8) << symbol;
		printAdditional(symbolHash, hashIndex, usedIndex, chainLgth);
		}
	else
		cout << symbol << " not found" << endl;
}
Beispiel #5
0
Try<string> nsname(int nsType)
{
  const hashmap<int, string> nsnames = {
    {CLONE_NEWNS, "mnt"},
    {CLONE_NEWUTS, "uts"},
    {CLONE_NEWIPC, "ipc"},
    {CLONE_NEWNET, "net"},
    {CLONE_NEWUSER, "user"},
    {CLONE_NEWPID, "pid"},
    {CLONE_NEWCGROUP, "cgroup"}
  };

  Option<string> nsname = nsnames.get(nsType);

  if (nsname.isNone()) {
    return Error("Unknown namespace");
  }

  return nsname.get();
}
Beispiel #6
0
Try<int> nstype(const string& ns)
{
  const hashmap<string, int> nstypes = {
    {"mnt", CLONE_NEWNS},
    {"uts", CLONE_NEWUTS},
    {"ipc", CLONE_NEWIPC},
    {"net", CLONE_NEWNET},
    {"user", CLONE_NEWUSER},
    {"pid", CLONE_NEWPID},
    {"cgroup", CLONE_NEWCGROUP}
  };

  Option<int> nstype = nstypes.get(ns);

  if (nstype.isNone()) {
    return Error("Unknown namespace '" + ns + "'");
  }

  return nstype.get();
}
Beispiel #7
0
std::vector<K> hashmap<K, V>::hashDifference (const hashmap& src) const
    {
    std::vector<K> diff;
    size_t listsize;
    size_t hashIndex;
    signed searchIndex;
    for (size_t i = 0; i < numBuckets; i++)
        {
        listsize = dictionary[i].size();
        for (size_t j = 0; j < listsize; j++)
            {
            pairptr<K, V> sample = dictionary[i].nPeek(j);
            if (false == src.get(sample->getKey()))
                {
                diff.push_back(sample.getKey());
                }
            }
        }
    
    return diff;
    }
Beispiel #8
0
Future<http::Response> MetricsProcess::__snapshot(
    const http::Request& request,
    const Option<Duration>& timeout,
    const hashmap<string, Future<double> >& metrics,
    const hashmap<string, Option<Statistics<double> > >& statistics)
{
  JSON::Object object;

  foreachpair (const string& key, const Future<double>& value, metrics) {
    // TODO(dhamon): Maybe add the failure message for this metric to the
    // response if value.isFailed().
    if (value.isPending()) {
      CHECK_SOME(timeout);
      VLOG(1) << "Exceeded timeout of " << timeout.get() << " when attempting "
              << "to get metric '" << key << "'";
    } else if (value.isReady()) {
      object.values[key] = value.get();
    }

    Option<Statistics<double> > statistics_ = statistics.get(key).get();

    if (statistics_.isSome()) {
      object.values[key + "/count"] = statistics_.get().count;
      object.values[key + "/min"] = statistics_.get().min;
      object.values[key + "/max"] = statistics_.get().max;
      object.values[key + "/p50"] = statistics_.get().p50;
      object.values[key + "/p90"] = statistics_.get().p90;
      object.values[key + "/p95"] = statistics_.get().p95;
      object.values[key + "/p99"] = statistics_.get().p99;
      object.values[key + "/p999"] = statistics_.get().p999;
      object.values[key + "/p9999"] = statistics_.get().p9999;
    }
  }

  return http::OK(object, request.query.get("jsonp"));
}