git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1416959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-12-04 14:24:07 +00:00
parent f5dff68d73
commit 7461c78a19
2 changed files with 180 additions and 124 deletions

View File

@ -30,6 +30,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.activeio.journal.Journal;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.BrokerServiceAware;
@ -50,7 +51,14 @@ import org.apache.activemq.kaha.impl.async.AsyncDataManager;
import org.apache.activemq.kaha.impl.async.Location;
import org.apache.activemq.kaha.impl.index.hash.HashIndex;
import org.apache.activemq.openwire.OpenWireFormat;
import org.apache.activemq.store.*;
import org.apache.activemq.store.JournaledStore;
import org.apache.activemq.store.MessageStore;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.store.ReferenceStore;
import org.apache.activemq.store.ReferenceStoreAdapter;
import org.apache.activemq.store.TopicMessageStore;
import org.apache.activemq.store.TopicReferenceStore;
import org.apache.activemq.store.TransactionStore;
import org.apache.activemq.store.kahadaptor.KahaReferenceStoreAdapter;
import org.apache.activemq.thread.Scheduler;
import org.apache.activemq.thread.Task;
@ -75,6 +83,7 @@ import org.slf4j.LoggerFactory;
* @org.apache.xbean.XBean element="amqPersistenceAdapter"
*
*/
@Deprecated
public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, BrokerServiceAware, JournaledStore {
private static final Logger LOG = LoggerFactory.getLogger(AMQPersistenceAdapter.class);
@ -132,6 +141,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
return this.brokerName;
}
@Override
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
if (this.referenceStoreAdapter != null) {
@ -143,10 +153,12 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
return brokerService;
}
@Override
public void setBrokerService(BrokerService brokerService) {
this.brokerService = brokerService;
}
@Override
public synchronized void start() throws Exception {
if (!started.compareAndSet(false, true)) {
return;
@ -234,6 +246,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
LOG.info("Active data files: " + files);
checkpointTask = taskRunnerFactory.createTaskRunner(new Task() {
@Override
public boolean iterate() {
doCheckpoint();
return false;
@ -268,6 +281,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
// Do a checkpoint periodically.
periodicCheckpointTask = new Runnable() {
@Override
public void run() {
checkpoint(false);
}
@ -275,6 +289,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
scheduler.executePeriodically(periodicCheckpointTask, getCheckpointInterval());
periodicCleanupTask = new Runnable() {
@Override
public void run() {
cleanup();
}
@ -290,6 +305,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
}
@Override
public void stop() throws Exception {
if (!started.compareAndSet(true, false)) {
@ -347,6 +363,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
*
* @param sync
*/
@Override
public void checkpoint(boolean sync) {
try {
if (asyncDataManager == null) {
@ -454,6 +471,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
}
}
@Override
public Set<ActiveMQDestination> getDestinations() {
Set<ActiveMQDestination> destinations = new HashSet<ActiveMQDestination>(referenceStoreAdapter.getDestinations());
destinations.addAll(queues.keySet());
@ -469,6 +487,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
}
}
@Override
public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException {
AMQMessageStore store = queues.get(destination);
if (store == null) {
@ -484,6 +503,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
return store;
}
@Override
public TopicMessageStore createTopicMessageStore(ActiveMQTopic destinationName) throws IOException {
AMQTopicMessageStore store = topics.get(destinationName);
if (store == null) {
@ -504,6 +524,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
*
* @param destination
*/
@Override
public void removeQueueMessageStore(ActiveMQQueue destination) {
AMQMessageStore store= queues.remove(destination);
referenceStoreAdapter.removeQueueMessageStore(destination);
@ -514,26 +535,32 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
*
* @param destination
*/
@Override
public void removeTopicMessageStore(ActiveMQTopic destination) {
topics.remove(destination);
}
@Override
public TransactionStore createTransactionStore() throws IOException {
return transactionStore;
}
@Override
public long getLastMessageBrokerSequenceId() throws IOException {
return referenceStoreAdapter.getLastMessageBrokerSequenceId();
}
@Override
public void beginTransaction(ConnectionContext context) throws IOException {
referenceStoreAdapter.beginTransaction(context);
}
@Override
public void commitTransaction(ConnectionContext context) throws IOException {
referenceStoreAdapter.commitTransaction(context);
}
@Override
public void rollbackTransaction(ConnectionContext context) throws IOException {
referenceStoreAdapter.rollbackTransaction(context);
}
@ -713,6 +740,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
return writeCommand(trace, sync);
}
@Override
public void onUsageChanged(Usage usage, int oldPercentUsage, int newPercentUsage) {
newPercentUsage = (newPercentUsage / 10) * 10;
oldPercentUsage = (oldPercentUsage / 10) * 10;
@ -725,6 +753,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
return transactionStore;
}
@Override
public synchronized void deleteAllMessages() throws IOException {
deleteAllMessages = true;
}
@ -796,6 +825,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
return usageManager;
}
@Override
public void setUsageManager(SystemUsage usageManager) {
this.usageManager = usageManager;
}
@ -813,10 +843,12 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
}
@Override
public synchronized File getDirectory() {
return directory;
}
@Override
public synchronized void setDirectory(File directory) {
this.directory = directory;
}
@ -836,6 +868,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
this.referenceStoreAdapter = referenceStoreAdapter;
}
@Override
public long size(){
return storeSize.get();
}
@ -1106,6 +1139,7 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener,
}
@Override
public long getLastProducerSequenceId(ProducerId id) {
// reference store send has adequate duplicate suppression
return -1;

View File

@ -57,6 +57,7 @@ import org.slf4j.LoggerFactory;
* @org.apache.xbean.XBean
*
*/
@Deprecated
public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerServiceAware {
private static final int STORE_LOCKED_WAIT_DELAY = 10 * 1000;
@ -78,7 +79,6 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
private boolean persistentIndex = true;
private BrokerService brokerService;
public KahaPersistenceAdapter(AtomicLong size) {
this.storeSize=size;
}
@ -87,6 +87,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
this(new AtomicLong());
}
@Override
public Set<ActiveMQDestination> getDestinations() {
Set<ActiveMQDestination> rc = new HashSet<ActiveMQDestination>();
try {
@ -104,6 +105,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
return rc;
}
@Override
public synchronized MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException {
MessageStore rc = queues.get(destination);
if (rc == null) {
@ -117,6 +119,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
return rc;
}
@Override
public synchronized TopicMessageStore createTopicMessageStore(ActiveMQTopic destination)
throws IOException {
TopicMessageStore rc = topics.get(destination);
@ -143,6 +146,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
*
* @param destination Destination to forget
*/
@Override
public void removeQueueMessageStore(ActiveMQQueue destination) {
queues.remove(destination);
try{
@ -159,6 +163,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
*
* @param destination Destination to forget
*/
@Override
public void removeTopicMessageStore(ActiveMQTopic destination) {
topics.remove(destination);
}
@ -168,6 +173,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
return result;
}
@Override
public TransactionStore createTransactionStore() throws IOException {
if (transactionStore == null) {
while (true) {
@ -194,32 +200,39 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
return transactionStore;
}
@Override
public void beginTransaction(ConnectionContext context) {
}
@Override
public void commitTransaction(ConnectionContext context) throws IOException {
if (theStore != null) {
theStore.force();
}
}
@Override
public void rollbackTransaction(ConnectionContext context) {
}
@Override
public void start() throws Exception {
initialize();
}
@Override
public void stop() throws Exception {
if (theStore != null) {
theStore.close();
}
}
@Override
public long getLastMessageBrokerSequenceId() throws IOException {
return 0;
}
@Override
public void deleteAllMessages() throws IOException {
if (theStore != null) {
if (theStore.isInitialized()) {
@ -268,6 +281,7 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
* @param usageManager The UsageManager that is controlling the broker's
* memory usage.
*/
@Override
public void setUsageManager(SystemUsage usageManager) {
}
@ -319,10 +333,12 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
return directory;
}
@Override
public String toString() {
return "KahaPersistenceAdapter(" + getStoreName() + ")";
}
@Override
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
@ -331,20 +347,24 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
return brokerName;
}
@Override
public File getDirectory() {
return this.directory;
}
@Override
public void setDirectory(File directory) {
this.directory = directory;
}
@Override
public void checkpoint(boolean sync) throws IOException {
if (sync) {
getStore().force();
}
}
@Override
public long size(){
return storeSize.get();
}
@ -367,10 +387,12 @@ public class KahaPersistenceAdapter implements PersistenceAdapter, BrokerService
}
}
@Override
public void setBrokerService(BrokerService brokerService) {
this.brokerService = brokerService;
}
@Override
public long getLastProducerSequenceId(ProducerId id) {
// reference store send has adequate duplicate suppression
return -1;