00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _ACTIVEMQ_TRANSPORT_FAILOVER_BACKUPTRANSPORTPOOL_H_
00019 #define _ACTIVEMQ_TRANSPORT_FAILOVER_BACKUPTRANSPORTPOOL_H_
00020
00021 #include <activemq/util/Config.h>
00022 #include <activemq/threads/CompositeTask.h>
00023 #include <activemq/threads/CompositeTaskRunner.h>
00024 #include <activemq/transport/failover/CloseTransportsTask.h>
00025 #include <activemq/transport/failover/BackupTransport.h>
00026 #include <activemq/transport/failover/URIPool.h>
00027
00028 #include <decaf/lang/Pointer.h>
00029 #include <decaf/io/IOException.h>
00030 #include <decaf/util/LinkedList.h>
00031
00032 namespace activemq {
00033 namespace transport {
00034 namespace failover {
00035
00036 using decaf::lang::Pointer;
00037 using decaf::util::LinkedList;
00038 using activemq::threads::CompositeTaskRunner;
00039
00040 class BackupTransportPoolImpl;
00041 class FailoverTransport;
00042
00043 class AMQCPP_API BackupTransportPool : public activemq::threads::CompositeTask {
00044 private:
00045
00046 friend class BackupTransport;
00047
00048 BackupTransportPoolImpl* impl;
00049
00050 FailoverTransport* parent;
00051 Pointer<CompositeTaskRunner> taskRunner;
00052 Pointer<CloseTransportsTask> closeTask;
00053 Pointer<URIPool> uriPool;
00054 Pointer<URIPool> updates;
00055 Pointer<URIPool> priorityUriPool;
00056 volatile int backupPoolSize;
00057 volatile bool enabled;
00058 volatile int maxReconnectDelay;
00059
00060 public:
00061
00062 BackupTransportPool(FailoverTransport* parent,
00063 const Pointer<CompositeTaskRunner> taskRunner,
00064 const Pointer<CloseTransportsTask> closeTask,
00065 const Pointer<URIPool> uriPool,
00066 const Pointer<URIPool> updates,
00067 const Pointer<URIPool> priorityUriPool);
00068
00069 BackupTransportPool(FailoverTransport* parent,
00070 int backupPoolSize,
00071 const Pointer<CompositeTaskRunner> taskRunner,
00072 const Pointer<CloseTransportsTask> closeTask,
00073 const Pointer<URIPool> uriPool,
00074 const Pointer<URIPool> updates,
00075 const Pointer<URIPool> priorityUriPool);
00076
00077 virtual ~BackupTransportPool();
00078
00082 void close();
00083
00087 virtual bool isPending() const;
00088
00095 Pointer<BackupTransport> getBackup();
00096
00101 virtual bool iterate();
00102
00107 int getBackupPoolSize() const {
00108 return this->backupPoolSize;
00109 }
00110
00115 void setBackupPoolSize(int size) {
00116 this->backupPoolSize = size;
00117 }
00118
00125 bool isEnabled() const {
00126 return this->enabled;
00127 }
00128
00135 void setEnabled(bool value);
00136
00143 bool isPriorityBackupAvailable() const;
00144
00145 private:
00146
00147
00148
00149
00150 void onBackupTransportFailure(BackupTransport* failedTransport);
00151
00152 Pointer<Transport> createTransport(const decaf::net::URI& location) const;
00153
00154 };
00155
00156 }}}
00157
00158 #endif