blob: d796f328de3c614e510b75021c405563d413c18e [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
#include <google/protobuf/message.h>
#include <mesos/agent/agent.hpp>
#include <mesos/mesos.hpp>
#include <mesos/resources.hpp>
#include <mesos/master/master.hpp>
#include <mesos/executor/executor.hpp>
#include <mesos/master/master.hpp>
#include <mesos/maintenance/maintenance.hpp>
#include <mesos/resource_provider/resource_provider.hpp>
#include <mesos/scheduler/scheduler.hpp>
#include <mesos/v1/mesos.hpp>
#include <mesos/v1/resources.hpp>
#include <mesos/v1/agent/agent.hpp>
#include <mesos/v1/executor/executor.hpp>
#include <mesos/v1/master/master.hpp>
#include <mesos/v1/resource_provider/resource_provider.hpp>
#include <mesos/v1/maintenance/maintenance.hpp>
#include <mesos/v1/scheduler/scheduler.hpp>
#include <stout/foreach.hpp>
#include <stout/json.hpp>
#include "messages/messages.hpp"
namespace mesos {
namespace internal {
// Helpers for evolving types between versions. Please add as necessary!
v1::AgentID evolve(const SlaveID& slaveId);
v1::AgentInfo evolve(const SlaveInfo& slaveInfo);
v1::DomainInfo evolve(const DomainInfo& domainInfo);
v1::ExecutorID evolve(const ExecutorID& executorId);
v1::ExecutorInfo evolve(const ExecutorInfo& executorInfo);
v1::FileInfo evolve(const FileInfo& fileInfo);
v1::FrameworkID evolve(const FrameworkID& frameworkId);
v1::FrameworkInfo evolve(const FrameworkInfo& frameworkInfo);
v1::InverseOffer evolve(const InverseOffer& inverseOffer);
v1::KillPolicy evolve(const KillPolicy& killPolicy);
v1::MachineID evolve(const MachineID& machineId);
v1::MasterInfo evolve(const MasterInfo& masterInfo);
v1::Offer evolve(const Offer& offer);
v1::OfferID evolve(const OfferID& offerId);
v1::Resource evolve(const Resource& resource);
v1::Resources evolve(const Resources& resources);
v1::Task evolve(const Task& task);
v1::TaskID evolve(const TaskID& taskId);
v1::TaskInfo evolve(const TaskInfo& taskInfo);
v1::TaskStatus evolve(const TaskStatus& status);
v1::agent::Call evolve(const mesos::agent::Call& call);
v1::agent::ProcessIO evolve(const mesos::agent::ProcessIO& processIO);
v1::agent::Response evolve(const mesos::agent::Response& response);
v1::maintenance::ClusterStatus evolve(
const maintenance::ClusterStatus& cluster);
v1::maintenance::Schedule evolve(const maintenance::Schedule& schedule);
v1::master::Response evolve(const mesos::master::Response& response);
v1::resource_provider::Call evolve(const mesos::resource_provider::Call& call);
v1::resource_provider::Event evolve(
const mesos::resource_provider::Event& event);
v1::scheduler::Call evolve(const scheduler::Call& call);
// Helper for repeated field evolving to 'T1' from 'T2'.
template <typename T1, typename T2>
google::protobuf::RepeatedPtrField<T1> evolve(
google::protobuf::RepeatedPtrField<T2> t2s)
google::protobuf::RepeatedPtrField<T1> t1s;
foreach (const T2& t2, t2s) {
return t1s;
v1::scheduler::Event evolve(const scheduler::Event& event);
// Helper functions that evolve old style internal messages to a
// v1::scheduler::Event.
v1::scheduler::Event evolve(const ExitedExecutorMessage& message);
v1::scheduler::Event evolve(const ExecutorToFrameworkMessage& message);
v1::scheduler::Event evolve(const FrameworkErrorMessage& message);
v1::scheduler::Event evolve(const FrameworkRegisteredMessage& message);
v1::scheduler::Event evolve(const FrameworkReregisteredMessage& message);
v1::scheduler::Event evolve(const InverseOffersMessage& message);
v1::scheduler::Event evolve(const LostSlaveMessage& message);
v1::scheduler::Event evolve(const ResourceOffersMessage& message);
v1::scheduler::Event evolve(const RescindInverseOfferMessage& message);
v1::scheduler::Event evolve(const RescindResourceOfferMessage& message);
v1::scheduler::Event evolve(const StatusUpdateMessage& message);
v1::executor::Call evolve(const executor::Call& call);
v1::executor::Event evolve(const executor::Event& event);
// Helper functions that evolve old style internal messages to a
// v1::Executor::Event.
v1::executor::Event evolve(const ExecutorRegisteredMessage& message);
v1::executor::Event evolve(const FrameworkToExecutorMessage& message);
v1::executor::Event evolve(const KillTaskMessage& message);
v1::executor::Event evolve(const RunTaskMessage& message);
v1::executor::Event evolve(const ShutdownExecutorMessage& message);
v1::executor::Event evolve(const StatusUpdateAcknowledgementMessage& message);
v1::master::Event evolve(const mesos::master::Event& event);
// Before the v1 API we had REST endpoints that returned JSON. The JSON was not
// specified in any formal way, i.e., there were no protobufs which captured the
// structure. As part of the v1 API we introduced the Call/Response protobufs
// (see v1/master.proto and v1/agent.proto). This evolve variant transforms a
// JSON object that would have been returned from a particular REST endpoint to
// a `Response` protobuf suitable for returning from the new v1 API endpoints.
// Declaration of helper functions for evolving JSON objects used in master's
// REST endpoints pre v1 API.
template <v1::master::Response::Type T>
v1::master::Response evolve(const JSON::Object& object);
// Declaration of helper functions for evolving JSON objects used in agent's
// REST endpoints pre v1 API.
template <v1::agent::Response::Type T>
v1::agent::Response evolve(const JSON::Object& object);
template <v1::agent::Response::Type T>
v1::agent::Response evolve(const JSON::Array& array);
} // namespace internal {
} // namespace mesos {