use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsAttributesSelfTest method testSerialization.
/**
* @throws Exception If failed.
*/
public void testSerialization() throws Exception {
Map<String, IgfsMode> pathModes = new HashMap<>();
pathModes.put("path1", PRIMARY);
pathModes.put("path2", PROXY);
IgfsAttributes attrs = new IgfsAttributes("testIgfsName", 513000, 888, "meta", "data", DUAL_SYNC, pathModes, true);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput os = new ObjectOutputStream(bos);
os.writeObject(attrs);
os.close();
IgfsAttributes deserializedAttrs = (IgfsAttributes) new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray())).readObject();
assertTrue(eq(attrs, deserializedAttrs));
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsMetricsSelfTest method primaryConfiguration.
/**
* Get configuration for a grid with the primary file system.
*
* @param idx Node index.
* @return Configuration.
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
private IgniteConfiguration primaryConfiguration(int idx) throws Exception {
FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
igfsCfg.setName(IGFS_PRIMARY);
igfsCfg.setBlockSize(PRIMARY_BLOCK_SIZE);
igfsCfg.setDefaultMode(DUAL_SYNC);
igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());
Map<String, IgfsMode> pathModes = new HashMap<>();
pathModes.put("/primary", PRIMARY);
igfsCfg.setPathModes(pathModes);
CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
dataCacheCfg.setCacheMode(PARTITIONED);
dataCacheCfg.setNearConfiguration(null);
dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
dataCacheCfg.setBackups(0);
dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
metaCacheCfg.setCacheMode(REPLICATED);
metaCacheCfg.setNearConfiguration(null);
metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
igfsCfg.setDataCacheConfiguration(dataCacheCfg);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName("grid-" + idx);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(discoSpi);
cfg.setFileSystemConfiguration(igfsCfg);
cfg.setLocalHost("127.0.0.1");
return cfg;
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class IgfsModeResolverSelfTest method testModesValidation.
/**
* @throws Exception If failed.
*/
public void testModesValidation() throws Exception {
// Another mode inside PRIMARY directory:
try {
IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(new T2<>(new IgfsPath("/a/"), PRIMARY), new T2<>(new IgfsPath("/a/b/"), DUAL_ASYNC)), new HashSet<IgfsPath>());
fail("IgniteCheckedException expected");
} catch (IgniteCheckedException ignored) {
// No-op.
}
// PRIMARY default mode and non-primary subfolder:
for (IgfsMode m : IgfsMode.values()) {
if (m != IgfsMode.PRIMARY) {
try {
IgfsUtils.preparePathModes(PRIMARY, Arrays.asList(new T2<>(new IgfsPath("/a/"), DUAL_ASYNC)), new HashSet<IgfsPath>());
fail("IgniteCheckedException expected");
} catch (IgniteCheckedException ignored) {
// No-op.
}
}
}
// Duplicated sub-folders should be ignored:
List<T2<IgfsPath, IgfsMode>> modes = IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(new T2<>(new IgfsPath("/a"), PRIMARY), new T2<>(new IgfsPath("/c/d/"), PRIMARY), new T2<>(new IgfsPath("/c/d/e/f"), PRIMARY)), new HashSet<IgfsPath>());
assertNotNull(modes);
assertEquals(2, modes.size());
assertEquals(modes, Arrays.asList(new T2<>(new IgfsPath("/c/d/"), PRIMARY), new T2<>(new IgfsPath("/a"), PRIMARY)));
// Non-duplicated sub-folders should not be ignored:
modes = IgfsUtils.preparePathModes(DUAL_SYNC, Arrays.asList(new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC), new T2<>(new IgfsPath("/a/b/c"), DUAL_SYNC), new T2<>(new IgfsPath("/a/b/c/d"), DUAL_ASYNC)), new HashSet<IgfsPath>());
assertNotNull(modes);
assertEquals(modes.size(), 3);
assertEquals(modes, Arrays.asList(new T2<>(new IgfsPath("/a/b/c/d"), DUAL_ASYNC), new T2<>(new IgfsPath("/a/b/c"), DUAL_SYNC), new T2<>(new IgfsPath("/a/b"), DUAL_ASYNC)));
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class VisorIgfsProfiler method aggregateIgfsProfilerEntries.
/**
* Aggregate IGFS profiler entries.
*
* @param entries Entries to sum.
* @return Single aggregated entry.
*/
public static VisorIgfsProfilerEntry aggregateIgfsProfilerEntries(List<VisorIgfsProfilerEntry> entries) {
assert !F.isEmpty(entries);
if (entries.size() == 1)
// No need to aggregate.
return entries.get(0);
else {
String path = entries.get(0).getPath();
Collections.sort(entries, VisorIgfsProfilerEntry.ENTRY_TIMESTAMP_COMPARATOR);
long ts = 0;
long size = 0;
long bytesRead = 0;
long readTime = 0;
long userReadTime = 0;
long bytesWritten = 0;
long writeTime = 0;
long userWriteTime = 0;
IgfsMode mode = null;
VisorIgfsProfilerUniformityCounters counters = new VisorIgfsProfilerUniformityCounters();
for (VisorIgfsProfilerEntry entry : entries) {
// Take last timestamp.
ts = entry.getTimestamp();
// Take last size.
size = entry.getSize();
// Take last mode.
mode = entry.getMode();
// Aggregate metrics.
bytesRead += entry.getBytesRead();
readTime += entry.getReadTime();
userReadTime += entry.getUserReadTime();
bytesWritten += entry.getBytesWritten();
writeTime += entry.getWriteTime();
userWriteTime += entry.getUserWriteTime();
counters.aggregate(entry.getCounters());
}
return new VisorIgfsProfilerEntry(path, ts, mode, size, bytesRead, readTime, userReadTime, bytesWritten, writeTime, userWriteTime, counters);
}
}
use of org.apache.ignite.igfs.IgfsMode in project ignite by apache.
the class HadoopFIleSystemFactorySelfTest method start.
/**
* Start Ignite node with IGFS instance.
*
* @param name Node and IGFS name.
* @param endpointPort Endpoint port.
* @param dfltMode Default path mode.
* @param secondaryFs Secondary file system.
* @return Igfs instance.
*/
private static IgfsEx start(String name, int endpointPort, IgfsMode dfltMode, @Nullable IgfsSecondaryFileSystem secondaryFs) {
IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();
endpointCfg.setType(IgfsIpcEndpointType.TCP);
endpointCfg.setHost("127.0.0.1");
endpointCfg.setPort(endpointPort);
FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
igfsCfg.setName(name);
igfsCfg.setDefaultMode(dfltMode);
igfsCfg.setIpcEndpointConfiguration(endpointCfg);
igfsCfg.setSecondaryFileSystem(secondaryFs);
CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
dataCacheCfg.setCacheMode(PARTITIONED);
dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
dataCacheCfg.setBackups(0);
dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
metaCacheCfg.setCacheMode(REPLICATED);
metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
igfsCfg.setDataCacheConfiguration(dataCacheCfg);
igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
if (secondaryFs != null) {
Map<String, IgfsMode> modes = new HashMap<>();
modes.put("/ignite/sync/", IgfsMode.DUAL_SYNC);
modes.put("/ignite/async/", IgfsMode.DUAL_ASYNC);
modes.put("/ignite/proxy/", IgfsMode.PROXY);
igfsCfg.setPathModes(modes);
}
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName(name);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
cfg.setDiscoverySpi(discoSpi);
cfg.setFileSystemConfiguration(igfsCfg);
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
return (IgfsEx) G.start(cfg).fileSystem(name);
}
Aggregations