activemq-cpp-3.9.5
BackupTransportPool.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _ACTIVEMQ_TRANSPORT_FAILOVER_BACKUPTRANSPORTPOOL_H_
19#define _ACTIVEMQ_TRANSPORT_FAILOVER_BACKUPTRANSPORTPOOL_H_
20
27
28#include <decaf/lang/Pointer.h>
31
32namespace activemq {
33namespace transport {
34namespace failover {
35
36 using decaf::lang::Pointer;
37 using decaf::util::LinkedList;
38 using activemq::threads::CompositeTaskRunner;
39
40 class BackupTransportPoolImpl;
42
44 private:
45
46 friend class BackupTransport;
47
48 BackupTransportPoolImpl* impl;
49
50 FailoverTransport* parent;
53 Pointer<URIPool> uriPool;
54 Pointer<URIPool> updates;
55 Pointer<URIPool> priorityUriPool;
56 volatile int backupPoolSize;
57 volatile bool enabled;
58 volatile int maxReconnectDelay;
59
60 public:
61
63 const Pointer<CompositeTaskRunner> taskRunner,
64 const Pointer<CloseTransportsTask> closeTask,
65 const Pointer<URIPool> uriPool,
66 const Pointer<URIPool> updates,
67 const Pointer<URIPool> priorityUriPool);
68
70 int backupPoolSize,
71 const Pointer<CompositeTaskRunner> taskRunner,
72 const Pointer<CloseTransportsTask> closeTask,
73 const Pointer<URIPool> uriPool,
74 const Pointer<URIPool> updates,
75 const Pointer<URIPool> priorityUriPool);
76
78
82 void close();
83
87 virtual bool isPending() const;
88
96
101 virtual bool iterate();
102
107 int getBackupPoolSize() const {
108 return this->backupPoolSize;
109 }
110
115 void setBackupPoolSize(int size) {
116 this->backupPoolSize = size;
117 }
118
125 bool isEnabled() const {
126 return this->enabled;
127 }
128
135 void setEnabled(bool value);
136
144
145 private:
146
147 // The backups report their failure to the pool, the pool removes them
148 // from the list and returns their URIs to the URIPool, and then adds
149 // the internal transport to the close transport's task for cleanup.
150 void onBackupTransportFailure(BackupTransport* failedTransport);
151
152 Pointer<Transport> createTransport(const decaf::net::URI& location) const;
153
154 };
155
156}}}
157
158#endif /*_ACTIVEMQ_TRANSPORT_FAILOVER_BACKUPTRANSPORTPOOL_H_*/
#define AMQCPP_API
Definition Config.h:30
Represents a single task that can be part of a set of Tasks that are contained in a CompositeTaskRunn...
Definition CompositeTask.h:33
void close()
Closes down the pool and destroys any Backups contained in the pool.
void setEnabled(bool value)
Sets if this Backup Transport Pool is enabled.
BackupTransportPool(FailoverTransport *parent, int backupPoolSize, const Pointer< CompositeTaskRunner > taskRunner, const Pointer< CloseTransportsTask > closeTask, const Pointer< URIPool > uriPool, const Pointer< URIPool > updates, const Pointer< URIPool > priorityUriPool)
Pointer< BackupTransport > getBackup()
Get a Connected Transport from the pool of Backups if any are present, otherwise it return a NULL Poi...
BackupTransportPool(FailoverTransport *parent, const Pointer< CompositeTaskRunner > taskRunner, const Pointer< CloseTransportsTask > closeTask, const Pointer< URIPool > uriPool, const Pointer< URIPool > updates, const Pointer< URIPool > priorityUriPool)
virtual bool iterate()
Connect to a Backup Broker if we haven't already connected to the max number of Backups.
bool isEnabled() const
Gets if the backup Transport Pool has been enabled or not, when not enabled no backups are created an...
Definition BackupTransportPool.h:125
virtual bool isPending() const
Return true if we don't currently have enough Connected Transports.
int getBackupPoolSize() const
Gets the Max number of Backups this Task will create.
Definition BackupTransportPool.h:107
bool isPriorityBackupAvailable() const
Returns true if there is a Backup in the pool that's on the priority backups list.
friend class BackupTransport
Definition BackupTransportPool.h:46
void setBackupPoolSize(int size)
Sets the Max number of Backups this Task will create.
Definition BackupTransportPool.h:115
Definition FailoverTransport.h:49
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
This class represents an instance of a URI as defined by RFC 2396.
Definition URI.h:37
Definition BackupTransport.h:31
Definition AbstractTransportFactory.h:30
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24