use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.
the class IgfsAbstractSelfTest method testAppendParentRoot.
/**
* Test create when parent is the root.
*
* @throws Exception If failed.
*/
public void testAppendParentRoot() throws Exception {
if (appendSupported()) {
IgfsPath file = new IgfsPath("/" + FILE.name());
createFile(igfs, file, true, BLOCK_SIZE, chunk);
appendFile(igfs, file, chunk);
checkFile(igfs, igfsSecondary, file, chunk, chunk);
}
}
use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.
the class IgfsBackupFailoverSelfTest method testReadFailoverAfterStopMultipleNodes.
/**
* Checks correct data read *after* N-1 nodes are stopped.
*
* @throws Exception On error.
*/
public void testReadFailoverAfterStopMultipleNodes() throws Exception {
final IgfsImpl igfs0 = nodeDatas[0].igfsImpl;
clear(igfs0);
IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null);
// Create files through the 0th node:
for (int f = 0; f < files; f++) {
final byte[] data = createChunk(fileSize, f);
createFile(igfs0, filePath(f), true, -1, /*block size unused*/
data);
}
// Check files:
for (int f = 0; f < files; f++) {
IgfsPath path = filePath(f);
byte[] data = createChunk(fileSize, f);
// Check through 0th node:
checkExist(igfs0, path);
checkFileContent(igfs0, path, data);
// Check the same file through other nodes:
for (int n = 1; n < numIgfsNodes; n++) {
checkExist(nodeDatas[n].igfsImpl, path);
checkFileContent(nodeDatas[n].igfsImpl, path, data);
}
}
// Now stop all the nodes but the 1st:
for (int n = 1; n < numIgfsNodes; n++) stopGrid(n);
// Check files again:
for (int f = 0; f < files; f++) {
IgfsPath path = filePath(f);
byte[] data = createChunk(fileSize, f);
// Check through 0th node:
checkExist(igfs0, path);
checkFileContent(igfs0, path, data);
}
}
use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.
the class IgfsBackupFailoverSelfTest method testReadFailoverWhileStoppingMultipleNodes.
/**
* Checks correct data read *while* N-1 nodes are being concurrently stopped.
*
* @throws Exception On error.
*/
public void testReadFailoverWhileStoppingMultipleNodes() throws Exception {
final IgfsImpl igfs0 = nodeDatas[0].igfsImpl;
clear(igfs0);
IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null);
// Create files:
for (int f = 0; f < files; f++) {
final byte[] data = createChunk(fileSize, f);
createFile(igfs0, filePath(f), true, -1, /*block size unused*/
data);
}
// Check files:
for (int f = 0; f < files; f++) {
IgfsPath path = filePath(f);
byte[] data = createChunk(fileSize, f);
// Check through 1st node:
checkExist(igfs0, path);
checkFileContent(igfs0, path, data);
// Check the same file through other nodes:
for (int n = 1; n < numIgfsNodes; n++) {
checkExist(nodeDatas[n].igfsImpl, path);
checkFileContent(nodeDatas[n].igfsImpl, path, data);
}
}
final AtomicBoolean stop = new AtomicBoolean();
GridTestUtils.runMultiThreadedAsync(new Callable() {
@Override
public Object call() throws Exception {
// Some delay to ensure read is in progress.
Thread.sleep(1_000);
// Now stop all the nodes but the 1st:
for (int n = 1; n < numIgfsNodes; n++) {
stopGrid(n);
X.println("grid " + n + " stopped.");
}
Thread.sleep(1_000);
stop.set(true);
return null;
}
}, 1, "igfs-node-stopper");
// Read the files repeatedly, while the nodes are being stopped:
while (!stop.get()) {
// Check files while the nodes are being stopped:
for (int f = 0; f < files; f++) {
IgfsPath path = filePath(f);
byte[] data = createChunk(fileSize, f);
// Check through 1st node:
checkExist(igfs0, path);
checkFileContent(igfs0, path, data);
}
}
}
use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.
the class IgfsBackupFailoverSelfTest method testWriteFailoverWhileStoppingMultipleNodes.
/**
*
* @throws Exception
*/
public void testWriteFailoverWhileStoppingMultipleNodes() throws Exception {
final IgfsImpl igfs0 = nodeDatas[0].igfsImpl;
clear(igfs0);
IgfsAbstractSelfTest.create(igfs0, paths(DIR, SUBDIR), null);
final IgfsOutputStream[] outStreams = new IgfsOutputStream[files];
// Create files:
for (int f = 0; f < files; f++) {
final byte[] data = createChunk(fileSize, f);
IgfsOutputStream os = null;
try {
os = igfs0.create(filePath(f), 256, true, null, 0, -1, null);
assert os != null;
writeFileChunks(os, data);
} finally {
if (os != null)
os.flush();
}
outStreams[f] = os;
X.println("write #1 completed: " + f);
}
final AtomicBoolean stop = new AtomicBoolean();
GridTestUtils.runMultiThreadedAsync(new Callable() {
@Override
public Object call() throws Exception {
// Some delay to ensure read is in progress.
Thread.sleep(10_000);
// Now stop all the nodes but the 1st:
for (int n = 1; n < numIgfsNodes; n++) {
stopGrid(n);
X.println("#### grid " + n + " stopped.");
}
//Thread.sleep(10_000);
stop.set(true);
return null;
}
}, 1, "igfs-node-stopper");
// Write #2:
for (int f0 = 0; f0 < files; f0++) {
final IgfsOutputStream os = outStreams[f0];
assert os != null;
final int f = f0;
int att = doWithRetries(1, new Callable<Void>() {
@Override
public Void call() throws Exception {
IgfsOutputStream ios = os;
try {
writeChunks0(igfs0, ios, f);
} catch (IOException ioe) {
log().warning("Attempt to append the data to existing stream failed: ", ioe);
ios = igfs0.append(filePath(f), false);
assert ios != null;
writeChunks0(igfs0, ios, f);
}
return null;
}
});
assert att == 1;
X.println("write #2 completed: " + f0 + " in " + att + " attempts.");
}
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return stop.get();
}
}, 25_000);
// Check files:
for (int f = 0; f < files; f++) {
IgfsPath path = filePath(f);
byte[] data = createChunk(fileSize, f);
// Check through 1st node:
checkExist(igfs0, path);
assertEquals("File length mismatch.", data.length * 2, igfs0.size(path));
checkFileContent(igfs0, path, data, data);
X.println("Read test completed: " + f);
}
}
use of org.apache.ignite.igfs.IgfsPath in project ignite by apache.
the class IgfsAbstractSelfTest method testMoveDirectorySourceParentRoot.
/**
* Test directory move when source parent is the root.
*
* @throws Exception If failed.
*/
public void testMoveDirectorySourceParentRoot() throws Exception {
IgfsPath dir = new IgfsPath("/" + SUBSUBDIR.name());
create(igfs, paths(DIR_NEW, SUBDIR_NEW, dir), null);
igfs.rename(dir, SUBDIR_NEW);
checkExist(igfs, igfsSecondary, new IgfsPath(SUBDIR_NEW, SUBSUBDIR.name()));
checkNotExist(igfs, igfsSecondary, dir);
}
Aggregations