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/18 12:04:12 UTC
[08/14] ignite git commit: IGNITE-1513: Merged Java to core module.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
new file mode 100644
index 0000000..dd7b988
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableConfiguration.java
@@ -0,0 +1,196 @@
+/*
+ * 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.platform.dotnet;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Mirror of .Net class PortableConfiguration.cs
+ */
+public class PlatformDotNetPortableConfiguration {
+ /** Type cfgs. */
+ private Collection<PlatformDotNetPortableTypeConfiguration> typesCfg;
+
+ /** Types. */
+ private Collection<String> types;
+
+ /** Default name mapper. */
+ private String dfltNameMapper;
+
+ /** Default id mapper. */
+ private String dfltIdMapper;
+
+ /** Default serializer. */
+ private String dfltSerializer;
+
+ /** Default metadata enabled. */
+ private boolean dfltMetadataEnabled = true;
+
+ /** Whether to cache deserialized value in IGridPortableObject */
+ private boolean dfltKeepDeserialized = true;
+
+ /**
+ * Default constructor.
+ */
+ public PlatformDotNetPortableConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ * @param cfg configuration to copy.
+ */
+ public PlatformDotNetPortableConfiguration(PlatformDotNetPortableConfiguration cfg) {
+ if (cfg.getTypesConfiguration() != null) {
+ typesCfg = new ArrayList<>();
+
+ for (PlatformDotNetPortableTypeConfiguration typeCfg : cfg.getTypesConfiguration())
+ typesCfg.add(new PlatformDotNetPortableTypeConfiguration(typeCfg));
+ }
+
+ if (cfg.getTypes() != null)
+ types = new ArrayList<>(cfg.getTypes());
+
+ dfltNameMapper = cfg.getDefaultNameMapper();
+ dfltIdMapper = cfg.getDefaultIdMapper();
+ dfltSerializer = cfg.getDefaultSerializer();
+ dfltMetadataEnabled = cfg.isDefaultMetadataEnabled();
+ dfltKeepDeserialized = cfg.isDefaultKeepDeserialized();
+ }
+
+ /**
+ * @return Type cfgs.
+ */
+ public Collection<PlatformDotNetPortableTypeConfiguration> getTypesConfiguration() {
+ return typesCfg;
+ }
+
+ /**
+ * @param typesCfg New type cfgs.
+ */
+ public void setTypesConfiguration(Collection<PlatformDotNetPortableTypeConfiguration> typesCfg) {
+ this.typesCfg = typesCfg;
+ }
+
+ /**
+ * @return Types.
+ */
+ public Collection<String> getTypes() {
+ return types;
+ }
+
+ /**
+ * @param types New types.
+ */
+ public void setTypes(Collection<String> types) {
+ this.types = types;
+ }
+
+ /**
+ * @return Default name mapper.
+ */
+ public String getDefaultNameMapper() {
+ return dfltNameMapper;
+ }
+
+ /**
+ * @param dfltNameMapper New default name mapper.
+ */
+ public void setDefaultNameMapper(String dfltNameMapper) {
+ this.dfltNameMapper = dfltNameMapper;
+ }
+
+ /**
+ * @return Default id mapper.
+ */
+ public String getDefaultIdMapper() {
+ return dfltIdMapper;
+ }
+
+ /**
+ * @param dfltIdMapper New default id mapper.
+ */
+ public void setDefaultIdMapper(String dfltIdMapper) {
+ this.dfltIdMapper = dfltIdMapper;
+ }
+
+ /**
+ * @return Default serializer.
+ */
+ public String getDefaultSerializer() {
+ return dfltSerializer;
+ }
+
+ /**
+ * @param dfltSerializer New default serializer.
+ */
+ public void setDefaultSerializer(String dfltSerializer) {
+ this.dfltSerializer = dfltSerializer;
+ }
+
+ /**
+ * Gets default metadata enabled flag. See {@link #setDefaultMetadataEnabled(boolean)} for more information.
+ *
+ * @return Default metadata enabled flag.
+ */
+ public boolean isDefaultMetadataEnabled() {
+ return dfltMetadataEnabled;
+ }
+
+ /**
+ * Sets default metadata enabled flag. When set to {@code true} all portable types will save it's metadata to
+ * cluster.
+ * <p />
+ * Can be overridden for particular type using
+ * {@link PlatformDotNetPortableTypeConfiguration#setMetadataEnabled(Boolean)}.
+ *
+ * @param dfltMetadataEnabled Default metadata enabled flag.
+ */
+ public void setDefaultMetadataEnabled(boolean dfltMetadataEnabled) {
+ this.dfltMetadataEnabled = dfltMetadataEnabled;
+ }
+
+ /**
+ * Gets default keep deserialized flag. See {@link #setDefaultKeepDeserialized(boolean)} for more information.
+ *
+ * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
+ */
+ public boolean isDefaultKeepDeserialized() {
+ return dfltKeepDeserialized;
+ }
+
+ /**
+ * Sets default keep deserialized flag.
+ * <p />
+ * Can be overridden for particular type using
+ * {@link PlatformDotNetPortableTypeConfiguration#setKeepDeserialized(Boolean)}.
+ *
+ * @param keepDeserialized Keep deserialized flag.
+ */
+ public void setDefaultKeepDeserialized(boolean keepDeserialized) {
+ this.dfltKeepDeserialized = keepDeserialized;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformDotNetPortableConfiguration.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
new file mode 100644
index 0000000..b04d2a7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java
@@ -0,0 +1,214 @@
+/*
+ * 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.platform.dotnet;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Mirror of .Net class GridDotNetPortableTypeConfiguration.cs
+ */
+public class PlatformDotNetPortableTypeConfiguration {
+ /** Assembly name. */
+ private String assemblyName;
+
+ /** Type name. */
+ private String typeName;
+
+ /** Name mapper. */
+ private String nameMapper;
+
+ /** Id mapper. */
+ private String idMapper;
+
+ /** Serializer. */
+ private String serializer;
+
+ /** Affinity key field name. */
+ private String affinityKeyFieldName;
+
+ /** Metadata enabled. */
+ private Boolean metadataEnabled;
+
+ /** Whether to cache deserialized value in IGridPortableObject. */
+ private Boolean keepDeserialized;
+
+ /**
+ * Default constructor.
+ */
+ public PlatformDotNetPortableTypeConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ * @param cfg configuration to copy.
+ */
+ public PlatformDotNetPortableTypeConfiguration(PlatformDotNetPortableTypeConfiguration cfg) {
+ assemblyName = cfg.getAssemblyName();
+ typeName = cfg.getTypeName();
+ nameMapper = cfg.getNameMapper();
+ idMapper = cfg.getIdMapper();
+ serializer = cfg.getSerializer();
+ affinityKeyFieldName = cfg.getAffinityKeyFieldName();
+ metadataEnabled = cfg.getMetadataEnabled();
+ keepDeserialized = cfg.isKeepDeserialized();
+ }
+
+ /**
+ * @return Assembly name.
+ */
+ public String getAssemblyName() {
+ return assemblyName;
+ }
+
+ /**
+ * @param assemblyName New assembly name.
+ */
+ public void setAssemblyName(String assemblyName) {
+ this.assemblyName = assemblyName;
+ }
+
+ /**
+ * @return Type name.
+ */
+ public String getTypeName() {
+ return typeName;
+ }
+
+ /**
+ * @param typeName New type name.
+ */
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ /**
+ * @return Name mapper.
+ */
+ public String getNameMapper() {
+ return nameMapper;
+ }
+
+ /**
+ * @param nameMapper New name mapper.
+ */
+ public void setNameMapper(String nameMapper) {
+ this.nameMapper = nameMapper;
+ }
+
+ /**
+ * @return Id mapper.
+ */
+ public String getIdMapper() {
+ return idMapper;
+ }
+
+ /**
+ * @param idMapper New id mapper.
+ */
+ public void setIdMapper(String idMapper) {
+ this.idMapper = idMapper;
+ }
+
+ /**
+ * @return Serializer.
+ */
+ public String getSerializer() {
+ return serializer;
+ }
+
+ /**
+ * @param serializer New serializer.
+ */
+ public void setSerializer(String serializer) {
+ this.serializer = serializer;
+ }
+
+ /**
+ * Gets metadata enabled flag. See {@link #setMetadataEnabled(Boolean)} for more information.
+ *
+ * @return Metadata enabled flag.
+ */
+ public Boolean getMetadataEnabled() {
+ return metadataEnabled;
+ }
+
+ /**
+ * Sets metadata enabled flag.
+ * <p />
+ * When set to {@code null} default value taken from
+ * {@link PlatformDotNetPortableConfiguration#isDefaultMetadataEnabled()} will be used.
+ *
+ * @param metadataEnabled New metadata enabled.
+ */
+ public void setMetadataEnabled(Boolean metadataEnabled) {
+ this.metadataEnabled = metadataEnabled;
+ }
+
+ /**
+ * @return Affinity key field name.
+ */
+ public String getAffinityKeyFieldName() {
+ return affinityKeyFieldName;
+ }
+
+ /**
+ * @param affinityKeyFieldName Affinity key field name.
+ */
+ public void setAffinityKeyFieldName(String affinityKeyFieldName) {
+ this.affinityKeyFieldName = affinityKeyFieldName;
+ }
+
+ /**
+ * Gets keep deserialized flag.
+ *
+ * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
+ * @deprecated Use {@link #getKeepDeserialized()} instead.
+ */
+ @Deprecated
+ @Nullable public Boolean isKeepDeserialized() {
+ return keepDeserialized;
+ }
+
+ /**
+ * Gets keep deserialized flag. See {@link #setKeepDeserialized(Boolean)} for more information.
+ *
+ * @return Flag indicates whether to cache deserialized value in IGridPortableObject.
+ */
+ @Nullable public Boolean getKeepDeserialized() {
+ return keepDeserialized;
+ }
+
+ /**
+ * Sets keep deserialized flag.
+ * <p />
+ * When set to {@code null} default value taken from
+ * {@link PlatformDotNetPortableConfiguration#isDefaultKeepDeserialized()} will be used.
+ *
+ * @param keepDeserialized Keep deserialized flag.
+ */
+ public void setKeepDeserialized(@Nullable Boolean keepDeserialized) {
+ this.keepDeserialized = keepDeserialized;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PlatformDotNetPortableTypeConfiguration.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/main/java/org/apache/ignite/platform/dotnet/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/package-info.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/package-info.java
new file mode 100644
index 0000000..0765e01
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains .Net platform-related classes.
+ */
+package org.apache.ignite.platform.dotnet;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/main/java/org/apache/ignite/platform/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/package-info.java b/modules/core/src/main/java/org/apache/ignite/platform/package-info.java
new file mode 100644
index 0000000..ac89b58
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains platform-related classes.
+ */
+package org.apache.ignite.platform;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java
new file mode 100644
index 0000000..c721e16
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBroadcastTask.java
@@ -0,0 +1,73 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Task collecting IDs of all nodes where it was executed.
+ */
+public class PlatformComputeBroadcastTask extends ComputeTaskAdapter<Object, Collection<UUID>> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
+ Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
+
+ for (ClusterNode node : subgrid)
+ jobs.put(new BroadcastJob(), node);
+
+ return jobs;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Collection<UUID> reduce(List<ComputeJobResult> results) {
+ List<UUID> ids = new ArrayList<>();
+
+ for (ComputeJobResult res : results)
+ ids.add((UUID)res.getData());
+
+ return ids;
+ }
+
+ /**
+ * Job.
+ */
+ private static class BroadcastJob extends ComputeJobAdapter {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ return ignite.cluster().localNode().id();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java
new file mode 100644
index 0000000..a14e481
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeDecimalTask.java
@@ -0,0 +1,106 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+@SuppressWarnings({"ConstantConditions", "UnusedDeclaration"})
+public class PlatformComputeDecimalTask extends ComputeTaskAdapter<Object[], BigDecimal> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object[] arg) {
+ return Collections.singletonMap(new DecimalJob((BigDecimal)arg[0], (String)arg[1]), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ @Nullable @Override public BigDecimal reduce(List<ComputeJobResult> results) {
+ ComputeJobResult res = results.get(0);
+
+ if (res.getException() != null)
+ throw res.getException();
+ else
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class DecimalJob extends ComputeJobAdapter implements Externalizable {
+ /** Value. */
+ private BigDecimal val;
+
+ /** Value as string. */
+ private String valStr;
+
+ /**
+ * Constructor.
+ */
+ public DecimalJob() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param val Value.
+ * @param valStr Value as string.
+ */
+ private DecimalJob(BigDecimal val, String valStr) {
+ this.val = val;
+ this.valStr = valStr;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ BigDecimal exp = new BigDecimal(valStr.replace(',', '.'));
+
+ if (val != null && !exp.equals(val))
+ throw new IgniteException("Actual=" + val);
+
+ return exp;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(val);
+ out.writeObject(valStr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ val = (BigDecimal)in.readObject();
+ valStr = (String)in.readObject();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
new file mode 100644
index 0000000..f64ca7d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
@@ -0,0 +1,188 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Test task producing result without any arguments.
+ */
+public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object> {
+ /** Type: NULL. */
+ private static final int TYPE_NULL = 0;
+
+ /** Type: byte. */
+ private static final int TYPE_BYTE = 1;
+
+ /** Type: bool. */
+ private static final int TYPE_BOOL = 2;
+
+ /** Type: short. */
+ private static final int TYPE_SHORT = 3;
+
+ /** Type: char. */
+ private static final int TYPE_CHAR = 4;
+
+ /** Type: int. */
+ private static final int TYPE_INT = 5;
+
+ /** Type: long. */
+ private static final int TYPE_LONG = 6;
+
+ /** Type: float. */
+ private static final int TYPE_FLOAT = 7;
+
+ /** Type: double. */
+ private static final int TYPE_DOUBLE = 8;
+
+ /** Type: array. */
+ private static final int TYPE_ARRAY = 9;
+
+ /** Type: collection. */
+ private static final int TYPE_COLLECTION = 10;
+
+ /** Type: map. */
+ private static final int TYPE_MAP = 11;
+
+ /** Type: portable object which exists in all platforms. */
+ private static final int TYPE_PORTABLE = 12;
+
+ /** Type: portable object which exists only in Java. */
+ private static final int TYPE_PORTABLE_JAVA = 13;
+
+ /** Type: object array. */
+ private static final int TYPE_OBJ_ARRAY = 14;
+
+ /** Type: portable object array. */
+ private static final int TYPE_PORTABLE_ARRAY = 15;
+
+ /** Type: enum. */
+ private static final int TYPE_ENUM = 16;
+
+ /** Type: enum array. */
+ private static final int TYPE_ENUM_ARRAY = 17;
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+ @Nullable Integer arg) {
+ return Collections.singletonMap(new EchoJob(arg), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object reduce(List<ComputeJobResult> results) {
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class EchoJob extends ComputeJobAdapter {
+ /** Type. */
+ private Integer type;
+
+ /**
+ * Constructor.
+ *
+ * @param type Result type.
+ */
+ public EchoJob(Integer type) {
+ this.type = type;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ switch (type) {
+ case TYPE_NULL:
+ return null;
+
+ case TYPE_BYTE:
+ return (byte)1;
+
+ case TYPE_BOOL:
+ return true;
+
+ case TYPE_SHORT:
+ return (short)1;
+
+ case TYPE_CHAR:
+ return (char)1;
+
+ case TYPE_INT:
+ return 1;
+
+ case TYPE_LONG:
+ return (long)1;
+
+ case TYPE_FLOAT:
+ return (float)1;
+
+ case TYPE_DOUBLE:
+ return (double)1;
+
+ case TYPE_ARRAY:
+ return new int[] { 1 };
+
+ case TYPE_COLLECTION:
+ return Collections.singletonList(1);
+
+ case TYPE_MAP:
+ return Collections.singletonMap(1, 1);
+
+ case TYPE_PORTABLE:
+ return new PlatformComputePortable(1);
+
+ case TYPE_PORTABLE_JAVA:
+ return new PlatformComputeJavaPortable(1);
+
+ case TYPE_OBJ_ARRAY:
+ return new String[] { "foo", "bar", "baz" };
+
+ case TYPE_PORTABLE_ARRAY:
+ return new PlatformComputePortable[] {
+ new PlatformComputePortable(1),
+ new PlatformComputePortable(2),
+ new PlatformComputePortable(3)
+ };
+
+ case TYPE_ENUM:
+ return PlatformComputeEnum.BAR;
+
+ case TYPE_ENUM_ARRAY:
+ return new PlatformComputeEnum[] {
+ PlatformComputeEnum.BAR,
+ PlatformComputeEnum.BAZ,
+ PlatformComputeEnum.FOO
+ };
+
+ default:
+ throw new IgniteException("Unknown type: " + type);
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java
new file mode 100644
index 0000000..7fc0623
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEnum.java
@@ -0,0 +1,28 @@
+/*
+ * 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.platform;
+
+/**
+ * Test enum.
+ */
+public enum PlatformComputeEnum
+{
+ FOO,
+ BAR,
+ BAZ
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
new file mode 100644
index 0000000..7a940c4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.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.platform;
+
+/**
+ * Portable object defined only in Java.
+ */
+public class PlatformComputeJavaPortable extends PlatformComputePortable {
+ /**
+ * Constructor.
+ */
+ public PlatformComputeJavaPortable() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public PlatformComputeJavaPortable(int field) {
+ super(field);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
new file mode 100644
index 0000000..f31f093
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
@@ -0,0 +1,42 @@
+/*
+ * 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.platform;
+
+/**
+ * Portable object for task tests.
+ */
+public class PlatformComputePortable {
+ /** Field. */
+ public int field;
+
+ /**
+ * Constructor.
+ */
+ public PlatformComputePortable() {
+ // No-op.
+ }
+
+ /**
+ * Constructor,
+ *
+ * @param field Field.
+ */
+ public PlatformComputePortable(int field) {
+ this.field = field;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
new file mode 100644
index 0000000..0e8b825
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
@@ -0,0 +1,119 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.portable.PortableMetadata;
+import org.apache.ignite.portable.PortableObject;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task working with portable argument.
+ */
+public class PlatformComputePortableArgTask extends ComputeTaskAdapter<Object, Integer> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
+ return Collections.singletonMap(new PortableArgJob(arg), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ @Nullable @Override public Integer reduce(List<ComputeJobResult> results) {
+ ComputeJobResult res = results.get(0);
+
+ if (res.getException() != null)
+ throw res.getException();
+ else
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class PortableArgJob extends ComputeJobAdapter implements Externalizable {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Argument. */
+ private Object arg;
+
+ /**
+ * Constructor.
+ */
+ public PortableArgJob() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param arg Argument.
+ */
+ private PortableArgJob(Object arg) {
+ this.arg = arg;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ PortableObject arg0 = ((PortableObject)arg);
+
+ PortableMetadata meta = ignite.portables().metadata(arg0.typeId());
+
+ if (meta == null)
+ throw new IgniteException("Metadata doesn't exist.");
+
+ if (meta.fields() == null || !meta.fields().contains("Field"))
+ throw new IgniteException("Field metadata doesn't exist.");
+
+ if (!F.eq("int", meta.fieldTypeName("Field")))
+ throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field"));
+
+ if (meta.affinityKeyFieldName() != null)
+ throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName());
+
+ return arg0.field("field");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(arg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ arg = in.readObject();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java
new file mode 100644
index 0000000..d9dee9d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformEventsWriteEventTask.java
@@ -0,0 +1,146 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.events.CacheQueryExecutedEvent;
+import org.apache.ignite.events.CacheQueryReadEvent;
+import org.apache.ignite.events.CacheRebalancingEvent;
+import org.apache.ignite.events.CheckpointEvent;
+import org.apache.ignite.events.DiscoveryEvent;
+import org.apache.ignite.events.JobEvent;
+import org.apache.ignite.events.SwapSpaceEvent;
+import org.apache.ignite.events.TaskEvent;
+import org.apache.ignite.internal.portable.PortableRawWriterEx;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
+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.F;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.events.*;
+
+import org.apache.ignite.plugin.security.SecurityPermission;
+import org.apache.ignite.plugin.security.SecuritySubjectType;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Test task writing all events to a stream.
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class PlatformEventsWriteEventTask extends ComputeTaskAdapter<Long, Object> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+ Long ptr) {
+ return Collections.singletonMap(new Job(ptr, F.first(subgrid)), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object reduce(List<ComputeJobResult> results) {
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ @SuppressWarnings("deprecation")
+ private static class Job extends ComputeJobAdapter {
+ /** Grid. */
+ @IgniteInstanceResource
+ protected transient Ignite ignite;
+
+ /** Stream ptr. */
+ private final long ptr;
+
+ private final ClusterNode node;
+
+ /**
+ * Constructor.
+ *
+ * @param ptr Stream ptr.
+ */
+ public Job(long ptr, ClusterNode node) {
+ this.ptr = ptr;
+ this.node = node;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ PlatformContext ctx = PlatformUtils.platformContext(ignite);
+
+ try (PlatformMemory mem = ctx.memory().get(ptr)) {
+ PlatformOutputStream out = mem.output();
+ PortableRawWriterEx writer = ctx.writer(out);
+
+ int evtType = EventType.EVT_SWAP_SPACE_CLEARED;
+ String msg = "msg";
+ UUID uuid = new UUID(1, 2);
+ IgniteUuid igniteUuid = new IgniteUuid(uuid, 3);
+
+ ctx.writeEvent(writer, new CacheEvent("cacheName", node, node, "msg", evtType, 1, true, 2,
+ igniteUuid, 3, 4, true, 5, true, uuid, "cloClsName", "taskName"));
+
+ //noinspection unchecked
+ ctx.writeEvent(writer, new CacheQueryExecutedEvent(node, msg, evtType, "qryType", "cacheName",
+ "clsName", "clause", null, null, null, uuid, "taskName"));
+
+ //noinspection unchecked
+ ctx.writeEvent(writer, new CacheQueryReadEvent(node, msg, evtType, "qryType", "cacheName",
+ "clsName", "clause", null, null, null, uuid, "taskName", 1, 2, 3, 4));
+
+ ctx.writeEvent(writer, new CacheRebalancingEvent("cacheName", node, msg, evtType, 1, node, 2, 3));
+
+ ctx.writeEvent(writer, new CheckpointEvent(node, msg, evtType, "cpKey"));
+
+ DiscoveryEvent discoveryEvent = new DiscoveryEvent(node, msg, evtType, node);
+ discoveryEvent.topologySnapshot(ignite.cluster().topologyVersion(), ignite.cluster().nodes());
+ ctx.writeEvent(writer, discoveryEvent);
+
+ JobEvent jobEvent = new JobEvent(node, msg, evtType);
+ jobEvent.jobId(igniteUuid);
+ jobEvent.taskClassName("taskClsName");
+ jobEvent.taskName("taskName");
+ jobEvent.taskNode(node);
+ jobEvent.taskSessionId(igniteUuid);
+ jobEvent.taskSubjectId(uuid);
+ ctx.writeEvent(writer, jobEvent);
+
+ ctx.writeEvent(writer, new SwapSpaceEvent(node, msg, evtType, "space"));
+
+ ctx.writeEvent(writer, new TaskEvent(node, msg, evtType, igniteUuid, "taskName", "taskClsName",
+ true, uuid));
+
+ out.synchronize();
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java
new file mode 100644
index 0000000..6effb0f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformMaxMemoryTask.java
@@ -0,0 +1,57 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.jetbrains.annotations.Nullable;
+
+import java.lang.management.ManagementFactory;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task to get max Java heap memory for node.
+ */
+public class PlatformMaxMemoryTask extends ComputeTaskAdapter<Object, Long> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+ @Nullable Object arg) {
+ return Collections.singletonMap(new MaxMemoryJob(), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Long reduce(List<ComputeJobResult> results) {
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class MaxMemoryJob extends ComputeJobAdapter {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java
new file mode 100644
index 0000000..23292f7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformMinMemoryTask.java
@@ -0,0 +1,57 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.jetbrains.annotations.Nullable;
+
+import java.lang.management.ManagementFactory;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task to get min Java heap memory for node.
+ */
+public class PlatformMinMemoryTask extends ComputeTaskAdapter<Object, Long> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+ @Nullable Object arg) {
+ return Collections.singletonMap(new MinMemoryJob(), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Long reduce(List<ComputeJobResult> results) {
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class MinMemoryJob extends ComputeJobAdapter {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java b/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java
new file mode 100644
index 0000000..d60912b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleBean.java
@@ -0,0 +1,47 @@
+/*
+ * 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.platform.lifecycle;
+
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.lifecycle.LifecycleEventType;
+
+/**
+ * Java lifecycle bean.
+ */
+public class PlatformJavaLifecycleBean implements LifecycleBean {
+ /** Count of "beforeStart" invocations. */
+ public static volatile int beforeStartCnt;
+
+ /** Count of "afterStart" invocations. */
+ public static volatile int afterStartCnt;
+
+ /** {@inheritDoc} */
+ @Override public void onLifecycleEvent(LifecycleEventType evt) {
+ switch (evt) {
+ case BEFORE_NODE_START:
+ beforeStartCnt++;
+
+ break;
+
+ case AFTER_NODE_START:
+ afterStartCnt++;
+
+ break;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java b/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java
new file mode 100644
index 0000000..ec01da1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/lifecycle/PlatformJavaLifecycleTask.java
@@ -0,0 +1,65 @@
+/*
+ * 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.platform.lifecycle;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Lifecycle task.
+ */
+public class PlatformJavaLifecycleTask extends ComputeTaskAdapter<Object, List<Integer>> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+ @Nullable Object arg) {
+ Map<ComputeJob, ClusterNode> jobs = new HashMap<>();
+
+ jobs.put(new LifecycleJob(), subgrid.get(0));
+
+ return jobs;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public List<Integer> reduce(List<ComputeJobResult> results) {
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class LifecycleJob extends ComputeJobAdapter {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ List<Integer> res = new ArrayList<Integer>();
+
+ res.add(PlatformJavaLifecycleBean.beforeStartCnt);
+ res.add(PlatformJavaLifecycleBean.afterStartCnt);
+
+ return res;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/pom.xml
----------------------------------------------------------------------
diff --git a/modules/platform/pom.xml b/modules/platform/pom.xml
deleted file mode 100644
index ac34436..0000000
--- a/modules/platform/pom.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<!--
- POM file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-parent</artifactId>
- <version>1</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <artifactId>ignite-platform</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <url>http://ignite.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-log4j</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-spring</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
-
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/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
deleted file mode 100644
index 7f015e7..0000000
--- a/modules/platform/src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory
+++ /dev/null
@@ -1,2 +0,0 @@
-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/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
deleted file mode 100644
index 7e71e11..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractBootstrap.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.Ignition;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.platform.memory.PlatformExternalMemory;
-import org.apache.ignite.lang.IgniteClosure;
-
-/**
- * Base interop bootstrap implementation.
- */
-public abstract class PlatformAbstractBootstrap implements PlatformBootstrap {
- /** {@inheritDoc} */
- @Override public PlatformProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr) {
- Ignition.setClientMode(new PlatformExternalMemory(null, dataPtr).input().readBoolean());
-
- IgniteConfiguration cfg0 = closure(envPtr).apply(cfg);
-
- IgniteEx node = (IgniteEx) Ignition.start(cfg0);
-
- return node.context().platform();
- }
-
- /**
- * Get configuration transformer closure.
- *
- * @param envPtr Environment pointer.
- * @return Closure.
- */
- protected abstract IgniteClosure<IgniteConfiguration, IgniteConfiguration> closure(long envPtr);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/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
deleted file mode 100644
index 2f7af71..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractConfigurationClosure.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractPredicate.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractPredicate.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractPredicate.java
deleted file mode 100644
index bcfe19e..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractPredicate.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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 java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-/**
- * Base interop predicate. Delegates apply to native platform.
- */
-public abstract class PlatformAbstractPredicate implements Externalizable {
- /** .Net portable predicate */
- protected Object pred;
-
- /** Pointer to deployed predicate. */
- protected transient long ptr;
-
- /** Interop processor. */
- protected transient PlatformContext ctx;
-
- /**
- * {@link java.io.Externalizable} support.
- */
- public PlatformAbstractPredicate() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param pred .Net portable predicate.
- * @param ptr Pointer to predicate in the native platform.
- * @param ctx Kernal context.
- */
- protected PlatformAbstractPredicate(Object pred, long ptr, PlatformContext ctx) {
- this.pred = pred;
- this.ptr = ptr;
- this.ctx = ctx;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(pred);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- pred = in.readObject();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
deleted file mode 100644
index 0f46517..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformAbstractTarget.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * 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.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.portable.PortableRawReaderEx;
-import org.apache.ignite.internal.portable.PortableRawWriterEx;
-import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
-import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
-import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
-import org.apache.ignite.internal.util.future.IgniteFutureImpl;
-import org.apache.ignite.lang.IgniteFuture;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Abstract interop target.
- */
-public abstract class PlatformAbstractTarget implements PlatformTarget {
- /** Constant: TRUE.*/
- protected static final int TRUE = 1;
-
- /** Constant: FALSE. */
- protected static final int FALSE = 0;
-
- /** */
- private static final int OP_META = -1;
-
- /** Context. */
- protected final PlatformContext platformCtx;
-
- /** Logger. */
- protected final IgniteLogger log;
-
- /**
- * Constructor.
- *
- * @param platformCtx Context.
- */
- protected PlatformAbstractTarget(PlatformContext platformCtx) {
- this.platformCtx = platformCtx;
-
- log = platformCtx.kernalContext().log(PlatformAbstractTarget.class);
- }
-
- /** {@inheritDoc} */
- @Override public long inStreamOutLong(int type, long memPtr) throws Exception {
- try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
- PortableRawReaderEx reader = platformCtx.reader(mem);
-
- if (type == OP_META) {
- platformCtx.processMetadata(reader);
-
- return TRUE;
- }
- else
- return processInStreamOutLong(type, reader);
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public Object inStreamOutObject(int type, long memPtr) throws Exception {
- try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
- PortableRawReaderEx reader = platformCtx.reader(mem);
-
- return processInStreamOutObject(type, reader);
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public long outLong(int type) throws Exception {
- try {
- return processOutLong(type);
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void outStream(int type, long memPtr) throws Exception {
- try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
- PlatformOutputStream out = mem.output();
-
- PortableRawWriterEx writer = platformCtx.writer(out);
-
- processOutStream(type, writer);
-
- out.synchronize();
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public Object outObject(int type) throws Exception {
- try {
- return processOutObject(type);
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void inStreamOutStream(int type, long inMemPtr, long outMemPtr) throws Exception {
- try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
- PortableRawReaderEx reader = platformCtx.reader(inMem);
-
- try (PlatformMemory outMem = platformCtx.memory().get(outMemPtr)) {
- PlatformOutputStream out = outMem.output();
-
- PortableRawWriterEx writer = platformCtx.writer(out);
-
- processInStreamOutStream(type, reader, writer);
-
- out.synchronize();
- }
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void inObjectStreamOutStream(int type, Object arg, long inMemPtr, long outMemPtr) throws Exception {
- try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
- PortableRawReaderEx reader = platformCtx.reader(inMem);
-
- try (PlatformMemory outMem = platformCtx.memory().get(outMemPtr)) {
- PlatformOutputStream out = outMem.output();
-
- PortableRawWriterEx writer = platformCtx.writer(out);
-
- processInObjectStreamOutStream(type, arg, reader, writer);
-
- out.synchronize();
- }
- }
- catch (Exception e) {
- throw convertException(e);
- }
- }
-
- /**
- * Convert caught exception.
- *
- * @param e Exception to convert.
- * @return Converted exception.
- */
- public Exception convertException(Exception e) {
- return e;
- }
-
- /**
- * @return Context.
- */
- public PlatformContext platformContext() {
- return platformCtx;
- }
-
- /** {@inheritDoc} */
- @Override public void listenFuture(final long futId, int typ) throws Exception {
- PlatformFutureUtils.listen(platformCtx, currentFutureWrapped(), futId, typ, null, this);
- }
-
- /** {@inheritDoc} */
- @Override public void listenFutureForOperation(final long futId, int typ, int opId) throws Exception {
- PlatformFutureUtils.listen(platformCtx, currentFutureWrapped(), futId, typ, futureWriter(opId), this);
- }
-
- /**
- * Get current future with proper exception conversions.
- *
- * @return Future.
- * @throws IgniteCheckedException If failed.
- */
- @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"})
- protected IgniteInternalFuture currentFutureWrapped() throws IgniteCheckedException {
- IgniteFutureImpl fut = (IgniteFutureImpl)currentFuture();
-
- return fut.internalFuture();
- }
-
- /**
- * When overridden in a derived class, gets future for the current operation.
- *
- * @return current future.
- * @throws IgniteCheckedException
- */
- protected IgniteFuture currentFuture() throws IgniteCheckedException {
- throw new IgniteCheckedException("Future listening is not supported in " + this.getClass());
- }
-
- /**
- * When overridden in a derived class, gets a custom future writer.
- *
- * @param opId Operation id.
- * @return A custom writer for given op id.
- */
- protected @Nullable PlatformFutureUtils.Writer futureWriter(int opId){
- return null;
- }
-
- /**
- * Process IN operation.
- *
- * @param type Type.
- * @param reader Portable reader.
- * @return Result.
- * @throws IgniteCheckedException In case of exception.
- */
- protected long processInStreamOutLong(int type, PortableRawReaderEx reader) throws IgniteCheckedException {
- return throwUnsupported(type);
- }
-
- /**
- * Process IN-OUT operation.
- *
- * @param type Type.
- * @param reader Portable reader.
- * @param writer Portable writer.
- * @throws IgniteCheckedException In case of exception.
- */
- protected void processInStreamOutStream(int type, PortableRawReaderEx reader, PortableRawWriterEx writer)
- throws IgniteCheckedException {
- throwUnsupported(type);
- }
-
- /**
- * Process IN operation with managed object as result.
- *
- * @param type Type.
- * @param reader Portable reader.
- * @return Result.
- * @throws IgniteCheckedException In case of exception.
- */
- protected Object processInStreamOutObject(int type, PortableRawReaderEx reader) throws IgniteCheckedException {
- return throwUnsupported(type);
- }
-
- /**
- * Process IN-OUT operation.
- *
- * @param type Type.
- * @param arg Argument.
- * @param reader Portable reader.
- * @param writer Portable writer.
- * @throws IgniteCheckedException In case of exception.
- */
- protected void processInObjectStreamOutStream(int type, @Nullable Object arg, PortableRawReaderEx reader,
- PortableRawWriterEx writer) throws IgniteCheckedException {
- throwUnsupported(type);
- }
-
- /**
- * Process OUT operation.
- *
- * @param type Type.
- * @throws IgniteCheckedException In case of exception.
- */
- protected long processOutLong(int type) throws IgniteCheckedException {
- return throwUnsupported(type);
- }
-
- /**
- * Process OUT operation.
- *
- * @param type Type.
- * @param writer Portable writer.
- * @throws IgniteCheckedException In case of exception.
- */
- protected void processOutStream(int type, PortableRawWriterEx writer) throws IgniteCheckedException {
- throwUnsupported(type);
- }
-
- /**
- * Process OUT operation.
- *
- * @param type Type.
- * @throws IgniteCheckedException In case of exception.
- */
- protected Object processOutObject(int type) throws IgniteCheckedException {
- return throwUnsupported(type);
- }
-
- /**
- * Throw an exception rendering unsupported operation type.
- *
- * @param type Operation type.
- * @return Dummy value which is never returned.
- * @throws IgniteCheckedException Exception to be thrown.
- */
- protected <T> T throwUnsupported(int type) throws IgniteCheckedException {
- throw new IgniteCheckedException("Unsupported operation type: " + type);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java
deleted file mode 100644
index 9d64649..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrap.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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;
-
-/**
- * Platform bootstrap. Responsible for starting Ignite node with non-Java platform.
- */
-public interface PlatformBootstrap {
- /**
- * Start Ignite node.
- *
- * @param cfg Configuration.
- * @param envPtr Environment pointer.
- * @param dataPtr Optional pointer to additional data required for startup.
- * @return Platform processor.
- */
- public PlatformProcessor start(IgniteConfiguration cfg, long envPtr, long dataPtr);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java
deleted file mode 100644
index 3a732b2..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformBootstrapFactory.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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;
-
-/**
- * Platform bootstrap factory.
- */
-public interface PlatformBootstrapFactory {
- /**
- * Get bootstrap factory ID.
- *
- * @return ID.
- */
- public int id();
-
- /**
- * Create bootstrap instance.
- *
- * @return Bootstrap instance.
- */
- public PlatformBootstrap create();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8045c820/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
deleted file mode 100644
index 66eff8b..0000000
--- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformConfigurationEx.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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