activemq-cpp-3.6.0
ConnectionStateTracker.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_STATE_CONNECTIONSTATETRACKER_H_
19 #define _ACTIVEMQ_STATE_CONNECTIONSTATETRACKER_H_
20 
21 #include <activemq/util/Config.h>
30 #include <activemq/state/Tracked.h>
32 
34 #include <decaf/lang/Pointer.h>
35 
36 namespace activemq {
37 namespace state {
38 
39  class RemoveTransactionAction;
42 
44  private:
45 
47  const Pointer<Tracked> TRACKED_RESPONSE_MARKER;
48 
51 
52  // TODO - The Map doesn't have a way to automatically remove the eldest Entry
53  // Either we need to implement something similar to LinkedHashMap or find
54  // some other way of tracking the eldest entry into the map and removing it
55  // if the cache size is exceeded.
57 
59 
60  bool trackTransactions;
61  bool restoreSessions;
62  bool restoreConsumers;
63  bool restoreProducers;
64  bool restoreTransaction;
65  bool trackMessages;
66  bool trackTransactionProducers;
67  int maxCacheSize;
68  int currentCacheSize;
69 
70  friend class RemoveTransactionAction;
71 
72  public:
73 
75 
76  virtual ~ConnectionStateTracker();
77 
78  Pointer<Tracked> track(Pointer<Command> command);
79 
80  void trackBack(Pointer<Command> command);
81 
82  void restore(Pointer<transport::Transport> transport);
83 
84  void connectionInterruptProcessingComplete(
85  transport::Transport* transport, Pointer<ConnectionId> connectionId);
86 
87  void transportInterrupted();
88 
89  virtual Pointer<Command> processDestinationInfo(DestinationInfo* info);
90 
91  virtual Pointer<Command> processRemoveDestination(DestinationInfo* info);
92 
93  virtual Pointer<Command> processProducerInfo(ProducerInfo* info);
94 
95  virtual Pointer<Command> processRemoveProducer(ProducerId* id);
96 
97  virtual Pointer<Command> processConsumerInfo(ConsumerInfo* info);
98 
99  virtual Pointer<Command> processRemoveConsumer(ConsumerId* id);
100 
101  virtual Pointer<Command> processSessionInfo(SessionInfo* info);
102 
103  virtual Pointer<Command> processRemoveSession(SessionId* id);
104 
105  virtual Pointer<Command> processConnectionInfo(ConnectionInfo* info);
106 
107  virtual Pointer<Command> processRemoveConnection(ConnectionId* id);
108 
109  virtual Pointer<Command> processMessage(Message* message);
110 
111  virtual Pointer<Command> processBeginTransaction(TransactionInfo* info);
112 
113  virtual Pointer<Command> processPrepareTransaction(TransactionInfo* info);
114 
115  virtual Pointer<Command> processCommitTransactionOnePhase(TransactionInfo* info);
116 
117  virtual Pointer<Command> processCommitTransactionTwoPhase(TransactionInfo* info);
118 
119  virtual Pointer<Command> processRollbackTransaction(TransactionInfo* info);
120 
121  virtual Pointer<Command> processEndTransaction(TransactionInfo* info);
122 
123  virtual Pointer<Command> processMessagePull(MessagePull* pull);
124 
125  bool isRestoreConsumers() const {
126  return this->restoreConsumers;
127  }
128 
129  void setRestoreConsumers(bool restoreConsumers) {
130  this->restoreConsumers = restoreConsumers;
131  }
132 
133  bool isRestoreProducers() const {
134  return this->restoreProducers;
135  }
136 
137  void setRestoreProducers(bool restoreProducers) {
138  this->restoreProducers = restoreProducers;
139  }
140 
141  bool isRestoreSessions() const {
142  return this->restoreSessions;
143  }
144 
145  void setRestoreSessions(bool restoreSessions) {
146  this->restoreSessions = restoreSessions;
147  }
148 
149  bool isTrackTransactions() const {
150  return this->trackTransactions;
151  }
152 
153  void setTrackTransactions(bool trackTransactions) {
154  this->trackTransactions = trackTransactions;
155  }
156 
157  bool isRestoreTransaction() const {
158  return this->restoreTransaction;
159  }
160 
161  void setRestoreTransaction(bool restoreTransaction) {
162  this->restoreTransaction = restoreTransaction;
163  }
164 
165  bool isTrackMessages() const {
166  return this->trackMessages;
167  }
168 
169  void setTrackMessages(bool trackMessages) {
170  this->trackMessages = trackMessages;
171  }
172 
173  int getMaxCacheSize() const {
174  return this->maxCacheSize;
175  }
176 
177  void setMaxCacheSize(int maxCacheSize) {
178  this->maxCacheSize = maxCacheSize;
179  }
180 
182  return this->trackTransactionProducers;
183  }
184 
185  void setTrackTransactionProducers(bool trackTransactionProducers) {
186  this->trackTransactionProducers = trackTransactionProducers;
187  }
188 
189  private:
190 
191  void doRestoreTransactions(Pointer<transport::Transport> transport, Pointer<ConnectionState> connectionState);
192 
193  void doRestoreSessions(Pointer<transport::Transport> transport, Pointer<ConnectionState> connectionState);
194 
195  void doRestoreConsumers(Pointer<transport::Transport> transport, Pointer<SessionState> sessionState);
196 
197  void doRestoreProducers(Pointer<transport::Transport> transport, Pointer<SessionState> sessionState);
198 
199  void doRestoreTempDestinations(Pointer<transport::Transport> transport, Pointer<ConnectionState> connectionState);
200 
201  };
202 
203 }}
204 
205 #endif /*_ACTIVEMQ_STATE_CONNECTIONSTATETRACKER_H_*/