当前位置: 首页>>代码示例>>C++>>正文


C++ ResourceUsage::CopyFrom方法代码示例

本文整理汇总了C++中ResourceUsage::CopyFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ ResourceUsage::CopyFrom方法的具体用法?C++ ResourceUsage::CopyFrom怎么用?C++ ResourceUsage::CopyFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ResourceUsage的用法示例。


在下文中一共展示了ResourceUsage::CopyFrom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LOG

TEST(QoSPipelineTest, FiltersNotProperlyFed) {
  uint64_t WINDOWS_SIZE = 10;
  uint64_t CONTENTION_COOLDOWN = 10;
  double_t RELATIVE_THRESHOLD = 0.5;

  Try<mesos::FixtureResourceUsage> usages =
      JsonUsage::ReadJson("tests/fixtures/pipeline/insufficient_metrics.json");
  if (usages.isError()) {
    LOG(ERROR) << "JsonSource failed: " << usages.error() << std::endl;
  }

  ResourceUsage usage;
  usage.CopyFrom(usages.get().resource_usage(0));

  QoSControllerPipeline* pipeline =
      new CpuQoSPipeline<RollingChangePointDetector>(
          QoSPipelineConf(
              ChangePointDetectionState::createForRollingDetector(
                  WINDOWS_SIZE,
                  CONTENTION_COOLDOWN,
                  RELATIVE_THRESHOLD),
              ema::DEFAULT_ALPHA,
              false,
              true));

  Result<QoSCorrections> corrections = pipeline->run(usage);
  EXPECT_NONE(corrections);

  delete pipeline;
}
开发者ID:lelezi,项目名称:serenity,代码行数:30,代码来源:qos_pipeline_test.cpp

示例2: LOG

TEST(QoSPipelineTest, FiltersNotProperlyFed) {
  uint64_t WINDOWS_SIZE = 10;
  uint64_t CONTENTION_COOLDOWN = 10;
  double_t FRATIONAL_THRESHOLD = 0.5;

  Try<mesos::FixtureResourceUsage> usages =
      JsonUsage::ReadJson("tests/fixtures/pipeline/insufficient_metrics.json");
  if (usages.isError()) {
    LOG(ERROR) << "JsonSource failed: " << usages.error() << std::endl;
  }

  ResourceUsage usage;
  usage.CopyFrom(usages.get().resource_usage(0));

  SerenityConfig conf;
  conf["Detector"] = createAssuranceDetectorCfg(
    WINDOWS_SIZE, CONTENTION_COOLDOWN, FRATIONAL_THRESHOLD);

  conf.set(ENABLED_VISUALISATION, false);
  conf.set(VALVE_OPENED, true);

  QoSControllerPipeline* pipeline = new CpuQoSPipeline(conf);

  Result<QoSCorrections> corrections = pipeline->run(usage);
  EXPECT_NONE(corrections);

  delete pipeline;
}
开发者ID:Bplotka,项目名称:serenity,代码行数:28,代码来源:qos_pipeline_test.cpp

示例3: loadGen

/**
 * In this test we generate stable load with drop and
 * test the RollingChangePointDetector. We expect one
 * contention.
 */
TEST(DropFilterRollingDetectorTest, StableLoadWithDrop) {
  const uint64_t WINDOWS_SIZE = 10;
  const uint64_t CONTENTION_COOLDOWN = 10;
  const double_t RELATIVE_THRESHOLD = 5;
  const uint64_t LOAD_ITERATIONS = 200;
  // End of pipeline.
  MockSink<Contentions> mockSink;
  EXPECT_CALL(mockSink, consume(_))
      .Times(LOAD_ITERATIONS);

  DropFilter<RollingChangePointDetector> dropFilter(
      &mockSink, usage::getIpc,
      ChangePointDetectionState::createForRollingDetector(
          WINDOWS_SIZE, CONTENTION_COOLDOWN, RELATIVE_THRESHOLD));

  // Fake slave ResourceUsage source.
  MockSource<ResourceUsage> usageSource(&dropFilter);

  Try<mesos::FixtureResourceUsage> usages =
      JsonUsage::ReadJson("tests/fixtures/start_json_test.json");
  if (usages.isError()) {
    LOG(ERROR) << "JsonSource failed: " << usages.error() << std::endl;
  }

  ResourceUsage usage;
  usage.CopyFrom(usages.get().resource_usage(0));

  const double_t DROP_PROGRES = 1;
  LoadGenerator loadGen(
      [](double_t iter) { return 10; },
      new ZeroNoise(),
      LOAD_ITERATIONS);

  bool dropped = false;
  for (; loadGen.end(); loadGen++) {
    usage.mutable_executors(0)->CopyFrom(
        generateIPC(usage.executors(0),
                    (*loadGen)(),
                    (*loadGen).timestamp));

    // Run pipeline iteration.
    usageSource.produce(usage);

    if (dropped) {
      dropped = false;
      mockSink.expectContentionWithVictim("serenity2");
    } else {
      mockSink.expectContentions(0);
    }

    if (loadGen.iteration >= 100 &&
        loadGen.iteration < 110) {
      // After 6 iterations of 1 drop progress value should be below
      // threshold (4).
      if (loadGen.iteration == 105)
        dropped = true;
      loadGen.modifier -= DROP_PROGRES;
    }
  }
}
开发者ID:lelezi,项目名称:serenity,代码行数:65,代码来源:test.cpp

示例4: cpuUsageEMAFilter

/**
 * In this test we generate load with noise and
 * test the CpuUsageEMAfilter output in every iteration.
 */
TEST(EMATest, CpuUsageEMATestNoisyConstSample) {
  // End of pipeline.
  MockSink<ResourceUsage> mockSink;

  // Third component in pipeline.
  EMAFilter cpuUsageEMAFilter(
    &mockSink, usage::getCpuUsage, usage::setEmaCpuUsage, 0.2);

  // Second component in pipeline.
  // We need that for cumulative metrics.
  CumulativeFilter cumulativeFilter(
    &cpuUsageEMAFilter);

  // First component in pipeline.
  MockSource<ResourceUsage> source(&cumulativeFilter);

  Try<mesos::FixtureResourceUsage> usages =
      JsonUsage::ReadJson("tests/fixtures/start_json_test.json");
  if (usages.isError()) {
    LOG(ERROR) << "JsonSource failed: " << usages.error() << std::endl;
  }

  ResourceUsage usage;
  usage.CopyFrom(usages.get().resource_usage(0));

  const double_t CPU_USAGE_VALUE = 10;
  const double_t THRESHOLD = 1.2;
  const double_t MAX_NOISE = 5;
  const int32_t ITERATIONS = 100;

  SignalScenario signalGen =
    SignalScenario(ITERATIONS)
      .use(math::const10Function)
      .use(new SymetricNoiseGenerator(MAX_NOISE));

  ITERATE_SIGNAL(signalGen) {
    usage.mutable_executors(0)->CopyFrom(
      generateCpuUsage(usage.executors(0),
                       (uint64_t)(*signalGen).cumulative(),
                       signalGen->timestamp));

    // Run pipeline iteration
    source.produce(usage);

    if (signalGen.iteration > 0)
      mockSink.expectCpuUsage(0, CPU_USAGE_VALUE, THRESHOLD);
  }

  EXPECT_EQ(99, mockSink.numberOfMessagesConsumed);
}
开发者ID:erikdw,项目名称:serenity,代码行数:54,代码来源:ema_test.cpp

示例5: LOG

TEST(EstimatorPipelineTest, FiltersNotProperlyFed) {
  Try<mesos::FixtureResourceUsage> usages =
      JsonUsage::ReadJson("tests/fixtures/pipeline/insufficient_metrics.json");
  if (usages.isError()) {
    LOG(ERROR) << "JsonSource failed: " << usages.error() << std::endl;
    ASSERT_FALSE(usages.isError());  // test failure.
  }

  ResourceUsage usage;
  usage.CopyFrom(usages.get().resource_usage(0));

  ResourceEstimatorPipeline* pipeline = new CpuEstimatorPipeline();

  Result<Resources> slack = pipeline->run(usage);
  EXPECT_NONE(slack);

  delete pipeline;
}
开发者ID:Oliverlyn,项目名称:serenity,代码行数:18,代码来源:estimator_pipeline_test.cpp

示例6: allocated

/**
 * Check if getRevocableExecutors function properly filters out PR executors.
 *
 * TODO(skonefal): Does it really work?
 */
TEST(HelperFunctionsTest, getRevocableExecutors) {
  Try<mesos::FixtureResourceUsage> usages = JsonUsage::ReadJson(QOS_FIXTURE);
  if (usages.isError()) {
    LOG(ERROR) << "JsonSource failed: " << usages.error() << std::endl;
  }

  ResourceUsage usage;
  usage.CopyFrom(usages.get().resource_usage(0));

  std::list<ResourceUsage_Executor> ret =
    ResourceUsageHelper::getRevocableExecutors(usage);

  ASSERT_EQ(3u, ret.size());

  // Expected only BE executors.
  for (auto executor : ret) {
    Resources allocated(executor.allocated());
    EXPECT_FALSE(allocated.revocable().empty());
  }
}
开发者ID:intelsdi-x,项目名称:serenity,代码行数:25,代码来源:resource_helper_test.cpp


注:本文中的ResourceUsage::CopyFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。