Search in sources :

Example 1 with PlatformDotNetLifecycleBean

use of org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean in project ignite by apache.

the class PlatformDotNetConfigurationClosure method prepare.

/**
 * Prepare .Net size.
 *
 * @param igniteCfg Ignite configuration.
 * @param interopCfg Interop configuration.
 */
private void prepare(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx interopCfg) {
    cfg = igniteCfg;
    try (PlatformMemory outMem = memMgr.allocate()) {
        try (PlatformMemory inMem = memMgr.allocate()) {
            PlatformOutputStream out = outMem.output();
            GridBinaryMarshaller marshaller = PlatformUtils.marshaller();
            BinaryRawWriterEx writer = marshaller.writer(out);
            PlatformConfigurationUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
            // Write .NET beans
            List<PlatformDotNetLifecycleBean> beans = beans(igniteCfg);
            writer.writeInt(beans.size());
            for (PlatformDotNetLifecycleBean bean : beans) {
                writer.writeString(bean.getTypeName());
                writer.writeMap(bean.getProperties());
            }
            // Write .NET affinity functions
            List<PlatformDotNetAffinityFunction> affFuncs = affinityFunctions(igniteCfg);
            writer.writeInt(affFuncs.size());
            for (PlatformDotNetAffinityFunction func : affFuncs) {
                writer.writeString(func.getTypeName());
                writer.writeMap(func.getProperties());
            }
            out.synchronize();
            gate.extensionCallbackInLongLongOutLong(PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), inMem.pointer());
            processPrepareResult(marshaller.reader(inMem.input()));
        }
    }
}
Also used : GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) PlatformDotNetAffinityFunction(org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction) PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory) PlatformDotNetLifecycleBean(org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean)

Example 2 with PlatformDotNetLifecycleBean

use of org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean 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

PlatformDotNetAffinityFunction (org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction)2 PlatformDotNetLifecycleBean (org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean)2 ArrayList (java.util.ArrayList)1 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1 PlatformLifecycleBean (org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean)1 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)1 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)1 LifecycleBean (org.apache.ignite.lifecycle.LifecycleBean)1