00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_STATE_CONNECTIONSTATETRACKER_H_ 00019 #define _ACTIVEMQ_STATE_CONNECTIONSTATETRACKER_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/commands/ConnectionId.h> 00023 #include <activemq/exceptions/ActiveMQException.h> 00024 #include <activemq/state/CommandVisitorAdapter.h> 00025 #include <activemq/state/ConnectionState.h> 00026 #include <activemq/state/ConsumerState.h> 00027 #include <activemq/state/ProducerState.h> 00028 #include <activemq/state/SessionState.h> 00029 #include <activemq/state/TransactionState.h> 00030 #include <activemq/state/Tracked.h> 00031 #include <activemq/transport/Transport.h> 00032 00033 #include <decaf/lang/Pointer.h> 00034 00035 namespace activemq { 00036 namespace state { 00037 00038 class RemoveTransactionAction; 00039 class StateTrackerImpl; 00040 00041 class AMQCPP_API ConnectionStateTracker: public CommandVisitorAdapter { 00042 private: 00043 00044 StateTrackerImpl* impl; 00045 00046 bool trackTransactions; 00047 bool restoreSessions; 00048 bool restoreConsumers; 00049 bool restoreProducers; 00050 bool restoreTransaction; 00051 bool trackMessages; 00052 bool trackTransactionProducers; 00053 int maxMessageCacheSize; 00054 int maxMessagePullCacheSize; 00055 00056 friend class RemoveTransactionAction; 00057 00058 public: 00059 00060 ConnectionStateTracker(); 00061 00062 virtual ~ConnectionStateTracker(); 00063 00064 Pointer<Tracked> track(Pointer<Command> command); 00065 00066 void trackBack(decaf::lang::Pointer<Command> command); 00067 00068 void restore(decaf::lang::Pointer<transport::Transport> transport); 00069 00070 void connectionInterruptProcessingComplete( 00071 transport::Transport* transport, decaf::lang::Pointer<ConnectionId> connectionId); 00072 00073 void transportInterrupted(); 00074 00075 virtual decaf::lang::Pointer<Command> processDestinationInfo(DestinationInfo* info); 00076 00077 virtual decaf::lang::Pointer<Command> processRemoveDestination(DestinationInfo* info); 00078 00079 virtual decaf::lang::Pointer<Command> processProducerInfo(ProducerInfo* info); 00080 00081 virtual decaf::lang::Pointer<Command> processRemoveProducer(ProducerId* id); 00082 00083 virtual decaf::lang::Pointer<Command> processConsumerInfo(ConsumerInfo* info); 00084 00085 virtual decaf::lang::Pointer<Command> processRemoveConsumer(ConsumerId* id); 00086 00087 virtual decaf::lang::Pointer<Command> processSessionInfo(SessionInfo* info); 00088 00089 virtual decaf::lang::Pointer<Command> processRemoveSession(SessionId* id); 00090 00091 virtual decaf::lang::Pointer<Command> processConnectionInfo(ConnectionInfo* info); 00092 00093 virtual decaf::lang::Pointer<Command> processRemoveConnection(ConnectionId* id); 00094 00095 virtual decaf::lang::Pointer<Command> processMessage(Message* message); 00096 00097 virtual decaf::lang::Pointer<Command> processBeginTransaction(TransactionInfo* info); 00098 00099 virtual decaf::lang::Pointer<Command> processPrepareTransaction(TransactionInfo* info); 00100 00101 virtual decaf::lang::Pointer<Command> processCommitTransactionOnePhase(TransactionInfo* info); 00102 00103 virtual decaf::lang::Pointer<Command> processCommitTransactionTwoPhase(TransactionInfo* info); 00104 00105 virtual decaf::lang::Pointer<Command> processRollbackTransaction(TransactionInfo* info); 00106 00107 virtual decaf::lang::Pointer<Command> processEndTransaction(TransactionInfo* info); 00108 00109 virtual decaf::lang::Pointer<Command> processMessagePull(MessagePull* pull); 00110 00111 bool isRestoreConsumers() const { 00112 return this->restoreConsumers; 00113 } 00114 00115 void setRestoreConsumers(bool restoreConsumers) { 00116 this->restoreConsumers = restoreConsumers; 00117 } 00118 00119 bool isRestoreProducers() const { 00120 return this->restoreProducers; 00121 } 00122 00123 void setRestoreProducers(bool restoreProducers) { 00124 this->restoreProducers = restoreProducers; 00125 } 00126 00127 bool isRestoreSessions() const { 00128 return this->restoreSessions; 00129 } 00130 00131 void setRestoreSessions(bool restoreSessions) { 00132 this->restoreSessions = restoreSessions; 00133 } 00134 00135 bool isTrackTransactions() const { 00136 return this->trackTransactions; 00137 } 00138 00139 void setTrackTransactions(bool trackTransactions) { 00140 this->trackTransactions = trackTransactions; 00141 } 00142 00143 bool isRestoreTransaction() const { 00144 return this->restoreTransaction; 00145 } 00146 00147 void setRestoreTransaction(bool restoreTransaction) { 00148 this->restoreTransaction = restoreTransaction; 00149 } 00150 00151 bool isTrackMessages() const { 00152 return this->trackMessages; 00153 } 00154 00155 void setTrackMessages(bool trackMessages) { 00156 this->trackMessages = trackMessages; 00157 } 00158 00159 int getMaxMessageCacheSize() const { 00160 return this->maxMessageCacheSize; 00161 } 00162 00163 void setMaxMessageCacheSize(int maxMessageCacheSize) { 00164 this->maxMessageCacheSize = maxMessageCacheSize; 00165 } 00166 00167 int getMaxMessagePullCacheSize() const { 00168 return this->maxMessagePullCacheSize; 00169 } 00170 00171 void setMaxMessagePullCacheSize(int maxMessagePullCacheSize) { 00172 this->maxMessagePullCacheSize = maxMessagePullCacheSize; 00173 } 00174 00175 bool isTrackTransactionProducers() const { 00176 return this->trackTransactionProducers; 00177 } 00178 00179 void setTrackTransactionProducers(bool trackTransactionProducers) { 00180 this->trackTransactionProducers = trackTransactionProducers; 00181 } 00182 00183 private: 00184 00185 void doRestoreTransactions(decaf::lang::Pointer<transport::Transport> transport, 00186 decaf::lang::Pointer<ConnectionState> connectionState); 00187 00188 void doRestoreSessions(decaf::lang::Pointer<transport::Transport> transport, 00189 decaf::lang::Pointer<ConnectionState> connectionState); 00190 00191 void doRestoreConsumers(decaf::lang::Pointer<transport::Transport> transport, 00192 decaf::lang::Pointer<SessionState> sessionState); 00193 00194 void doRestoreProducers(decaf::lang::Pointer<transport::Transport> transport, 00195 decaf::lang::Pointer<SessionState> sessionState); 00196 00197 void doRestoreTempDestinations(decaf::lang::Pointer<transport::Transport> transport, 00198 decaf::lang::Pointer<ConnectionState> connectionState); 00199 00200 }; 00201 00202 }} 00203 00204 #endif /*_ACTIVEMQ_STATE_CONNECTIONSTATETRACKER_H_*/
1.6.1