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

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setClassLoader() . 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: GridCacheAtomicEntryProcessorDeploymentSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    if (cfg.isClientMode())
        cfg.setClassLoader(getExternalClassLoader());

    cfg.setDeploymentMode(depMode);
    cfg.setCacheConfiguration(cacheConfiguration());
    cfg.setConnectorConfiguration(null);

    return cfg;
}
 
Example 2
Source File: IgniteCacheBinaryObjectsScanSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setIncludeEventTypes(getIncludeEventTypes());

    cfg.setMarshaller(null);
    cfg.setPeerClassLoadingEnabled(false);

    if ("client".equals(igniteInstanceName))
        cfg.setClassLoader(ldr);

    return cfg;
}
 
Example 3
Source File: IgniteCacheAbstractExecutionContextTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setClassLoader(new UsersClassLoader());

    return cfg;
}
 
Example 4
Source File: IgniteAbstractOsgiContextActivator.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Method invoked by OSGi to start the bundle. It starts the specified Ignite configuration.
 *
 * @param ctx Bundle context.
 * @throws Exception
 */
@Override public final void start(BundleContext ctx) throws Exception {
    // Ensure that no other instances are running.
    if (IgniteOsgiUtils.gridCount() > 0) {
        throw new IgniteException("Failed to start Ignite instance (another instance is already running " +
            "and ignite-osgi is currently limited to a single instance per container).");
    }

    bundleCtx = ctx;

    // Start the Ignite configuration specified by the user.
    IgniteConfiguration cfg = igniteConfiguration();

    A.notNull(cfg, "Ignite configuration");

    // Override the classloader with the classloading strategy chosen by the user.
    ClassLoader clsLdr;

    if (classLoadingStrategy() == OsgiClassLoadingStrategyType.BUNDLE_DELEGATING)
        clsLdr = new BundleDelegatingClassLoader(bundleCtx.getBundle(), Ignite.class.getClassLoader());
    else
        clsLdr = new ContainerSweepClassLoader(bundleCtx.getBundle(), Ignite.class.getClassLoader());

    cfg.setClassLoader(clsLdr);

    onBeforeStart(ctx);

    // Start Ignite.
    try {
        ignite = Ignition.start(cfg);
    }
    catch (Throwable t) {
        U.error(log, "Failed to start Ignite via OSGi Activator [errMsg=" + t.getMessage() + ']', t);

        onAfterStart(ctx, t);

        return;
    }

    log = ignite.log();

    if (log.isInfoEnabled())
        log.info("Started Ignite from OSGi Activator [name=" + ignite.name() + ']');

    // Add into Ignite's OSGi registry.
    IgniteOsgiUtils.classloaders().put(ignite, clsLdr);

    // Export Ignite as a service.
    exportOsgiService(ignite);

    onAfterStart(ctx, null);
}
 
Example 5
Source File: IgniteServiceDeployment2ClassLoadersDefaultMarshallerTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setMarshaller(marshaller());

    cfg.setUserAttributes(Collections.singletonMap(NODE_NAME_ATTR, igniteInstanceName));

    if (grp1.contains(igniteInstanceName))
        cfg.setClassLoader(extClsLdr1);

    if (grp2.contains(igniteInstanceName))
        cfg.setClassLoader(extClsLdr2);

    return cfg;
}
 
Example 6
Source File: ContinuousQueryRemoteFilterMissingInClassPathSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<Object, Object> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(CacheMode.PARTITIONED);

    cacheCfg.setNodeFilter(node -> node.attribute("filter") == null);

    cfg.setCacheConfiguration(cacheCfg);

    if (setExternalLoader)
        cfg.setClassLoader(extLdr);

    if (log != null)
        cfg.setGridLogger(log);

    if (setFilterAttr)
        cfg.setUserAttributes(U.map("filter", 1));

    return cfg;
}
 
Example 7
Source File: IgniteBinaryObjectFieldsQuerySelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setMarshaller(null);

    if (getTestIgniteInstanceName(3).equals(igniteInstanceName))
        cfg.setClassLoader(extClassLoader);

    return cfg;
}
 
Example 8
Source File: IgniteServiceDeploymentClassLoadingDefaultMarshallerTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setMarshaller(marshaller());

    cfg.setUserAttributes(Collections.singletonMap(NODE_NAME_ATTR, igniteInstanceName));

    if (extClsLdrGrids.contains(igniteInstanceName))
        cfg.setClassLoader(extClsLdr);

    return cfg;
}
 
Example 9
Source File: IgniteCacheScanPredicateDeploymentSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    if (getTestIgniteInstanceName(3).equals(igniteInstanceName))
        cfg.setClassLoader(getExternalClassLoader());

    cfg.setCacheConfiguration(cacheConfiguration());

    cfg.setConnectorConfiguration(null);

    return cfg;
}