use of org.apache.ignite.lifecycle.LifecycleAware in project ignite by apache.
the class HadoopBasicFileSystemFactoryDelegate method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteException {
BasicHadoopFileSystemFactory proxy0 = (BasicHadoopFileSystemFactory) proxy;
cfg = HadoopUtils.safeCreateConfiguration();
if (proxy0.getConfigPaths() != null) {
for (String cfgPath : proxy0.getConfigPaths()) {
if (cfgPath == null)
throw new NullPointerException("Configuration path cannot be null: " + Arrays.toString(proxy0.getConfigPaths()));
else {
URL url = U.resolveIgniteUrl(cfgPath);
if (url == null) {
// If secConfPath is given, it should be resolvable:
throw new IgniteException("Failed to resolve secondary file system configuration path " + "(ensure that it exists locally and you have read access to it): " + cfgPath);
}
cfg.addResource(url);
}
}
}
// If secondary fs URI is not given explicitly, try to get it from the configuration:
if (proxy0.getUri() == null)
fullUri = FileSystem.getDefaultUri(cfg);
else {
try {
fullUri = new URI(proxy0.getUri());
} catch (URISyntaxException ignored) {
throw new IgniteException("Failed to resolve secondary file system URI: " + proxy0.getUri());
}
}
String strWorkDir = fullUri.getPath();
if (!"/".equals(strWorkDir))
workDir = new Path(strWorkDir);
usrNameMapper = proxy0.getUserNameMapper();
if (usrNameMapper != null && usrNameMapper instanceof LifecycleAware)
((LifecycleAware) usrNameMapper).start();
}
use of org.apache.ignite.lifecycle.LifecycleAware in project ignite by apache.
the class CacheJtaManager method start0.
/**
* {@inheritDoc}
*/
@Override
protected void start0() throws IgniteCheckedException {
super.start0();
if (cctx.txConfig() != null) {
tmFactory = cctx.txConfig().getTxManagerFactory();
if (tmFactory != null) {
cctx.kernalContext().resource().injectGeneric(tmFactory);
if (tmFactory instanceof LifecycleAware)
((LifecycleAware) tmFactory).start();
Object txMgr;
try {
txMgr = tmFactory.create();
} catch (Exception e) {
throw new IgniteCheckedException("Failed to create transaction manager [tmFactory=" + tmFactory + "]", e);
}
if (txMgr == null)
throw new IgniteCheckedException("Failed to create transaction manager (transaction manager " + "factory created null-value transaction manager) [tmFactory=" + tmFactory + "]");
if (!(txMgr instanceof TransactionManager))
throw new IgniteCheckedException("Failed to create transaction manager (transaction manager " + "factory created object that is not an instance of TransactionManager) [tmFactory=" + tmFactory + ", txMgr=" + txMgr + "]");
jtaTm = (TransactionManager) txMgr;
} else {
String txLookupClsName = cctx.txConfig().getTxManagerLookupClassName();
if (txLookupClsName != null)
tmLookupRef.set(createTmLookup(txLookupClsName));
}
useJtaSync = cctx.txConfig().isUseJtaSynchronization();
}
}
use of org.apache.ignite.lifecycle.LifecycleAware in project ignite by apache.
the class CacheJtaManager method createTmLookup.
/**
* @throws IgniteCheckedException
*/
private CacheTmLookup createTmLookup(String tmLookupClsName) throws IgniteCheckedException {
try {
Class<?> cls = Class.forName(tmLookupClsName);
CacheTmLookup res = (CacheTmLookup) cls.newInstance();
cctx.kernalContext().resource().injectGeneric(res);
if (res instanceof LifecycleAware)
((LifecycleAware) res).start();
return res;
} catch (Exception e) {
throw new IgniteCheckedException("Failed to instantiate transaction manager lookup.", e);
}
}
use of org.apache.ignite.lifecycle.LifecycleAware in project ignite by apache.
the class GridCacheUtils method startStoreSessionListeners.
/**
* Creates and starts store session listeners.
*
* @param ctx Kernal context.
* @param factories Factories.
* @return Listeners.
* @throws IgniteCheckedException In case of error.
*/
public static Collection<CacheStoreSessionListener> startStoreSessionListeners(GridKernalContext ctx, Factory<CacheStoreSessionListener>[] factories) throws IgniteCheckedException {
if (factories == null)
return null;
Collection<CacheStoreSessionListener> lsnrs = new ArrayList<>(factories.length);
for (Factory<CacheStoreSessionListener> factory : factories) {
CacheStoreSessionListener lsnr = factory.create();
if (lsnr != null) {
ctx.resource().injectGeneric(lsnr);
if (lsnr instanceof LifecycleAware)
((LifecycleAware) lsnr).start();
lsnrs.add(lsnr);
}
}
return lsnrs;
}
use of org.apache.ignite.lifecycle.LifecycleAware in project ignite by apache.
the class GridCacheStoreManagerAdapter method start0.
/**
* {@inheritDoc}
*/
@Override
protected void start0() throws IgniteCheckedException {
if (store instanceof LifecycleAware) {
try {
// Avoid second start() call on store in case when near cache is enabled.
if (cctx.config().isWriteBehindEnabled()) {
if (!cctx.isNear())
((LifecycleAware) store).start();
}
} catch (Exception e) {
throw new IgniteCheckedException("Failed to start cache store: " + e, e);
}
}
CacheConfiguration cfg = cctx.config();
if (cfgStore != null) {
if (!cfg.isWriteThrough() && !cfg.isReadThrough()) {
U.quietAndWarn(log, "Persistence store is configured, but both read-through and write-through are disabled. This " + "configuration makes sense if the store implements loadCache method only. If this is the " + "case, ignore this warning. Otherwise, fix the configuration for the cache: " + cfg.getName(), "Persistence store is configured, but both read-through and write-through are disabled " + "for cache: " + cfg.getName());
}
if (!cfg.isWriteThrough() && cfg.isWriteBehindEnabled()) {
U.quietAndWarn(log, "To enable write-behind mode for the cache store it's also required to set " + "CacheConfiguration.setWriteThrough(true) property, otherwise the persistence " + "store will be never updated. Consider fixing configuration for the cache: " + cfg.getName(), "Write-behind mode for the cache store also requires CacheConfiguration.setWriteThrough(true) " + "property. Fix configuration for the cache: " + cfg.getName());
}
if (cctx.group().persistenceEnabled() && (cfg.isWriteThrough() || cfg.isReadThrough()))
U.quietAndWarn(log, "Both Ignite native persistence and CacheStore are configured for cache '" + cfg.getName() + "'. " + "This configuration does not guarantee strict consistency between CacheStore and Ignite data " + "storage upon restarts. Consult documentation for more details.");
}
sesLsnrs = CU.startStoreSessionListeners(cctx.kernalContext(), cfg.getCacheStoreSessionListenerFactories());
if (sesLsnrs == null) {
sesLsnrs = cctx.shared().storeSessionListeners();
globalSesLsnrs = true;
}
}
Aggregations