You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/09/02 14:17:07 UTC
ignite git commit: IGNITE-1357: Moved bootstrap logic to Ignite.
Repository: ignite
Updated Branches:
refs/heads/master 86ab3a734 -> 61aad3c32
IGNITE-1357: Moved bootstrap logic to Ignite.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/61aad3c3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/61aad3c3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/61aad3c3
Branch: refs/heads/master
Commit: 61aad3c32cd5823e355f4492eda359e6ff060263
Parents: 86ab3a7
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Sep 2 15:17:47 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Sep 2 15:17:47 2015 +0300
----------------------------------------------------------------------
...processors.platform.PlatformBootstrapFactory | 2 +
.../PlatformAbstractConfigurationClosure.java | 61 +++++
.../platform/PlatformConfigurationEx.java | 48 ++++
.../platform/cpp/PlatformCppBootstrap.java | 31 +++
.../cpp/PlatformCppBootstrapFactory.java | 39 +++
.../cpp/PlatformCppConfigurationClosure.java | 99 +++++++
.../cpp/PlatformCppConfigurationEx.java | 82 ++++++
.../dotnet/PlatformDotNetBootstrap.java | 31 +++
.../dotnet/PlatformDotNetBootstrapFactory.java | 39 +++
.../PlatformDotNetConfigurationClosure.java | 255 +++++++++++++++++++
.../dotnet/PlatformDotNetConfigurationEx.java | 91 +++++++
.../platform/utils/PlatformUtils.java | 14 +
12 files changed, 792 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory b/modules/platform/src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory
new file mode 100644
index 0000000..7f015e7
--- /dev/null
+++ b/modules/platform/src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory
@@ -0,0 +1,2 @@
+org.apache.ignite.internal.processors.platform.cpp.PlatformCppBootstrapFactory
+org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetBootstrapFactory
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractConfigurationClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractConfigurationClosure.java
new file mode 100644
index 0000000..2f7af71
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractConfigurationClosure.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
+import org.apache.ignite.lang.IgniteClosure;
+
+/**
+ * Abstract interop configuration closure.
+ */
+public abstract class PlatformAbstractConfigurationClosure
+ implements IgniteClosure<IgniteConfiguration, IgniteConfiguration> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Native gateway. */
+ protected final PlatformCallbackGateway gate;
+
+ /**
+ * Constructor.
+ *
+ * @param envPtr Environment pointer.
+ */
+ protected PlatformAbstractConfigurationClosure(long envPtr) {
+ this.gate = new PlatformCallbackGateway(envPtr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteConfiguration apply(IgniteConfiguration igniteCfg) {
+ assert igniteCfg != null;
+
+ IgniteConfiguration igniteCfg0 = new IgniteConfiguration(igniteCfg);
+
+ apply0(igniteCfg0);
+
+ return igniteCfg0;
+ }
+
+ /**
+ * Internal apply routine.
+ *
+ * @param igniteCfg Ignite configuration.
+ */
+ protected abstract void apply0(IgniteConfiguration igniteCfg);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformConfigurationEx.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformConfigurationEx.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformConfigurationEx.java
new file mode 100644
index 0000000..66eff8b
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformConfigurationEx.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform;
+
+import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
+
+import java.util.Collection;
+
+/**
+ * Extended platform configuration.
+ */
+public interface PlatformConfigurationEx {
+ /*
+ * @return Native gateway.
+ */
+ public PlatformCallbackGateway gate();
+
+ /**
+ * @return Memory manager.
+ */
+ public PlatformMemoryManagerImpl memory();
+
+ /**
+ * @return Platform name.
+ */
+ public String platform();
+
+ /**
+ * @return Warnings to be displayed on grid start.
+ */
+ public Collection<String> warnings();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrap.java
new file mode 100644
index 0000000..d066296
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrap.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cpp;
+
+import org.apache.ignite.internal.processors.platform.PlatformAbstractBootstrap;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
+
+/**
+ * Platform .Net bootstrap.
+ */
+public class PlatformCppBootstrap extends PlatformAbstractBootstrap {
+ /** {@inheritDoc} */
+ @Override protected PlatformAbstractConfigurationClosure closure(long envPtr) {
+ return new PlatformCppConfigurationClosure(envPtr);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrapFactory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrapFactory.java
new file mode 100644
index 0000000..4933713
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppBootstrapFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cpp;
+
+import org.apache.ignite.internal.processors.platform.PlatformBootstrap;
+import org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory;
+
+/**
+ * Platform .Net bootstrap factory.
+ */
+public class PlatformCppBootstrapFactory implements PlatformBootstrapFactory {
+ /** Bootstrap ID. */
+ public static final int ID = 2;
+
+ /** {@inheritDoc} */
+ @Override public int id() {
+ return ID;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformBootstrap create() {
+ return new PlatformCppBootstrap();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
new file mode 100644
index 0000000..648726b
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cpp;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PlatformConfiguration;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.platform.cpp.PlatformCppConfiguration;
+
+import java.util.Collections;
+
+/**
+ * Interop CPP configuration closure.
+ */
+public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurationClosure {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Constructor.
+ *
+ * @param envPtr Environment pointer.
+ */
+ public PlatformCppConfigurationClosure(long envPtr) {
+ super(envPtr);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("deprecation")
+ @Override protected void apply0(IgniteConfiguration igniteCfg) {
+ // 3. Validate and copy Interop configuration setting environment pointer along the way.
+ PlatformConfiguration interopCfg = igniteCfg.getPlatformConfiguration();
+
+ if (interopCfg != null && !(interopCfg instanceof PlatformCppConfiguration))
+ throw new IgniteException("Illegal interop configuration (must be of type " +
+ PlatformCppConfiguration.class.getName() + "): " + interopCfg.getClass().getName());
+
+ PlatformCppConfiguration cppCfg = interopCfg != null ? (PlatformCppConfiguration)interopCfg : null;
+
+ if (cppCfg == null)
+ cppCfg = new PlatformCppConfiguration();
+
+ PlatformMemoryManagerImpl memMgr = new PlatformMemoryManagerImpl(gate, 1024);
+
+ PlatformCppConfigurationEx cppCfg0 = new PlatformCppConfigurationEx(cppCfg, gate, memMgr);
+
+ igniteCfg.setPlatformConfiguration(cppCfg0);
+
+ // Check marshaller
+ Marshaller marsh = igniteCfg.getMarshaller();
+
+ if (marsh == null) {
+ igniteCfg.setMarshaller(new PortableMarshaller());
+
+ cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
+ PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
+ }
+ else if (!(marsh instanceof PortableMarshaller))
+ throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
+ " can be used when running Ignite for C++): " + marsh.getClass().getName());
+
+ // Set Ignite home so that marshaller context works.
+ String ggHome = igniteCfg.getIgniteHome();
+
+ if (ggHome == null)
+ ggHome = U.getIgniteHome();
+ else
+ // If user provided IGNITE_HOME - set it as a system property.
+ U.setIgniteHome(ggHome);
+
+ try {
+ U.setWorkDirectory(igniteCfg.getWorkDirectory(), ggHome);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationEx.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationEx.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationEx.java
new file mode 100644
index 0000000..ea11ce9
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationEx.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.cpp;
+
+import org.apache.ignite.internal.processors.platform.PlatformConfigurationEx;
+import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
+import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
+import org.apache.ignite.platform.cpp.PlatformCppConfiguration;
+
+import java.util.Collection;
+
+/**
+ * Internal interop CPP configuration.
+ */
+public class PlatformCppConfigurationEx extends PlatformCppConfiguration implements PlatformConfigurationEx {
+ /** Native gateway. */
+ private final PlatformCallbackGateway gate;
+
+ /** Memory manager. */
+ private final PlatformMemoryManagerImpl memMgr;
+
+ /** Warnings */
+ private Collection<String> warns;
+
+ /**
+ * Copy constructor.
+ *
+ * @param cfg Configuration to copy.
+ * @param gate Native gateway.
+ * @param memMgr Memory manager.
+ */
+ public PlatformCppConfigurationEx(PlatformCppConfiguration cfg, PlatformCallbackGateway gate,
+ PlatformMemoryManagerImpl memMgr) {
+ super(cfg);
+
+ this.gate = gate;
+ this.memMgr = memMgr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformCallbackGateway gate() {
+ return gate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformMemoryManagerImpl memory() {
+ return memMgr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String platform() {
+ return PlatformUtils.PLATFORM_CPP;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> warnings() {
+ return warns;
+ }
+
+ /**
+ * @param warnings Warnings.
+ */
+ public void warnings(Collection<String> warnings) {
+ this.warns = warnings;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrap.java
new file mode 100644
index 0000000..837ded9
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrap.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.PlatformAbstractBootstrap;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
+
+/**
+ * Interop .Net bootstrap.
+ */
+public class PlatformDotNetBootstrap extends PlatformAbstractBootstrap {
+ /** {@inheritDoc} */
+ @Override protected PlatformAbstractConfigurationClosure closure(long envPtr) {
+ return new PlatformDotNetConfigurationClosure(envPtr);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrapFactory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrapFactory.java
new file mode 100644
index 0000000..6b2a6cd
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetBootstrapFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.PlatformBootstrap;
+import org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory;
+
+/**
+ * Interop .Net bootstrap factory.
+ */
+public class PlatformDotNetBootstrapFactory implements PlatformBootstrapFactory {
+ /** Bootstrap ID. */
+ public static final int ID = 1;
+
+ /** {@inheritDoc} */
+ @Override public int id() {
+ return ID;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformBootstrap create() {
+ return new PlatformDotNetBootstrap();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
new file mode 100644
index 0000000..56351e6
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.dotnet;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PlatformConfiguration;
+import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.internal.portable.PortableMetaDataHandler;
+import org.apache.ignite.internal.portable.PortableRawWriterEx;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
+import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
+import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
+import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
+import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableMetadata;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Closure to apply dot net configuration.
+ */
+@SuppressWarnings({"UnusedDeclaration"})
+public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigurationClosure {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Configuration. */
+ private IgniteConfiguration cfg;
+
+ /** Memory manager. */
+ private PlatformMemoryManagerImpl memMgr;
+
+ /**
+ * Constructor.
+ *
+ * @param envPtr Environment pointer.
+ */
+ public PlatformDotNetConfigurationClosure(long envPtr) {
+ super(envPtr);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("deprecation")
+ @Override protected void apply0(IgniteConfiguration igniteCfg) {
+ // 3. Validate and copy Interop configuration setting environment pointer along the way.
+ PlatformConfiguration interopCfg = igniteCfg.getPlatformConfiguration();
+
+ if (interopCfg != null && !(interopCfg instanceof PlatformDotNetConfiguration))
+ throw new IgniteException("Illegal platform configuration (must be of type " +
+ PlatformDotNetConfiguration.class.getName() + "): " + interopCfg.getClass().getName());
+
+ PlatformDotNetConfiguration dotNetCfg = interopCfg != null ? (PlatformDotNetConfiguration)interopCfg : null;
+
+ if (dotNetCfg == null)
+ dotNetCfg = new PlatformDotNetConfiguration();
+
+ memMgr = new PlatformMemoryManagerImpl(gate, 1024);
+
+ PlatformDotNetConfigurationEx dotNetCfg0 = new PlatformDotNetConfigurationEx(dotNetCfg, gate, memMgr);
+
+ igniteCfg.setPlatformConfiguration(dotNetCfg0);
+
+ // Check marshaller
+ Marshaller marsh = igniteCfg.getMarshaller();
+
+ if (marsh == null) {
+ igniteCfg.setMarshaller(new PortableMarshaller());
+
+ dotNetCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
+ PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
+ }
+ else if (!(marsh instanceof PortableMarshaller))
+ throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
+ " can be used when running Ignite for .Net): " + marsh.getClass().getName());
+
+ // Set Ignite home so that marshaller context works.
+ String ggHome = igniteCfg.getIgniteHome();
+
+ if (ggHome == null)
+ ggHome = U.getIgniteHome();
+ else
+ // If user provided IGNITE_HOME - set it as a system property.
+ U.setIgniteHome(ggHome);
+
+ try {
+ U.setWorkDirectory(igniteCfg.getWorkDirectory(), ggHome);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+
+ // 4. Callback to .Net.
+ prepare(igniteCfg, dotNetCfg0);
+ }
+
+ /**
+ * Prepare .Net size.
+ *
+ * @param igniteCfg Ignite configuration.
+ * @param interopCfg Interop configuration.
+ */
+ @SuppressWarnings("ConstantConditions")
+ private void prepare(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx interopCfg) {
+ this.cfg = igniteCfg;
+
+ try (PlatformMemory outMem = memMgr.allocate()) {
+ try (PlatformMemory inMem = memMgr.allocate()) {
+ PlatformOutputStream out = outMem.output();
+
+ PortableRawWriterEx writer = marshaller().writer(out);
+
+ writer.writeObject(interopCfg.unwrap());
+
+ List<PlatformDotNetLifecycleBean> beans = beans(igniteCfg);
+
+ writer.writeInt(beans.size());
+
+ for (PlatformDotNetLifecycleBean bean : beans) {
+ writer.writeString(bean.getAssemblyName());
+ writer.writeString(bean.getClassName());
+ writer.writeMap(bean.getProperties());
+ }
+
+ out.synchronize();
+
+ gate.extensionCallbackInLongLongOutLong(
+ PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), inMem.pointer());
+
+ processPrepareResult(inMem.input());
+ }
+ }
+ }
+
+ /**
+ * Process prepare result.
+ *
+ * @param in Input stream.
+ */
+ private void processPrepareResult(PlatformInputStream in) {
+ assert cfg != null;
+
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Find .Net lifecycle beans in configuration.
+ *
+ * @param cfg Configuration.
+ * @return Beans.
+ */
+ private static List<PlatformDotNetLifecycleBean> beans(IgniteConfiguration cfg) {
+ List<PlatformDotNetLifecycleBean> res = new ArrayList<>();
+
+ if (cfg.getLifecycleBeans() != null) {
+ for (LifecycleBean bean : cfg.getLifecycleBeans()) {
+ if (bean instanceof PlatformDotNetLifecycleBean)
+ res.add((PlatformDotNetLifecycleBean)bean);
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Create portable marshaller.
+ *
+ * @return Marshaller.
+ */
+ @SuppressWarnings("deprecation")
+ private static GridPortableMarshaller marshaller() {
+ try {
+ PortableContext ctx = new PortableContext(new PortableMetaDataHandler() {
+ @Override public void addMeta(int typeId, PortableMetadata meta)
+ throws PortableException {
+ // No-op.
+ }
+
+ @Override public PortableMetadata metadata(int typeId) throws PortableException {
+ return null;
+ }
+ }, null);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setContext(new MarshallerContextImpl(null));
+
+ ctx.configure(marsh);
+
+ return new GridPortableMarshaller(ctx);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
new file mode 100644
index 0000000..eaf0997
--- /dev/null
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationEx.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.PlatformConfigurationEx;
+import org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
+import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
+import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
+
+import java.util.Collection;
+
+/**
+ * Extended .Net configuration.
+ */
+public class PlatformDotNetConfigurationEx extends PlatformDotNetConfiguration implements PlatformConfigurationEx {
+ /** Native gateway. */
+ private final PlatformCallbackGateway gate;
+
+ /** Memory manager. */
+ private final PlatformMemoryManagerImpl memMgr;
+
+ /** Warnings */
+ private Collection<String> warnings;
+
+ /**
+ * Copy constructor.
+ *
+ * @param cfg Configuration to copy.
+ * @param gate Native gateway.
+ * @param memMgr Memory manager.
+ */
+ public PlatformDotNetConfigurationEx(PlatformDotNetConfiguration cfg, PlatformCallbackGateway gate,
+ PlatformMemoryManagerImpl memMgr) {
+ super(cfg);
+
+ this.gate = gate;
+ this.memMgr = memMgr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformCallbackGateway gate() {
+ return gate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformMemoryManagerImpl memory() {
+ return memMgr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String platform() {
+ return PlatformUtils.PLATFORM_DOTNET;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> warnings() {
+ return warnings;
+ }
+
+ /**
+ * @param warnings Warnings.
+ */
+ public void warnings(Collection<String> warnings) {
+ this.warnings = warnings;
+ }
+
+ /**
+ * Unwrap extended configuration.
+ *
+ * @return Original configuration.
+ */
+ public PlatformDotNetConfiguration unwrap() {
+ return new PlatformDotNetConfiguration(this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/61aad3c3/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 2e1da0b..ee3124d 100644
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -48,11 +48,25 @@ import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX;
+
/**
* Platform utility methods.
*/
@SuppressWarnings({"UnusedDeclaration", "unchecked"})
public class PlatformUtils {
+ /** Node attribute: platform. */
+ public static final String ATTR_PLATFORM = ATTR_PREFIX + ".platform";
+
+ /** Platform: CPP. */
+ public static final String PLATFORM_CPP = "cpp";
+
+ /** Platform: .Net. */
+ public static final String PLATFORM_DOTNET = "dotnet";
+
+ /** Operation: prepare .Net platform. */
+ public static final int OP_PREPARE_DOT_NET = 1;
+
/** Amount of peek modes available. */
private static final int CACHE_PEEK_MODES_CNT = CachePeekMode.values().length;