/** * @return {@code True} If store writes should be performed from dht transactions. This happens if both * {@code writeBehindEnabled} and {@code writeBehindPreferPrimary} cache configuration properties * are set to {@code true} or the store is local. */ public boolean writeToStoreFromDht() { return store().isLocalStore() || cacheCfg.isWriteBehindEnabled(); }
/** * @param ccfg Cache configuration. * @return Data transfer object for write-behind cache configuration properties. */ public static VisorWriteBehindConfig from(GridCacheConfiguration ccfg) { VisorWriteBehindConfig cfg = new VisorWriteBehindConfig(); cfg.enabled(ccfg.isWriteBehindEnabled()); cfg.batchSize(ccfg.getWriteBehindBatchSize()); cfg.flushFrequency(ccfg.getWriteBehindFlushFrequency()); cfg.flushSize(ccfg.getWriteBehindFlushSize()); cfg.flushThreadCount(ccfg.getWriteBehindFlushThreadCount()); return cfg; }
/** {@inheritDoc} */ @Override protected void stop0(boolean cancel) { if (store instanceof GridLifecycleAware) { try { // Avoid second start() call on store in case when near cache is enabled. if (cctx.config().isWriteBehindEnabled()) { if (!cctx.isNear()) ((GridLifecycleAware)store).stop(); } else { if (cctx.isNear() || !CU.isNearEnabled(cctx)) ((GridLifecycleAware)store).stop(); } } catch (GridException e) { U.error(log(), "Failed to stop cache store.", e); } } }
/** * Creates a wrapped cache store if write-behind cache is configured. * * @param gridName Grid name. * @param cfg Cache configuration. * @param near Whether or not store retrieved for near cache. * @return Instance if {@link GridCacheWriteBehindStore} if write-behind store is configured, * or user-defined cache store. */ @SuppressWarnings({"unchecked"}) private GridCacheStore cacheStore(String gridName, GridCacheConfiguration cfg, boolean near) { if (cfg.getStore() == null || !cfg.isWriteBehindEnabled()) return cfg.getStore(); // Write-behind store is used in DHT cache only. if (!near) { GridCacheWriteBehindStore store = new GridCacheWriteBehindStore(gridName, cfg.getName(), log, cfg.getStore()); store.setFlushSize(cfg.getWriteBehindFlushSize()); store.setFlushThreadCount(cfg.getWriteBehindFlushThreadCount()); store.setFlushFrequency(cfg.getWriteBehindFlushFrequency()); store.setBatchSize(cfg.getWriteBehindBatchSize()); return store; } else return cfg.getStore(); }
/** {@inheritDoc} */ @Override protected void start0() throws GridException { if (store instanceof GridLifecycleAware) { // Avoid second start() call on store in case when near cache is enabled. if (cctx.config().isWriteBehindEnabled()) { if (!cctx.isNear()) ((GridLifecycleAware)store).start(); } else { if (cctx.isNear() || !CU.isNearEnabled(cctx)) ((GridLifecycleAware)store).start(); } } boolean convertPortable = !cctx.config().isKeepPortableInStore(); if (cctx.config().isPortableEnabled()) { GridCacheStore store0 = store; if (store0 instanceof GridCacheWriteBehindStore) store0 = ((GridCacheWriteBehindStore)store0).store(); if (store0 instanceof GridInteropAware) ((GridInteropAware)store0).configure(cctx.cache().name(), convertPortable); else this.convertPortable = convertPortable; } else if (convertPortable) U.warn(log, "GridCacheConfiguration.isKeepPortableInStore() configuration property will " + "be ignored because portable mode is not enabled for cache: " + cctx.namex()); }
txSerEnabled = cfg.isTxSerializableEnabled(); writeBehindBatchSize = cfg.getWriteBehindBatchSize(); writeBehindEnabled = cfg.isWriteBehindEnabled(); writeBehindFlushFreq = cfg.getWriteBehindFlushFrequency(); writeBehindFlushSize = cfg.getWriteBehindFlushSize();
"for cache: " + cc.getName()); if (cc.isWriteBehindEnabled()) { if (cc.getStore() == null) throw new GridException("Cannot enable write-behind cache (cache store is not provided) for cache: " +
txSerEnabled = cc.isTxSerializableEnabled(); writeBehindBatchSize = cc.getWriteBehindBatchSize(); writeBehindEnabled = cc.isWriteBehindEnabled(); writeBehindFlushFreq = cc.getWriteBehindFlushFrequency(); writeBehindFlushSize = cc.getWriteBehindFlushSize();