Search in sources :

Example 1 with PlatformLifecycleBean

use of org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean in project ignite by apache.

the class PlatformDotNetConfigurationClosure method processPrepareResult.

/**
 * Process prepare result.
 *
 * @param in Input stream.
 */
private void processPrepareResult(BinaryReaderExImpl in) {
    assert cfg != null;
    PlatformConfigurationUtils.readIgniteConfiguration(in, cfg);
    // Process beans
    List<PlatformDotNetLifecycleBean> beans = beans(cfg);
    List<PlatformLifecycleBean> newBeans = new ArrayList<>();
    int len = in.readInt();
    for (int i = 0; i < len; i++) {
        if (i < beans.size())
            // Existing bean.
            beans.get(i).initialize(gate, in.readLong());
        else
            // This bean is defined in .Net.
            newBeans.add(new PlatformLifecycleBean(gate, in.readLong()));
    }
    if (!newBeans.isEmpty()) {
        LifecycleBean[] newBeans0 = newBeans.toArray(new LifecycleBean[newBeans.size()]);
        // New beans were added. Let's append them to the tail of the rest configured lifecycle beans.
        LifecycleBean[] oldBeans = cfg.getLifecycleBeans();
        if (oldBeans == null)
            cfg.setLifecycleBeans(newBeans0);
        else {
            LifecycleBean[] mergedBeans = new LifecycleBean[oldBeans.length + newBeans.size()];
            System.arraycopy(oldBeans, 0, mergedBeans, 0, oldBeans.length);
            System.arraycopy(newBeans0, 0, mergedBeans, oldBeans.length, newBeans0.length);
            cfg.setLifecycleBeans(mergedBeans);
        }
    }
    // Process affinity functions
    List<PlatformDotNetAffinityFunction> affFuncs = affinityFunctions(cfg);
    if (!affFuncs.isEmpty()) {
        for (PlatformDotNetAffinityFunction aff : affFuncs) aff.init(PlatformConfigurationUtils.readAffinityFunction(in));
    }
}
Also used : PlatformLifecycleBean(org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean) ArrayList(java.util.ArrayList) PlatformDotNetLifecycleBean(org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean) LifecycleBean(org.apache.ignite.lifecycle.LifecycleBean) PlatformLifecycleBean(org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean) PlatformDotNetAffinityFunction(org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction) PlatformDotNetLifecycleBean(org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean)

Aggregations

ArrayList (java.util.ArrayList)1 PlatformLifecycleBean (org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean)1 LifecycleBean (org.apache.ignite.lifecycle.LifecycleBean)1 PlatformDotNetAffinityFunction (org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction)1 PlatformDotNetLifecycleBean (org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean)1