Method from org.apache.activemq.state.ConnectionStateTracker Detail: |
public int getMaxCacheSize() {
return maxCacheSize;
}
|
public boolean isRestoreConsumers() {
return restoreConsumers;
}
|
public boolean isRestoreProducers() {
return restoreProducers;
}
|
public boolean isRestoreSessions() {
return restoreSessions;
}
|
public boolean isRestoreTransaction() {
return restoreTransaction;
}
|
public boolean isTrackMessages() {
return trackMessages;
}
|
public boolean isTrackTransactionProducers() {
return this.trackTransactionProducers;
}
|
public boolean isTrackTransactions() {
return trackTransactions;
}
|
public Response processAddConnection(ConnectionInfo info) {
if (info != null) {
connectionStates.put(info.getConnectionId(), new ConnectionState(info));
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processAddConsumer(ConsumerInfo info) {
if (info != null) {
SessionId sessionId = info.getConsumerId().getParentId();
if (sessionId != null) {
ConnectionId connectionId = sessionId.getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
SessionState ss = cs.getSessionState(sessionId);
if (ss != null) {
ss.addConsumer(info);
}
}
}
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processAddDestination(DestinationInfo info) {
if (info != null) {
ConnectionState cs = connectionStates.get(info.getConnectionId());
if (cs != null && info.getDestination().isTemporary()) {
cs.addTempDestination(info);
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processAddProducer(ProducerInfo info) {
if (info != null && info.getProducerId() != null) {
SessionId sessionId = info.getProducerId().getParentId();
if (sessionId != null) {
ConnectionId connectionId = sessionId.getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
SessionState ss = cs.getSessionState(sessionId);
if (ss != null) {
ss.addProducer(info);
}
}
}
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processAddSession(SessionInfo info) {
if (info != null) {
ConnectionId connectionId = info.getSessionId().getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
cs.addSession(info);
}
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processBeginTransaction(TransactionInfo info) {
if (trackTransactions && info != null && info.getTransactionId() != null) {
ConnectionId connectionId = info.getConnectionId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
cs.addTransactionState(info.getTransactionId());
TransactionState state = cs.getTransactionState(info.getTransactionId());
state.addCommand(info);
}
}
return TRACKED_RESPONSE_MARKER;
}
return null;
}
|
public Response processCommitTransactionOnePhase(TransactionInfo info) throws Exception {
if (trackTransactions && info != null) {
ConnectionId connectionId = info.getConnectionId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
TransactionState transactionState = cs.getTransactionState(info.getTransactionId());
if (transactionState != null) {
transactionState.addCommand(info);
return new Tracked(new RemoveTransactionAction(info));
}
}
}
}
return null;
}
|
public Response processCommitTransactionTwoPhase(TransactionInfo info) throws Exception {
if (trackTransactions && info != null) {
ConnectionId connectionId = info.getConnectionId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
TransactionState transactionState = cs.getTransactionState(info.getTransactionId());
if (transactionState != null) {
transactionState.addCommand(info);
return new Tracked(new RemoveTransactionAction(info));
}
}
}
}
return null;
}
|
public Response processEndTransaction(TransactionInfo info) throws Exception {
if (trackTransactions && info != null) {
ConnectionId connectionId = info.getConnectionId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
TransactionState transactionState = cs.getTransactionState(info.getTransactionId());
if (transactionState != null) {
transactionState.addCommand(info);
}
}
}
return TRACKED_RESPONSE_MARKER;
}
return null;
}
|
public Response processMessage(Message send) throws Exception {
if (send != null) {
if (trackTransactions && send.getTransactionId() != null) {
ProducerId producerId = send.getProducerId();
ConnectionId connectionId = producerId.getParentId().getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
TransactionState transactionState = cs.getTransactionState(send.getTransactionId());
if (transactionState != null) {
transactionState.addCommand(send);
if (trackTransactionProducers) {
// for jmstemplate, track the producer in case it is closed before commit
// and needs to be replayed
SessionState ss = cs.getSessionState(producerId.getParentId());
ProducerState producerState = ss.getProducerState(producerId);
producerState.setTransactionState(transactionState);
}
}
}
}
return TRACKED_RESPONSE_MARKER;
}else if (trackMessages) {
messageCache.put(send.getMessageId(), send.copy());
}
}
return null;
}
|
public Response processPrepareTransaction(TransactionInfo info) throws Exception {
if (trackTransactions && info != null) {
ConnectionId connectionId = info.getConnectionId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
TransactionState transactionState = cs.getTransactionState(info.getTransactionId());
if (transactionState != null) {
transactionState.addCommand(info);
}
}
}
return TRACKED_RESPONSE_MARKER;
}
return null;
}
|
public Response processRemoveConnection(ConnectionId id,
long lastDeliveredSequenceId) throws Exception {
if (id != null) {
connectionStates.remove(id);
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processRemoveConsumer(ConsumerId id,
long lastDeliveredSequenceId) {
if (id != null) {
SessionId sessionId = id.getParentId();
if (sessionId != null) {
ConnectionId connectionId = sessionId.getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
SessionState ss = cs.getSessionState(sessionId);
if (ss != null) {
ss.removeConsumer(id);
}
}
}
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processRemoveDestination(DestinationInfo info) {
if (info != null) {
ConnectionState cs = connectionStates.get(info.getConnectionId());
if (cs != null && info.getDestination().isTemporary()) {
cs.removeTempDestination(info.getDestination());
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processRemoveProducer(ProducerId id) {
if (id != null) {
SessionId sessionId = id.getParentId();
if (sessionId != null) {
ConnectionId connectionId = sessionId.getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
SessionState ss = cs.getSessionState(sessionId);
if (ss != null) {
ss.removeProducer(id);
}
}
}
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processRemoveSession(SessionId id,
long lastDeliveredSequenceId) {
if (id != null) {
ConnectionId connectionId = id.getParentId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
cs.removeSession(id);
}
}
}
return TRACKED_RESPONSE_MARKER;
}
|
public Response processRollbackTransaction(TransactionInfo info) throws Exception {
if (trackTransactions && info != null) {
ConnectionId connectionId = info.getConnectionId();
if (connectionId != null) {
ConnectionState cs = connectionStates.get(connectionId);
if (cs != null) {
TransactionState transactionState = cs.getTransactionState(info.getTransactionId());
if (transactionState != null) {
transactionState.addCommand(info);
return new Tracked(new RemoveTransactionAction(info));
}
}
}
}
return null;
}
|
public void restore(Transport transport) throws IOException {
// Restore the connections.
for (Iterator< ConnectionState > iter = connectionStates.values().iterator(); iter.hasNext();) {
ConnectionState connectionState = iter.next();
if (LOG.isDebugEnabled()) {
LOG.debug("conn: " + connectionState.getInfo().getConnectionId());
}
transport.oneway(connectionState.getInfo());
restoreTempDestinations(transport, connectionState);
if (restoreSessions) {
restoreSessions(transport, connectionState);
}
if (restoreTransaction) {
restoreTransactions(transport, connectionState);
}
}
//now flush messages
for (Message msg:messageCache.values()) {
transport.oneway(msg);
}
}
|
protected void restoreConsumers(Transport transport,
SessionState sessionState) throws IOException {
// Restore the session's consumers
for (Iterator iter3 = sessionState.getConsumerStates().iterator(); iter3.hasNext();) {
ConsumerState consumerState = (ConsumerState)iter3.next();
if (LOG.isDebugEnabled()) {
LOG.debug("restore consumer: " + consumerState.getInfo().getConsumerId());
}
transport.oneway(consumerState.getInfo());
}
}
|
protected void restoreProducers(Transport transport,
SessionState sessionState) throws IOException {
// Restore the session's producers
for (Iterator iter3 = sessionState.getProducerStates().iterator(); iter3.hasNext();) {
ProducerState producerState = (ProducerState)iter3.next();
if (LOG.isDebugEnabled()) {
LOG.debug("producer: " + producerState.getInfo().getProducerId());
}
transport.oneway(producerState.getInfo());
}
}
|
protected void restoreSessions(Transport transport,
ConnectionState connectionState) throws IOException {
// Restore the connection's sessions
for (Iterator iter2 = connectionState.getSessionStates().iterator(); iter2.hasNext();) {
SessionState sessionState = (SessionState)iter2.next();
if (LOG.isDebugEnabled()) {
LOG.debug("session: " + sessionState.getInfo().getSessionId());
}
transport.oneway(sessionState.getInfo());
if (restoreProducers) {
restoreProducers(transport, sessionState);
}
if (restoreConsumers) {
restoreConsumers(transport, sessionState);
}
}
}
|
protected void restoreTempDestinations(Transport transport,
ConnectionState connectionState) throws IOException {
// Restore the connection's temp destinations.
for (Iterator iter2 = connectionState.getTempDesinations().iterator(); iter2.hasNext();) {
transport.oneway((DestinationInfo)iter2.next());
}
}
|
public void setMaxCacheSize(int maxCacheSize) {
this.maxCacheSize = maxCacheSize;
}
|
public void setRestoreConsumers(boolean restoreConsumers) {
this.restoreConsumers = restoreConsumers;
}
|
public void setRestoreProducers(boolean restoreProducers) {
this.restoreProducers = restoreProducers;
}
|
public void setRestoreSessions(boolean restoreSessions) {
this.restoreSessions = restoreSessions;
}
|
public void setRestoreTransaction(boolean restoreTransaction) {
this.restoreTransaction = restoreTransaction;
}
|
public void setTrackMessages(boolean trackMessages) {
this.trackMessages = trackMessages;
}
|
public void setTrackTransactionProducers(boolean trackTransactionProducers) {
this.trackTransactionProducers = trackTransactionProducers;
}
|
public void setTrackTransactions(boolean trackTransactions) {
this.trackTransactions = trackTransactions;
}
|
public Tracked track(Command command) throws IOException {
try {
return (Tracked)command.visit(this);
} catch (IOException e) {
throw e;
} catch (Throwable e) {
throw IOExceptionSupport.create(e);
}
}
|
public void trackBack(Command command) {
if (trackMessages && command != null && command.isMessage()) {
Message message = (Message) command;
if (message.getTransactionId()==null) {
currentCacheSize = currentCacheSize + message.getSize();
}
}
}
|