Repository: ignite Updated Branches: refs/heads/ignite-1.6 b95487d61 -> a606f59b5
IGNITE-3149: IGFS: Simplified default configuration and added some sensible defaults which are set automatically. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/992fe660 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/992fe660 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/992fe660 Branch: refs/heads/ignite-1.6 Commit: 992fe660b5efc788ce8106c274cbc0aadf01d9f6 Parents: b369d03 Author: vozerov-gridgain <[email protected]> Authored: Tue May 17 15:11:01 2016 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Tue May 17 15:11:01 2016 +0300 ---------------------------------------------------------------------- config/hadoop/default-config.xml | 111 +++++-------------- .../configuration/FileSystemConfiguration.java | 4 +- .../configuration/HadoopConfiguration.java | 2 +- .../igfs/IgfsGroupDataBlocksKeyMapper.java | 43 ++++++- .../processors/igfs/IgfsDataManager.java | 2 +- .../processors/igfs/IgfsDeleteWorker.java | 10 +- .../internal/processors/igfs/IgfsProcessor.java | 2 +- .../internal/processors/igfs/IgfsUtils.java | 14 +++ 8 files changed, 92 insertions(+), 96 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/config/hadoop/default-config.xml ---------------------------------------------------------------------- diff --git a/config/hadoop/default-config.xml b/config/hadoop/default-config.xml index 30413b0..d8d3636 100644 --- a/config/hadoop/default-config.xml +++ b/config/hadoop/default-config.xml @@ -50,54 +50,32 @@ </bean> <!-- - Abstract IGFS file system configuration to be used as a template. - --> - <bean id="igfsCfgBase" class="org.apache.ignite.configuration.FileSystemConfiguration" abstract="true"> - <!-- Must correlate with cache affinity mapper. --> - <property name="blockSize" value="#{128 * 1024}"/> - <property name="perNodeBatchSize" value="512"/> - <property name="perNodeParallelBatchCount" value="16"/> - - <property name="prefetchBlocks" value="32"/> - </bean> - - <!-- - Abstract cache configuration for IGFS file data to be used as a template. - --> - <bean id="dataCacheCfgBase" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true"> - <property name="cacheMode" value="PARTITIONED"/> - <property name="atomicityMode" value="TRANSACTIONAL"/> - <property name="writeSynchronizationMode" value="FULL_SYNC"/> - <property name="backups" value="0"/> - <property name="affinityMapper"> - <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper"> - <!-- How many sequential blocks will be stored on the same node. --> - <constructor-arg value="512"/> - </bean> - </property> - </bean> - - <!-- - Abstract cache configuration for IGFS metadata to be used as a template. - --> - <bean id="metaCacheCfgBase" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true"> - <property name="cacheMode" value="REPLICATED"/> - <property name="atomicityMode" value="TRANSACTIONAL"/> - <property name="writeSynchronizationMode" value="FULL_SYNC"/> - </bean> - - <!-- Configuration of Ignite node. --> <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> <!-- - Apache Hadoop Accelerator configuration. + Configure caches where IGFS will store data. --> - <property name="hadoopConfiguration"> - <bean class="org.apache.ignite.configuration.HadoopConfiguration"> - <!-- Information about finished jobs will be kept for 30 seconds. --> - <property name="finishedJobInfoTtl" value="30000"/> - </bean> + <property name="cacheConfiguration"> + <list> + <!-- + Configure metadata cache where file system structure will be stored. It must be TRANSACTIONAL, + and must have backups to maintain file system consistency in case of node crash. + --> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="igfs-meta"/> + <property name="cacheMode" value="REPLICATED"/> + <property name="atomicityMode" value="TRANSACTIONAL"/> + </bean> + + <!-- + Configure data cache where file's data will be stored. + --> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="igfs-data"/> + <property name="atomicityMode" value="TRANSACTIONAL"/> + </bean> + </list> </property> <!-- @@ -114,7 +92,8 @@ --> <property name="fileSystemConfiguration"> <list> - <bean class="org.apache.ignite.configuration.FileSystemConfiguration" parent="igfsCfgBase"> + <bean class="org.apache.ignite.configuration.FileSystemConfiguration"> + <!-- IGFS name you will use to access IGFS through Hadoop API. --> <property name="name" value="igfs"/> <!-- Caches with these names must be configured. --> @@ -130,19 +109,17 @@ </bean> </property> - <!-- Sample secondary file system configuration. - 'uri' - the URI of the secondary file system. - 'cfgPath' - optional configuration path of the secondary file system, - e.g. /opt/foo/core-site.xml. Typically left to be null. - 'userName' - optional user name to access the secondary file system on behalf of. Use it - if Hadoop client and the Ignite node are running on behalf of different users. + <!-- + Configure secondary file system if needed. --> <!-- <property name="secondaryFileSystem"> <bean class="org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem"> - <constructor-arg name="uri" value="hdfs://localhost:9000"/> - <constructor-arg name="cfgPath"><null/></constructor-arg> - <constructor-arg name="userName" value="client-user-name"/> + <property name="fileSystemFactory"> + <bean class="org.apache.ignite.hadoop.fs.CachingHadoopFileSystemFactory"> + <property name="uri" value="hdfs://your_hdfs_host:9000"/> + </bean> + </property> </bean> </property> --> @@ -151,34 +128,6 @@ </property> <!-- - Caches needed by IGFS. - --> - <property name="cacheConfiguration"> - <list> - <!-- File system metadata cache. --> - <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="metaCacheCfgBase"> - <property name="name" value="igfs-meta"/> - </bean> - - <!-- File system files data cache. --> - <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="dataCacheCfgBase"> - <property name="name" value="igfs-data"/> - </bean> - </list> - </property> - - <!-- - Disable events. - --> - <property name="includeEventTypes"> - <list> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/> - <util:constant static-field="org.apache.ignite.events.EventType.EVT_JOB_MAPPED"/> - </list> - </property> - - <!-- TCP discovery SPI can be configured with list of addresses if multicast is not available. --> <!-- http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java index 518bbf6..75a9db0 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java @@ -59,10 +59,10 @@ public class FileSystemConfiguration { public static final String DFLT_IGFS_LOG_DIR = "work/igfs/log"; /** Default per node buffer size. */ - public static final int DFLT_PER_NODE_BATCH_SIZE = 100; + public static final int DFLT_PER_NODE_BATCH_SIZE = 512; /** Default number of per node parallel operations. */ - public static final int DFLT_PER_NODE_PARALLEL_BATCH_CNT = 8; + public static final int DFLT_PER_NODE_PARALLEL_BATCH_CNT = 16; /** Default IGFS mode. */ public static final IgfsMode DFLT_MODE = IgfsMode.DUAL_ASYNC; http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java index 51aa291..95ce9d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/HadoopConfiguration.java @@ -25,7 +25,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; */ public class HadoopConfiguration { /** Default finished job info time-to-live. */ - public static final long DFLT_FINISHED_JOB_INFO_TTL = 10_000; + public static final long DFLT_FINISHED_JOB_INFO_TTL = 30_000; /** Default value for external execution flag. */ public static final boolean DFLT_EXTERNAL_EXECUTION = false; http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java index 317c645..b35b692 100644 --- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsGroupDataBlocksKeyMapper.java @@ -31,12 +31,12 @@ import org.apache.ignite.internal.util.typedef.internal.S; * {@code 64kb * 256 = 16Mb}. Larger group sizes would reduce number of splits required to run map-reduce * tasks, but will increase inequality of data size being stored on different nodes. * <p> - * Note that {@link #groupSize()} parameter must correlate to Hadoop split size parameter defined + * Note that {@link #getGroupSize()} parameter must correlate to Hadoop split size parameter defined * in Hadoop via {@code mapred.max.split.size} property. Ideally you want all blocks accessed * within one split to be mapped to {@code 1} group, so they can be located on the same grid node. * For example, default Hadoop split size is {@code 64mb} and default {@code IGFS} block size * is {@code 64kb}. This means that to make sure that each split goes only through blocks on - * the same node (without hopping between nodes over network), we have to make the {@link #groupSize()} + * the same node (without hopping between nodes over network), we have to make the {@link #getGroupSize()} * value be equal to {@code 64mb / 64kb = 1024}. * <p> * It is required for {@code IGFS} data cache to be configured with this mapper. Here is an @@ -47,7 +47,7 @@ import org.apache.ignite.internal.util.typedef.internal.S; * <property name="affinityMapper"> * <bean class="org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper"> * <!-- How many sequential blocks will be stored on the same node. --> - * <constructor-arg value="512"/> + * <property name="groupSize" value="512"/> * </bean> * </property> * ... @@ -58,8 +58,18 @@ public class IgfsGroupDataBlocksKeyMapper extends GridCacheDefaultAffinityKeyMap /** */ private static final long serialVersionUID = 0L; + /** Default group size.*/ + public static final int DFLT_GRP_SIZE = 1024; + /** Size of the group. */ - private final int grpSize; + private int grpSize = DFLT_GRP_SIZE; + + /** + * Default constructor. + */ + public IgfsGroupDataBlocksKeyMapper() { + // No-op. + } /*** * Constructs affinity mapper to group several data blocks with the same key. @@ -89,12 +99,33 @@ public class IgfsGroupDataBlocksKeyMapper extends GridCacheDefaultAffinityKeyMap } /** - * @return Size of the group. + * Get group size. + * <p> + * Group size defines how many sequential file blocks will reside on the same node. This parameter + * must correlate to Hadoop split size parameter defined in Hadoop via {@code mapred.max.split.size} + * property. Ideally you want all blocks accessed within one split to be mapped to {@code 1} group, + * so they can be located on the same grid node. For example, default Hadoop split size is {@code 64mb} + * and default {@code IGFS} block size is {@code 64kb}. This means that to make sure that each split + * goes only through blocks on the same node (without hopping between nodes over network), we have to + * make the group size be equal to {@code 64mb / 64kb = 1024}. + * <p> + * Defaults to {@link #DFLT_GRP_SIZE}. + * + * @return Group size. */ - public int groupSize() { + public int getGroupSize() { return grpSize; } + /** + * Set group size. See {@link #getGroupSize()} for more information. + * + * @param grpSize Group size. + */ + public void setGroupSize(int grpSize) { + this.grpSize = grpSize; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(IgfsGroupDataBlocksKeyMapper.class, this); http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java index 16fbeb8..77fb0a9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java @@ -253,7 +253,7 @@ public class IgfsDataManager extends IgfsManager { .internalCache(igfsCtx.configuration().getDataCacheName()).configuration().getAffinityMapper(); grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ? - ((IgfsGroupDataBlocksKeyMapper)mapper).groupSize() : 1; + ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1; grpBlockSize = igfsCtx.configuration().getBlockSize() * grpSize; http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java index aef60dd..bac7569 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java @@ -27,7 +27,6 @@ import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException import org.apache.ignite.internal.managers.communication.GridIoPolicy; import org.apache.ignite.internal.util.future.GridCompoundFuture; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.internal.util.typedef.internal.LT; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteUuid; @@ -169,11 +168,14 @@ public class IgfsDeleteWorker extends IgfsThread { try { info = meta.info(trashId); } - catch (ClusterTopologyServerNotFoundException e) { - LT.warn(log, e, "Server nodes not found."); + catch (ClusterTopologyServerNotFoundException ignore) { + // Ignore. } catch (IgniteCheckedException e) { - U.error(log, "Cannot obtain trash directory info.", e); + U.warn(log, "Cannot obtain trash directory info (is node stopping?)"); + + if (log.isDebugEnabled()) + U.error(log, "Cannot obtain trash directory info.", e); } if (info != null) { http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java index f152170..82404e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java @@ -162,7 +162,7 @@ public class IgfsProcessor extends IgfsProcessorAdapter { attrVals.add(new IgfsAttributes( igfsCfg.getName(), igfsCfg.getBlockSize(), - ((IgfsGroupDataBlocksKeyMapper)affMapper).groupSize(), + ((IgfsGroupDataBlocksKeyMapper)affMapper).getGroupSize(), igfsCfg.getMetaCacheName(), igfsCfg.getDataCacheName(), igfsCfg.getDefaultMode(), http://git-wip-us.apache.org/repos/asf/ignite/blob/992fe660/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java index 2b31868..45d4bb6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java @@ -23,6 +23,7 @@ import org.apache.ignite.IgniteSystemProperties; import org.apache.ignite.binary.BinaryRawReader; import org.apache.ignite.binary.BinaryRawWriter; import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.configuration.CacheConfiguration; @@ -30,6 +31,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.events.IgfsEvent; import org.apache.ignite.igfs.IgfsException; +import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper; import org.apache.ignite.igfs.IgfsPath; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.binary.BinaryUtils; @@ -356,8 +358,12 @@ public class IgfsUtils { for (FileSystemConfiguration igfsCfg : igfsCfgs) { if (igfsCfg != null) { if (F.eq(ccfg.getName(), igfsCfg.getMetaCacheName())) { + // No copy-on-read. ccfg.setCopyOnRead(false); + // Always full-sync to maintain consistency. + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + // Set co-located affinity mapper if needed. if (igfsCfg.isColocateMetadata() && ccfg.getCacheMode() == CacheMode.REPLICATED && ccfg.getAffinityMapper() == null) @@ -367,8 +373,16 @@ public class IgfsUtils { } if (F.eq(ccfg.getName(), igfsCfg.getDataCacheName())) { + // No copy-on-read. ccfg.setCopyOnRead(false); + // Always full-sync to maintain consistency. + ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); + + // Set affinity mapper if needed. + if (ccfg.getAffinityMapper() == null) + ccfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper()); + return; } }
