This closes #2222
This commit is contained in:
commit
44d4fea65c
|
@ -224,8 +224,10 @@ public abstract class AbstractSequentialFileFactory implements SequentialFileFac
|
|||
@Override
|
||||
public void createDirs() throws Exception {
|
||||
boolean ok = journalDir.mkdirs();
|
||||
if (!ok) {
|
||||
throw new IOException("Failed to create directory " + journalDir);
|
||||
if (!ok && !journalDir.exists()) {
|
||||
IOException e = new IOException("Unable to create directory: " + journalDir);
|
||||
onIOError(e, e.getMessage(), null);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.HashSet;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -96,6 +97,7 @@ import org.apache.activemq.artemis.utils.actors.ArtemisExecutor;
|
|||
import org.jboss.logging.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -1400,6 +1402,62 @@ public class PagingTest extends ActiveMQTestBase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInabilityToCreateDirectoryDuringPaging() throws Exception {
|
||||
// this test only applies to file-based stores
|
||||
Assume.assumeTrue(storeType == StoreConfiguration.StoreType.FILE);
|
||||
|
||||
clearDataRecreateServerDirs();
|
||||
|
||||
Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false).setPagingDirectory(UUID.randomUUID().toString());
|
||||
|
||||
server = createServer(true, config, PagingTest.PAGE_SIZE, PagingTest.PAGE_MAX);
|
||||
|
||||
server.start();
|
||||
|
||||
final int numberOfMessages = 100;
|
||||
|
||||
locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true);
|
||||
|
||||
sf = createSessionFactory(locator);
|
||||
|
||||
ClientSession session = sf.createSession(false, true, true);
|
||||
|
||||
session.createQueue(PagingTest.ADDRESS, RoutingType.MULTICAST, PagingTest.ADDRESS, null, true);
|
||||
|
||||
ClientProducer producer = session.createProducer(PagingTest.ADDRESS);
|
||||
|
||||
ClientMessage message = null;
|
||||
|
||||
byte[] body = new byte[MESSAGE_SIZE];
|
||||
|
||||
ByteBuffer bb = ByteBuffer.wrap(body);
|
||||
|
||||
for (int j = 1; j <= MESSAGE_SIZE; j++) {
|
||||
bb.put(getSamplebyte(j));
|
||||
}
|
||||
|
||||
for (int i = 0; i < numberOfMessages; i++) {
|
||||
message = session.createMessage(true);
|
||||
|
||||
ActiveMQBuffer bodyLocal = message.getBodyBuffer();
|
||||
|
||||
bodyLocal.writeBytes(body);
|
||||
|
||||
message.putIntProperty(new SimpleString("id"), i);
|
||||
|
||||
try {
|
||||
producer.send(message);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
assertTrue(Wait.waitFor(() -> server.getState() == ActiveMQServer.SERVER_STATE.STOPPED, 5000, 200));
|
||||
session.close();
|
||||
sf.close();
|
||||
locator.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test will remove all the page directories during a restart, simulating a crash scenario. The server should still start after this
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue