OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InstanceManager Class Reference

#include <instance_manager.h>

Collaboration diagram for InstanceManager:

Classes

struct  InstanceManagerChildEvent
 
class  NamespaceStaleCleaner
 

Public Types

enum  CmdType { Start = 1, Stop }
 
enum  ChldEventType { OnErrorEvent, OnTaskTimeoutEvent, OnExitEvent }
 

Public Member Functions

 InstanceManager (Agent *)
 
 ~InstanceManager ()
 
void Initialize (DB *database, const std::string &netns_cmd, const std::string &docker_cmd, const int netns_workers, const int netns_timeout)
 
void Terminate ()
 
bool DequeueEvent (InstanceManagerChildEvent event)
 
InstanceStateGetState (ServiceInstance *) const
 
bool StaleTimeout ()
 
void SetStaleTimerInterval (int minutes)
 
int StaleTimerInterval ()
 
void SetNamespaceStorePath (std::string path)
 
void SetNetNSCmd (const std::string &netns_cmd)
 

Static Public Attributes

static const int kTimeoutDefault = 30
 
static const int kWorkersDefault = 1
 
static const int kReattemptsDefault = 2
 

Private Types

typedef std::map< InstanceTask
*, ServiceInstance * > 
TaskSvcMap
 

Private Member Functions

void RegisterSigHandler ()
 
void InitSigHandler (AgentSignal *signal)
 
InstanceManagerAdapterFindApplicableAdapter (const ServiceInstance::Properties &props)
 
void StartServiceInstance (ServiceInstance *svc_instance, InstanceState *state, bool update)
 
void StopServiceInstance (ServiceInstance *svc_instance, InstanceState *state)
 
void StopStaleNetNS (ServiceInstance::Properties &props)
 
void OnError (InstanceTask *task, const std::string errors)
 
void OnExit (InstanceTask *task, const boost::system::error_code &ec)
 
void RegisterSvcInstance (InstanceTask *task, ServiceInstance *svc_instance)
 
void UnregisterSvcInstance (ServiceInstance *svc_instance)
 
ServiceInstanceUnregisterSvcInstance (InstanceTask *task)
 
ServiceInstanceGetSvcInstance (InstanceTask *task) const
 
InstanceTaskQueueGetTaskQueue (const std::string &str)
 
void Enqueue (InstanceTask *task, const boost::uuids::uuid &uuid)
 
void ScheduleNextTask (InstanceTaskQueue *task_queue)
 
bool StartTask (InstanceTaskQueue *task_queue, InstanceTask *task)
 
InstanceStateGetState (InstanceTask *task) const
 
void SetState (ServiceInstance *svc_instance, InstanceState *state)
 
void ClearState (ServiceInstance *svc_instance)
 
bool DeleteState (ServiceInstance *svc_instance)
 
void UpdateStateStatusType (InstanceManagerChildEvent event)
 
void SetLastCmdType (ServiceInstance *svc_instance, int last_cmd_type)
 
int GetLastCmdType (ServiceInstance *svc_instance) const
 
void ClearLastCmdType (ServiceInstance *svc_instance)
 
void OnTaskTimeout (InstanceTaskQueue *task_queue)
 
void OnErrorEventHandler (InstanceManagerChildEvent event)
 
void OnExitEventHandler (InstanceManagerChildEvent event)
 
void OnTaskTimeoutEventHandler (InstanceManagerChildEvent event)
 
void StateClear ()
 
void EventObserver (DBTablePartBase *db_part, DBEntryBase *entry)
 
 DISALLOW_COPY_AND_ASSIGN (InstanceManager)
 

Private Attributes

DBTableBase::ListenerId si_listener_
 
std::string netns_cmd_
 
int netns_timeout_
 
int netns_reattempts_
 
WorkQueue
< InstanceManagerChildEvent
work_queue_
 
std::vector< InstanceTaskQueue * > task_queues_
 
TaskSvcMap task_svc_instances_
 
std::map< std::string, int > last_cmd_types_
 
std::string loadbalancer_config_path_
 
std::string namespace_store_path_
 
int stale_timer_interval_
 
Timerstale_timer_
 
std::unique_ptr
< NamespaceStaleCleaner
stale_cleaner_
 
Agentagent_
 
std::vector
< InstanceManagerAdapter * > 
adapters_
 

Friends

class InstanceManagerTest
 

Detailed Description

Definition at line 33 of file instance_manager.h.

Member Typedef Documentation

Definition at line 151 of file instance_manager.h.

Member Enumeration Documentation

Enumerator
OnErrorEvent 
OnTaskTimeoutEvent 
OnExitEvent 

Definition at line 40 of file instance_manager.h.

Enumerator
Start 
Stop 

Definition at line 35 of file instance_manager.h.

Constructor & Destructor Documentation

InstanceManager::InstanceManager ( Agent agent)

Definition at line 129 of file instance_manager.cc.

Here is the call graph for this function:

InstanceManager::~InstanceManager ( )

Definition at line 124 of file instance_manager.cc.

Here is the call graph for this function:

Member Function Documentation

void InstanceManager::ClearLastCmdType ( ServiceInstance svc_instance)
private

Definition at line 775 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::ClearState ( ServiceInstance svc_instance)
private

Definition at line 370 of file instance_manager.cc.

Here is the call graph for this function:

bool InstanceManager::DeleteState ( ServiceInstance svc_instance)
private

Definition at line 374 of file instance_manager.cc.

Here is the call graph for this function:

bool InstanceManager::DequeueEvent ( InstanceManagerChildEvent  event)

Definition at line 289 of file instance_manager.cc.

Here is the call graph for this function:

InstanceManager::DISALLOW_COPY_AND_ASSIGN ( InstanceManager  )
private
void InstanceManager::Enqueue ( InstanceTask task,
const boost::uuids::uuid uuid 
)
private

Definition at line 430 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::EventObserver ( DBTablePartBase db_part,
DBEntryBase entry 
)
private

Definition at line 784 of file instance_manager.cc.

Here is the call graph for this function:

InstanceManagerAdapter * InstanceManager::FindApplicableAdapter ( const ServiceInstance::Properties props)
private

Definition at line 615 of file instance_manager.cc.

Here is the call graph for this function:

int InstanceManager::GetLastCmdType ( ServiceInstance svc_instance) const
private

Definition at line 764 of file instance_manager.cc.

Here is the call graph for this function:

InstanceState * InstanceManager::GetState ( ServiceInstance svc_instance) const

Definition at line 349 of file instance_manager.cc.

Here is the call graph for this function:

InstanceState * InstanceManager::GetState ( InstanceTask task) const
private

Definition at line 355 of file instance_manager.cc.

Here is the call graph for this function:

ServiceInstance * InstanceManager::GetSvcInstance ( InstanceTask task) const
private

Definition at line 561 of file instance_manager.cc.

InstanceTaskQueue * InstanceManager::GetTaskQueue ( const std::string &  str)
private

Definition at line 439 of file instance_manager.cc.

void InstanceManager::Initialize ( DB database,
const std::string &  netns_cmd,
const std::string &  docker_cmd,
const int  netns_workers,
const int  netns_timeout 
)

Definition at line 150 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::InitSigHandler ( AgentSignal signal)
private
void InstanceManager::OnError ( InstanceTask task,
const std::string  errors 
)
private

Definition at line 687 of file instance_manager.cc.

void InstanceManager::OnErrorEventHandler ( InstanceManagerChildEvent  event)
private

Definition at line 244 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::OnExit ( InstanceTask task,
const boost::system::error_code &  ec 
)
private

Definition at line 698 of file instance_manager.cc.

void InstanceManager::OnExitEventHandler ( InstanceManagerChildEvent  event)
private

Definition at line 260 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::OnTaskTimeout ( InstanceTaskQueue task_queue)
private

Definition at line 228 of file instance_manager.cc.

void InstanceManager::OnTaskTimeoutEventHandler ( InstanceManagerChildEvent  event)
private

Definition at line 236 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::RegisterSigHandler ( )
private
void InstanceManager::RegisterSvcInstance ( InstanceTask task,
ServiceInstance svc_instance 
)
private

Definition at line 570 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::ScheduleNextTask ( InstanceTaskQueue task_queue)
private

Definition at line 506 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::SetLastCmdType ( ServiceInstance svc_instance,
int  last_cmd_type 
)
private

Definition at line 752 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::SetNamespaceStorePath ( std::string  path)

Definition at line 838 of file instance_manager.cc.

void InstanceManager::SetNetNSCmd ( const std::string &  netns_cmd)

Definition at line 214 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::SetStaleTimerInterval ( int  minutes)

Definition at line 224 of file instance_manager.cc.

void InstanceManager::SetState ( ServiceInstance svc_instance,
InstanceState state 
)
private

Definition at line 364 of file instance_manager.cc.

Here is the call graph for this function:

bool InstanceManager::StaleTimeout ( )

Definition at line 828 of file instance_manager.cc.

int InstanceManager::StaleTimerInterval ( )
inline

Definition at line 86 of file instance_manager.h.

void InstanceManager::StartServiceInstance ( ServiceInstance svc_instance,
InstanceState state,
bool  update 
)
private

Definition at line 626 of file instance_manager.cc.

Here is the call graph for this function:

bool InstanceManager::StartTask ( InstanceTaskQueue task_queue,
InstanceTask task 
)
private

Definition at line 453 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::StateClear ( )
private

Definition at line 392 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::StopServiceInstance ( ServiceInstance svc_instance,
InstanceState state 
)
private

Definition at line 657 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::StopStaleNetNS ( ServiceInstance::Properties props)
private

Definition at line 709 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::Terminate ( )

Definition at line 412 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::UnregisterSvcInstance ( ServiceInstance svc_instance)
private

Definition at line 598 of file instance_manager.cc.

Here is the call graph for this function:

ServiceInstance * InstanceManager::UnregisterSvcInstance ( InstanceTask task)
private

Definition at line 581 of file instance_manager.cc.

Here is the call graph for this function:

void InstanceManager::UpdateStateStatusType ( InstanceManagerChildEvent  event)
private

Definition at line 301 of file instance_manager.cc.

Here is the call graph for this function:

Friends And Related Function Documentation

friend class InstanceManagerTest
friend

Definition at line 91 of file instance_manager.h.

Member Data Documentation

std::vector<InstanceManagerAdapter *> InstanceManager::adapters_
private

Definition at line 161 of file instance_manager.h.

Agent* InstanceManager::agent_
private

Definition at line 159 of file instance_manager.h.

const int InstanceManager::kReattemptsDefault = 2
static

Definition at line 72 of file instance_manager.h.

const int InstanceManager::kTimeoutDefault = 30
static

Definition at line 70 of file instance_manager.h.

const int InstanceManager::kWorkersDefault = 1
static

Definition at line 71 of file instance_manager.h.

std::map<std::string, int> InstanceManager::last_cmd_types_
private

Definition at line 153 of file instance_manager.h.

std::string InstanceManager::loadbalancer_config_path_
private

Definition at line 154 of file instance_manager.h.

std::string InstanceManager::namespace_store_path_
private

Definition at line 155 of file instance_manager.h.

std::string InstanceManager::netns_cmd_
private

Definition at line 145 of file instance_manager.h.

int InstanceManager::netns_reattempts_
private

Definition at line 147 of file instance_manager.h.

int InstanceManager::netns_timeout_
private

Definition at line 146 of file instance_manager.h.

DBTableBase::ListenerId InstanceManager::si_listener_
private

Definition at line 144 of file instance_manager.h.

std::unique_ptr<NamespaceStaleCleaner> InstanceManager::stale_cleaner_
private

Definition at line 158 of file instance_manager.h.

Timer* InstanceManager::stale_timer_
private

Definition at line 157 of file instance_manager.h.

int InstanceManager::stale_timer_interval_
private

Definition at line 156 of file instance_manager.h.

std::vector<InstanceTaskQueue *> InstanceManager::task_queues_
private

Definition at line 150 of file instance_manager.h.

TaskSvcMap InstanceManager::task_svc_instances_
private

Definition at line 152 of file instance_manager.h.

WorkQueue<InstanceManagerChildEvent> InstanceManager::work_queue_
private

Definition at line 148 of file instance_manager.h.


The documentation for this class was generated from the following files: