text:
using namespace process;

using mesos::internal::master::Master;

using mesos::internal::protobuf::createLabel;

using mesos::internal::slave::LoadQoSController;
using mesos::internal::slave::Slave;

using mesos::master::detector::MasterDetector;
using mesos::master::detector::StandaloneMasterDetector;

using mesos::slave::QoSCorrection;

using std::list;
using std::string;
using std::vector;

using testing::_;
using testing::AtMost;
using testing::DoAll;
using testing::Eq;
using testing::InvokeWithoutArgs;
using testing::Return;

namespace mesos {
namespace internal {
namespace tests {

const char FIXED_RESOURCE_ESTIMATOR_NAME[] =
  "org_apache_mesos_FixedResourceEstimator";

class OversubscriptionTest : public MesosTest
{
protected:
  virtual void SetUp()
  {
    MesosTest::SetUp();
  }

  virtual void TearDown()
  {
    // Unload modules.
    foreach (const Modules::Library& library, modules.libraries()) {
      foreach (const Modules::Library::Module& module, library.modules()) {
        if (module.has_name()) {
          ASSERT_SOME(modules::ModuleManager::unload(module.name()));
        }
      }
    }

    MesosTest::TearDown();
  }

  void loadFixedResourceEstimatorModule(const string& resources)
  {
    string libraryPath = getModulePath("fixed_resource_estimator");

    Modules::Library* library = modules.add_libraries();
    library->set_name("fixed_resource_estimator");
    library->set_file(libraryPath);

    Modules::Library::Module* module = library->add_modules();
    module->set_name(FIXED_RESOURCE_ESTIMATOR_NAME);

    Parameter* parameter = module->add_parameters();
    parameter->set_key("resources");
    parameter->set_value(resources);

    ASSERT_SOME(modules::ModuleManager::load(modules));
  }

  // TODO(vinod): Make this a global helper that other tests (e.g.,
  // hierarchical allocator tests) can use.
  Resources createRevocableResources(
      const string& name,
      const string& value,
      const string& role = "*")
  {
    Resource resource = Resources::parse(name, value, role).get();
    resource.mutable_revocable();
    return resource;
  }

  ResourceStatistics createResourceStatistics()
  {
    ResourceStatistics statistics;
    statistics.set_cpus_nr_periods(100);
    statistics.set_cpus_nr_throttled(2);
    statistics.set_cpus_user_time_secs(4);
    statistics.set_cpus_system_time_secs(1);
    statistics.set_cpus_throttled_time_secs(0.5);
    statistics.set_cpus_limit(1.0);
    statistics.set_mem_file_bytes(0);
    statistics.set_mem_anon_bytes(0);
    statistics.set_mem_mapped_file_bytes(0);
    statistics.set_mem_rss_bytes(1024);
    statistics.set_mem_limit_bytes(2048);
    statistics.set_timestamp(0);

    return statistics;
  }

  ExecutorInfo createExecutorInfo(
      const string& _frameworkId,
      const string& _executorId)
  {
    FrameworkID frameworkId;
    frameworkId.set_value(_frameworkId);

    ExecutorID executorId;
    executorId.set_value(_executorId);

    ExecutorInfo executorInfo;
    executorInfo.mutable_executor_id()->CopyFrom(executorId);
    executorInfo.mutable_framework_id()->CopyFrom(frameworkId);

    return executorInfo;
  }

private:
  Modules modules;
};

// This test verifies that the ResourceEstimator is able to fetch
// ResourceUsage statistics about running executor.
TEST_F(OversubscriptionTest, FetchResourceUsage)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  const ResourceStatistics statistics = createResourceStatistics();

  // Make sure that containerizer will report stub statistics.
  EXPECT_CALL(containerizer, usage(_))
    .WillOnce(Return(statistics));

  MockResourceEstimator resourceEstimator;

  Future<lambda::function<Future<ResourceUsage>()>> usageCallback;

  // Catching callback which is passed to the ResourceEstimator.
  EXPECT_CALL(resourceEstimator, initialize(_))
    .WillOnce(DoAll(FutureArg<0>(&usageCallback), Return(Nothing())));

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave = StartSlave(
      detector.get(),
      &containerizer,
      &resourceEstimator,
      CreateSlaveFlags());
  ASSERT_SOME(slave);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());

  TaskInfo task = createTask(offers.get()[0], "sleep 10", DEFAULT_EXECUTOR_ID);
  task.mutable_labels()->add_labels()->CopyFrom(
      createLabel("key1", "value1"));
  task.mutable_executor()->mutable_labels()->add_labels()->CopyFrom(
      createLabel("key2", "value2"));

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  EXPECT_CALL(exec, registered(_, _, _, _));

  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(status);
  EXPECT_EQ(TASK_RUNNING, status->state());

  AWAIT_READY(usageCallback);

  Future<ResourceUsage> usage = usageCallback.get()();
  AWAIT_READY(usage);

  // Expecting the same statistics as these returned by mocked containerizer.
  ASSERT_EQ(1, usage->executors_size());
  EXPECT_EQ(usage->executors(0).executor_info().executor_id(),
            DEFAULT_EXECUTOR_ID);
  ASSERT_EQ(usage->executors(0).statistics(), statistics);
  ASSERT_EQ(task.executor().labels(),
            usage->executors(0).executor_info().labels());
  ASSERT_EQ(1, usage->executors(0).tasks().size());
  ASSERT_EQ(task.name(),
            usage->executors(0).tasks(0).name());
  ASSERT_EQ(task.task_id(),
            usage->executors(0).tasks(0).id());
  ASSERT_EQ(task.resources(),
            usage->executors(0).tasks(0).resources());
  ASSERT_EQ(task.labels(),
            usage->executors(0).tasks(0).labels());

  EXPECT_CALL(exec, shutdown(_))
    .Times(AtMost(1));

  driver.stop();
  driver.join();
}

// This test verifies that slave will forward the estimation of the
// oversubscribed resources to the master.
TEST_F(OversubscriptionTest, ForwardUpdateSlaveMessage)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  Future<SlaveRegisteredMessage> slaveRegistered =
    FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);

  MockResourceEstimator resourceEstimator;

  EXPECT_CALL(resourceEstimator, initialize(_));

  Queue<Resources> estimations;
  EXPECT_CALL(resourceEstimator, oversubscribable())
    .WillOnce(InvokeWithoutArgs(&estimations, &Queue<Resources>::get));

  slave::Flags flags = CreateSlaveFlags();

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &resourceEstimator, flags);
  ASSERT_SOME(slave);

  AWAIT_READY(slaveRegistered);

  Future<UpdateSlaveMessage> update =
    FUTURE_PROTOBUF(UpdateSlaveMessage(), _, _);

  Clock::pause();
  // No update should be sent until there is an estimate.
  Clock::advance(flags.oversubscribed_resources_interval);
  Clock::settle();

  ASSERT_FALSE(update.isReady());

  // Inject an estimation of oversubscribable resources.
  Resources resources = createRevocableResources("cpus", "1");
  estimations.put(resources);

  AWAIT_READY(update);

  EXPECT_TRUE(update->has_resource_categories());
  EXPECT_TRUE(update->resource_categories().has_oversubscribed());
  EXPECT_TRUE(update->resource_categories().oversubscribed());
  EXPECT_EQ(update->oversubscribed_resources(), resources);

  // Ensure the metric is updated.
  JSON::Object metrics = Metrics();
  ASSERT_EQ(
      1u,
      metrics.values.count("master/messages_update_slave"));
  ASSERT_EQ(
      1u,
      metrics.values["master/messages_update_slave"]);

  ASSERT_EQ(
      1u,
      metrics.values.count("master/cpus_revocable_total"));
  ASSERT_EQ(
      1.0,
      metrics.values["master/cpus_revocable_total"]);
}

// This test verifies that a framework that accepts revocable
// resources can launch a task with revocable resources.
TEST_F(OversubscriptionTest, RevocableOffer)
{
  // Start the master.
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  // Start the slave with mock executor and test resource estimator.
  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  MockResourceEstimator resourceEstimator;

  EXPECT_CALL(resourceEstimator, initialize(_));

  Queue<Resources> estimations;
  EXPECT_CALL(resourceEstimator, oversubscribable())
    .WillOnce(InvokeWithoutArgs(&estimations, &Queue<Resources>::get));

  slave::Flags flags = CreateSlaveFlags();

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &containerizer, &resourceEstimator, flags);
  ASSERT_SOME(slave);

  // Start the framework which accepts revocable resources.
  FrameworkInfo framework = DEFAULT_FRAMEWORK_INFO;
  framework.add_capabilities()->set_type(
      FrameworkInfo::Capability::REVOCABLE_RESOURCES);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, framework, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer>> offers1;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers1));

  driver.start();

  // Initially the framework will get all regular resources.
  AWAIT_READY(offers1);
  ASSERT_FALSE(offers1->empty());
  EXPECT_TRUE(Resources(offers1.get()[0].resources()).revocable().empty());

  Future<vector<Offer>> offers2;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers2))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  // Inject an estimation of oversubscribable cpu resources.
  estimations.put(createRevocableResources("cpus", "2"));

  Resources taskResources = createRevocableResources("cpus", "1");
  taskResources.allocate(framework.role());

  Resources executorResources = createRevocableResources("cpus", "1");
  executorResources.allocate(framework.role());

  // Now the framework will get revocable resources.
  AWAIT_READY(offers2);
  ASSERT_FALSE(offers2->empty());
  EXPECT_EQ(
      taskResources + executorResources,
      Resources(offers2.get()[0].resources()));

  // Now launch a task that uses revocable resources.
  TaskInfo task =
    createTask(offers2.get()[0].slave_id(), taskResources, "", exec.id);

  task.mutable_executor()->mutable_resources()->CopyFrom(executorResources);

  EXPECT_CALL(exec, registered(_, _, _, _));

  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  driver.launchTasks({offers1.get()[0].id(), offers2.get()[0].id()}, {task});

  AWAIT_READY(status);
  EXPECT_EQ(TASK_RUNNING, status->state());

  EXPECT_CALL(exec, shutdown(_))
    .Times(AtMost(1));

  driver.stop();
  driver.join();
}

// This test verifies that when the master receives a new estimate for
// oversubscribed resources it rescinds outstanding revocable offers.
// In this test the oversubscribed resources are increased, so the master
// will send out new offers with increased revocable resources.
TEST_F(OversubscriptionTest, RescindRevocableOfferWithIncreasedRevocable)
{
  // Pause the clock because we want to manually drive the allocations.
  Clock::pause();

  // Start the master.
  master::Flags masterFlags = CreateMasterFlags();
  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
  ASSERT_SOME(master);

  // Start the slave with test resource estimator.
  MockResourceEstimator resourceEstimator;

  EXPECT_CALL(resourceEstimator, initialize(_));

  Queue<Resources> estimations;
  // We expect 2 calls for 2 estimations.
  EXPECT_CALL(resourceEstimator, oversubscribable())
    .Times(2)
    .WillRepeatedly(InvokeWithoutArgs(&estimations, &Queue<Resources>::get));

  slave::Flags agentFlags = CreateSlaveFlags();

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &resourceEstimator, agentFlags);
  ASSERT_SOME(slave);

  // Start the framework which desires revocable resources.
  FrameworkInfo framework = DEFAULT_FRAMEWORK_INFO;
  framework.add_capabilities()->set_type(
      FrameworkInfo::Capability::REVOCABLE_RESOURCES);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, framework, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Queue<Offer> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillRepeatedly(EnqueueOffers(&offers));

  driver.start();

  // Initially the framework will get all regular resources.
  Clock::advance(agentFlags.registration_backoff_factor);
  Clock::advance(masterFlags.allocation_interval);
  Clock::settle();

  ASSERT_EQ(1u, offers.size());
  EXPECT_TRUE(Resources(offers.get()->resources()).revocable().empty());

  // Inject an estimation of oversubscribable resources.
  Resources resources1 = createRevocableResources("cpus", "1");
  estimations.put(resources1);

  // Now the framework will get revocable resources.
  Clock::settle();

  EXPECT_EQ(1u, offers.size());
  Future<Offer> offer = offers.get();
  AWAIT_READY(offer);
  EXPECT_EQ(allocatedResources(resources1, framework.role()),
            Resources(offer->resources()));

  Future<OfferID> offerId;
  EXPECT_CALL(sched, offerRescinded(&driver, _))
    .WillOnce(FutureArg<1>(&offerId));

  // Inject another estimation of increased oversubscribable resources
  // while the previous revocable offer is outstanding.
  Resources resources2 = createRevocableResources("cpus", "3");
  estimations.put(resources2);

  // Advance the clock for the slave to send the new estimate.
  Clock::advance(agentFlags.oversubscribed_resources_interval);
  Clock::settle();

  // The previous revocable offer should be rescinded.
  AWAIT_EXPECT_EQ(offer->id(), offerId);

  // The allocation run triggered by the agent resource update may or
  // may not take into account the rescinded offer due to a race
  // between the dispatched allocation and the recovery of the resources
  // from the recinded offer. Therefore we advance the clock after these
  // resources are recovered to trigger a batch allocation to make sure
  // all resources are allocated.
  Clock::settle();
  Clock::advance(masterFlags.allocation_interval);
  Clock::settle();

  ASSERT_GT(offers.size(), 0);

  // The total offered resources after the latest estimate.
  Resources resources3;
  for (size_t i = 0; i < offers.size(); i++) {
    resources3 += offers.get()->resources();
  }

  // The offered resources should match the resource estimate.
  EXPECT_EQ(allocatedResources(resources2, framework.role()), resources3);

  driver.stop();
  driver.join();
}

// This test verifies that when the master receives a new estimate for
// oversubscribed resources it rescinds outstanding revocable offers.
// In this test the oversubscribed resources are decreased, so the
// master will send out only one offer with the latest oversubscribed
// resources from the resource estimator.
TEST_F(OversubscriptionTest, RescindRevocableOfferWithDecreasedRevocable)
{
  // Pause the clock because we want to manually drive the allocations.
  Clock::pause();

  // Start the master.
  master::Flags masterFlags = CreateMasterFlags();
  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
  ASSERT_SOME(master);

  // Start the slave with test resource estimator.
  MockResourceEstimator resourceEstimator;

  EXPECT_CALL(resourceEstimator, initialize(_));

  Queue<Resources> estimations;
  // We expect 2 calls for 2 estimations.
  EXPECT_CALL(resourceEstimator, oversubscribable())
    .Times(2)
    .WillRepeatedly(InvokeWithoutArgs(&estimations, &Queue<Resources>::get));

  slave::Flags agentFlags = CreateSlaveFlags();

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &resourceEstimator, agentFlags);
  ASSERT_SOME(slave);

  // Start the framework which desires revocable resources.
  FrameworkInfo framework = DEFAULT_FRAMEWORK_INFO;
  framework.add_capabilities()->set_type(
      FrameworkInfo::Capability::REVOCABLE_RESOURCES);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, framework, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer>> offers1;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers1));

  driver.start();

  // Initially the framework will get all regular resources.
  Clock::advance(agentFlags.registration_backoff_factor);
  Clock::advance(masterFlags.allocation_interval);
  AWAIT_READY(offers1);
  ASSERT_FALSE(offers1->empty());
  EXPECT_TRUE(Resources(offers1.get()[0].resources()).revocable().empty());

  Future<vector<Offer>> offers2;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers2));

  // Inject an estimation of oversubscribable resources.
  Resources resources1 = createRevocableResources("cpus", "3");
  estimations.put(resources1);

  // Now the framework will get revocable resources.
  AWAIT_READY(offers2);
  ASSERT_FALSE(offers2->empty());
  EXPECT_EQ(allocatedResources(resources1, framework.role()),
            Resources(offers2.get()[0].resources()));

  Future<OfferID> offerId;
  EXPECT_CALL(sched, offerRescinded(&driver, _))
    .WillOnce(FutureArg<1>(&offerId));

  Future<vector<Offer>> offers3;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers3));

  // Inject another estimation of decreased oversubscribable resources
  // while the previous revocable offer is outstanding.
  Resources resources2 = createRevocableResources("cpus", "1");
  estimations.put(resources2);

  // Advance the clock for the slave to send the new estimate.
  Clock::advance(agentFlags.oversubscribed_resources_interval);
  Clock::settle();

  // The previous revocable offer should be rescinded.
  AWAIT_EXPECT_EQ(offers2.get()[0].id(), offerId);

  // Advance the clock to trigger a batch allocation, this will
  // allocate the oversubscribed resources that were rescinded.
  Clock::advance(masterFlags.allocation_interval);
  Clock::settle();

  // The new offer should include the latest oversubscribed resources.
  AWAIT_READY(offers3);
  ASSERT_FALSE(offers3->empty());
  EXPECT_EQ(allocatedResources(resources2, framework.role()),
            Resources(offers3.get()[0].resources()));

  driver.stop();
  driver.join();
}

// This test verifies the functionality of the fixed resource
// estimator. The total oversubscribed resources on the slave that
// uses a fixed resource estimator should stay the same.
TEST_F(OversubscriptionTest, FixedResourceEstimator)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  Future<SlaveRegisteredMessage> slaveRegistered =
    FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);

  Future<UpdateSlaveMessage> update =
    FUTURE_PROTOBUF(UpdateSlaveMessage(), _, _);

  loadFixedResourceEstimatorModule("cpus(*):2");

  slave::Flags flags = CreateSlaveFlags();
  flags.resource_estimator = FIXED_RESOURCE_ESTIMATOR_NAME;

  Owned<MasterDetector> detector = master.get()->createDetector();
  Try<Owned<cluster::Slave>> slave = StartSlave(detector.get(), flags);
  ASSERT_SOME(slave);

  AWAIT_READY(slaveRegistered);

  // Advance the clock for the slave to send the estimate.
  Clock::pause();
  Clock::advance(flags.oversubscribed_resources_interval);
  Clock::settle();

  AWAIT_READY(update);
  ASSERT_TRUE(update->has_resource_categories());
  ASSERT_TRUE(update->resource_categories().has_oversubscribed());
  ASSERT_TRUE(update->resource_categories().oversubscribed());

  Resources resources = update->oversubscribed_resources();
  EXPECT_SOME_EQ(2.0, resources.cpus());

  Clock::resume();

  // Launch a task that uses revocable resources and verify that the
  // total oversubscribed resources does not change.

  // We don't expect to receive an UpdateSlaveMessage because the
  // total oversubscribed resources does not change.
  EXPECT_NO_FUTURE_PROTOBUFS(UpdateSlaveMessage(), _, _);

  // Start the framework which desires revocable resources.
  FrameworkInfo framework = DEFAULT_FRAMEWORK_INFO;
  framework.add_capabilities()->set_type(
      FrameworkInfo::Capability::REVOCABLE_RESOURCES);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, framework, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(_, _, _));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());
  const Offer offer = offers.get()[0];

  // The offer should contain revocable resources.
  ASSERT_SOME_EQ(2.0, Resources(offer.resources()).revocable().cpus());

  // Now, launch a task that uses revocable resources.
  Resources taskResources = createRevocableResources("cpus", "1");
  taskResources += Resources::parse("mem:32").get();

  TaskInfo task = createTask(
      offer.slave_id(),
      taskResources,
      "sleep 1000");

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  driver.launchTasks(offer.id(), {task});

  AWAIT_READY(status);
  EXPECT_EQ(task.task_id(), status->task_id());
  EXPECT_EQ(TASK_STARTING, status->state());

  // Advance the clock for the slave to trigger the calculation of the
  // total oversubscribed resources. As we described above, we don't
  // expect a new UpdateSlaveMessage being generated.
  Clock::pause();
  Clock::advance(flags.oversubscribed_resources_interval);
  Clock::settle();
  Clock::resume();

  driver.stop();
  driver.join();
}

// This test verifies that the QoS Controller is able to fetch
// ResourceUsage statistics about running executor.
TEST_F(OversubscriptionTest, QoSFetchResourceUsage)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  const ResourceStatistics statistics = createResourceStatistics();

  // Make sure that containerizer will report stub statistics.
  EXPECT_CALL(containerizer, usage(_))
    .WillOnce(Return(statistics));

  MockQoSController controller;

  Future<lambda::function<Future<ResourceUsage>()>> usageCallback;

  // Catching callback which is passed to QoS Controller.
  EXPECT_CALL(controller, initialize(_))
    .WillOnce(DoAll(FutureArg<0>(&usageCallback), Return(Nothing())));

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave = StartSlave(
      detector.get(),
      &containerizer,
      &controller,
      CreateSlaveFlags());
  ASSERT_SOME(slave);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched, registered(&driver, _, _));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());

  TaskInfo task = createTask(offers.get()[0], "sleep 10", DEFAULT_EXECUTOR_ID);
  task.mutable_executor()->mutable_labels()->add_labels()->CopyFrom(
      createLabel("key", "value"));

  Future<TaskStatus> status;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  EXPECT_CALL(exec, registered(_, _, _, _));

  EXPECT_CALL(exec, launchTask(_, _))
    .WillOnce(SendStatusUpdateFromTask(TASK_RUNNING));

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(status);
  EXPECT_EQ(TASK_RUNNING, status->state());

  AWAIT_READY(usageCallback);

  Future<ResourceUsage> usage = usageCallback.get()();
  AWAIT_READY(usage);

  // Expecting the same statistics as these returned by mocked containerizer.
  ASSERT_EQ(1, usage->executors_size());
  EXPECT_EQ(usage->executors(0).executor_info().executor_id(),
            DEFAULT_EXECUTOR_ID);
  ASSERT_EQ(usage->executors(0).statistics(), statistics);
  ASSERT_EQ(task.executor().labels(),
            usage->executors(0).executor_info().labels());

  EXPECT_CALL(exec, shutdown(_))
    .Times(AtMost(1));

  driver.stop();
  driver.join();
}

// Ensures the slave forwards the estimation whenever receiving
// a registered or re-registered message from the master, even
// if the total oversubscribable resources does not change.
TEST_F(OversubscriptionTest, Reregistration)
{
  loadFixedResourceEstimatorModule("cpus(*):2");

  slave::Flags agentFlags = CreateSlaveFlags();
  agentFlags.resource_estimator = FIXED_RESOURCE_ESTIMATOR_NAME;

  Future<Nothing> slaveRecover = FUTURE_DISPATCH(_, &Slave::recover);

  StandaloneMasterDetector detector;

  Try<Owned<cluster::Slave>> slave = StartSlave(&detector, agentFlags);
  ASSERT_SOME(slave);

  AWAIT_READY(slaveRecover);

  // Advance the clock for the slave to compute an estimate.
  Clock::pause();
  Clock::advance(agentFlags.oversubscribed_resources_interval);
  Clock::settle();

  // Start a master, we expect the slave to send the update
  // message after registering!
  master::Flags masterFlags = CreateMasterFlags();
  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
  ASSERT_SOME(master);

  Future<SlaveRegisteredMessage> slaveRegistered =
    FUTURE_PROTOBUF(SlaveRegisteredMessage(), _, _);

  Future<UpdateSlaveMessage> update =
    FUTURE_PROTOBUF(UpdateSlaveMessage(), _, _);

  detector.appoint(master.get()->pid);

  Clock::advance(agentFlags.registration_backoff_factor);
  AWAIT_READY(slaveRegistered);
  AWAIT_READY(update);
  ASSERT_TRUE(update->has_resource_categories());
  ASSERT_TRUE(update->resource_categories().has_oversubscribed());
  ASSERT_TRUE(update->resource_categories().oversubscribed());

  Resources resources = update->oversubscribed_resources();
  EXPECT_SOME_EQ(2.0, resources.cpus());

  // Trigger a re-registration and expect another update message.
  Future<SlaveReregisteredMessage> slaveReregistered =
    FUTURE_PROTOBUF(SlaveReregisteredMessage(), _, _);

  update = FUTURE_PROTOBUF(UpdateSlaveMessage(), _, _);

  detector.appoint(master.get()->pid);

  // Clock::settle();
  Clock::advance(agentFlags.registration_backoff_factor);
  AWAIT_READY(slaveReregistered);
  AWAIT_READY(update);
  EXPECT_TRUE(update->has_resource_categories());
  EXPECT_TRUE(update->resource_categories().has_oversubscribed());
  EXPECT_TRUE(update->resource_categories().oversubscribed());
}

// Tests interactions between QoS Controller and slave. The
// TestQoSController's correction queue is filled and a mocked slave
// is checked for receiving the given correction.
TEST_F(OversubscriptionTest, ReceiveQoSCorrection)
{
  StandaloneMasterDetector detector;
  TestContainerizer containerizer;

  MockQoSController controller;

  Queue<list<QoSCorrection>> corrections;

  EXPECT_CALL(controller, corrections())
    .WillRepeatedly(InvokeWithoutArgs(
        &corrections,
        &Queue<list<QoSCorrection>>::get));

  MockSlave slave(CreateSlaveFlags(), &detector, &containerizer, &controller);

  Future<list<QoSCorrection>> qosCorrections;
  EXPECT_CALL(slave, _qosCorrections(_))
    .WillOnce(FutureArg<0>(&qosCorrections));

  spawn(slave);

  list<QoSCorrection> expected = { QoSCorrection() };
  corrections.put(expected);

  AWAIT_READY(qosCorrections);

  ASSERT_EQ(qosCorrections->size(), 1u);

  // TODO(nnielsen): Test for equality of QoSCorrections.

  terminate(slave);
  wait(slave);
}

// This test verifies that a QoS controller can kill a running task,
// and that this results in sending a TASK_LOST status update with
// REASON_EXECUTOR_PREEMPTED if the framework is not partition-aware.
TEST_F(OversubscriptionTest, QoSCorrectionKill)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockQoSController controller;

  Queue<list<mesos::slave::QoSCorrection>> corrections;

  EXPECT_CALL(controller, corrections())
    .WillRepeatedly(InvokeWithoutArgs(
        &corrections,
        &Queue<list<mesos::slave::QoSCorrection>>::get));

  Future<lambda::function<Future<ResourceUsage>()>> usageCallback;

  // Catching callback which is passed to the QoS Controller.
  EXPECT_CALL(controller, initialize(_))
    .WillOnce(DoAll(FutureArg<0>(&usageCallback), Return(Nothing())));

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &controller, CreateSlaveFlags());
  ASSERT_SOME(slave);

  // Verify presence and initial value of counter for preempted
  // executors.
  JSON::Object snapshot = Metrics();
  EXPECT_EQ(1u, snapshot.values.count("slave/executors_preempted"));
  EXPECT_EQ(0u, snapshot.values["slave/executors_preempted"]);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);

  Future<FrameworkID> frameworkId;
  EXPECT_CALL(sched, registered(&driver, _, _))
    .WillOnce(FutureArg<1>(&frameworkId));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(frameworkId);

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());

  TaskInfo task = createTask(offers.get()[0], "sleep 10");

  Future<TaskStatus> status0;
  Future<TaskStatus> status1;
  Future<TaskStatus> status2;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status0))
    .WillOnce(FutureArg<1>(&status1))
    .WillOnce(FutureArg<1>(&status2))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(status0);
  ASSERT_EQ(TASK_STARTING, status0->state());

  AWAIT_READY(status1);
  ASSERT_EQ(TASK_RUNNING, status1->state());

  AWAIT_READY(usageCallback);

  Future<ResourceUsage> usage = usageCallback.get()();
  AWAIT_READY(usage);

  // Expecting the same statistics as these returned by mocked containerizer.
  ASSERT_EQ(1, usage->executors_size());

  const ResourceUsage::Executor& executor = usage->executors(0);
  // Carry out kill correction.
  QoSCorrection killCorrection;

  QoSCorrection::Kill* kill = killCorrection.mutable_kill();
  kill->mutable_framework_id()->CopyFrom(frameworkId.get());
  kill->mutable_executor_id()->CopyFrom(executor.executor_info().executor_id());
  kill->mutable_container_id()->CopyFrom(executor.container_id());

  corrections.put({killCorrection});

  // Verify task status is TASK_LOST.
  AWAIT_READY(status2);
  EXPECT_EQ(TASK_LOST, status2->state());
  EXPECT_EQ(TaskStatus::REASON_CONTAINER_PREEMPTED, status2->reason());
  EXPECT_EQ(TaskStatus::SOURCE_SLAVE, status2->source());

  // Verify that slave incremented metrics appropriately.
  snapshot = Metrics();
  EXPECT_EQ(1u, snapshot.values["slave/executors_preempted"]);
  EXPECT_EQ(1u, snapshot.values["slave/tasks_lost"]);
  EXPECT_EQ(0u, snapshot.values["slave/tasks_gone"]);

  driver.stop();
  driver.join();
}

// This test verifies that a QoS controller can kill a running task,
// and that this results in sending a TASK_GONE status update with
// REASON_EXECUTOR_PREEMPTED if the framework is partition-aware.
TEST_F(OversubscriptionTest, QoSCorrectionKillPartitionAware)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  MockQoSController controller;

  Queue<list<mesos::slave::QoSCorrection>> corrections;

  EXPECT_CALL(controller, corrections())
    .WillRepeatedly(InvokeWithoutArgs(
        &corrections,
        &Queue<list<mesos::slave::QoSCorrection>>::get));

  Future<lambda::function<Future<ResourceUsage>()>> usageCallback;

  // Catching callback which is passed to the QoS Controller.
  EXPECT_CALL(controller, initialize(_))
    .WillOnce(DoAll(FutureArg<0>(&usageCallback), Return(Nothing())));

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &controller, CreateSlaveFlags());
  ASSERT_SOME(slave);

  // Verify presence and initial value of counter for preempted
  // executors.
  JSON::Object snapshot = Metrics();
  EXPECT_EQ(1u, snapshot.values.count("slave/executors_preempted"));
  EXPECT_EQ(0u, snapshot.values["slave/executors_preempted"]);

  FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
  frameworkInfo.add_capabilities()->set_type(
      FrameworkInfo::Capability::PARTITION_AWARE);

  MockScheduler sched;
  MesosSchedulerDriver driver(
      &sched, frameworkInfo, master.get()->pid, DEFAULT_CREDENTIAL);

  Future<FrameworkID> frameworkId;
  EXPECT_CALL(sched, registered(&driver, _, _))
    .WillOnce(FutureArg<1>(&frameworkId));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(&driver, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(frameworkId);

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());

  TaskInfo task = createTask(offers.get()[0], "sleep 10");

  Future<TaskStatus> status0;
  Future<TaskStatus> status1;
  Future<TaskStatus> status2;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&status0))
    .WillOnce(FutureArg<1>(&status1))
    .WillOnce(FutureArg<1>(&status2))
    .WillRepeatedly(Return());       // Ignore subsequent updates.

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(status0);
  ASSERT_EQ(TASK_STARTING, status0->state());

  AWAIT_READY(status1);
  ASSERT_EQ(TASK_RUNNING, status1->state());

  AWAIT_READY(usageCallback);

  Future<ResourceUsage> usage = usageCallback.get()();
  AWAIT_READY(usage);

  // Expecting the same statistics as these returned by mocked containerizer.
  ASSERT_EQ(1, usage->executors_size());

  const ResourceUsage::Executor& executor = usage->executors(0);
  // Carry out kill correction.
  QoSCorrection killCorrection;

  QoSCorrection::Kill* kill = killCorrection.mutable_kill();
  kill->mutable_framework_id()->CopyFrom(frameworkId.get());
  kill->mutable_executor_id()->CopyFrom(executor.executor_info().executor_id());
  kill->mutable_container_id()->CopyFrom(executor.container_id());

  corrections.put({killCorrection});

  // Verify task status is TASK_GONE.
  AWAIT_READY(status2);
  EXPECT_EQ(TASK_GONE, status2->state());
  EXPECT_EQ(TaskStatus::REASON_CONTAINER_PREEMPTED, status2->reason());
  EXPECT_EQ(TaskStatus::SOURCE_SLAVE, status2->source());

  // Verify that slave incremented metrics appropriately.
  snapshot = Metrics();
  EXPECT_EQ(1u, snapshot.values["slave/executors_preempted"]);
  EXPECT_EQ(1u, snapshot.values["slave/tasks_gone"]);
  EXPECT_EQ(0u, snapshot.values["slave/tasks_lost"]);

  driver.stop();
  driver.join();
}

// This test verifies that when a framework re-registers with updated
// FrameworkInfo, it gets updated in the allocator. The steps involved
// are:
//   1. Launch a master, slave and scheduler.
//   2. Record FrameworkID of launched scheduler.
//   3. Check if revocable offers are being sent to the framework.
//   4. Launch a second scheduler which has the same FrameworkID as
//      the first scheduler and also has updated FrameworkInfo.
//   5. Check if revocable offers are being sent to the framework.
TEST_F(OversubscriptionTest, UpdateAllocatorOnSchedulerFailover)
{
  master::Flags masterFlags = MesosTest::CreateMasterFlags();
  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
  ASSERT_SOME(master);

  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  MockResourceEstimator resourceEstimator;

  EXPECT_CALL(resourceEstimator, initialize(_));

  Queue<Resources> estimations;
  EXPECT_CALL(resourceEstimator, oversubscribable())
    .WillOnce(InvokeWithoutArgs(&estimations, &Queue<Resources>::get));

  slave::Flags flags = CreateSlaveFlags();

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &containerizer, &resourceEstimator, flags);
  ASSERT_SOME(slave);

  // Launch the first (i.e., failing) scheduler and wait until
  // registered gets called to launch the second (i.e., failover)
  // scheduler with updated information.

  FrameworkInfo framework1 = DEFAULT_FRAMEWORK_INFO;

  MockScheduler sched1;
  MesosSchedulerDriver driver1(
      &sched1, framework1, master.get()->pid, DEFAULT_CREDENTIAL);

  Future<FrameworkID> frameworkId;
  EXPECT_CALL(sched1, registered(&driver1, _, _))
    .WillOnce(FutureArg<1>(&frameworkId));

  Future<vector<Offer>> offers1;
  EXPECT_CALL(sched1, resourceOffers(&driver1, _))
    .WillOnce(FutureArg<1>(&offers1));

  driver1.start();

  // Framework doesn't receive revocable resources because
  // it doesn't have the capability set.

  AWAIT_READY(offers1);
  ASSERT_FALSE(offers1->empty());
  EXPECT_TRUE(Resources(offers1.get()[0].resources()).revocable().empty());

  // Now launch the second (i.e., failover) scheduler using the
  // framework id recorded from the first scheduler, along with the
  // updated FrameworkInfo and wait until it gets a registered
  // callback.

  MockScheduler sched2;

  FrameworkInfo framework2 = DEFAULT_FRAMEWORK_INFO;
  framework2.mutable_id()->MergeFrom(frameworkId.get());
  auto capabilityType = FrameworkInfo::Capability::REVOCABLE_RESOURCES;
  framework2.add_capabilities()->set_type(capabilityType);

  MesosSchedulerDriver driver2(
      &sched2, framework2, master.get()->pid, DEFAULT_CREDENTIAL);

  Future<Nothing> sched2Registered;
  EXPECT_CALL(sched2, registered(&driver2, frameworkId.get(), _))
    .WillOnce(FutureSatisfy(&sched2Registered));

  // Scheduler1's expectations.

  EXPECT_CALL(sched1, offerRescinded(&driver1, _))
    .Times(AtMost(1));

  Future<Nothing> sched1Error;
  EXPECT_CALL(sched1, error(&driver1, "Framework failed over"))
    .WillOnce(FutureSatisfy(&sched1Error));

  EXPECT_CALL(sched2, resourceOffers(&driver2, _))
    .WillOnce(FutureArg<1>(&offers1));

  // Initially the framework will get all regular resources.

  driver2.start();

  AWAIT_READY(sched2Registered);

  AWAIT_READY(sched1Error);

  // Advance the clock and trigger a batch allocation.
  Clock::pause();
  Clock::advance(masterFlags.allocation_interval);
  Clock::resume();

  AWAIT_READY(offers1);
  ASSERT_FALSE(offers1->empty());
  EXPECT_TRUE(Resources(offers1.get()[0].resources()).revocable().empty());

  // Check if framework receives revocable offers.
  Future<vector<Offer>> offers2;
  EXPECT_CALL(sched2, resourceOffers(&driver2, _))
    .WillOnce(FutureArg<1>(&offers2));

  Resources revocable = createRevocableResources("cpus", "2");
  estimations.put(revocable);

  AWAIT_READY(offers2);
  ASSERT_FALSE(offers2->empty());
  EXPECT_EQ(allocatedResources(revocable, framework2.role()),
            Resources(offers2.get()[0].resources()));

  EXPECT_EQ(DRIVER_STOPPED, driver2.stop());
  EXPECT_EQ(DRIVER_STOPPED, driver2.join());

  EXPECT_EQ(DRIVER_ABORTED, driver1.stop());
  EXPECT_EQ(DRIVER_STOPPED, driver1.join());
}

TEST_F(OversubscriptionTest, RemoveCapabilitiesOnSchedulerFailover)
{
  // Start the master.
  master::Flags masterFlags = MesosTest::CreateMasterFlags();
  Try<Owned<cluster::Master>> master = StartMaster(masterFlags);
  ASSERT_SOME(master);

  // Start the slave with mock executor and test resource estimator.
  MockExecutor exec(DEFAULT_EXECUTOR_ID);
  TestContainerizer containerizer(&exec);

  MockResourceEstimator resourceEstimator;

  EXPECT_CALL(resourceEstimator, initialize(_));

  Queue<Resources> estimations;
  EXPECT_CALL(resourceEstimator, oversubscribable())
    .WillOnce(InvokeWithoutArgs(&estimations, &Queue<Resources>::get));

  slave::Flags flags = CreateSlaveFlags();

  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), &containerizer, &resourceEstimator, flags);
  ASSERT_SOME(slave);

  // Start the framework which accepts revocable resources.
  FrameworkInfo framework1 = DEFAULT_FRAMEWORK_INFO;
  framework1.add_capabilities()->set_type(
      FrameworkInfo::Capability::REVOCABLE_RESOURCES);

  MockScheduler sched1;
  MesosSchedulerDriver driver1(
      &sched1, framework1, master.get()->pid, DEFAULT_CREDENTIAL);

  Future<FrameworkID> frameworkId;
  EXPECT_CALL(sched1, registered(&driver1, _, _))
    .WillOnce(FutureArg<1>(&frameworkId));

  Future<vector<Offer>> offers1;
  EXPECT_CALL(sched1, resourceOffers(&driver1, _))
    .WillOnce(FutureArg<1>(&offers1));

  driver1.start();

  // Initially the framework will get all regular resources.
  AWAIT_READY(offers1);
  ASSERT_FALSE(offers1->empty());
  EXPECT_TRUE(Resources(offers1.get()[0].resources()).revocable().empty());

  Future<vector<Offer>> offers2;
  EXPECT_CALL(sched1, resourceOffers(&driver1, _))
    .WillOnce(FutureArg<1>(&offers2))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  // Inject an estimation of oversubscribable cpu resources.
  Resources revocable = createRevocableResources("cpus", "2");
  estimations.put(revocable);

  // Now the framework will get revocable resources.
  AWAIT_READY(offers2);
  ASSERT_FALSE(offers2->empty());
  EXPECT_EQ(allocatedResources(revocable, framework1.role()),
            Resources(offers2.get()[0].resources()));

  // Reregister the framework with removal of revocable resources capability.
  FrameworkInfo framework2 = DEFAULT_FRAMEWORK_INFO;
  framework2.mutable_id()->MergeFrom(frameworkId.get());

  MockScheduler sched2;
  MesosSchedulerDriver driver2(
      &sched2, framework2, master.get()->pid, DEFAULT_CREDENTIAL);

  EXPECT_CALL(sched2, registered(&driver2, _, _));

  // Scheduler1's expectations.

  EXPECT_CALL(sched1, offerRescinded(&driver1, _))
    .Times(AtMost(1));

  Future<Nothing> sched1Error;
  EXPECT_CALL(sched1, error(&driver1, "Framework failed over"))
    .WillOnce(FutureSatisfy(&sched1Error));

  Future<vector<Offer>> offers3;
  EXPECT_CALL(sched2, resourceOffers(&driver2, _))
    .WillOnce(FutureArg<1>(&offers3))
    .WillRepeatedly(Return());

  driver2.start();

  // Ensure resources are be recovered before a batch allocation is triggered.
  Clock::pause();
  Clock::settle();
  Clock::advance(masterFlags.allocation_interval);
  Clock::resume();

  AWAIT_READY(offers3);
  ASSERT_FALSE(offers3->empty());
  EXPECT_TRUE(Resources(offers3.get()[0].resources()).revocable().empty());

  driver1.stop();
  driver1.join();

  driver2.stop();
  driver2.join();
}

// This test verifies the functionality of the Load QoS Controller.
// If the total system load on the agent exceeds the configured threshold then
// it should evict all revocable executors.
// 1. Run first correction iteration with two revocable executors and the system
//    load below the thresholds. Eviction should not appear.
// 2. Run second correction iteration with the same executors and the system
//    5min load above the threshold. QoSCorrection message should appear.
TEST_F(OversubscriptionTest, LoadQoSController)
{
  // Configure Load QoS Controller. Revocable tasks will be killed when
  // the load 5min value will be above 7 or load 15min above 6.
  // This configuration could be a reasonable one for an 8 CPUs machine.
  const double loadThreshold5Min = 7;
  const double loadThreshold15Min = 6;

  // Prepare stubbed os::Load whose values are below thresholds.
  os::Load stubLoad;

  stubLoad.one = 1;
  stubLoad.five = loadThreshold5Min - 0.2;
  stubLoad.fifteen = loadThreshold15Min - 0.2;

  // Construct `LoadQoSController` with configured thresholds and fake
  // loadAverage lambda.
  LoadQoSController controller(loadThreshold5Min,
                               loadThreshold15Min,
                               [&stubLoad]() { return stubLoad; });

  // Prepare lambda creating ResourceUsage stub with two revocable executors.
  controller.initialize([this]() -> Future<ResourceUsage> {
    ResourceUsage usage;
    ResourceStatistics statistics = createResourceStatistics();

    Resources resources = Resources::parse("mem:128").get();
    resources += createRevocableResources("cpus", "1");

    // Prepare first revocable executor.
    ResourceUsage::Executor* executor = usage.add_executors();
    executor->mutable_executor_info()->CopyFrom(
        createExecutorInfo("framework", "executor1"));
    executor->mutable_allocated()->CopyFrom(resources);
    executor->mutable_statistics()->CopyFrom(statistics);

    // Prepare second revocable executor.
    resources = Resources::parse("mem:256").get();
    resources += createRevocableResources("cpus", "7");

    executor = usage.add_executors();
    executor->mutable_executor_info()->CopyFrom(
        createExecutorInfo("framework", "executor2"));
    executor->mutable_allocated()->CopyFrom(resources);
    executor->mutable_statistics()->CopyFrom(statistics);

    return usage;
  });

  // First correction iteration. All system loads are below the threshold.
  Future<list<QoSCorrection>> qosCorrections = controller.corrections();

  AWAIT(qosCorrections);

  // Expect no corrections.
  ASSERT_EQ(qosCorrections->size(), 0u);

  // Second correction iteration. Make system 5 minutes load above the
  // threshold.
  stubLoad.five = loadThreshold5Min + 0.2;
  qosCorrections = controller.corrections();

  AWAIT(qosCorrections);

  // Expect two corrections, since there were two revocable executors.
  ASSERT_EQ(qosCorrections->size(), 2u);
}

} // namespace tests {
} // namespace internal {
} // namespace mesos {

redpajama_set_name: RedPajamaGithub


text:
HomeNewsArticle Display
Get them off the X!
By Senior Airman Ruben Rios, 514th Air Mobility Wing / Published November 03, 2021
PHOTO DETAILS / DOWNLOAD HI-RES 1 of 6
U.S. Air Force National Guardsman Staff Sgt. Matthew Kensecki, 171st Air Refueling Wing, Pennsylvania, simulates calling in a nine-line during Tactical Combat Casualty Care training at the Medical Simulation and Training Center at JB MDL, N.J., October 31, 2021. True to the concept of Air Force Total Force Integration, reserve, guard, and active duty squadrons came together to develop in this potentially life-saving course.
U.S. Airmen from the 514th Air Mobility Wing and the 421st Combat Training Squadron, both at Joint Base McGuire-Dix-Lakehurst, New Jersey, the 171st Air Refueling Wing, Pennsylvania, and the Office of the Surgeon General, Headquarters U.S. Air Force, Virginia, simulate retrieving a fallen comrade while providing tactical cover during the care under fire portion of a Tactical Combat Casualty Care course at the Medical Simulation and Training Center at JB MDL, N.J., October 31, 2021. The course was designed to provide members who are not normally involved in combat environments the skills to survive and care for casualties in the event they are under attack.
U.S. Airmen from the 514th Air Mobility Wing, Joint Base McGuire-Dix-Lakehurst, New Jersey, and the 171st Air Refueling Wing, Pennsylvania, simulate calling in a nine-line while providing patient care and transport during Tactical Combat Casualty Care training at the Medical Simulation and Training Center at JB MDL, N.J., October 31, 2021. True to the concept of Air Force Total Force Integration, reserve, guard, and active duty squadrons came together to participate in this potentially life-saving course.
U.S. Airmen from the 514th Air Mobility Wing and the 421st Combat Training Squadron, both at Joint Base McGuire-Dix-Lakehurst, New Jersey, the 171st Air Refueling Wing, Pennsylvania, and the Office of the Surgeon General, Headquarters U.S. Air Force, Virginia, simulate taking cover during the tactical maneuvers portion of a Tactical Combat Casualty Care course at the Medical Simulation and Training Center at JB MDL, N.J., October 31, 2021. The course was designed to provide members who are not normally involved in combat environments the skills to survive and care for casualties in the event they are under attack.
U.S. Air Force National Guardsman Senior Airman Katelynn McFall, 171st Air Refueling Wing, Pennsylvania, and Reserve Citizen Airman Technical Sgt. Kevin Hyde, 514th Aeromedical Staging Squadron, Joint Base McGuire-Dix-Lakehurst, New Jersey, simulate providing care under fire on an "injured comrade" during the mass casualty incident exercise of the Tactical Combat Casualty Care course at the Medical Simulation and Training Center at JB MDL, N.J., October 31, 2021. True to the concept of Air Force Total Force Integration, reserve, guard, and active duty squadrons came together to participate in this potentially life-saving course.
U.S. Airmen from the 514th Air Mobility Wing and the 421st Combat Training Squadron, both at Joint Base McGuire-Dix-Lakehurst, New Jersey, the 171st Air Refueling Wing, Pennsylvania, and the Office of the Surgeon General, Headquarters U.S. Air Force, Virginia, pose for a photo at the Medical Simulation and Training Center at JB MDL, N.J., October 31, 2021. The Airmen participated in a pilot program Tactical Combat Casualty Care course designed to provide members who are not normally involved in combat environments the skills to survive and care for casualties in the event they are under attack.
Joint Base McGuire-Dix-Lakehurst, N.J. -- We're not talking about a treasure map here. In a combat environment, the X is a place you do not want to be. It's not easy to talk about but, caught between live fire while your brother or sister-in-arms is bleeding out, what do you do? When faced with overwhelming odds, many experts will say, "refer back to your training," and that is exactly what the Combat Lifesaver Tactical Combat Casualty Care course tries to ingrain in its students: the skills to save lives.
U.S. Airmen from the 514th Air Mobility Wing and the 421st Combat Training Squadron, both at Joint Base McGuire-Dix-Lakehurst, New Jersey, the 171st Air Refueling Wing, Pennsylvania, and Office of the Surgeon General, Headquarters U.S. Air Force, Virginia, participated in a test of concept TCCC course at JB MDL, N.J., October 30-31, 2021.
At the helm of this pilot program was the 514th Aeromedical Staging Squadron, 514th AMW, who designed the TCCC course to provide members who are not normally involved in combat environments the skills to survive and care for casualties in the event they are under attack. Course students included Airmen from both medical and non-medical career fields, and ranged from airman first class to brigadier general.
"The individuals who participated in this class came from many different backgrounds and career fields," said Brig. Gen. Bonnie J. Bosler, mobilization assistant to the director of medical operations, Office of the Surgeon General. "We have representation from both the guard and reserve, as well as active duty, with exceptional instructors from all three components."
True to the concept of Air Force Total Force Integration, the 421st CTS, an active duty squadron, the 514th ASTS and 514th Aeromedical Evacuation Squadron, both reserve squadrons, and the 171st ARW, a guard wing came together to develop this potentially life-saving course.
"This course was a unique collaboration between the teams at JB MDL and the 171st ARW," said 1st Lt. Heather Edsall, 171st ARW emergency trauma nurse and TCCC cadre. "We utilized non-traditional means of communication to take a foundational idea and fully developed it into a training opportunity that could pave the way for additional Joint Force Integration offerings."
Participants began by reading course materials online with check points to track their understanding. From there, students came to the course in-person with a base knowledge, so that they could more efficiently get to the hands-on portion of the class.
"We were able to take the information from the course material and then apply those foundational skills to hands-on practice to give us the confidence to be able to perform our job in any situation," said Bosler.
Skills that were practiced included tourniquet application, splinting, trauma patient care and transport, providing care under fire, tactical maneuvers, and calling in a nine-line.
"The goal is to integrate combat ready, medical skills across all career fields to provide a uniform standard of care and survival regardless of what Air Force Specialty Code a service member has," said Staff Sgt. Michael Sicola, 514th ASTS flight medical technician and TCCC cadre. "Ultimately, we want to give them the tools they need to make it back home."
Though only a pilot program, the potential for the TCCC sees no end.
"I hope to continue the growth of the program and maybe even become a training site for instructors so they can bring back the training to their home units," said Major Jonathan Trager, 514th ASTS critical care air transport team physician and TCCC program medical director. "The ultimate goal is to create a joint service training center for medical care, evacuation, and en route care."
Until then, the TCCC course will continue to teach those who are lucky enough to participate the skills to save the lives of not only our military service members, but anyone who needs it!
"Seeing six other Guardsmen from the 171st fully immersed in this multi-component environment alongside active duty and reserve was an invaluable experience for all, and one of the most fulfilling experiences of my 20 plus year military career," said Edsall. "This program equips our members with one of the single most important things we can arm our Airmen with, both stateside and down range, and that is the knowledge on how to save a life."

redpajama_set_name: RedPajamaCommonCrawl


How and why do we collect this collect this information?
We collect this information from our newsletter and subscribers to keep you informed of news, events and anything that may be of interest to the reader.
We endeavour to ensure that your data is stored securely and to prevent unauthorised access. We have measures in place to protect your information and this is monitored regularly.
Information is kept for as long as long as you are an active subscriber.
Do we disclose, share or sell any information to outside parties?
We do not sell, trade, or otherwise transfer to outside parties your personally identifiable information. This does not include trusted third parties who assist us in operating our website, conducting our business, or servicing you, so long as those parties agree to keep this information confidential. We may also release your information if/when we believe release is appropriate to comply with the law, enforce our site policies, or protect ours or others' rights, property, or safety. However, non-personally identifiable visitor information, such as site demographics, may be provided to other parties for marketing, advertising, or other uses.
Yes. Cookies are small files that a site or its service provider transfers to your computer's hard drive through your web browser (if you allow), that enable the sites or service providers systems to recognise your browser, and capture and remember certain information.
You may inform us of any changes in your personal data and we will be happy to update, verify or remove. This can be done by contacting our Data Protection Officer using the contact details below.


text:
Lead Areas
Platt Branch Wildlife and Environmental Area
Platt Branch - History
Habitat and Management
The area that is now the Platt Branch WEA was listed as "unexplored prairie" on a government map from the 1850s. The area remained virtually unsettled and was used for hunting, grazing, settlement and timbering over the years. Most of the major land-use changes started during the 1900s, with turpentine and timber industries booming during the 1920s. Several older pines still provide evidence of turpentining scars. Timber harvesting slowed until the late 1980s when about 100 acres of pines were cut in the southwestern segment.
Aerial photographs from 1941 show several home sites in the area, and one 1939 gravestone in the African Methodist Episcopal Church cemetery gives proof of a temporary settlement. Yet, only several old sand roads, small clearings and two well sites are still in existence.
Before the 1947 fence law in Florida, this area was "free range" for cattle. The property was fenced during the 1970s and subjected to more continuous cattle grazing for about 20 years. Cattle were removed from the site in 1993, and no grazing has occurred since. Aerial photos reveal that there were no large clearings as late as the 1950s, although more than 100 adjacent acres were cleared in the 1960s, with land converted to pasture. The trend continued as many acres of flatwoods and oak scrub were converted to pasture during the 1970s and 1980s.
Minor wetland drainage activities began during the 1950s. These ditches served mostly to speed the runoff of water during periods of high rainfall and did little to change the water levels during normal conditions. Several cattle ponds still drain along some wetland margins.
Platt Branch was identified by FWC personnel during the late 1980s as a site for potential state acquisition because of its value to listed species and high quality natural plant communities. The property was acquired by the state in 1995.


This page displays sold house prices for Meadow Park in Aylesbury.
Meadow Park in Stoke Mandeville, Aylesbury consists predominantly of detached houses. Properties on Meadow Park typically have values around £450,000 - £600,000, but larger detached houses can command upwards of £600,000.
Map showing Meadow Park in Aylesbury.


text:
Matthew Morgan & Jocelyn Cooper
Producers of The Afropunk Festival
Arts & Humanities, Diversity Speakers, Entertainers, Producers and Directors, Virtual Speakers
Matthew Morgan & Jocelyn Cooper Biography
The Afropunk Festival is an annual arts festival that includes live music, film, fashion, and art produced by black artists. The festival made its first debut at the Brooklyn Academy of Music in 2005, and has since expanded to other parts of the world.
Contact a speaker booking agent to check availability on Matthew Morgan & Jocelyn Cooper and other top speakers and celebrities.
AFROPUNK Presents The Triptych: A Live Stream (2/2/15) - YouTube
Join director Terence Nance, along with AfroPunk producers Jocelyn Cooper and...
HOW TO BOOK Matthew Morgan & Jocelyn Cooper?
Our booking agents have successfully helped clients around the world secure talent like Matthew Morgan & Jocelyn Cooper for both live and virtual events for over 15 years. The team at All American Entertainment represents and listens to the needs of organizations and corporations seeking to hire keynote speakers, celebrities or entertainers for speaking engagements, personal appearances, product endorsements, or corporate entertainment. Fill out a booking request form for Matthew Morgan & Jocelyn Cooper, or call our office at 1.800.698.2536 to discuss your upcoming event. One of our experienced agents will be happy to help you get pricing information and check availability for Matthew Morgan & Jocelyn Cooper or any other celebrity of your choice.
HOW MUCH DOES IT COST TO BOOK Matthew Morgan & Jocelyn Cooper?
Booking fees for Matthew Morgan & Jocelyn Cooper, or any other speakers and celebrities, are determined based on a number of factors and may change without notice. Pricing often varies between live and virtual events. Other factors that can affect speaker fees include the talent's schedule, market conditions, length of presentation, and the location of the event. The live and virtual event speaking fees listed on this website are intended to serve as a guideline only. In some cases, the actual quote may be above or below the stated range. For the most current fee to hire Matthew Morgan & Jocelyn Cooper, please fill out the booking request form or call our office at 1.800.698.2536 to speak with an experienced booking agent.
WHO IS THE AGENT FOR Matthew Morgan & Jocelyn Cooper?
All American Entertainment has successfully secured celebrity talent like Matthew Morgan & Jocelyn Cooper for clients worldwide for more than 15 years. As a full-service talent booking agency, we have access to virtually any speaker or celebrity in the world. Our agents are happy and able to submit an offer to the speaker or celebrity of your choice, letting you benefit from our reputation and long-standing relationships in the industry. Fill out the booking request form or call our office at 1.800.698.2536, and one of our agents will assist you to book Matthew Morgan & Jocelyn Cooper for your next private or corporate function.
All American Speakers is a "buyers agent" and exclusively represents talent buyers, meeting planners and event professionals, who are looking to secure celebrities and speakers for personal appearances, speaking engagements, corporate entertainment, public relations campaigns, commercials, or endorsements. We do not exclusively represent Matthew Morgan & Jocelyn Cooper or claim ourselves as the exclusive booking agency, business manager, publicist, speakers bureau or management for Matthew Morgan & Jocelyn Cooper or any other speaker or celebrity on this website. For more information on how we work and what makes us unique, please read the AAE Advantage.
Director, Film Producer, and Actor; Best Known for...
Rapper, Producer, Screenwriter & Director; Known for "Sorry...
Discwoman
DJ Crew, Music Publishing Group & Activists
Actor & Producer Known for "Fresh Prince of Bel-Air," "I Am...
Singer-Songwriter, Producer & Entrepreneur; Known for the...
Kareem Burke
Entrepreneur, Record Executive, Film Producer & Co-Founder...
Singer, Songwriter, Record Producer, Music Video Director &...
Tariq Nasheed
Author, Film Producer Known for "Hidden Colors" Series
Singer-Songwriter, Rapper & Actress
Award-Winning Music producer and DJ
Rapper, Actor, Producer, Director & Writer Known for "21...
Film Director and Producer; Best Known for "Olympus Has...
Actor, Writer, Producer, Comedian & Director; CEO of Tyler...
Academy Award-Winning Writer, Producer, Actor & Director;...
Award-Winning Actress & Co-Founder of Bassett/Vance...
Kevin Abstract
Rapper; Singer-Songwriter; Director
Charles D. King
Entrepreneur, Investor, Activist, Producer, CEO of MACRO
Rick Famuyiwa
Director, Producer & Screenwriter; Known for "The Wood" and...
Film Director Known for "Ride Along" & "Think Like A Man"
Singer-Songwriter & Tony Award-Winning Actress Known for...
Matthew Morgan & Jocelyn Cooper Videos
Join director Terence Nance, along with AfroPunk producers Jocelyn Cooper and Matthew Morgan in this live online web event where they will ...
Speaker Lists Featuring Matthew Morgan & Jocelyn Cooper
Inspiring Speakers on the Full Color 50
Full Color Future recognizes top leaders of color in areas such as the arts, entrepreneurship, social activism and more. These diverse men and women have achieved enormous success and their work is paving the way to a more...
Browse All Keynote Speaker Lists »
FAQs on booking Matthew Morgan & Jocelyn Cooper
Matthew Morgan & Jocelyn Cooper is a keynote speaker and industry expert who speaks on a wide range of topics . The estimated speaking fee range to book Matthew Morgan & Jocelyn Cooper for your event is available upon request. Matthew Morgan & Jocelyn Cooper generally travels from Brooklyn, NY, USA and can be booked for (private) corporate events, personal appearances, keynote speeches, or other performances. Similar motivational celebrity speakers are F. Gary Gray, Boots Riley, Discwoman, Will Smith and Pharrell Williams. Contact All American Speakers for ratings, reviews, videos and information on scheduling Matthew Morgan & Jocelyn Cooper for an upcoming live or virtual event.
Matthew Morgan & Jocelyn Cooper Speaker Videos
Provide you with the speaking fee to book Matthew Morgan & Jocelyn Cooper or other celebrity appearance fees
Speakers Similar to Matthew Morgan & Jocelyn Cooper
Director, Film Producer, and Actor; Best Known for Directing "Straight Outta Compton" & "The Italian Job"
Rapper, Producer, Screenwriter & Director; Known for "Sorry To Bother You"
Actor & Producer Known for "Fresh Prince of Bel-Air," "I Am Legend," "Concussion" and "Suicide Squad"
Singer-Songwriter, Producer & Entrepreneur; Known for the Hit Single, "Happy"
Entrepreneur, Record Executive, Film Producer & Co-Founder of Roc-A-Fella Records
Singer, Songwriter, Record Producer, Music Video Director & Fashion Designer
Rapper, Actor, Producer, Director & Writer Known for "21 Jumpstreet" and "Straight Outta Compton"
Film Director and Producer; Best Known for "Olympus Has Fallen" & "The Equalizer"
Actor, Writer, Producer, Comedian & Director; CEO of Tyler Perry Studios
Academy Award-Winning Writer, Producer, Actor & Director; Best Known for "BlacKkKlansman" & "Malcolm X"
Award-Winning Actress & Co-Founder of Bassett/Vance Productions
Director, Producer & Screenwriter; Known for "The Wood" and "Brown Sugar"
Singer-Songwriter & Tony Award-Winning Actress Known for "The Color Purple" and Portraying Harriet Tubman in "Harriet"


Kilrea brownie troop has received a set of twenty high visibility vests from Specsavers Ballymena to help keep them safe when walking in winter. The giveaway was part of Specsavers' sponsorship of Road Safety Week and aimed to highlight the importance of being seen on the roads to young children.
Specsavers recommends that drivers also need to make sure that their vision is up to scratch before getting behind the wheel and should have an eye examination every two years. To make an appointment at the Specsavers store, Fairhill Shopping Centre you can call 02825648100.


It turns out that games on the Xbox One won't be held back by pesky little restrictions like region-locking. We can't wait for the flood of imports.
An article on Eurogamer features statements from Microsoft commenting on the news that it will be delaying launch in eight countries. Eurogamer asked if, given the region-free nature of the Xbox One, fans in those eight countries could import them from elsewhere. Microsoft responded by saying that the issue of online payments and local currency would still need to be implemented.
In their statement, Microsoft said, "When the console launches this November, we will support Xbox One in 13 markets. Xbox One may be used in all countries, including the non-launched markets. In addition, Xbox One games are not region locked. Any Xbox One game purchased at retail can be used in any country on any Xbox One."
They followed up by saying that, even though physical games could still work, valid payment methods would still need to be set up in order to purchase content on Xbox Live and that voice support for different languages still needs to be implemented.
But, at the very least, gamers in those eight countries can rest a little bit easier knowing they can buy an Xbox One from a different nation and start playing the games.
Let us know what you think of the Xbox One's games being region-free in the comments below.


Application was exceedingly sheer, meaning I still have visible nail lines, and … it's pink. Not this orange shade you see here under my halogen lights, and not the crimson you assume from the name. It's pink. Fuschia-pink under most lights. Not a bad colour, as it happens, but not what I wanted!
Also, the holograph-effect is barely visible on the nail.
It's a nice polish. But not a great one. I like it, but I don't love it. It's also started to chip after about 18 hours on the nail. Boo! Holographic polishes are notoriously chippy though, so maybe that's me being picky. I bought mine from eBay.
ooh that is not the colour I expected to see when I clicked on the link!
However, I really do like the colour it looks in the photos.
Shame it's not like that in real life.
I had one of these… they're from a very old OPI collection I think. I didn't like it on me, ironically it was too orange for my liking, so I swapped it!
It looks nice to me! But I haven't seen it in person, and am not a fan of fuchsia generally. It crossed my mind that this may be an eBay fake, if the colour and quality are not what you expected?


text:
USA Guide | USA Inspiration | USA Destinations | USA's Trains | USA Holidays and Tours
Memphis is the second largest city in Tennessee, and was named after the ancient Egyptian capital. Founded in 1819, the city became wealthy as one of America's largest cotton markets. Like much of the South, Memphis was briefly plunged into an economic depression after their defeat in the Civil War and the abolition of slavery. But it quickly rose from these ashes, thanks to its position on the Mississippi River and its location as a rail hub.
Order your free brochure Sign up to newsletter
Our guide to Memphis
Local sites to see
Sun Studio
The city is now perhaps best known for its 20th century musical heritage, and iconic performers made their records here. Many of the city's highlights are music-related. One such highlight is the Sun Studio.
In 1954, a 19-year-old trucker made this quiet recording studio infamous when he recorded 'That's All Right'. Although the song failed to chart, it was still Elvis Presley's first single and so many of his contemporaries flocked to the studio to record their songs. Jerry Lee Lewis, Roy Orbison, Carl Perkins and Johnny Cash all had hits originating from Sun Studios. The studio closed in 1959 and became a scuba-diving shop. But its soundproofing had never been removed and so in 1987, it was decided the studio should be restored to working condition - with a museum to commemorate its historical significance.
The Stax Museum
Another of Memphis' highlights is the Stax Museum, which stands of the site of the former Stax Studios. Otis Redding and Isaac Hayes were just two of the acts that put more than 230 records into America's Billboard Hot 100 for the famous label. Today the museum tells the story of the major operation that came to be known as 'Soulsville USA' through a range of audio and visual exhibits. The museum also provides space for up-and-coming talent to rehearse.
Holiday ideas for Memphis
Tracks of the Deep South
2023AprMayJunSepOct
2024FebAprMayJunSepOct
14 days from
Discover by Destination
AlaskaView more
AtlantaView more
BostonView more
ChicagoView more
Las VegasView more
Los AngelesView more
NashvilleView more
New OrleansView more
New YorkView more
San FranciscoView more
Washington D.C.View more
USAView more
USA's Trains
AmtrakView tours
North ConwayView tours
Lookout MountainView tours
DurangoView tours
Tennessee ValleyView tours
Grand CanyonView tours
Mount WashingtonView tours
Royal GorgeView tours
Prefer to browse our brochures!
Sign up to receive one of our Free holiday brochures and our email list to discover more about our fantastic holidays.
Order brochure Sign up to newsletter


text:
Oceana PARC Career Fair to Offer Rewarding Job Opportunities
May 29, 2019 in News
Written by PARC Retirement Living
Are you seeking meaningful work in a growing field? Do you take pride in delivering top-rated customer service while earning a living wage? And does the idea of a fun work environment in a brand-new building – located in a revitalized coastal community – excite you?
Then you won't want to miss Oceana PARC's first-ever career fair, held over two days on June 15 and 19, 2019.
Come out to meet the management team behind PARC Retirement Living's newest resort-style residence while learning about rewarding employment opportunities in the senior living sector. Find out why PARC is the ideal place to launch or expand your career and how Oceana PARC is the right fit for you. The career fair will take place from 10 a.m. to 4 p.m. each day at the White Rock Community Centre, where PARC staff will conduct on-site interviews.
"We decided to have a career fair so people could come to meet the Oceana PARC management team, learn more about who we are and why PARC is a great place to work," explains Tori Phillips, PARC's Human Resources Leader.
Why work at Oceana PARC?
Slated to open in September in central White Rock, the 23-storey/198-unit Oceana PARC will require a dedicated team of 50-60 employees when it reaches full capacity. "We know it's the team members in our communities that make PARC residences the best places to live," says Phillips. "As such, we're very excited to be an active member of the White Rock community and to offer employment opportunities to people who share our values."
Already involved with Friends of the Pier and other local groups, PARC also firmly believes in being a Living Wage Employer. In fact, PARC's commitment to such key values recently earned the company the Best Employer Award.
"It's important for us at PARC to support our communities in as many ways as possible. Some of the ways we do this are by constructing LEED-certified buildings, by partnering with organizations to strengthen bonds in our neighbourhoods and by making sure our team members are able to support themselves and their family members financially," says Phillips. "Being a Living Wage Employer is just one way that we say thank you to our amazing team members."
Potential Oceana PARC team members will be able to apply to a variety of full-time, part-time or casual positions including:
dining room supervisor
Work at a senior residence with a difference
New employees will not only reap the rewards of working with independent and active older adults, they'll also be joining a senior living company that stands apart from the rest. Indeed, from food to fitness, PARC's hospitality-style services and design make living at home feel like a never-ending holiday. And nowhere is this more true than at the new Oceana PARC.
For example, floor-to-ceiling windows, an ocean-themed colour palette and sailing rope accents will grace Oceana's casual and fine dining venues – serving daily gourmet meals prepared by Executive Chef Shaughn Halls. Also here, the first PARC Active Living seniors-oriented fitness centre will offer state-of-the-art exercise equipment and classes like Tai Chi and chair yoga. And then there are the suites, boasting ample natural light and city-ocean-mountain views off spacious balconies. All within walking distance of White Rock's world-famous waterfront – and all part of your new workplace environment!
As Phillips says: "It's an exciting time to be joining PARC. Being part of an opening is a great experience. As residents move into Oceana PARC, we'll need a core of dedicated and dynamic employees who are committed to having fun and to delivering customer service excellence. We're looking for upbeat, energetic and excited team members to join us."
Oceana PARC Career Fair
Dates: June 15 and 19, 2019
Time: 10 a.m.-4 p.m.
Location: White Rock Community Centre, 15154 Russell Ave., White Rock, B.C.
For more information or to schedule a career fair interview, email [email protected].
Mulberry PARC partners with programs that enrich the lives of independent seniors in Burnaby
PARC donates $1.2 million to Peace Arch Hospital Foundation
© 2020 PARC Retirement Living.


text:
[x] close image
Part of a series of 8 split release cassettes, hand-painted & numbered; Side A is our very own Carl Kruger for improvised, manipulated acoustic recordings through an unusual peep hole; the mysterious NJ9842 presents a lurching sound collage of unusual sources.
Format: CASSETTE
Packaging: Cassette
Carl Kruger
NJ9842
1 Evil Peep Hole 14:51
1 Paranoid Configuration Of Space And Time 14:08
"[...] Carl Kruger (I want to call him Professor Kruger for some reason, is that odd?) begins his side of this split with bubbles which sound more like boiling water than anything else. There are dings and shuffling and it doesn't just have that kitchen feel of dishes but rather the feel of forks hitting plates and that whole idea. It really feels like water is boiling on the stove and next to it is a pan and stirring utensil and Carl Kruger is cooking something up. And, no, the next time I boil water for pasta I am not going to record it and see if it sounds similar (I do not want to drop my phone in boiling water or any recording device for that matter)
Louder static bursts come out and then there is also some beeping. It's got this sort of harmonica vibe to it as well. By the end there is just this eerie sort of glitch where it sounds like something you might call "glitch" but at the same time it just really gives me the chills like something out of a classic horror movie. (For the record, classic horror movies are ones which came out before the 21st Century and usually involve John Carpenter or Leatherface) It is also needs to be noted that for most of this piece there is this muted primal grunting in the background which reminds me of Frankgoshit. But overall this does remind me of something influenced by Jay Peele, which I used to say a lot more than I do now so I'm glad it's coming back again.
NJ9842 begins Side B with an electronic symphony. Drum machine beats come out at random and then it turns to glitch because it just keeps repeating in a way. I used to have a lot of different CD players when I was in my teenage years. I'm not sure why, but I wanted to have all of these five disc changers and what not and I'd always have them for less than a year before they'd crap out. But when the CD would get stuck it'd just go into this repeat noise and that's kind of what I feel like I'm hearing in here. (Side Note: Anyone who wants to make glitch noise, definitely use some old multi-disc CD players from the late 1990's) One time, a Marilyn Manson CD got eaten by a six disc changer and I was like, "The power of Christ compells you!", trying to get it out and what not.
So anyway, there is a buzzing which comes out as well and I feel like we're in a video game or just on the outside looking in, kind of hearing the sounds of a video game consule. I don't really pay as much attention as I should to side lengths and everything- which I assume can be found at the Bandcamp link above- but there is a decent amount of dead air on here which I feel means that Professor Kruger's piece goes on for a bit longer than this one. I also wonder what NJ9842 stands for exactly. I can't remember the number pattern because 9842 doesn't really click with me, but I do remember it starts with "NJ" because of New Jersey, though it's probably just a name such as Nick Jonas. Could 9/8/42 be a birthday? Could someone that old be making this??
Another split from Bicephalic Records and, well, if you've not gotten into their split series yet this is the perfect time to do so because "1/11-GR opal" has two artists I've never really heard before but enjoy both immensely."-Joshua Macala, Raise by Gypsies
[NJ9842 is the northernmost demarcated point of the India-Pakistan cease fire line known as the Line of Control.
Get additional information at Raised by Gypsies
Sound, Noise, &c.
Organized Sound and Sample Based Music
New in Experimental & Electronic Music
CHANGES TO blind
evolvensume
(Squidco Records)
Are You Now Or Have You Ever Been
Flamingo Creatures
Fisch Versucht Das Sprechenlernen
(Discombobulate)
Odd Person / Miguel A. Garcia
NOOSPHERTILIZER V [CASSETTE + ART BOOKLET]
(Aubjects)
Amalgamated
Bathetic Resonance
(Mystery School Records)
Monas (Fisher / DeBlase / Millions)
Freedom [CASSETTE + DOWNLOAD]
Jackson / Baker / Kirshner
The Noisy Miner [CASSETTE with DOWNLOAD CODE]


text:
Cycling: Pardoe seventh in big stamina test
Reading Cycling Club were well represented in the London Cycling Association's Centenary 100-mile time trial at the weekend.
Mark Pardoe, Lucinda Seymour, Rupert Shute and Stephen Millward all faced the timekeeper for the long test based on the A31 in Hampshire.
The weather started cool and calm, but a rising wind brought the threat of rain showers.
Pardoe, who had returned from a family holiday the evening before, finished an excellent seventh in a time of 4hrs 4mins 3secs – nine seconds slower than his personal best for the course.
It was Seymour's first 100-mile time trial and she said: "I won't be doing another this year."
She added: "I did this one in order to qualify for the British Best All-Rounder competition.
"It was tougher mentally and physically than I expected it to be.
"Perhaps this was because of going round the same circuit five times, or the fact that the way out felt incredibly tough and the way back in was fast, which meant more effort to try and make up time.
"The support from the people watching and clapping for the last few laps, made all the difference in encouraging me to keep going."
The riders enjoyed a free buffet laid on after the race by Mick and Marion Fountain of Didcot Phoenix CC. The awards were made by Dennis Burrows, winner of the 1947 WLCA event.
Pardoe remarked: "It was excellent to see so many people stay on for the buffet and presentation.
"It was a wonderful event and organiser Jim Burgin should take credit for his part in making it all happen."
Selected results: 1 Nik Bowdler (Farnborough & Camberley CC) 3:43:50; 7 Mark Pardoe (Reading) 4:04:03; 22 Stephen Millward (Reading) 4:40:58; 28 Lucinda Seymour (Reading) 4:50:08; 31 Rupert Shute (Reading) 4:53:08
— Rod MacFadyen and Dave Gaida took part in a low-key Veterans Time Trial Association event on the Fifield 10-mile circuit.
MacFadyen was seventh with a time of 24:22, while Gaida recorded 29:32.
"It's a good circuit," said MacFadyen. "I was a little slower than I'd hoped, but a headwind on the lengthy Drift Road section did not help."
Fastest rider was Hillingdon's Graham Weeks, whose time of 22:37 beat the field by more than a minute.
— A thinly-attended Tuesday evening Reading CC club event saw MacFadyen record the fastest time on the challenging Bucklebury circuit.
Results: 1 Rod MacFadyen 41.13; 2 Steve Millward 41.53; 3 Trevor Bradbury 42.53; 4 J Enticknap 46.32; 5 Peter Watson 46.55; 6 Paul Marshall 52.23; two-up Stuart Pankhurst and M Nylam 51.54; Kevin Marshall did not finish.
—Next Sunday is a busy day for Reading as the club are promoting two separate events.
There is a 23-mile time trial on a Heckfield-based circuit organised by Dave Ridge.
Among those entered are Trevor Bradbury, Steve Fleming, Nick English, Ian Richardson, Mark Pardoe and Rod MacFadyen, along with Ray Hughes (Clarence Wheelers) and Tim Bedingfield (awcycles.co.uk).
Those seeking a different challenge are catered for by a 200km sportive ride through some of southern England's best cycling country.
The 'Kennet Flyer' criss-crosses the Ridgeway Trail seven times before reaching Marlborough, then heads for home on quiet country roads across the downs of Wiltshire, North Hampshire and West Berkshire before a final dash along the A4 to Theale. The route includes a substantial amount of climbing but the long fast stretches of downland riding will encourage participants to post impressive times for this long sportif. Those wanting a shorter day in the saddle are catered for with the 'Lambourn Chase'.
This covers a distance of 85km with a mix of both hills and open stretches allowing faster riding.
Both events can be entered online at www.readingccsportive.co.uk.
Andy CarrollBelgian giants Anderlecht linked with January transfer move for out-of-favour Reading FC strikerReading FC striker George Puscas has struggled this season in front of goal and the Romanian has been linked with a move away from the Royals during the January transfer window
Veljko Paunovic and Reading FC given timely boost ahead of Luton Town amid Liam Moore decision
Reading FCReading FC could welcome back experienced defender Michael Morrison in the near future after he featured for the Royals' under-23s side against Newcastle United on Friday
Veljko Paunovic sends key message to Reading FC players and fans ahead of Luton Town clash
Reading FCReading FC have two home games this week in the Championship, with the Royals hosting Luton Town on Wednesday night before the visit of Huddersfield Town on Saturday
Reading FC hero Jobi McAnuff issues verdict on Andy Carroll's future amid Burnley transfer links
Andy CarrollFormer Reading FC captain Jobi McAnuff has spoken about the future of Andy Carroll, with the former Newcastle United and Liverpool striker linked with Burnley after his short-term Royals deal
Josh Laurent has message for Reading FC fans as he pinpoints what needs to change for Royals
Reading FCReading FC endured a difficult end to a terrible week on the pitch as Royals lost out 2-1 against Middlesbrough, having led at the Riverside Stadium through Andy Carroll's goal


My Observations as a person, parent and Me. I promote blogs on Parenting, General Niche, and My Observations as a person.
Ward Girl not Award Girl #WomensDay – Keep Smiling !!
The Women of Substance #WomensDay – Keep Smiling !!
A Mother's Guide – How to Calm Colicky Baby #MotherSparsh – Keep Smiling !!
How to Arrange Diaper Bag Essentials for Your Baby – Keep Smiling !!
Kalpana M. – I Took the Road Less Travelled! #OrganicFarmer #WomensDay – Keep Smiling !!