use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsFragmentizerSelfTest method checkFlushFragmentizing.
/**
* @param chunkSize Chunk size to test.
* @throws Exception If failed.
*/
private void checkFlushFragmentizing(int chunkSize) throws Exception {
IgfsPath path = new IgfsPath("/someFile");
long written = 0;
int cnt = 0;
int fileSize = 50 * IGFS_GROUP_SIZE * IGFS_BLOCK_SIZE;
IgniteFileSystem igfs = grid(0).fileSystem("igfs");
byte[] chunk = new byte[chunkSize];
while (written < fileSize) {
try (IgfsOutputStream out = igfs.append(path, true)) {
for (int i = 0; i < 8; i++) {
Arrays.fill(chunk, (byte) cnt);
out.write(chunk);
out.flush();
written += chunkSize;
cnt++;
}
}
}
try (IgfsInputStream in = igfs.open(path)) {
cnt = 0;
int read = 0;
while (read < fileSize) {
readFully(in, chunk);
for (byte b : chunk) assertEquals("For read offset [start=" + read + ", filler=" + (cnt & 0xFF) + ']', cnt & 0xFF, b & 0xFF);
cnt++;
read += chunkSize;
}
}
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsFragmentizerTopologySelfTest method testCoordinatorLeave.
/**
* @throws Exception If failed.
*/
public void testCoordinatorLeave() throws Exception {
stopGrid(0);
// Now node 1 should be coordinator.
try {
IgfsPath path = new IgfsPath("/someFile");
IgniteFileSystem igfs = grid(1).fileSystem("igfs");
try (IgfsOutputStream out = igfs.create(path, true)) {
for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) out.write(new byte[IGFS_BLOCK_SIZE]);
}
awaitFileFragmenting(1, path);
} finally {
startGrid(0);
}
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class VisorNodeDataCollectorJob method igfs.
/**
* Collect IGFSs.
*
* @param res Job result.
*/
protected void igfs(VisorNodeDataCollectorJobResult res) {
try {
IgfsProcessorAdapter igfsProc = ignite.context().igfs();
for (IgniteFileSystem igfs : igfsProc.igfss()) {
long start0 = U.currentTimeMillis();
FileSystemConfiguration igfsCfg = igfs.configuration();
if (proxyCache(igfsCfg.getDataCacheConfiguration().getName()) || proxyCache(igfsCfg.getMetaCacheConfiguration().getName()))
continue;
try {
Collection<IpcServerEndpoint> endPoints = igfsProc.endpoints(igfs.name());
if (endPoints != null) {
for (IpcServerEndpoint ep : endPoints) if (ep.isManagement())
res.getIgfsEndpoints().add(new VisorIgfsEndpoint(igfs.name(), ignite.name(), ep.getHost(), ep.getPort()));
}
res.getIgfss().add(new VisorIgfs(igfs));
} finally {
if (debug)
log(ignite.log(), "Collected IGFS: " + igfs.name(), getClass(), start0);
}
}
} catch (Exception e) {
res.setIgfssEx(new VisorExceptionWrapper(e));
}
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsJobImpl method execute.
/**
* {@inheritDoc}
*/
@Override
public Object execute() {
IgniteFileSystem fs = ignite.fileSystem(igfsName);
try (IgfsInputStream in = fs.open(path)) {
IgfsFileRange split = new IgfsFileRange(path, start, len);
if (rslvr != null) {
split = rslvr.resolveRecords(fs, in, split);
if (split == null) {
log.warning("No data found for split on local node after resolver is applied " + "[igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']');
return null;
}
}
in.seek(split.start());
return job.execute(fs, new IgfsFileRange(path, split.start(), split.length()), in);
} catch (IOException e) {
throw new IgniteException("Failed to execute IGFS job for file split [igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']', e);
}
}
use of org.apache.ignite.IgniteFileSystem in project ignite by apache.
the class IgfsMetricsSelfTest method testMultipleClose.
/**
* @throws Exception If failed.
*/
public void testMultipleClose() throws Exception {
IgniteFileSystem fs = igfsPrimary[0];
IgfsOutputStream out = fs.create(new IgfsPath("/primary/file"), false);
out.close();
out.close();
IgfsInputStream in = fs.open(new IgfsPath("/primary/file"));
in.close();
in.close();
IgfsMetrics m = fs.metrics();
assertEquals(0, m.filesOpenedForWrite());
assertEquals(0, m.filesOpenedForRead());
}
Aggregations