mirror of
https://github.com/apache/activemq.git
synced 2025-02-17 07:24:51 +00:00
https://issues.apache.org/jira/browse/AMQ-6005 - have plist whack it existing state on start. Start the temp store after the primary persistence adapter which does the locking
(cherry picked from commit 768fa17085ac938441915a82987c99b37ac52515)
This commit is contained in:
parent
2be754583c
commit
9e8f020301
@ -665,6 +665,19 @@ public class BrokerService implements Service {
|
||||
}
|
||||
getPersistenceAdapter().start();
|
||||
|
||||
getTempDataStore();
|
||||
if (tempDataStore != null) {
|
||||
try {
|
||||
// start after we have the store lock
|
||||
tempDataStore.start();
|
||||
} catch (Exception e) {
|
||||
RuntimeException exception = new RuntimeException(
|
||||
"Failed to start temp data store: " + tempDataStore, e);
|
||||
LOG.error(exception.getLocalizedMessage(), e);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
getJobSchedulerStore();
|
||||
if (jobSchedulerStore != null) {
|
||||
try {
|
||||
@ -1717,32 +1730,11 @@ public class BrokerService implements Service {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
boolean result = true;
|
||||
boolean empty = true;
|
||||
try {
|
||||
File directory = getTmpDataDirectory();
|
||||
if (directory.exists() && directory.isDirectory()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null && files.length > 0) {
|
||||
empty = false;
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (!file.isDirectory()) {
|
||||
result &= file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty) {
|
||||
String str = result ? "Successfully deleted" : "Failed to delete";
|
||||
LOG.info("{} temporary storage", str);
|
||||
}
|
||||
|
||||
String clazz = "org.apache.activemq.store.kahadb.plist.PListStoreImpl";
|
||||
this.tempDataStore = (PListStore) getClass().getClassLoader().loadClass(clazz).newInstance();
|
||||
this.tempDataStore.setDirectory(getTmpDataDirectory());
|
||||
configureService(tempDataStore);
|
||||
this.tempDataStore.start();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -1757,13 +1749,6 @@ public class BrokerService implements Service {
|
||||
public void setTempDataStore(PListStore tempDataStore) {
|
||||
this.tempDataStore = tempDataStore;
|
||||
configureService(tempDataStore);
|
||||
try {
|
||||
tempDataStore.start();
|
||||
} catch (Exception e) {
|
||||
RuntimeException exception = new RuntimeException("Failed to start provided temp data store: " + tempDataStore, e);
|
||||
LOG.error(exception.getLocalizedMessage(), e);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPersistenceThreadPriority() {
|
||||
|
@ -276,6 +276,7 @@ public class PListStoreImpl extends ServiceSupport implements BrokerServiceAware
|
||||
this.directory = new File(IOHelper.getDefaultDataDirectory() + File.pathSeparator + "delayedDB");
|
||||
}
|
||||
IOHelper.mkdirs(this.directory);
|
||||
IOHelper.deleteChildren(this.directory);
|
||||
lock();
|
||||
this.journal = new Journal();
|
||||
this.journal.setDirectory(directory);
|
||||
|
@ -39,7 +39,7 @@ public class FilePendingMessageCursorTestSupport {
|
||||
@After
|
||||
public void stopBroker() throws Exception {
|
||||
if (brokerService != null) {
|
||||
brokerService.getTempDataStore().stop();
|
||||
brokerService.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ public class FilePendingMessageCursorTestSupport {
|
||||
brokerService.setUseJmx(false);
|
||||
SystemUsage usage = brokerService.getSystemUsage();
|
||||
usage.getTempUsage().setLimit(1025*1024*15);
|
||||
brokerService.start();
|
||||
|
||||
// put something in the temp store to on demand initialise it
|
||||
PList dud = brokerService.getTempDataStore().getPList("dud");
|
||||
|
@ -44,6 +44,7 @@ public class KahaDBFilePendingMessageCursorTest extends FilePendingMessageCursor
|
||||
String body = new String(new byte[1024]);
|
||||
Destination destination = new Queue(brokerService, new ActiveMQQueue("Q"), null, new DestinationStatistics(), null);
|
||||
|
||||
brokerService.start();
|
||||
underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
|
||||
underTest.setSystemUsage(usage);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user