美文网首页
Ignite 源码分析(一)

Ignite 源码分析(一)

作者: 走在成长的道路上 | 来源:发表于2020-10-06 22:09 被阅读0次

基础架构图

源码架构

主程序中由 spring 架构进行支撑,将配置以 Bean 的方式存在,比如 IgniteConfiguration 就是在 default-config.xml 文件中进行申明的主要配置内容。

/**
 * This class defines grid runtime configuration. This configuration is passed to
 * {@link Ignition#start(IgniteConfiguration)} method. It defines all configuration
 * parameters required to start a grid instance. Usually, a special
 * class called "loader" will create an instance of this interface and apply
 * {@link Ignition#start(IgniteConfiguration)} method to initialize Ignite instance.
 * <p>
 * Note that you should only set values that differ from defaults, as grid
 * will automatically pick default values for all values that are not set.
 * <p>
 * For more information about grid configuration and startup refer to {@link Ignition}
 * documentation.
 */
public class IgniteConfiguration {
    /** Courtesy notice log category. */
    public static final String COURTESY_LOGGER_NAME = "org.apache.ignite.CourtesyConfigNotice";

    /**
     * Default flag for peer class loading. By default the value is {@code false}
     * which means that peer class loading is disabled.
     */
    public static final boolean DFLT_P2P_ENABLED = false;

    /** Default metrics history size (value is {@code 10000}). */
    public static final int DFLT_METRICS_HISTORY_SIZE = 10000;

    /** Default metrics update frequency. */
    public static final long DFLT_METRICS_UPDATE_FREQ = 2000;

    /**
     * Default metrics expire time. The value is {@link Long#MAX_VALUE} which
     * means that metrics never expire.
     */
    public static final long DFLT_METRICS_EXPIRE_TIME = Long.MAX_VALUE;

    /** Default maximum timeout to wait for network responses in milliseconds (value is {@code 5,000ms}). */
    public static final long DFLT_NETWORK_TIMEOUT = 5000;

    /** Default compression level for network messages (value is Deflater.BEST_SPEED. */
    public static final int DFLT_NETWORK_COMPRESSION = Deflater.BEST_SPEED;

    /** Default interval between message send retries. */
    public static final long DFLT_SEND_RETRY_DELAY = 1000;

    /** Default message send retries count. */
    public static final int DFLT_SEND_RETRY_CNT = 3;

    /** Default discovery startup delay in milliseconds (value is {@code 60,000ms}). */
    public static final long DFLT_DISCOVERY_STARTUP_DELAY = 60000;

    /** Default deployment mode (value is {@link DeploymentMode#SHARED}). */
    public static final DeploymentMode DFLT_DEPLOYMENT_MODE = DeploymentMode.SHARED;

    /** Default cache size for missed resources. */
    public static final int DFLT_P2P_MISSED_RESOURCES_CACHE_SIZE = 100;

    /** Default time server port base. */
    public static final int DFLT_TIME_SERVER_PORT_BASE = 31100;

    /** Default time server port range. */
    public static final int DFLT_TIME_SERVER_PORT_RANGE = 100;

    /** Default core size of public thread pool. */
    public static final int AVAILABLE_PROC_CNT = Runtime.getRuntime().availableProcessors();

    /** Default core size of public thread pool. */
    public static final int DFLT_PUBLIC_THREAD_CNT = max(8, AVAILABLE_PROC_CNT);

    /** Default size of data streamer thread pool. */
    public static final int DFLT_DATA_STREAMER_POOL_SIZE = DFLT_PUBLIC_THREAD_CNT;

    /** Default limit of threads used for rebalance. */
    public static final int DFLT_REBALANCE_THREAD_POOL_SIZE = 4;

    /** Default rebalance message timeout in milliseconds (value is {@code 10000}). */
    public static final long DFLT_REBALANCE_TIMEOUT = 10000;

    /** Default rebalance batches prefetch count (value is {@code 3}). */
    public static final long DFLT_REBALANCE_BATCHES_PREFETCH_COUNT = 3;

    /** Time to wait between rebalance messages in milliseconds to avoid overloading CPU (value is {@code 0}). */
    public static final long DFLT_REBALANCE_THROTTLE = 0;

    /** Default rebalance batch size in bytes (value is {@code 512Kb}). */
    public static final int DFLT_REBALANCE_BATCH_SIZE = 512 * 1024; // 512K

    /** Default size of system thread pool. */
    public static final int DFLT_SYSTEM_CORE_THREAD_CNT = DFLT_PUBLIC_THREAD_CNT;

    /** Default size of query thread pool. */
    public static final int DFLT_QUERY_THREAD_POOL_SIZE = DFLT_PUBLIC_THREAD_CNT;

    /** Default size of index create/rebuild thread pool. */
    public static final int DFLT_BUILD_IDX_THREAD_POOL_SIZE = min(4, max(1, AVAILABLE_PROC_CNT / 4));

    /** Default Ignite thread keep alive time. */
    public static final long DFLT_THREAD_KEEP_ALIVE_TIME = 60_000L;

    /** Default size of peer class loading thread pool. */
    public static final int DFLT_P2P_THREAD_CNT = 2;

    /** Default size of management thread pool. */
    public static final int DFLT_MGMT_THREAD_CNT = 4;

    /** Default segmentation policy. */
    public static final SegmentationPolicy DFLT_SEG_PLC = STOP;

    /** Default value for wait for segment on startup flag. */
    public static final boolean DFLT_WAIT_FOR_SEG_ON_START = true;

    /** Default value for all segmentation resolvers pass required. */
    public static final boolean DFLT_ALL_SEG_RESOLVERS_PASS_REQ = true;

    /** Default value segmentation resolve attempts count. */
    public static final int DFLT_SEG_RESOLVE_ATTEMPTS = 2;

    /** Default segment check frequency in discovery manager. */
    public static final long DFLT_SEG_CHK_FREQ = 10000;

    /** Default frequency of metrics log print out. */
    public static final long DFLT_METRICS_LOG_FREQ = 60000;

    /** Default TCP server port. */
    public static final int DFLT_TCP_PORT = 11211;

    /** Default marshal local jobs flag. */
    public static final boolean DFLT_MARSHAL_LOCAL_JOBS = false;

    /** Default value for cache sanity check enabled flag. */
    public static final boolean DFLT_CACHE_SANITY_CHECK_ENABLED = true;

    /** Default relative working directory path for snapshot operation result. */
    public static final String DFLT_SNAPSHOT_DIRECTORY = "snapshots";

    /** Default value for late affinity assignment flag. */
    @Deprecated
    public static final boolean DFLT_LATE_AFF_ASSIGNMENT = true;

    /** Default value for cluster state on start. */
    public static final ClusterState DFLT_STATE_ON_START = ClusterState.ACTIVE;

    /** Default value for active on start flag. */
    @Deprecated
    public static final boolean DFLT_ACTIVE_ON_START = true;

    /** Default value for auto-activation flag. */
    @Deprecated
    public static final boolean DFLT_AUTO_ACTIVATION = true;

    /** Default failure detection timeout in millis. */
    @SuppressWarnings("UnnecessaryBoxing")
    public static final Long DFLT_FAILURE_DETECTION_TIMEOUT = new Long(10_000);

    /** Default failure detection timeout for client nodes in millis. */
    @SuppressWarnings("UnnecessaryBoxing")
    public static final Long DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT = new Long(30_000);

    /**
     *  Default timeout after which long query warning will be printed.
     *
     * @deprecated Please use {@link SqlConfiguration#DFLT_LONG_QRY_WARN_TIMEOUT}.
     */
    @Deprecated
    public static final long DFLT_LONG_QRY_WARN_TIMEOUT = SqlConfiguration.DFLT_LONG_QRY_WARN_TIMEOUT;

    /** Default number of MVCC vacuum threads.. */
    public static final int DFLT_MVCC_VACUUM_THREAD_CNT = 2;

    /** Default time interval between MVCC vacuum runs in milliseconds. */
    public static final long DFLT_MVCC_VACUUM_FREQUENCY = 5000;

    /**
     * Default SQL query history size.
     *
     * @deprecated Please use {@link SqlConfiguration#DFLT_SQL_QUERY_HISTORY_SIZE}.
     */
    @Deprecated
    public static final int DFLT_SQL_QUERY_HISTORY_SIZE = SqlConfiguration.DFLT_SQL_QUERY_HISTORY_SIZE;

    /** Optional local Ignite instance name. */
    private String igniteInstanceName;

    /** User attributes. */
    private Map<String, ?> userAttrs;

    /** Logger. */
    private IgniteLogger log;

    /** Public pool size. */
    private int pubPoolSize = DFLT_PUBLIC_THREAD_CNT;

    /** Service pool size. */
    private Integer svcPoolSize;

    /** Async Callback pool size. */
    private int callbackPoolSize = DFLT_PUBLIC_THREAD_CNT;

    /**
     * Use striped pool for internal requests processing when possible
     * (e.g. cache requests per-partition striping).
     */
    private int stripedPoolSize = DFLT_PUBLIC_THREAD_CNT;

    /** System pool size. */
    private int sysPoolSize = DFLT_SYSTEM_CORE_THREAD_CNT;

    /** Management pool size. */
    private int mgmtPoolSize = DFLT_MGMT_THREAD_CNT;

    /** Data stream pool size. */
    private int dataStreamerPoolSize = DFLT_DATA_STREAMER_POOL_SIZE;

    /** Utility cache pool size. */
    private int utilityCachePoolSize = DFLT_SYSTEM_CORE_THREAD_CNT;

    /** Utility cache pool keep alive time. */
    private long utilityCacheKeepAliveTime = DFLT_THREAD_KEEP_ALIVE_TIME;

    /** P2P pool size. */
    private int p2pPoolSize = DFLT_P2P_THREAD_CNT;

    /** Query pool size. */
    private int qryPoolSize = DFLT_QUERY_THREAD_POOL_SIZE;

    /** Index create/rebuild pool size. */
    private int buildIdxPoolSize = DFLT_BUILD_IDX_THREAD_POOL_SIZE;

    /** Ignite installation folder. */
    private String igniteHome;

    /** Ignite work folder. */
    private String igniteWorkDir;

    /** MBean server. */
    private MBeanServer mbeanSrv;

    /** Local node ID. */
    private UUID nodeId;

    /** Marshaller. */
    private Marshaller marsh;

    /** Marshal local jobs. */
    private boolean marshLocJobs = DFLT_MARSHAL_LOCAL_JOBS;

    /** Daemon flag. */
    private boolean daemon;

    /** Whether or not peer class loading is enabled. */
    private boolean p2pEnabled = DFLT_P2P_ENABLED;

    /** List of package prefixes from the system class path that should be P2P loaded. */
    private String[] p2pLocClsPathExcl;

    /** Events of these types should be recorded. */
    private int[] inclEvtTypes;

    /** Maximum network requests timeout. */
    private long netTimeout = DFLT_NETWORK_TIMEOUT;

    /** Compression level for network binary messages. */
    private int netCompressionLevel = DFLT_NETWORK_COMPRESSION;

    /** Interval between message send retries. */
    private long sndRetryDelay = DFLT_SEND_RETRY_DELAY;

    /** Message send retries delay. */
    private int sndRetryCnt = DFLT_SEND_RETRY_CNT;

    /** Metrics history time. */
    private int metricsHistSize = DFLT_METRICS_HISTORY_SIZE;

    /** Full metrics enabled flag. */
    private long metricsUpdateFreq = DFLT_METRICS_UPDATE_FREQ;

    /** Metrics expire time. */
    private long metricsExpTime = DFLT_METRICS_EXPIRE_TIME;

    /** Collection of life-cycle beans. */
    private LifecycleBean[] lifecycleBeans;

    /** Discovery SPI. */
    private DiscoverySpi discoSpi;

    /** Segmentation policy. */
    private SegmentationPolicy segPlc = DFLT_SEG_PLC;

    /** Segmentation resolvers. */
    private SegmentationResolver[] segResolvers;

    /** Segmentation resolve attempts count. */
    private int segResolveAttempts = DFLT_SEG_RESOLVE_ATTEMPTS;

    /** Wait for segment on startup flag. */
    private boolean waitForSegOnStart = DFLT_WAIT_FOR_SEG_ON_START;

    /** All segmentation resolvers pass required flag. */
    private boolean allResolversPassReq = DFLT_ALL_SEG_RESOLVERS_PASS_REQ;

    /** Segment check frequency. */
    private long segChkFreq = DFLT_SEG_CHK_FREQ;

    /** Communication SPI. */
    private CommunicationSpi commSpi;

    /** Event storage SPI. */
    private EventStorageSpi evtSpi;

    /** Collision SPI. */
    private CollisionSpi colSpi;

    /** Deployment SPI. */
    private DeploymentSpi deploySpi;

    /** Checkpoint SPI. */
    private CheckpointSpi[] cpSpi;

    /** Failover SPI. */
    private FailoverSpi[] failSpi;

    /** Load balancing SPI. */
    private LoadBalancingSpi[] loadBalancingSpi;

    /** Indexing SPI. */
    private IndexingSpi indexingSpi;

    /** Address resolver. */
    private AddressResolver addrRslvr;

    /** Encryption SPI. */
    private EncryptionSpi encryptionSpi;

    /** Metric exporter SPI. */
    private MetricExporterSpi[] metricExporterSpi;

    /** System view exporter SPI. */
    private SystemViewExporterSpi[] sysViewExporterSpi;

    /** Tracing SPI. */
    private TracingSpi tracingSpi;

    /** Cache configurations. */
    private CacheConfiguration[] cacheCfg;

    /** Client mode flag. */
    private Boolean clientMode;

    /** Rebalance thread pool size. */
    private int rebalanceThreadPoolSize = DFLT_REBALANCE_THREAD_POOL_SIZE;

    /** Rrebalance messages timeout in milliseconds. */
    private long rebalanceTimeout = DFLT_REBALANCE_TIMEOUT;

    /** Rebalance batches prefetch count. */
    private long rebalanceBatchesPrefetchCnt = DFLT_REBALANCE_BATCHES_PREFETCH_COUNT;

    /** Time to wait between rebalance messages in milliseconds. */
    private long rebalanceThrottle = DFLT_REBALANCE_THROTTLE;

    /** Rebalance batch size in bytes. */
    private int rebalanceBatchSize = DFLT_REBALANCE_BATCH_SIZE;

    /** Transactions configuration. */
    private TransactionConfiguration txCfg = new TransactionConfiguration();

    /** */
    @Deprecated
    private PluginConfiguration[] pluginCfgs;

    /** Flag indicating whether cache sanity check is enabled. */
    private boolean cacheSanityCheckEnabled = DFLT_CACHE_SANITY_CHECK_ENABLED;

    /** Discovery startup delay. */
    @Deprecated
    private long discoStartupDelay = DFLT_DISCOVERY_STARTUP_DELAY;

    /** Tasks classes sharing mode. */
    private DeploymentMode deployMode = DFLT_DEPLOYMENT_MODE;

    /** Cache size of missed resources. */
    private int p2pMissedCacheSize = DFLT_P2P_MISSED_RESOURCES_CACHE_SIZE;

    /** Local host. */
    private String locHost;

    /** Base port number for time server. */
    private int timeSrvPortBase = DFLT_TIME_SERVER_PORT_BASE;

    /** Port number range for time server. */
    private int timeSrvPortRange = DFLT_TIME_SERVER_PORT_RANGE;

    /** Failure detection timeout. */
    private Long failureDetectionTimeout = DFLT_FAILURE_DETECTION_TIMEOUT;

    /** Timeout for blocked system workers detection. */
    private Long sysWorkerBlockedTimeout;

    /** Failure detection timeout for client nodes. */
    private Long clientFailureDetectionTimeout = DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT;

    /** Property names to include into node attributes. */
    private String[] includeProps;

    /** Frequency of metrics log print out. */
    private long metricsLogFreq = DFLT_METRICS_LOG_FREQ;

    /** Local event listeners. */
    private Map<IgnitePredicate<? extends Event>, int[]> lsnrs;

    /** Service configuration. */
    private ServiceConfiguration[] svcCfgs;

    /** Client access configuration. */
    private ConnectorConfiguration connectorCfg = new ConnectorConfiguration();

    /** ODBC configuration. */
    @Deprecated
    private OdbcConfiguration odbcCfg;

    /** Warmup closure. Will be invoked before actual grid start. */
    private IgniteInClosure<IgniteConfiguration> warmupClos;

    /** */
    private AtomicConfiguration atomicCfg = new AtomicConfiguration();

    /** User's class loader. */
    private ClassLoader classLdr;

    /** Cache store session listeners. */
    private Factory<CacheStoreSessionListener>[] storeSesLsnrs;

    /** Consistent globally unique node ID which survives node restarts. */
    private Serializable consistentId;

    /** SSL connection factory. */
    private Factory<SSLContext> sslCtxFactory;

    /** Platform configuration. */
    private PlatformConfiguration platformCfg;

    /** Cache key configuration. */
    private CacheKeyConfiguration[] cacheKeyCfg;

    /** */
    private BinaryConfiguration binaryCfg;

    /** Custom executor configurations. */
    private ExecutorConfiguration[] execCfgs;

    /** Page memory configuration. */
    @Deprecated
    private MemoryConfiguration memCfg;

    /** Persistence store configuration. */
    @Deprecated
    private PersistentStoreConfiguration pstCfg;

    /** Page memory configuration. */
    private DataStorageConfiguration dsCfg;

    /**
     * Directory where will be stored all results of snapshot operations. The internal
     * {@link U#resolveWorkDirectory(String, String, boolean)} is used to configure
     * snapshot working directory.
     */
    private String snapshotPath = DFLT_SNAPSHOT_DIRECTORY;

    /** Active on start flag. */
    @Deprecated
    private boolean activeOnStart = DFLT_ACTIVE_ON_START;

    /** Indicates that activeOnStart property was set explicitly. */
    private boolean activeOnStartPropSetFlag;

    /** Auto-activation flag. */
    @Deprecated
    private boolean autoActivation = DFLT_AUTO_ACTIVATION;

    /** Indicates that autoActivation property was set explicitly. */
    private boolean autoActivationPropSetFlag;

    /** Cluster state on start. */
    private ClusterState clusterStateOnStart;

    /** SQL connector configuration. */
    @Deprecated
    private SqlConnectorConfiguration sqlConnCfg;

    /** Client connector configuration. */
    private ClientConnectorConfiguration cliConnCfg = ClientListenerProcessor.DFLT_CLI_CFG;

    /** Size of MVCC vacuum thread pool. */
    private int mvccVacuumThreadCnt = DFLT_MVCC_VACUUM_THREAD_CNT;

    /** Time interval between vacuum runs (ms). */
    private long mvccVacuumFreq = DFLT_MVCC_VACUUM_FREQUENCY;

    /** 用户认证使能 */
    private boolean authEnabled;

    /** 失败处理 */
    private FailureHandler failureHnd;

    /** Communication failure resolver */
    private CommunicationFailureResolver commFailureRslvr;

    /** Plugin providers. */
    private PluginProvider[] pluginProvs;

    /** SQL configuration. */
    private SqlConfiguration sqlCfg = new SqlConfiguration();

...省略后续代码...
}

相关文章

网友评论

      本文标题:Ignite 源码分析(一)

      本文链接:https://www.haomeiwen.com/subject/rwlxpktx.html