Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#getFileSystemConfiguration()

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#getFileSystemConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgfsProcessorValidationSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testRemoteIfAffinityMapperGroupSizeDiffers() throws Exception {
    IgniteConfiguration g2Cfg = getConfiguration("g2");

    G.start(g1Cfg);

    for (FileSystemConfiguration igfsCfg : g2Cfg.getFileSystemConfiguration())
        igfsCfg.setDataCacheConfiguration(dataCache(1000));

    checkGridStartFails(g2Cfg, "Affinity mapper group size should be the same on all nodes in grid for IGFS",
        false);
}
 
Example 2
Source File: IgfsUtils.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Prepare cache configuration if this is IGFS meta or data cache.
 *
 * @param cfg Configuration.
 * @throws IgniteCheckedException If failed.
 */
public static void prepareCacheConfigurations(IgniteConfiguration cfg) throws IgniteCheckedException {
    FileSystemConfiguration[] igfsCfgs = cfg.getFileSystemConfiguration();
    List<CacheConfiguration> ccfgs = new ArrayList<>(Arrays.asList(cfg.getCacheConfiguration()));

    if (igfsCfgs != null) {
        for (FileSystemConfiguration igfsCfg : igfsCfgs) {
            if (igfsCfg == null)
                continue;

            CacheConfiguration ccfgMeta = igfsCfg.getMetaCacheConfiguration();

            if (ccfgMeta == null) {
                ccfgMeta = defaultMetaCacheConfig();

                igfsCfg.setMetaCacheConfiguration(ccfgMeta);
            }

            ccfgMeta.setName(IGFS_CACHE_PREFIX + igfsCfg.getName() + META_CACHE_SUFFIX);

            ccfgs.add(ccfgMeta);

            CacheConfiguration ccfgData = igfsCfg.getDataCacheConfiguration();

            if (ccfgData == null) {
                ccfgData = defaultDataCacheConfig();

                igfsCfg.setDataCacheConfiguration(ccfgData);
            }

            ccfgData.setName(IGFS_CACHE_PREFIX + igfsCfg.getName() + DATA_CACHE_SUFFIX);

            ccfgs.add(ccfgData);

            // No copy-on-read.
            ccfgMeta.setCopyOnRead(false);
            ccfgData.setCopyOnRead(false);

            // Always full-sync to maintain consistency.
            ccfgMeta.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
            ccfgData.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);

            // Set co-located affinity mapper if needed.
            if (igfsCfg.isColocateMetadata() && ccfgMeta.getAffinityMapper() == null)
                ccfgMeta.setAffinityMapper(new IgfsColocatedMetadataAffinityKeyMapper());

            // Set affinity mapper if needed.
            if (ccfgData.getAffinityMapper() == null)
                ccfgData.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper());
        }

        cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
    }

    validateLocalIgfsConfigurations(cfg);
}
 
Example 3
Source File: IgfsUtils.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Validates local IGFS configurations. Compares attributes only for IGFSes with same name.
 *
 * @param igniteCfg Ignite config.
 * @throws IgniteCheckedException If any of IGFS configurations is invalid.
 */
private static void validateLocalIgfsConfigurations(IgniteConfiguration igniteCfg)
    throws IgniteCheckedException {

    if (igniteCfg.getFileSystemConfiguration() == null || igniteCfg.getFileSystemConfiguration().length == 0)
        return;

    Collection<String> cfgNames = new HashSet<>();

    for (FileSystemConfiguration cfg : igniteCfg.getFileSystemConfiguration()) {
        String name = cfg.getName();

        if (name == null)
            throw new IgniteCheckedException("IGFS name cannot be null");

        if (cfgNames.contains(name))
            throw new IgniteCheckedException("Duplicate IGFS name found (check configuration and " +
                "assign unique name to each): " + name);

        CacheConfiguration ccfgData = cfg.getDataCacheConfiguration();

        CacheConfiguration ccfgMeta = cfg.getMetaCacheConfiguration();

        if (QueryUtils.isEnabled(ccfgData))
            throw new IgniteCheckedException("IGFS data cache cannot start with enabled query indexing.");

        if (QueryUtils.isEnabled(ccfgMeta))
            throw new IgniteCheckedException("IGFS metadata cache cannot start with enabled query indexing.");

        if (ccfgMeta.getAtomicityMode() != TRANSACTIONAL)
            throw new IgniteCheckedException("IGFS metadata cache should be transactional: " + cfg.getName());

        if (!(ccfgData.getAffinityMapper() instanceof IgfsGroupDataBlocksKeyMapper))
            throw new IgniteCheckedException(
                "Invalid IGFS data cache configuration (key affinity mapper class should be " +
                IgfsGroupDataBlocksKeyMapper.class.getSimpleName() + "): " + cfg);

        IgfsIpcEndpointConfiguration ipcCfg = cfg.getIpcEndpointConfiguration();

        if (ipcCfg != null) {
            final int tcpPort = ipcCfg.getPort();

            if (!(tcpPort >= MIN_TCP_PORT && tcpPort <= MAX_TCP_PORT))
                throw new IgniteCheckedException("IGFS endpoint TCP port is out of range [" + MIN_TCP_PORT +
                    ".." + MAX_TCP_PORT + "]: " + tcpPort);

            if (ipcCfg.getThreadCount() <= 0)
                throw new IgniteCheckedException("IGFS endpoint thread count must be positive: " +
                    ipcCfg.getThreadCount());
        }

        boolean secondary = cfg.getDefaultMode() == IgfsMode.PROXY;

        if (cfg.getPathModes() != null) {
            for (Map.Entry<String, IgfsMode> mode : cfg.getPathModes().entrySet()) {
                if (mode.getValue() == IgfsMode.PROXY)
                    secondary = true;
            }
        }

        if (secondary && cfg.getSecondaryFileSystem() == null) {
            // When working in any mode except of primary, secondary FS config must be provided.
            throw new IgniteCheckedException("Grid configuration parameter invalid: " +
                "secondaryFileSystem cannot be null when mode is not " + IgfsMode.PRIMARY);
        }

        cfgNames.add(name);
    }
}