00001 #ifndef _broker_Link_h
00002 #define _broker_Link_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <boost/shared_ptr.hpp>
00026 #include "MessageStore.h"
00027 #include "PersistableConfig.h"
00028 #include "Bridge.h"
00029 #include "qpid/sys/Mutex.h"
00030 #include "qpid/sys/ProtocolAccess.h"
00031 #include "qpid/framing/FieldTable.h"
00032 #include "qpid/management/Manageable.h"
00033 #include "qpid/management/Link.h"
00034 #include <boost/ptr_container/ptr_vector.hpp>
00035
00036 namespace qpid {
00037 namespace broker {
00038
00039 using std::string;
00040 class LinkRegistry;
00041 class Broker;
00042 class Connection;
00043
00044 class Link : public PersistableConfig, public management::Manageable {
00045 private:
00046 sys::Mutex lock;
00047 LinkRegistry* links;
00048 MessageStore* store;
00049 string host;
00050 uint16_t port;
00051 bool useSsl;
00052 bool durable;
00053 string authMechanism;
00054 string username;
00055 string password;
00056 mutable uint64_t persistenceId;
00057 management::Link::shared_ptr mgmtObject;
00058 Broker* broker;
00059 int state;
00060 sys::ProtocolAccess access;
00061 uint32_t visitCount;
00062 uint32_t currentInterval;
00063 bool closing;
00064
00065 typedef std::vector<Bridge::shared_ptr> Bridges;
00066 Bridges created;
00067 Bridges active;
00068 uint channelCounter;
00069 boost::shared_ptr<Connection> connection;
00070
00071 static const int STATE_WAITING = 1;
00072 static const int STATE_CONNECTING = 2;
00073 static const int STATE_OPERATIONAL = 3;
00074
00075 static const uint32_t MAX_INTERVAL = 16;
00076
00077 void setStateLH (int newState);
00078 void startConnectionLH();
00079 void established();
00080 void closed(int, std::string);
00081 void destroy();
00082 void ioThreadProcessing();
00083 void setConnection(boost::shared_ptr<Connection>);
00084
00085 public:
00086 typedef boost::shared_ptr<Link> shared_ptr;
00087
00088 Link(LinkRegistry* links,
00089 MessageStore* store,
00090 string& host,
00091 uint16_t port,
00092 bool useSsl,
00093 bool durable,
00094 string& authMechanism,
00095 string& username,
00096 string& password,
00097 Broker* broker,
00098 management::Manageable* parent = 0);
00099 virtual ~Link();
00100
00101 std::string getHost() { return host; }
00102 uint16_t getPort() { return port; }
00103 bool isDurable() { return durable; }
00104 void maintenanceVisit ();
00105 uint nextChannel();
00106 void add(Bridge::shared_ptr);
00107 void cancel(Bridge::shared_ptr);
00108
00109
00110 void setPersistenceId(uint64_t id) const;
00111 uint64_t getPersistenceId() const { return persistenceId; }
00112 uint32_t encodedSize() const;
00113 void encode(framing::Buffer& buffer) const;
00114 const string& getName() const;
00115
00116 static Link::shared_ptr decode(LinkRegistry& links, framing::Buffer& buffer);
00117
00118
00119 management::ManagementObject::shared_ptr GetManagementObject (void) const;
00120 management::Manageable::status_t ManagementMethod (uint32_t, management::Args&);
00121 };
00122 }
00123 }
00124
00125
00126 #endif