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()));
}
}
}
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));
}
}
Aggregations