You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/11/04 11:28:13 UTC
[10/16] ignite git commit: IGNITE-950 - Renaming examples.
IGNITE-950 - Renaming examples.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9fae3cd8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9fae3cd8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9fae3cd8
Branch: refs/heads/ignite-950-new
Commit: 9fae3cd859d8d877fa7c9a9d9c29f0572598c7e7
Parents: 22f867d
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Nov 4 12:23:51 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 4 12:23:51 2015 +0300
----------------------------------------------------------------------
.../config/binary/example-ignite-binary.xml | 44 +++
.../config/portable/example-ignite-portable.xml | 44 ---
.../apache/ignite/examples/binary/Address.java | 72 ++++
.../apache/ignite/examples/binary/Employee.java | 93 ++++++
.../ignite/examples/binary/EmployeeKey.java | 90 +++++
.../binary/ExampleBinaryNodeStartup.java | 36 ++
.../ignite/examples/binary/Organization.java | 93 ++++++
.../examples/binary/OrganizationType.java | 32 ++
...ComputeClientBinaryTaskExecutionExample.java | 153 +++++++++
.../binary/computegrid/ComputeClientTask.java | 116 +++++++
.../binary/computegrid/package-info.java | 21 ++
.../CacheClientBinaryPutGetExample.java | 230 +++++++++++++
.../datagrid/CacheClientBinaryQueryExample.java | 329 +++++++++++++++++++
.../examples/binary/datagrid/package-info.java | 21 ++
.../ignite/examples/binary/package-info.java | 21 ++
.../ignite/examples/portable/Address.java | 72 ----
.../ignite/examples/portable/Employee.java | 93 ------
.../ignite/examples/portable/EmployeeKey.java | 90 -----
.../portable/ExamplePortableNodeStartup.java | 36 --
.../ignite/examples/portable/Organization.java | 93 ------
.../examples/portable/OrganizationType.java | 32 --
...mputeClientPortableTaskExecutionExample.java | 154 ---------
.../portable/computegrid/ComputeClientTask.java | 116 -------
.../portable/computegrid/package-info.java | 21 --
.../CacheClientPortablePutGetExample.java | 230 -------------
.../CacheClientPortableQueryExample.java | 325 ------------------
.../portable/datagrid/package-info.java | 21 --
.../ignite/examples/portable/package-info.java | 21 --
.../CacheClientPortableExampleTest.java | 8 +-
.../ComputeClientPortableExampleTest.java | 4 +-
.../org/apache/ignite/cache/QueryIndex.java | 19 ++
.../DataStreamProcessorPortableSelfTest.java | 33 ++
.../DataStreamProcessorSelfTest.java | 8 +
33 files changed, 1417 insertions(+), 1354 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/config/binary/example-ignite-binary.xml
----------------------------------------------------------------------
diff --git a/examples/config/binary/example-ignite-binary.xml b/examples/config/binary/example-ignite-binary.xml
new file mode 100644
index 0000000..cde15ea
--- /dev/null
+++ b/examples/config/binary/example-ignite-binary.xml
@@ -0,0 +1,44 @@
+<?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.
+-->
+
+<!--
+ Ignite configuration with all defaults and enabled p2p deployment, events and portable marshaller.
+
+ Use this configuration file when running HTTP REST examples (see 'examples/rest' folder).
+
+ When starting a standalone node, you need to execute the following command:
+ {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/portable/example-ignite-portable.xml
+
+ When starting Ignite from Java IDE, pass path to this file to Ignition:
+ Ignition.start("examples/config/portable/example-ignite-portable.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <!-- Imports default Ignite configuration -->
+ <import resource="../example-default.xml"/>
+
+ <bean parent="ignite.cfg">
+ <!-- Enables portable marshaller -->
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"/>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/config/portable/example-ignite-portable.xml
----------------------------------------------------------------------
diff --git a/examples/config/portable/example-ignite-portable.xml b/examples/config/portable/example-ignite-portable.xml
deleted file mode 100644
index cde15ea..0000000
--- a/examples/config/portable/example-ignite-portable.xml
+++ /dev/null
@@ -1,44 +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.
--->
-
-<!--
- Ignite configuration with all defaults and enabled p2p deployment, events and portable marshaller.
-
- Use this configuration file when running HTTP REST examples (see 'examples/rest' folder).
-
- When starting a standalone node, you need to execute the following command:
- {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/portable/example-ignite-portable.xml
-
- When starting Ignite from Java IDE, pass path to this file to Ignition:
- Ignition.start("examples/config/portable/example-ignite-portable.xml");
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <!-- Imports default Ignite configuration -->
- <import resource="../example-default.xml"/>
-
- <bean parent="ignite.cfg">
- <!-- Enables portable marshaller -->
- <property name="marshaller">
- <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"/>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/Address.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/Address.java b/examples/src/main/java/org/apache/ignite/examples/binary/Address.java
new file mode 100644
index 0000000..76d8774
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/Address.java
@@ -0,0 +1,72 @@
+/*
+ * 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.examples.binary;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+
+/**
+ * Employee address.
+ * <p>
+ * This class implements {@link org.apache.ignite.binary.Binarylizable} only for example purposes,
+ * in order to show how to customize serialization and deserialization of
+ * binary objects.
+ */
+public class Address implements Binarylizable {
+ /** Street. */
+ private String street;
+
+ /** ZIP code. */
+ private int zip;
+
+ /**
+ * Required for binary deserialization.
+ */
+ public Address() {
+ // No-op.
+ }
+
+ /**
+ * @param street Street.
+ * @param zip ZIP code.
+ */
+ public Address(String street, int zip) {
+ this.street = street;
+ this.zip = zip;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ writer.writeString("street", street);
+ writer.writeInt("zip", zip);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ street = reader.readString("street");
+ zip = reader.readInt("zip");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Address [street=" + street +
+ ", zip=" + zip + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java b/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java
new file mode 100644
index 0000000..744b44f
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java
@@ -0,0 +1,93 @@
+/*
+ * 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.examples.binary;
+
+import java.util.Collection;
+
+/**
+ * This class represents employee object.
+ */
+public class Employee {
+ /** Name. */
+ private String name;
+
+ /** Salary. */
+ private long salary;
+
+ /** Address. */
+ private Address address;
+
+ /** Departments. */
+ private Collection<String> departments;
+
+ /**
+ * Required for binary deserialization.
+ */
+ public Employee() {
+ // No-op.
+ }
+
+ /**
+ * @param name Name.
+ * @param salary Salary.
+ * @param address Address.
+ * @param departments Departments.
+ */
+ public Employee(String name, long salary, Address address, Collection<String> departments) {
+ this.name = name;
+ this.salary = salary;
+ this.address = address;
+ this.departments = departments;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return Salary.
+ */
+ public long salary() {
+ return salary;
+ }
+
+ /**
+ * @return Address.
+ */
+ public Address address() {
+ return address;
+ }
+
+ /**
+ * @return Departments.
+ */
+ public Collection<String> departments() {
+ return departments;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Employee [name=" + name +
+ ", salary=" + salary +
+ ", address=" + address +
+ ", departments=" + departments + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java b/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java
new file mode 100644
index 0000000..2794230
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java
@@ -0,0 +1,90 @@
+/*
+ * 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.examples.binary;
+
+/**
+ * This class represents key for employee object.
+ * <p>
+ * Used in query example to collocate employees
+ * with their organizations.
+ */
+public class EmployeeKey {
+ /** ID. */
+ private int id;
+
+ /** Organization ID. */
+ private int organizationId;
+
+ /**
+ * Required for binary deserialization.
+ */
+ public EmployeeKey() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param organizationId Organization ID.
+ */
+ public EmployeeKey(int id, int organizationId) {
+ this.id = id;
+ this.organizationId = organizationId;
+ }
+
+ /**
+ * @return ID.
+ */
+ public int id() {
+ return id;
+ }
+
+ /**
+ * @return Organization ID.
+ */
+ public int organizationId() {
+ return organizationId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ EmployeeKey key = (EmployeeKey)o;
+
+ return id == key.id && organizationId == key.organizationId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = id;
+
+ res = 31 * res + organizationId;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "EmployeeKey [id=" + id +
+ ", organizationId=" + organizationId + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java
new file mode 100644
index 0000000..30a015b
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java
@@ -0,0 +1,36 @@
+/*
+ * 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.examples.binary;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+
+/**
+ * Starts up an empty node with example configuration and binary marshaller enabled.
+ */
+public class ExampleBinaryNodeStartup {
+ /**
+ * Start up an empty node with example configuration and binary marshaller enabled.
+ *
+ * @param args Command line arguments, none required.
+ * @throws IgniteException If failed.
+ */
+ public static void main(String[] args) throws IgniteException {
+ Ignition.start("examples/config/binary/example-ignite-binary.xml");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java b/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java
new file mode 100644
index 0000000..b42bb27
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java
@@ -0,0 +1,93 @@
+/*
+ * 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.examples.binary;
+
+import java.sql.Timestamp;
+
+/**
+ * This class represents organization object.
+ */
+public class Organization {
+ /** Name. */
+ private String name;
+
+ /** Address. */
+ private Address address;
+
+ /** Type. */
+ private OrganizationType type;
+
+ /** Last update time. */
+ private Timestamp lastUpdated;
+
+ /**
+ * Required for binary deserialization.
+ */
+ public Organization() {
+ // No-op.
+ }
+
+ /**
+ * @param name Name.
+ * @param address Address.
+ * @param type Type.
+ * @param lastUpdated Last update time.
+ */
+ public Organization(String name, Address address, OrganizationType type, Timestamp lastUpdated) {
+ this.name = name;
+ this.address = address;
+ this.type = type;
+ this.lastUpdated = lastUpdated;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return Address.
+ */
+ public Address address() {
+ return address;
+ }
+
+ /**
+ * @return Type.
+ */
+ public OrganizationType type() {
+ return type;
+ }
+
+ /**
+ * @return Last update time.
+ */
+ public Timestamp lastUpdated() {
+ return lastUpdated;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Organization [name=" + name +
+ ", address=" + address +
+ ", type=" + type +
+ ", lastUpdated=" + lastUpdated + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java b/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java
new file mode 100644
index 0000000..6548210
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java
@@ -0,0 +1,32 @@
+/*
+ * 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.examples.binary;
+
+/**
+ * Organization type enum.
+ */
+public enum OrganizationType {
+ /** Non-profit organization. */
+ NON_PROFIT,
+
+ /** Private organization. */
+ PRIVATE,
+
+ /** Government organization. */
+ GOVERNMENT
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java
new file mode 100644
index 0000000..ae5d169
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java
@@ -0,0 +1,153 @@
+/*
+ * 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.examples.binary.computegrid;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.examples.binary.Address;
+import org.apache.ignite.examples.binary.Employee;
+import org.apache.ignite.binary.BinaryObject;
+
+/**
+ * This example demonstrates use of binary objects with task execution.
+ * Specifically it shows that binary objects are simple Java POJOs and do not require any special treatment.
+ * <p>
+ * The example executes map-reduce task that accepts collection of binary objects as an argument.
+ * Since these objects are never deserialized on remote nodes, classes are not required on classpath
+ * of these nodes.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables the binary marshaller: {@code 'ignite.{sh|bat} examples/config/binary/example-ignite-binary.xml'}.
+ * <p>
+ * Alternatively you can run {@link org.apache.ignite.examples.binary.ExampleBinaryNodeStartup} in another JVM which will
+ * start node with {@code examples/config/binary/example-ignite-binary.xml} configuration.
+ */
+public class ComputeClientBinaryTaskExecutionExample {
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ try (Ignite ignite = Ignition.start("examples/config/binary/example-ignite-binary.xml")) {
+ System.out.println();
+ System.out.println(">>> Binary objects task execution example started.");
+
+ if (ignite.cluster().forRemotes().nodes().isEmpty()) {
+ System.out.println();
+ System.out.println(">>> This example requires remote nodes to be started.");
+ System.out.println(">>> Please start at least 1 remote node.");
+ System.out.println(">>> Refer to example's javadoc for details on configuration.");
+ System.out.println();
+
+ return;
+ }
+
+ // Generate employees to calculate average salary for.
+ Collection<Employee> employees = employees();
+
+ System.out.println();
+ System.out.println(">>> Calculating average salary for employees:");
+
+ for (Employee employee : employees)
+ System.out.println(">>> " + employee);
+
+ // Convert collection of employees to collection of binary objects.
+ // This allows to send objects across nodes without requiring to have
+ // Employee class on classpath of these nodes.
+ Collection<BinaryObject> binaries = ignite.binary().toBinary(employees);
+
+ // Execute task and get average salary.
+ Long avgSalary = ignite.compute(ignite.cluster().forRemotes()).execute(new ComputeClientTask(), binaries);
+
+ System.out.println();
+ System.out.println(">>> Average salary for all employees: " + avgSalary);
+ System.out.println();
+ }
+ }
+
+ /**
+ * Creates collection of employees.
+ *
+ * @return Collection of employees.
+ */
+ private static Collection<Employee> employees() {
+ Collection<Employee> employees = new ArrayList<>();
+
+ employees.add(new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ Arrays.asList("Human Resources", "Customer Service")
+ ));
+
+ employees.add(new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78205),
+ Arrays.asList("Development", "QA")
+ ));
+
+ employees.add(new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ Arrays.asList("Logistics")
+ ));
+
+ employees.add(new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, Hornitos, CA", 95325),
+ Arrays.asList("Development")
+ ));
+
+ employees.add(new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78758),
+ Arrays.asList("Sales")
+ ));
+
+ employees.add(new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ Arrays.asList("Sales")
+ ));
+
+ employees.add(new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ Arrays.asList("Development", "QA")
+ ));
+
+ employees.add(new Employee(
+ "Jack Yang",
+ 12900,
+ new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
+ Arrays.asList("Sales")
+ ));
+
+ return employees;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java
new file mode 100644
index 0000000..36d6734
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java
@@ -0,0 +1,116 @@
+/*
+ * 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.examples.binary.computegrid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskSplitAdapter;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.binary.BinaryObject;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Task that is used for {@link ComputeClientBinaryTaskExecutionExample} and
+ * similar examples in .NET and C++.
+ * <p>
+ * This task calculates average salary for provided collection of employees.
+ * It splits the collection into batches of size {@code 3} and creates a job
+ * for each batch. After all jobs are executed, there results are reduced to
+ * get the average salary.
+ */
+public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<BinaryObject>, Long> {
+ /** {@inheritDoc} */
+ @Override protected Collection<? extends ComputeJob> split(
+ int gridSize,
+ Collection<BinaryObject> arg
+ ) {
+ Collection<ComputeClientJob> jobs = new ArrayList<>();
+
+ Collection<BinaryObject> employees = new ArrayList<>();
+
+ // Split provided collection into batches and
+ // create a job for each batch.
+ for (BinaryObject employee : arg) {
+ employees.add(employee);
+
+ if (employees.size() == 3) {
+ jobs.add(new ComputeClientJob(employees));
+
+ employees = new ArrayList<>(3);
+ }
+ }
+
+ if (!employees.isEmpty())
+ jobs.add(new ComputeClientJob(employees));
+
+ return jobs;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Long reduce(List<ComputeJobResult> results) {
+ long sum = 0;
+ int cnt = 0;
+
+ for (ComputeJobResult res : results) {
+ IgniteBiTuple<Long, Integer> t = res.getData();
+
+ sum += t.get1();
+ cnt += t.get2();
+ }
+
+ return sum / cnt;
+ }
+
+ /**
+ * Remote job for {@link ComputeClientTask}.
+ */
+ private static class ComputeClientJob extends ComputeJobAdapter {
+ /** Collection of employees. */
+ private final Collection<BinaryObject> employees;
+
+ /**
+ * @param employees Collection of employees.
+ */
+ private ComputeClientJob(Collection<BinaryObject> employees) {
+ this.employees = employees;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ long sum = 0;
+ int cnt = 0;
+
+ for (BinaryObject employee : employees) {
+ System.out.println(">>> Processing employee: " + employee.field("name"));
+
+ // Get salary from binary object. Note that object
+ // doesn't need to be fully deserialized.
+ long salary = employee.field("salary");
+
+ sum += salary;
+ cnt++;
+ }
+
+ return new IgniteBiTuple<>(sum, cnt);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java
new file mode 100644
index 0000000..e5e9d7f
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Demonstrates the usage of binary objects with task execution.
+ */
+package org.apache.ignite.examples.binary.computegrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java
new file mode 100644
index 0000000..bb88ee0
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java
@@ -0,0 +1,230 @@
+/*
+ * 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.examples.binary.datagrid;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.binary.Address;
+import org.apache.ignite.examples.binary.Organization;
+import org.apache.ignite.examples.binary.OrganizationType;
+import org.apache.ignite.binary.BinaryObject;
+
+/**
+ * This example demonstrates use of binary objects with Ignite cache.
+ * Specifically it shows that binary objects are simple Java POJOs and do not require any special treatment.
+ * <p>
+ * The example executes several put-get operations on Ignite cache with binary values. Note that
+ * it demonstrates how binary object can be retrieved in fully-deserialized form or in binary object
+ * format using special cache projection.
+ * <p>
+ * Remote nodes should always be started with special configuration file which
+ * enables the binary marshaller: {@code 'ignite.{sh|bat} examples/config/binary/example-ignite-binary.xml'}.
+ * <p>
+ * Alternatively you can run {@link org.apache.ignite.examples.binary.ExampleBinaryNodeStartup} in another JVM which will
+ * start node with {@code examples/config/binary/example-ignite-binary.xml} configuration.
+ */
+@SuppressWarnings("TypeMayBeWeakened")
+public class CacheClientBinaryPutGetExample {
+ /** Cache name. */
+ private static final String CACHE_NAME = CacheClientBinaryPutGetExample.class.getSimpleName();
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ try (Ignite ignite = Ignition.start("examples/config/binary/example-ignite-binary.xml")) {
+ System.out.println();
+ System.out.println(">>> Binary objects cache put-get example started.");
+
+ CacheConfiguration<Integer, Organization> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(CACHE_NAME);
+ cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+
+ try (IgniteCache<Integer, Organization> cache = ignite.createCache(cfg)) {
+ if (ignite.cluster().forDataNodes(cache.getName()).nodes().isEmpty()) {
+ System.out.println();
+ System.out.println(">>> This example requires remote cache node nodes to be started.");
+ System.out.println(">>> Please start at least 1 remote cache node.");
+ System.out.println(">>> Refer to example's javadoc for details on configuration.");
+ System.out.println();
+
+ return;
+ }
+
+ putGet(cache);
+ putGetBinary(cache);
+ putGetAll(cache);
+ putGetAllBinary(cache);
+
+ System.out.println();
+ }
+ finally {
+ // Delete cache with its content completely.
+ ignite.destroyCache(CACHE_NAME);
+ }
+ }
+ }
+
+ /**
+ * Execute individual put and get.
+ *
+ * @param cache Cache.
+ */
+ private static void putGet(IgniteCache<Integer, Organization> cache) {
+ // Create new Organization binary object to store in cache.
+ Organization org = new Organization(
+ "Microsoft", // Name.
+ new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+ OrganizationType.PRIVATE, // Type.
+ new Timestamp(System.currentTimeMillis())); // Last update time.
+
+ // Put created data entry to cache.
+ cache.put(1, org);
+
+ // Get recently created organization as a strongly-typed fully de-serialized instance.
+ Organization orgFromCache = cache.get(1);
+
+ System.out.println();
+ System.out.println(">>> Retrieved organization instance from cache: " + orgFromCache);
+ }
+
+ /**
+ * Execute individual put and get, getting value in binary format, without de-serializing it.
+ *
+ * @param cache Cache.
+ */
+ private static void putGetBinary(IgniteCache<Integer, Organization> cache) {
+ // Create new Organization binary object to store in cache.
+ Organization org = new Organization(
+ "Microsoft", // Name.
+ new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+ OrganizationType.PRIVATE, // Type.
+ new Timestamp(System.currentTimeMillis())); // Last update time.
+
+ // Put created data entry to cache.
+ cache.put(1, org);
+
+ // Get cache that will get values as binary objects.
+ IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary();
+
+ // Get recently created organization as a binary object.
+ BinaryObject po = binaryCache.get(1);
+
+ // Get organization's name from binary object (note that
+ // object doesn't need to be fully deserialized).
+ String name = po.field("name");
+
+ System.out.println();
+ System.out.println(">>> Retrieved organization name from binary object: " + name);
+ }
+
+ /**
+ * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations.
+ *
+ * @param cache Cache.
+ */
+ private static void putGetAll(IgniteCache<Integer, Organization> cache) {
+ // Create new Organization binary objects to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft", // Name.
+ new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+ OrganizationType.PRIVATE, // Type.
+ new Timestamp(System.currentTimeMillis())); // Last update time.
+
+ Organization org2 = new Organization(
+ "Red Cross", // Name.
+ new Address("184 Fidler Drive, San Antonio, TX", 78205), // Address.
+ OrganizationType.NON_PROFIT, // Type.
+ new Timestamp(System.currentTimeMillis())); // Last update time.
+
+ Map<Integer, Organization> map = new HashMap<>();
+
+ map.put(1, org1);
+ map.put(2, org2);
+
+ // Put created data entries to cache.
+ cache.putAll(map);
+
+ // Get recently created organizations as a strongly-typed fully de-serialized instances.
+ Map<Integer, Organization> mapFromCache = cache.getAll(map.keySet());
+
+ System.out.println();
+ System.out.println(">>> Retrieved organization instances from cache:");
+
+ for (Organization org : mapFromCache.values())
+ System.out.println(">>> " + org);
+ }
+
+ /**
+ * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations,
+ * getting values in binary format, without de-serializing it.
+ *
+ * @param cache Cache.
+ */
+ private static void putGetAllBinary(IgniteCache<Integer, Organization> cache) {
+ // Create new Organization binary objects to store in cache.
+ Organization org1 = new Organization(
+ "Microsoft", // Name.
+ new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address.
+ OrganizationType.PRIVATE, // Type.
+ new Timestamp(System.currentTimeMillis())); // Last update time.
+
+ Organization org2 = new Organization(
+ "Red Cross", // Name.
+ new Address("184 Fidler Drive, San Antonio, TX", 78205), // Address.
+ OrganizationType.NON_PROFIT, // Type.
+ new Timestamp(System.currentTimeMillis())); // Last update time.
+
+ Map<Integer, Organization> map = new HashMap<>();
+
+ map.put(1, org1);
+ map.put(2, org2);
+
+ // Put created data entries to cache.
+ cache.putAll(map);
+
+ // Get cache that will get values as binary objects.
+ IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary();
+
+ // Get recently created organizations as binary objects.
+ Map<Integer, BinaryObject> poMap = binaryCache.getAll(map.keySet());
+
+ Collection<String> names = new ArrayList<>();
+
+ // Get organizations' names from binary objects (note that
+ // objects don't need to be fully deserialized).
+ for (BinaryObject po : poMap.values())
+ names.add(po.<String>field("name"));
+
+ System.out.println();
+ System.out.println(">>> Retrieved organization names from binary objects: " + names);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
new file mode 100644
index 0000000..aa4d66b
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java
@@ -0,0 +1,329 @@
+/*
+ * 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.examples.binary.datagrid;
+
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.examples.binary.Address;
+import org.apache.ignite.examples.binary.Employee;
+import org.apache.ignite.examples.binary.EmployeeKey;
+import org.apache.ignite.examples.binary.Organization;
+import org.apache.ignite.examples.binary.OrganizationType;
+import org.apache.ignite.binary.BinaryObject;
+
+/**
+ * This example demonstrates use of binary objects with cache queries.
+ * The example populates cache with sample data and runs several SQL and full text queries over this data.
+ * <p>
+ * Remote nodes should always be started with {@link org.apache.ignite.examples.binary.ExampleBinaryNodeStartup} which starts a node with
+ * {@code examples/config/binary/example-ignite-binary.xml} configuration.
+ */
+public class CacheClientBinaryQueryExample {
+ /** Organization cache name. */
+ private static final String ORGANIZATION_CACHE_NAME = CacheClientBinaryQueryExample.class.getSimpleName()
+ + "Organizations";
+
+ /** Employee cache name. */
+ private static final String EMPLOYEE_CACHE_NAME = CacheClientBinaryQueryExample.class.getSimpleName()
+ + "Employees";
+
+ /**
+ * Executes example.
+ *
+ * @param args Command line arguments, none required.
+ */
+ public static void main(String[] args) {
+ try (Ignite ignite = Ignition.start("examples/config/binary/example-ignite-binary.xml")) {
+ System.out.println();
+ System.out.println(">>> Binary objects cache query example started.");
+
+ CacheConfiguration<Integer, Organization> orgCacheCfg = new CacheConfiguration<>();
+
+ orgCacheCfg.setCacheMode(CacheMode.PARTITIONED);
+ orgCacheCfg.setName(ORGANIZATION_CACHE_NAME);
+
+ orgCacheCfg.setQueryEntities(Arrays.asList(createOrganizationQueryEntity()));
+
+ CacheConfiguration<EmployeeKey, Employee> employeeCacheCfg = new CacheConfiguration<>();
+
+ employeeCacheCfg.setCacheMode(CacheMode.PARTITIONED);
+ employeeCacheCfg.setName(EMPLOYEE_CACHE_NAME);
+
+ employeeCacheCfg.setQueryEntities(Arrays.asList(createEmployeeQueryEntity()));
+
+ try (IgniteCache<Integer, Organization> orgCache = ignite.createCache(orgCacheCfg);
+ IgniteCache<EmployeeKey, Employee> employeeCache = ignite.createCache(employeeCacheCfg)
+ ) {
+ if (ignite.cluster().forDataNodes(orgCache.getName()).nodes().isEmpty()) {
+ System.out.println();
+ System.out.println(">>> This example requires remote cache nodes to be started.");
+ System.out.println(">>> Please start at least 1 remote cache node.");
+ System.out.println(">>> Refer to example's javadoc for details on configuration.");
+ System.out.println();
+
+ return;
+ }
+
+ // Populate cache with sample data entries.
+ populateCache(orgCache, employeeCache);
+
+ // Get cache that will work with binary objects.
+ IgniteCache<BinaryObject, BinaryObject> binaryCache = employeeCache.withKeepBinary();
+
+ // Run SQL query example.
+ sqlQuery(binaryCache);
+
+ // Run SQL query with join example.
+ sqlJoinQuery(binaryCache);
+
+ // Run SQL fields query example.
+ sqlFieldsQuery(binaryCache);
+
+ // Run full text query example.
+ textQuery(binaryCache);
+
+ System.out.println();
+ }
+ finally {
+ // Delete caches with their content completely.
+ ignite.destroyCache(ORGANIZATION_CACHE_NAME);
+ ignite.destroyCache(EMPLOYEE_CACHE_NAME);
+ }
+ }
+ }
+
+ /**
+ * Create cache type metadata for {@link Employee}.
+ *
+ * @return Cache type metadata.
+ */
+ private static QueryEntity createEmployeeQueryEntity() {
+ QueryEntity employeeEntity = new QueryEntity();
+
+ employeeEntity.setValueType(Employee.class.getName());
+ employeeEntity.setKeyType(EmployeeKey.class.getName());
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("name", String.class.getName());
+ fields.put("salary", Long.class.getName());
+ fields.put("address.zip", Integer.class.getName());
+ fields.put("organizationId", Integer.class.getName());
+
+ employeeEntity.setFields(fields);
+
+ employeeEntity.setIndexes(Arrays.asList(
+ new QueryIndex("name"),
+ new QueryIndex("salary"),
+ new QueryIndex("address.zip"),
+ new QueryIndex("organizationId"),
+ new QueryIndex("address.street", QueryIndexType.FULLTEXT)
+ ));
+
+ return employeeEntity;
+ }
+
+ /**
+ * Create cache type metadata for {@link Organization}.
+ *
+ * @return Cache type metadata.
+ */
+ private static QueryEntity createOrganizationQueryEntity() {
+ QueryEntity organizationEntity = new QueryEntity();
+
+ organizationEntity.setValueType(Organization.class.getName());
+ organizationEntity.setKeyType(Integer.class.getName());
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("name", String.class.getName());
+ fields.put("address.street", String.class.getName());
+
+ organizationEntity.setFields(fields);
+
+ organizationEntity.setIndexes(Arrays.asList(
+ new QueryIndex("name")
+ ));
+
+ return organizationEntity;
+ }
+
+ /**
+ * Queries employees that have provided ZIP code in address.
+ *
+ * @param cache Ignite cache.
+ */
+ private static void sqlQuery(IgniteCache<BinaryObject, BinaryObject> cache) {
+ SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Employee.class, "zip = ?");
+
+ int zip = 94109;
+
+ QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query.setArgs(zip));
+
+ System.out.println();
+ System.out.println(">>> Employees with zip " + zip + ':');
+
+ for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll())
+ System.out.println(">>> " + e.getValue().deserialize());
+ }
+
+ /**
+ * Queries employees that work for organization with provided name.
+ *
+ * @param cache Ignite cache.
+ */
+ private static void sqlJoinQuery(IgniteCache<BinaryObject, BinaryObject> cache) {
+ SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Employee.class,
+ "from Employee, \"" + ORGANIZATION_CACHE_NAME + "\".Organization as org " +
+ "where Employee.organizationId = org._key and org.name = ?");
+
+ String organizationName = "GridGain";
+
+ QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees =
+ cache.query(query.setArgs(organizationName));
+
+ System.out.println();
+ System.out.println(">>> Employees working for " + organizationName + ':');
+
+ for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll())
+ System.out.println(">>> " + e.getValue());
+ }
+
+ /**
+ * Queries names and salaries for all employees.
+ *
+ * @param cache Ignite cache.
+ */
+ private static void sqlFieldsQuery(IgniteCache<BinaryObject, BinaryObject> cache) {
+ SqlFieldsQuery query = new SqlFieldsQuery("select name, salary from Employee");
+
+ QueryCursor<List<?>> employees = cache.query(query);
+
+ System.out.println();
+ System.out.println(">>> Employee names and their salaries:");
+
+ for (List<?> row : employees.getAll())
+ System.out.println(">>> [Name=" + row.get(0) + ", salary=" + row.get(1) + ']');
+ }
+
+ /**
+ * Queries employees that live in Texas using full-text query API.
+ *
+ * @param cache Ignite cache.
+ */
+ private static void textQuery(IgniteCache<BinaryObject, BinaryObject> cache) {
+ TextQuery<BinaryObject, BinaryObject> query = new TextQuery<>(Employee.class, "TX");
+
+ QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query);
+
+ System.out.println();
+ System.out.println(">>> Employees living in Texas:");
+
+ for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll())
+ System.out.println(">>> " + e.getValue().deserialize());
+ }
+
+ /**
+ * Populates cache with data.
+ *
+ * @param orgCache Organization cache.
+ * @param employeeCache Employee cache.
+ */
+ @SuppressWarnings("TypeMayBeWeakened")
+ private static void populateCache(IgniteCache<Integer, Organization> orgCache,
+ IgniteCache<EmployeeKey, Employee> employeeCache) {
+ orgCache.put(1, new Organization(
+ "GridGain",
+ new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404),
+ OrganizationType.PRIVATE,
+ new Timestamp(System.currentTimeMillis())
+ ));
+
+ orgCache.put(2, new Organization(
+ "Microsoft",
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ OrganizationType.PRIVATE,
+ new Timestamp(System.currentTimeMillis())
+ ));
+
+ employeeCache.put(new EmployeeKey(1, 1), new Employee(
+ "James Wilson",
+ 12500,
+ new Address("1096 Eddy Street, San Francisco, CA", 94109),
+ Arrays.asList("Human Resources", "Customer Service")
+ ));
+
+ employeeCache.put(new EmployeeKey(2, 1), new Employee(
+ "Daniel Adams",
+ 11000,
+ new Address("184 Fidler Drive, San Antonio, TX", 78130),
+ Arrays.asList("Development", "QA")
+ ));
+
+ employeeCache.put(new EmployeeKey(3, 1), new Employee(
+ "Cristian Moss",
+ 12500,
+ new Address("667 Jerry Dove Drive, Florence, SC", 29501),
+ Arrays.asList("Logistics")
+ ));
+
+ employeeCache.put(new EmployeeKey(4, 2), new Employee(
+ "Allison Mathis",
+ 25300,
+ new Address("2702 Freedom Lane, San Francisco, CA", 94109),
+ Arrays.asList("Development")
+ ));
+
+ employeeCache.put(new EmployeeKey(5, 2), new Employee(
+ "Breana Robbin",
+ 6500,
+ new Address("3960 Sundown Lane, Austin, TX", 78130),
+ Arrays.asList("Sales")
+ ));
+
+ employeeCache.put(new EmployeeKey(6, 2), new Employee(
+ "Philip Horsley",
+ 19800,
+ new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
+ Arrays.asList("Sales")
+ ));
+
+ employeeCache.put(new EmployeeKey(7, 2), new Employee(
+ "Brian Peters",
+ 10600,
+ new Address("1407 Pearlman Avenue, Boston, MA", 12110),
+ Arrays.asList("Development", "QA")
+ ));
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java
new file mode 100644
index 0000000..da65bf6
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Demonstrates the usage of binary objects with cache.
+ */
+package org.apache.ignite.examples.binary.datagrid;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java b/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java
new file mode 100644
index 0000000..17bdbb5
--- /dev/null
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Contains Ignite Binary objects classes and examples.
+ */
+package org.apache.ignite.examples.binary;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/Address.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Address.java b/examples/src/main/java/org/apache/ignite/examples/portable/Address.java
deleted file mode 100644
index 77278aa..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/Address.java
+++ /dev/null
@@ -1,72 +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.examples.portable;
-
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-
-/**
- * Employee address.
- * <p>
- * This class implements {@link org.apache.ignite.binary.Binarylizable} only for example purposes,
- * in order to show how to customize serialization and deserialization of
- * portable objects.
- */
-public class Address implements Binarylizable {
- /** Street. */
- private String street;
-
- /** ZIP code. */
- private int zip;
-
- /**
- * Required for portable deserialization.
- */
- public Address() {
- // No-op.
- }
-
- /**
- * @param street Street.
- * @param zip ZIP code.
- */
- public Address(String street, int zip) {
- this.street = street;
- this.zip = zip;
- }
-
- /** {@inheritDoc} */
- @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
- writer.writeString("street", street);
- writer.writeInt("zip", zip);
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
- street = reader.readString("street");
- zip = reader.readInt("zip");
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Address [street=" + street +
- ", zip=" + zip + ']';
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java b/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java
deleted file mode 100644
index 9614168..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java
+++ /dev/null
@@ -1,93 +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.examples.portable;
-
-import java.util.Collection;
-
-/**
- * This class represents employee object.
- */
-public class Employee {
- /** Name. */
- private String name;
-
- /** Salary. */
- private long salary;
-
- /** Address. */
- private Address address;
-
- /** Departments. */
- private Collection<String> departments;
-
- /**
- * Required for portable deserialization.
- */
- public Employee() {
- // No-op.
- }
-
- /**
- * @param name Name.
- * @param salary Salary.
- * @param address Address.
- * @param departments Departments.
- */
- public Employee(String name, long salary, Address address, Collection<String> departments) {
- this.name = name;
- this.salary = salary;
- this.address = address;
- this.departments = departments;
- }
-
- /**
- * @return Name.
- */
- public String name() {
- return name;
- }
-
- /**
- * @return Salary.
- */
- public long salary() {
- return salary;
- }
-
- /**
- * @return Address.
- */
- public Address address() {
- return address;
- }
-
- /**
- * @return Departments.
- */
- public Collection<String> departments() {
- return departments;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Employee [name=" + name +
- ", salary=" + salary +
- ", address=" + address +
- ", departments=" + departments + ']';
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java b/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java
deleted file mode 100644
index f322167..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/EmployeeKey.java
+++ /dev/null
@@ -1,90 +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.examples.portable;
-
-/**
- * This class represents key for employee object.
- * <p>
- * Used in query example to collocate employees
- * with their organizations.
- */
-public class EmployeeKey {
- /** ID. */
- private int id;
-
- /** Organization ID. */
- private int organizationId;
-
- /**
- * Required for portable deserialization.
- */
- public EmployeeKey() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param organizationId Organization ID.
- */
- public EmployeeKey(int id, int organizationId) {
- this.id = id;
- this.organizationId = organizationId;
- }
-
- /**
- * @return ID.
- */
- public int id() {
- return id;
- }
-
- /**
- * @return Organization ID.
- */
- public int organizationId() {
- return organizationId;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- EmployeeKey key = (EmployeeKey)o;
-
- return id == key.id && organizationId == key.organizationId;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = id;
-
- res = 31 * res + organizationId;
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "EmployeeKey [id=" + id +
- ", organizationId=" + organizationId + ']';
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java
deleted file mode 100644
index 87a41f7..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/ExamplePortableNodeStartup.java
+++ /dev/null
@@ -1,36 +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.examples.portable;
-
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-
-/**
- * Starts up an empty node with example configuration and portable marshaller enabled.
- */
-public class ExamplePortableNodeStartup {
- /**
- * Start up an empty node with example configuration and portable marshaller enabled.
- *
- * @param args Command line arguments, none required.
- * @throws IgniteException If failed.
- */
- public static void main(String[] args) throws IgniteException {
- Ignition.start("examples/config/portable/example-ignite-portable.xml");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java b/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java
deleted file mode 100644
index f52cac1..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/Organization.java
+++ /dev/null
@@ -1,93 +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.examples.portable;
-
-import java.sql.Timestamp;
-
-/**
- * This class represents organization object.
- */
-public class Organization {
- /** Name. */
- private String name;
-
- /** Address. */
- private Address address;
-
- /** Type. */
- private OrganizationType type;
-
- /** Last update time. */
- private Timestamp lastUpdated;
-
- /**
- * Required for portable deserialization.
- */
- public Organization() {
- // No-op.
- }
-
- /**
- * @param name Name.
- * @param address Address.
- * @param type Type.
- * @param lastUpdated Last update time.
- */
- public Organization(String name, Address address, OrganizationType type, Timestamp lastUpdated) {
- this.name = name;
- this.address = address;
- this.type = type;
- this.lastUpdated = lastUpdated;
- }
-
- /**
- * @return Name.
- */
- public String name() {
- return name;
- }
-
- /**
- * @return Address.
- */
- public Address address() {
- return address;
- }
-
- /**
- * @return Type.
- */
- public OrganizationType type() {
- return type;
- }
-
- /**
- * @return Last update time.
- */
- public Timestamp lastUpdated() {
- return lastUpdated;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Organization [name=" + name +
- ", address=" + address +
- ", type=" + type +
- ", lastUpdated=" + lastUpdated + ']';
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java b/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java
deleted file mode 100644
index c753e2d..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/OrganizationType.java
+++ /dev/null
@@ -1,32 +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.examples.portable;
-
-/**
- * Organization type enum.
- */
-public enum OrganizationType {
- /** Non-profit organization. */
- NON_PROFIT,
-
- /** Private organization. */
- PRIVATE,
-
- /** Government organization. */
- GOVERNMENT
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java
deleted file mode 100644
index d6b8fd3..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientPortableTaskExecutionExample.java
+++ /dev/null
@@ -1,154 +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.examples.portable.computegrid;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.examples.portable.Address;
-import org.apache.ignite.examples.portable.Employee;
-import org.apache.ignite.examples.portable.ExamplePortableNodeStartup;
-import org.apache.ignite.binary.BinaryObject;
-
-/**
- * This example demonstrates use of portable objects with task execution.
- * Specifically it shows that portable objects are simple Java POJOs and do not require any special treatment.
- * <p>
- * The example executes map-reduce task that accepts collection of portable objects as an argument.
- * Since these objects are never deserialized on remote nodes, classes are not required on classpath
- * of these nodes.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables the portable marshaller: {@code 'ignite.{sh|bat} examples/config/portable/example-ignite-portable.xml'}.
- * <p>
- * Alternatively you can run {@link ExamplePortableNodeStartup} in another JVM which will
- * start node with {@code examples/config/portable/example-ignite-portable.xml} configuration.
- */
-public class ComputeClientPortableTaskExecutionExample {
- /**
- * Executes example.
- *
- * @param args Command line arguments, none required.
- */
- public static void main(String[] args) {
- try (Ignite ignite = Ignition.start("examples/config/portable/example-ignite-portable.xml")) {
- System.out.println();
- System.out.println(">>> Portable objects task execution example started.");
-
- if (ignite.cluster().forRemotes().nodes().isEmpty()) {
- System.out.println();
- System.out.println(">>> This example requires remote nodes to be started.");
- System.out.println(">>> Please start at least 1 remote node.");
- System.out.println(">>> Refer to example's javadoc for details on configuration.");
- System.out.println();
-
- return;
- }
-
- // Generate employees to calculate average salary for.
- Collection<Employee> employees = employees();
-
- System.out.println();
- System.out.println(">>> Calculating average salary for employees:");
-
- for (Employee employee : employees)
- System.out.println(">>> " + employee);
-
- // Convert collection of employees to collection of portable objects.
- // This allows to send objects across nodes without requiring to have
- // Employee class on classpath of these nodes.
- Collection<BinaryObject> portables = ignite.binary().toBinary(employees);
-
- // Execute task and get average salary.
- Long avgSalary = ignite.compute(ignite.cluster().forRemotes()).execute(new ComputeClientTask(), portables);
-
- System.out.println();
- System.out.println(">>> Average salary for all employees: " + avgSalary);
- System.out.println();
- }
- }
-
- /**
- * Creates collection of employees.
- *
- * @return Collection of employees.
- */
- private static Collection<Employee> employees() {
- Collection<Employee> employees = new ArrayList<>();
-
- employees.add(new Employee(
- "James Wilson",
- 12500,
- new Address("1096 Eddy Street, San Francisco, CA", 94109),
- Arrays.asList("Human Resources", "Customer Service")
- ));
-
- employees.add(new Employee(
- "Daniel Adams",
- 11000,
- new Address("184 Fidler Drive, San Antonio, TX", 78205),
- Arrays.asList("Development", "QA")
- ));
-
- employees.add(new Employee(
- "Cristian Moss",
- 12500,
- new Address("667 Jerry Dove Drive, Florence, SC", 29501),
- Arrays.asList("Logistics")
- ));
-
- employees.add(new Employee(
- "Allison Mathis",
- 25300,
- new Address("2702 Freedom Lane, Hornitos, CA", 95325),
- Arrays.asList("Development")
- ));
-
- employees.add(new Employee(
- "Breana Robbin",
- 6500,
- new Address("3960 Sundown Lane, Austin, TX", 78758),
- Arrays.asList("Sales")
- ));
-
- employees.add(new Employee(
- "Philip Horsley",
- 19800,
- new Address("2803 Elsie Drive, Sioux Falls, SD", 57104),
- Arrays.asList("Sales")
- ));
-
- employees.add(new Employee(
- "Brian Peters",
- 10600,
- new Address("1407 Pearlman Avenue, Boston, MA", 12110),
- Arrays.asList("Development", "QA")
- ));
-
- employees.add(new Employee(
- "Jack Yang",
- 12900,
- new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130),
- Arrays.asList("Sales")
- ));
-
- return employees;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9fae3cd8/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java
deleted file mode 100644
index c83dbf2..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/ComputeClientTask.java
+++ /dev/null
@@ -1,116 +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.examples.portable.computegrid;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.apache.ignite.compute.ComputeJob;
-import org.apache.ignite.compute.ComputeJobAdapter;
-import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.compute.ComputeTaskSplitAdapter;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.binary.BinaryObject;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Task that is used for {@link ComputeClientPortableTaskExecutionExample} and
- * similar examples in .NET and C++.
- * <p>
- * This task calculates average salary for provided collection of employees.
- * It splits the collection into batches of size {@code 3} and creates a job
- * for each batch. After all jobs are executed, there results are reduced to
- * get the average salary.
- */
-public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<BinaryObject>, Long> {
- /** {@inheritDoc} */
- @Override protected Collection<? extends ComputeJob> split(
- int gridSize,
- Collection<BinaryObject> arg
- ) {
- Collection<ComputeClientJob> jobs = new ArrayList<>();
-
- Collection<BinaryObject> employees = new ArrayList<>();
-
- // Split provided collection into batches and
- // create a job for each batch.
- for (BinaryObject employee : arg) {
- employees.add(employee);
-
- if (employees.size() == 3) {
- jobs.add(new ComputeClientJob(employees));
-
- employees = new ArrayList<>(3);
- }
- }
-
- if (!employees.isEmpty())
- jobs.add(new ComputeClientJob(employees));
-
- return jobs;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Long reduce(List<ComputeJobResult> results) {
- long sum = 0;
- int cnt = 0;
-
- for (ComputeJobResult res : results) {
- IgniteBiTuple<Long, Integer> t = res.getData();
-
- sum += t.get1();
- cnt += t.get2();
- }
-
- return sum / cnt;
- }
-
- /**
- * Remote job for {@link ComputeClientTask}.
- */
- private static class ComputeClientJob extends ComputeJobAdapter {
- /** Collection of employees. */
- private final Collection<BinaryObject> employees;
-
- /**
- * @param employees Collection of employees.
- */
- private ComputeClientJob(Collection<BinaryObject> employees) {
- this.employees = employees;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object execute() {
- long sum = 0;
- int cnt = 0;
-
- for (BinaryObject employee : employees) {
- System.out.println(">>> Processing employee: " + employee.field("name"));
-
- // Get salary from portable object. Note that object
- // doesn't need to be fully deserialized.
- long salary = employee.field("salary");
-
- sum += salary;
- cnt++;
- }
-
- return new IgniteBiTuple<>(sum, cnt);
- }
- }
-}