use of org.apache.ignite.igfs.IgfsOutputStream in project ignite by apache.
the class IgfsBackupFailoverSelfTest method testWriteFailoverAfterStopMultipleNodes.
/**
* Checks possibility to append the data to files *after* N-1 nodes are stopped.
* First, some data written to files.
* After that N-1 nodes are stopped.
* Then data are attempted to append to the streams opened before the nodes stop.
* If failed, the streams are attempted to reopen and the files are attempted to append.
* After that the read operation is performed to check data correctness.
*
* The test is temporarily disabled due to issues .... .
*
* @throws Exception On error.
*/
public void testWriteFailoverAfterStopMultipleNodes() 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);
}
// Now stop all the nodes but the 1st:
for (int n = 1; n < numIgfsNodes; n++) {
stopGrid(n);
X.println("#### grid " + n + " stopped.");
}
// Create files:
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.");
}
// 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.IgfsOutputStream in project ignite by apache.
the class IgfsAbstractRecordResolverSelfTest method write.
/**
* Write data to the file.
*
* @param chunks Data chunks.
* @throws Exception In case of exception.
*/
protected void write(byte[]... chunks) throws Exception {
IgfsOutputStream os = igfs.create(FILE, true);
if (chunks != null) {
for (byte[] chunk : chunks) os.write(chunk);
}
os.close();
}
Aggregations