Search in sources :

Example 1 with IgfsMode

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));
}
Also used : IgfsMode(org.apache.ignite.igfs.IgfsMode) ObjectOutput(java.io.ObjectOutput) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with IgfsMode

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;
}
Also used : IgfsMode(org.apache.ignite.igfs.IgfsMode) IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 3 with IgfsMode

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)));
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) IgfsMode(org.apache.ignite.igfs.IgfsMode) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) T2(org.apache.ignite.internal.util.typedef.T2) HashSet(java.util.HashSet)

Example 4 with IgfsMode

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);
    }
}
Also used : IgfsMode(org.apache.ignite.igfs.IgfsMode)

Example 5 with IgfsMode

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);
}
Also used : IgfsMode(org.apache.ignite.igfs.IgfsMode) IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) IgfsEx(org.apache.ignite.internal.processors.igfs.IgfsEx) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) IgfsIpcEndpointConfiguration(org.apache.ignite.igfs.IgfsIpcEndpointConfiguration) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

IgfsMode (org.apache.ignite.igfs.IgfsMode)16 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 HashMap (java.util.HashMap)6 IgniteException (org.apache.ignite.IgniteException)5 IgfsException (org.apache.ignite.igfs.IgfsException)5 IgfsInvalidPathException (org.apache.ignite.igfs.IgfsInvalidPathException)5 IgfsPathIsDirectoryException (org.apache.ignite.igfs.IgfsPathIsDirectoryException)5 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)5 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)4 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)4 IgfsPath (org.apache.ignite.igfs.IgfsPath)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IgfsFile (org.apache.ignite.igfs.IgfsFile)2 IgfsIpcEndpointConfiguration (org.apache.ignite.igfs.IgfsIpcEndpointConfiguration)2 T2 (org.apache.ignite.internal.util.typedef.T2)2 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)2