Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
00001 #ifndef _qpid_agent_ManagementAgent_ 00002 #define _qpid_agent_ManagementAgent_ 00003 00004 // 00005 // Licensed to the Apache Software Foundation (ASF) under one 00006 // or more contributor license agreements. See the NOTICE file 00007 // distributed with this work for additional information 00008 // regarding copyright ownership. The ASF licenses this file 00009 // to you under the Apache License, Version 2.0 (the 00010 // "License"); you may not use this file except in compliance 00011 // with the License. You may obtain a copy of the License at 00012 // 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // 00015 // Unless required by applicable law or agreed to in writing, 00016 // software distributed under the License is distributed on an 00017 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00018 // KIND, either express or implied. See the License for the 00019 // specific language governing permissions and limitations 00020 // under the License. 00021 // 00022 00023 #include "qpid/agent/QmfAgentImportExport.h" 00024 #include "qpid/management/ManagementObject.h" 00025 #include "qpid/management/ManagementEvent.h" 00026 #include "qpid/management/Manageable.h" 00027 #include "qpid/sys/Mutex.h" 00028 #include "qpid/client/ConnectionSettings.h" 00029 00030 namespace qpid { 00031 namespace management { 00032 00033 class ManagementAgent 00034 { 00035 public: 00036 00037 class Singleton { 00038 public: 00039 QMF_AGENT_EXTERN Singleton(bool disableManagement = false); 00040 QMF_AGENT_EXTERN ~Singleton(); 00041 QMF_AGENT_EXTERN static ManagementAgent* getInstance(); 00042 private: 00043 static sys::Mutex lock; 00044 static bool disabled; 00045 static int refCount; 00046 static ManagementAgent* agent; 00047 }; 00048 00049 typedef enum { 00050 SEV_EMERG = 0, 00051 SEV_ALERT = 1, 00052 SEV_CRIT = 2, 00053 SEV_ERROR = 3, 00054 SEV_WARN = 4, 00055 SEV_NOTE = 5, 00056 SEV_INFO = 6, 00057 SEV_DEBUG = 7, 00058 SEV_DEFAULT = 8 00059 } severity_t; 00060 00061 ManagementAgent() {} 00062 virtual ~ManagementAgent() {} 00063 00064 virtual int getMaxThreads() = 0; 00065 00066 // Connect to a management broker 00067 // 00068 // brokerHost - Hostname or IP address (dotted-quad) of broker. 00069 // 00070 // brokerPort - TCP port of broker. 00071 // 00072 // intervalSeconds - The interval (in seconds) that this agent shall use 00073 // between broadcast updates to the broker. 00074 // 00075 // useExternalThread - If true, the thread of control used for callbacks 00076 // must be supplied by the user of the object (via the 00077 // pollCallbacks method). 00078 // 00079 // If false, callbacks shall be invoked on the management 00080 // agent's thread. In this case, the callback implementations 00081 // MUST be thread safe. 00082 // 00083 // storeFile - File where this process has read and write access. This 00084 // file shall be used to store persistent state. 00085 // 00086 virtual void init(const std::string& brokerHost = "localhost", 00087 uint16_t brokerPort = 5672, 00088 uint16_t intervalSeconds = 10, 00089 bool useExternalThread = false, 00090 const std::string& storeFile = "", 00091 const std::string& uid = "guest", 00092 const std::string& pwd = "guest", 00093 const std::string& mech = "PLAIN", 00094 const std::string& proto = "tcp") = 0; 00095 00096 virtual void init(const client::ConnectionSettings& settings, 00097 uint16_t intervalSeconds = 10, 00098 bool useExternalThread = false, 00099 const std::string& storeFile = "") = 0; 00100 00101 // Register a schema with the management agent. This is normally called by the 00102 // package initializer generated by the management code generator. 00103 // 00104 virtual void 00105 registerClass(const std::string& packageName, 00106 const std::string& className, 00107 uint8_t* md5Sum, 00108 management::ManagementObject::writeSchemaCall_t schemaCall) = 0; 00109 00110 virtual void 00111 registerEvent(const std::string& packageName, 00112 const std::string& eventName, 00113 uint8_t* md5Sum, 00114 management::ManagementEvent::writeSchemaCall_t schemaCall) = 0; 00115 00116 // Add a management object to the agent. Once added, this object shall be visible 00117 // in the greater management context. 00118 // 00119 // Please note that ManagementObject instances are not explicitly deleted from 00120 // the management agent. When the core object represented by a management object 00121 // is deleted, the "resourceDestroy" method on the management object must be called. 00122 // It will then be reclaimed in due course by the management agent. 00123 // 00124 // Once a ManagementObject instance is added to the agent, the agent then owns the 00125 // instance. The caller MUST NOT free the resources of the instance at any time. 00126 // When it is no longer needed, invoke its "resourceDestroy" method and discard the 00127 // pointer. This allows the management agent to report the deletion of the object 00128 // in an orderly way. 00129 // 00130 virtual ObjectId addObject(ManagementObject* objectPtr, uint64_t persistId = 0) = 0; 00131 00132 // 00133 // 00134 virtual void raiseEvent(const ManagementEvent& event, 00135 severity_t severity = SEV_DEFAULT) = 0; 00136 00137 // If "useExternalThread" was set to true in init, this method must 00138 // be called to provide a thread for any pending method calls that have arrived. 00139 // The method calls for ManagementObject instances shall be invoked synchronously 00140 // during the execution of this method. 00141 // 00142 // callLimit may optionally be used to limit the number of callbacks invoked. 00143 // if 0, no limit is imposed. 00144 // 00145 // The return value is the number of callbacks that remain queued after this 00146 // call is complete. It can be used to determine whether or not further calls 00147 // to pollCallbacks are necessary to clear the backlog. If callLimit is zero, 00148 // the return value will also be zero. 00149 // 00150 virtual uint32_t pollCallbacks(uint32_t callLimit = 0) = 0; 00151 00152 // If "useExternalThread" was set to true in the constructor, this method provides 00153 // a standard file descriptor that can be used in a select statement to signal that 00154 // there are method callbacks ready (i.e. that "pollCallbacks" will result in at 00155 // least one method call). When this fd is ready-for-read, pollCallbacks may be 00156 // invoked. Calling pollCallbacks shall reset the ready-to-read state of the fd. 00157 // 00158 virtual int getSignalFd() = 0; 00159 }; 00160 00161 }} 00162 00163 #endif