use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsProcessorSelfTest method testigfsEnabled.
/**
* @throws Exception If failed.
*/
public void testigfsEnabled() throws Exception {
IgniteFileSystem igfs = grid(0).fileSystem(igfsName());
assertNotNull(igfs);
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class HadoopIgfs20FileSystemAbstractSelfTest method testZeroReplicationFactor.
/**
* @throws Exception If failed.
*/
public void testZeroReplicationFactor() throws Exception {
// This test doesn't make sense for any mode except of PRIMARY.
if (mode == PRIMARY) {
Path igfsHome = new Path(primaryFsUri);
Path file = new Path(igfsHome, "someFile");
try (FSDataOutputStream out = fs.create(file, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault()), Options.CreateOpts.repFac((short) 1))) {
out.write(new byte[1024 * 1024]);
}
IgniteFileSystem igfs = grid(0).fileSystem("igfs");
IgfsPath filePath = new IgfsPath("/someFile");
IgfsFile fileInfo = igfs.info(filePath);
Collection<IgfsBlockLocation> locations = igfs.affinity(filePath, 0, fileInfo.length());
assertEquals(1, locations.size());
IgfsBlockLocation location = F.first(locations);
assertEquals(1, location.nodeIds().size());
}
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsFragmentizerSelfTest method testReadFragmentizing.
/**
* @throws Exception If failed.
*/
public void testReadFragmentizing() throws Exception {
IgniteFileSystem igfs = grid(0).fileSystem("igfs");
IgfsPath path = new IgfsPath("/someFile");
try (IgfsOutputStream out = igfs.create(path, true)) {
// Write 10 groups.
for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) {
byte[] data = new byte[IGFS_BLOCK_SIZE];
Arrays.fill(data, (byte) i);
out.write(data);
}
}
long start = System.currentTimeMillis();
do {
try (IgfsInputStream in = igfs.open(path)) {
for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) {
for (int j = 0; j < IGFS_BLOCK_SIZE; j++) assertEquals(i & 0xFF, in.read());
}
assertEquals(-1, in.read());
}
} while (System.currentTimeMillis() - start < 7000);
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsFragmentizerSelfTest method checkAppendFragmentizing.
/**
* @throws Exception If failed.
*/
private void checkAppendFragmentizing(int chunkSize, boolean rotate) throws Exception {
IgfsPath path = new IgfsPath("/someFile");
long written = 0;
int i = 0;
int igfsIdx = 0;
int fileSize = 30 * IGFS_GROUP_SIZE * IGFS_BLOCK_SIZE;
while (written < fileSize) {
IgniteFileSystem igfs = grid(igfsIdx).fileSystem("igfs");
try (IgfsOutputStream out = igfs.append(path, true)) {
byte[] data = new byte[chunkSize];
Arrays.fill(data, (byte) i);
out.write(data);
}
System.out.println("Written [start=" + written + ", filler=" + i + ']');
written += chunkSize;
i++;
if (rotate && i % 5 == 0) {
igfsIdx++;
if (igfsIdx >= NODE_CNT)
igfsIdx = 0;
}
}
IgniteFileSystem igfs = grid(0).fileSystem("igfs");
try (IgfsInputStream in = igfs.open(path)) {
i = 0;
int read = 0;
byte[] chunk = new byte[chunkSize];
while (read < fileSize) {
readFully(in, chunk);
for (byte b : chunk) assertEquals("For read offset [start=" + read + ", filler=" + (i & 0xFF) + ']', i & 0xFF, b & 0xFF);
i++;
read += chunkSize;
}
}
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class HadoopClientProtocolMultipleServersSelfTest method beforeJob.
/**
* @throws Exception If failed.
*/
private void beforeJob() throws Exception {
IgniteFileSystem igfs = grid(0).fileSystem(HadoopAbstractSelfTest.igfsName);
igfs.clear();
igfs.mkdirs(new IgfsPath(PATH_INPUT));
try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create(new IgfsPath(PATH_INPUT + "/test.file"), true)))) {
bw.write("word");
}
}
Aggregations