diff --git a/examples/config/example-default.xml b/examples/config/example-default.xml deleted file mode 100644 index e6c359d..0000000 --- a/examples/config/example-default.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 127.0.0.1:47500..47509 - - - - - - - - diff --git a/examples/config/example-ignite.xml b/examples/config/example-ignite.xml index d842a6d..e7adb54 100644 --- a/examples/config/example-ignite.xml +++ b/examples/config/example-ignite.xml @@ -22,18 +22,62 @@ --> - - + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 127.0.0.1:47500..47509 + + + + + + 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 @@ - - - - - - - - - - - - - - - - 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 cb08b25..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.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; - -/** - * Employee address. - *

- * This class implements {@link PortableMarshalAware} only for example purposes, - * in order to show how to customize serialization and deserialization of - * portable objects. - */ -public class Address implements PortableMarshalAware { - /** 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 writePortable(PortableWriter writer) throws PortableException { - writer.writeString("street", street); - writer.writeInt("zip", zip); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - street = reader.readString("street"); - zip = reader.readInt("zip"); - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Address [street=" + street + - ", zip=" + zip + ']'; - } -} 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 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 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 departments() { - return departments; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Employee [name=" + name + - ", salary=" + salary + - ", address=" + address + - ", departments=" + departments + ']'; - } -} 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. - *

- * 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 + ']'; - } -} 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"); - } -} 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 + ']'; - } -} 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 -} 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 34d9cde..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.portable.PortableObject; - -/** - * 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. - *

- * 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. - *

- * 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'}. - *

- * 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 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 portables = ignite.portables().toPortable(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 employees() { - Collection 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; - } -} 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 0eee8c6..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.portable.PortableObject; -import org.jetbrains.annotations.Nullable; - -/** - * Task that is used for {@link ComputeClientPortableTaskExecutionExample} and - * similar examples in .NET and C++. - *

- * 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, Long> { - /** {@inheritDoc} */ - @Override protected Collection split( - int gridSize, - Collection arg - ) { - Collection jobs = new ArrayList<>(); - - Collection employees = new ArrayList<>(); - - // Split provided collection into batches and - // create a job for each batch. - for (PortableObject 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 results) { - long sum = 0; - int cnt = 0; - - for (ComputeJobResult res : results) { - IgniteBiTuple 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 employees; - - /** - * @param employees Collection of employees. - */ - private ComputeClientJob(Collection employees) { - this.employees = employees; - } - - /** {@inheritDoc} */ - @Nullable @Override public Object execute() { - long sum = 0; - int cnt = 0; - - for (PortableObject 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); - } - } -} diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java deleted file mode 100644 index 469128c..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/portable/computegrid/package-info.java +++ /dev/null @@ -1,21 +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. - */ - -/** - * Demonstrates the usage of portable objects with task execution. - */ -package org.apache.ignite.examples.portable.computegrid; \ No newline at end of file diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java deleted file mode 100644 index 77c5d95..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortablePutGetExample.java +++ /dev/null @@ -1,230 +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.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.portable.Address; -import org.apache.ignite.examples.portable.ExamplePortableNodeStartup; -import org.apache.ignite.examples.portable.Organization; -import org.apache.ignite.examples.portable.OrganizationType; -import org.apache.ignite.portable.PortableObject; - -/** - * This example demonstrates use of portable objects with Ignite cache. - * Specifically it shows that portable objects are simple Java POJOs and do not require any special treatment. - *

- * The example executes several put-get operations on Ignite cache with portable values. Note that - * it demonstrates how portable object can be retrieved in fully-deserialized form or in portable object - * format using special cache projection. - *

- * 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'}. - *

- * 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 CacheClientPortablePutGetExample { - /** Cache name. */ - private static final String CACHE_NAME = CacheClientPortablePutGetExample.class.getSimpleName(); - - /** - * 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 cache put-get example started."); - - CacheConfiguration cfg = new CacheConfiguration<>(); - - cfg.setCacheMode(CacheMode.PARTITIONED); - cfg.setName(CACHE_NAME); - cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); - - try (IgniteCache 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); - putGetPortable(cache); - putGetAll(cache); - putGetAllPortable(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 cache) { - // Create new Organization portable 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 portable format, without de-serializing it. - * - * @param cache Cache. - */ - private static void putGetPortable(IgniteCache cache) { - // Create new Organization portable 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 portable objects. - IgniteCache portableCache = cache.withKeepPortable(); - - // Get recently created organization as a portable object. - PortableObject po = portableCache.get(1); - - // Get organization's name from portable 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 portable object: " + name); - } - - /** - * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations. - * - * @param cache Cache. - */ - private static void putGetAll(IgniteCache cache) { - // Create new Organization portable 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 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 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 portable format, without de-serializing it. - * - * @param cache Cache. - */ - private static void putGetAllPortable(IgniteCache cache) { - // Create new Organization portable 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 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 portable objects. - IgniteCache portableCache = cache.withKeepPortable(); - - // Get recently created organizations as portable objects. - Map poMap = portableCache.getAll(map.keySet()); - - Collection names = new ArrayList<>(); - - // Get organizations' names from portable objects (note that - // objects don't need to be fully deserialized). - for (PortableObject po : poMap.values()) - names.add(po.field("name")); - - System.out.println(); - System.out.println(">>> Retrieved organization names from portable objects: " + names); - } -} diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java deleted file mode 100644 index 3170864..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/CacheClientPortableQueryExample.java +++ /dev/null @@ -1,325 +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.datagrid; - -import java.sql.Timestamp; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -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.CacheTypeMetadata; -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.portable.Address; -import org.apache.ignite.examples.portable.Employee; -import org.apache.ignite.examples.portable.EmployeeKey; -import org.apache.ignite.examples.portable.ExamplePortableNodeStartup; -import org.apache.ignite.examples.portable.Organization; -import org.apache.ignite.examples.portable.OrganizationType; -import org.apache.ignite.portable.PortableObject; - -/** - * This example demonstrates use of portable objects with cache queries. - * The example populates cache with sample data and runs several SQL and full text queries over this data. - *

- * Remote nodes should always be started with {@link ExamplePortableNodeStartup} which starts a node with - * {@code examples/config/portable/example-ignite-portable.xml} configuration. - */ -public class CacheClientPortableQueryExample { - /** Organization cache name. */ - private static final String ORGANIZATION_CACHE_NAME = CacheClientPortableQueryExample.class.getSimpleName() - + "Organizations"; - - /** Employee cache name. */ - private static final String EMPLOYEE_CACHE_NAME = CacheClientPortableQueryExample.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/portable/example-ignite-portable.xml")) { - System.out.println(); - System.out.println(">>> Portable objects cache query example started."); - - CacheConfiguration orgCacheCfg = new CacheConfiguration<>(); - - orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); - orgCacheCfg.setName(ORGANIZATION_CACHE_NAME); - - orgCacheCfg.setTypeMetadata(Arrays.asList(createOrganizationTypeMetadata())); - - CacheConfiguration employeeCacheCfg = new CacheConfiguration<>(); - - employeeCacheCfg.setCacheMode(CacheMode.PARTITIONED); - employeeCacheCfg.setName(EMPLOYEE_CACHE_NAME); - - employeeCacheCfg.setTypeMetadata(Arrays.asList(createEmployeeTypeMetadata())); - - try (IgniteCache orgCache = ignite.createCache(orgCacheCfg); - IgniteCache 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 portable objects. - IgniteCache portableCache = employeeCache.withKeepPortable(); - - // Run SQL query example. - sqlQuery(portableCache); - - // Run SQL query with join example. - sqlJoinQuery(portableCache); - - // Run SQL fields query example. - sqlFieldsQuery(portableCache); - - // Run full text query example. - textQuery(portableCache); - - 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 CacheTypeMetadata createEmployeeTypeMetadata() { - CacheTypeMetadata employeeTypeMeta = new CacheTypeMetadata(); - - employeeTypeMeta.setValueType(Employee.class); - - employeeTypeMeta.setKeyType(EmployeeKey.class); - - Map> ascFields = new HashMap<>(); - - ascFields.put("name", String.class); - ascFields.put("salary", Long.class); - ascFields.put("address.zip", Integer.class); - ascFields.put("organizationId", Integer.class); - - employeeTypeMeta.setAscendingFields(ascFields); - - employeeTypeMeta.setTextFields(Arrays.asList("address.street")); - - return employeeTypeMeta; - } - - /** - * Create cache type metadata for {@link Organization}. - * - * @return Cache type metadata. - */ - private static CacheTypeMetadata createOrganizationTypeMetadata() { - CacheTypeMetadata organizationTypeMeta = new CacheTypeMetadata(); - - organizationTypeMeta.setValueType(Organization.class); - - organizationTypeMeta.setKeyType(Integer.class); - - Map> ascFields = new HashMap<>(); - - ascFields.put("name", String.class); - - Map> queryFields = new HashMap<>(); - - queryFields.put("address.street", String.class); - - organizationTypeMeta.setAscendingFields(ascFields); - - organizationTypeMeta.setQueryFields(queryFields); - - return organizationTypeMeta; - } - - /** - * Queries employees that have provided ZIP code in address. - * - * @param cache Ignite cache. - */ - private static void sqlQuery(IgniteCache cache) { - SqlQuery query = new SqlQuery<>(Employee.class, "zip = ?"); - - int zip = 94109; - - QueryCursor> employees = cache.query(query.setArgs(zip)); - - System.out.println(); - System.out.println(">>> Employees with zip " + zip + ':'); - - for (Cache.Entry 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 cache) { - SqlQuery 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> employees = - cache.query(query.setArgs(organizationName)); - - System.out.println(); - System.out.println(">>> Employees working for " + organizationName + ':'); - - for (Cache.Entry e : employees.getAll()) - System.out.println(">>> " + e.getValue()); - } - - /** - * Queries names and salaries for all employees. - * - * @param cache Ignite cache. - */ - private static void sqlFieldsQuery(IgniteCache cache) { - SqlFieldsQuery query = new SqlFieldsQuery("select name, salary from Employee"); - - QueryCursor> 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 cache) { - TextQuery query = new TextQuery<>(Employee.class, "TX"); - - QueryCursor> employees = cache.query(query); - - System.out.println(); - System.out.println(">>> Employees living in Texas:"); - - for (Cache.Entry e : employees.getAll()) - System.out.println(">>> " + e.getValue().deserialize()); - } - - /** - * Populates cache with data. - * - * @param orgCache Organization cache. - * @param employeeCache Employee cache. - */ - private static void populateCache(IgniteCache orgCache, - IgniteCache 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") - )); - } -} - diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java deleted file mode 100644 index b24f233..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/portable/datagrid/package-info.java +++ /dev/null @@ -1,21 +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. - */ - -/** - * Demonstrates the usage of portable objects with cache. - */ -package org.apache.ignite.examples.portable.datagrid; \ No newline at end of file diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java b/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java deleted file mode 100644 index 4301027..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/portable/package-info.java +++ /dev/null @@ -1,21 +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. - */ - -/** - * Contains portable classes and examples. - */ -package org.apache.ignite.examples.portable; \ No newline at end of file diff --git a/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java b/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java deleted file mode 100644 index 6ea1484..0000000 --- a/examples/src/test/java/org/apache/ignite/examples/CacheClientPortableExampleTest.java +++ /dev/null @@ -1,46 +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; - -import org.apache.ignite.examples.portable.datagrid.CacheClientPortablePutGetExample; -import org.apache.ignite.examples.portable.datagrid.CacheClientPortableQueryExample; -import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; - -/** - * - */ -public class CacheClientPortableExampleTest extends GridAbstractExamplesTest { - /** {@inheritDoc} */ - @Override protected String defaultConfig() { - return "examples/config/portable/example-ignite-portable.xml"; - } - - /** - * @throws Exception If failed. - */ - public void testPortablePutGetExample() throws Exception { - CacheClientPortablePutGetExample.main(new String[] {}); - } - - /** - * @throws Exception If failed. - */ - public void testPortableQueryExample() throws Exception { - CacheClientPortableQueryExample.main(new String[] {}); - } -} \ No newline at end of file diff --git a/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.java b/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.java deleted file mode 100644 index 2223aec..0000000 --- a/examples/src/test/java/org/apache/ignite/examples/ComputeClientPortableExampleTest.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.examples; - -import org.apache.ignite.examples.portable.computegrid.ComputeClientPortableTaskExecutionExample; -import org.apache.ignite.testframework.junits.common.GridAbstractExamplesTest; - -/** - * - */ -public class ComputeClientPortableExampleTest extends GridAbstractExamplesTest { - /** {@inheritDoc} */ - @Override protected String defaultConfig() { - return "examples/config/portable/example-ignite-portable.xml"; - } - - /** - * @throws Exception If failed. - */ - public void testPortableTaskExecutionExample() throws Exception { - ComputeClientPortableTaskExecutionExample.main(new String[] {}); - } -} \ No newline at end of file diff --git a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java index baa23fc..4669ae4 100644 --- a/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java +++ b/examples/src/test/java/org/apache/ignite/testsuites/IgniteExamplesSelfTestSuite.java @@ -20,12 +20,10 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.examples.BasicExamplesMultiNodeSelfTest; import org.apache.ignite.examples.BasicExamplesSelfTest; -import org.apache.ignite.examples.CacheClientPortableExampleTest; import org.apache.ignite.examples.CacheExamplesMultiNodeSelfTest; import org.apache.ignite.examples.CacheExamplesSelfTest; import org.apache.ignite.examples.CheckpointExamplesSelfTest; import org.apache.ignite.examples.ClusterGroupExampleSelfTest; -import org.apache.ignite.examples.ComputeClientPortableExampleTest; import org.apache.ignite.examples.ContinuationExamplesMultiNodeSelfTest; import org.apache.ignite.examples.ContinuationExamplesSelfTest; import org.apache.ignite.examples.ContinuousMapperExamplesMultiNodeSelfTest; @@ -95,10 +93,6 @@ public class IgniteExamplesSelfTestSuite extends TestSuite { suite.addTest(new TestSuite(MonteCarloExamplesMultiNodeSelfTest.class)); suite.addTest(new TestSuite(HibernateL2CacheExampleMultiNodeSelfTest.class)); - // Portable. - suite.addTest(new TestSuite(CacheClientPortableExampleTest.class)); - suite.addTest(new TestSuite(ComputeClientPortableExampleTest.class)); - return suite; } } \ No newline at end of file diff --git a/modules/core/pom.xml b/modules/core/pom.xml index 2f0dde7..9162afe 100644 --- a/modules/core/pom.xml +++ b/modules/core/pom.xml @@ -34,13 +34,6 @@ 1.4.0-SNAPSHOT http://ignite.apache.org - - - ignite-portables-test-repo - file://${basedir}/src/test/portables/repo - - - apache-ignite @@ -176,20 +169,6 @@ 2.4 test - - - org.apache.ignite.portable - test1 - 1.1 - test - - - - org.apache.ignite.portable - test2 - 1.1 - test - diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java index 62fd020..0afccd0 100644 --- a/modules/core/src/main/java/org/apache/ignite/Ignite.java +++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java @@ -459,13 +459,6 @@ public interface Ignite extends AutoCloseable { public T plugin(String name) throws PluginNotFoundException; /** - * Gets an instance of {@link IgnitePortables} interface. - * - * @return Instance of {@link IgnitePortables} interface. - */ - public IgnitePortables portables(); - - /** * Closes {@code this} instance of grid. This method is identical to calling * {@link G#stop(String, boolean) G.stop(gridName, true)}. *

diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index e0f9f55..e5abbb4 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -55,7 +55,7 @@ import org.apache.ignite.lang.IgniteAsyncSupported; import org.apache.ignite.lang.IgniteBiInClosure; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.lang.IgniteFuture; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; import org.apache.ignite.mxbean.CacheMetricsMXBean; import org.jetbrains.annotations.Nullable; @@ -132,44 +132,6 @@ public interface IgniteCache extends javax.cache.Cache, IgniteAsyncS public IgniteCache withNoRetries(); /** - * Returns cache that will operate with portable objects. - *

- * Cache returned by this method will not be forced to deserialize portable objects, - * so keys and values will be returned from cache API methods without changes. Therefore, - * signature of the cache can contain only following types: - *

- *

- * For example, if you use {@link Integer} as a key and {@code Value} class as a value - * (which will be stored in portable format), you should acquire following projection - * to avoid deserialization: - *

-     * IgniteCache prj = cache.withKeepPortable();
-     *
-     * // Value is not deserialized and returned in portable format.
-     * PortableObject po = prj.get(1);
-     * 
- *

- * Note that this method makes sense only if cache is working in portable mode ({@link PortableMarshaller} is used). - * If not, this method is no-op and will return current cache. - * - * @return New cache instance for portable objects. - */ - public IgniteCache withKeepPortable(); - - /** * Executes {@link #localLoadCache(IgniteBiPredicate, Object...)} on all cache nodes. * * @param p Optional predicate (may be {@code null}). If provided, will be used to diff --git a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java deleted file mode 100644 index ee0a4ec..0000000 --- a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java +++ /dev/null @@ -1,370 +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; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.TreeMap; -import java.util.UUID; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableSerializer; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.jetbrains.annotations.Nullable; - -/** - * Defines portable objects functionality. With portable objects you are able to: - *

- *

Working With Portables Directly

- * Once an object is defined as portable, - * Ignite will always store it in memory in the portable (i.e. binary) format. - * User can choose to work either with the portable format or with the deserialized form - * (assuming that class definitions are present in the classpath). - *

- * To work with the portable format directly, user should create a special cache projection - * using {@link IgniteCache#withKeepPortable()} method and then retrieve individual fields as needed: - *

- * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepPortable();
- *
- * // Convert instance of MyKey to portable format.
- * // We could also use PortableBuilder to create the key in portable format directly.
- * PortableObject key = grid.portables().toPortable(new MyKey());
- *
- * PortableObject val = prj.get(key);
- *
- * String field = val.field("myFieldName");
- * 
- * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized - * typed objects at all times. In this case we do incur the deserialization cost. However, if - * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access - * and will cache the deserialized object, so it does not have to be deserialized again: - *
- * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
- *
- * MyValue val = cache.get(new MyKey());
- *
- * // Normal java getter.
- * String fieldVal = val.getMyFieldName();
- * 
- * If we used, for example, one of the automatically handled portable types for a key, like integer, - * and still wanted to work with binary portable format for values, then we would declare cache projection - * as follows: - *
- * IgniteCache<Integer.class, PortableObject> prj = cache.withKeepPortable();
- * 
- *

Automatic Portable Types

- * Note that only portable classes are converted to {@link PortableObject} format. Following - * classes are never converted (e.g., {@link #toPortable(Object)} method will return original - * object, and instances of these classes will be stored in cache without changes): - * - *

Working With Maps and Collections

- * All maps and collections in the portable objects are serialized automatically. When working - * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most - * adequate collection or map in either language. For example, {@link ArrayList} in Java will become - * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} - * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} - * in C#, etc. - *

Building Portable Objects

- * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: - *
- * PortableBuilder builder = Ignition.ignite().portables().builder();
- *
- * builder.typeId("MyObject");
- *
- * builder.stringField("fieldA", "A");
- * build.intField("fieldB", "B");
- *
- * PortableObject portableObj = builder.build();
- * 
- * For the cases when class definition is present - * in the class path, it is also possible to populate a standard POJO and then - * convert it to portable format, like so: - *
- * MyObject obj = new MyObject();
- *
- * obj.setFieldA("A");
- * obj.setFieldB(123);
- *
- * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
- * 
- * NOTE: you don't need to convert typed objects to portable format before storing - * them in cache, Ignite will do that automatically. - *

Portable Metadata

- * Even though Ignite portable protocol only works with hash codes for type and field names - * to achieve better performance, Ignite provides metadata for all portable types which - * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class)} - * methods. Having metadata also allows for proper formatting of {@code PortableObject#toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - *

Dynamic Structure Changes

- * Since objects are always cached in the portable binary format, server does not need to - * be aware of the class definitions. Moreover, if class definitions are not present or not - * used on the server, then clients can continuously change the structure of the portable - * objects without having to restart the cluster. For example, if one client stores a - * certain class with fields A and B, and another client stores the same class with - * fields B and C, then the server-side portable object will have the fields A, B, and C. - * As the structure of a portable object changes, the new fields become available for SQL queries - * automatically. - *

Configuration

- * By default all your objects are considered as portables and no specific configuration is needed. - * However, in some cases, like when an object is used by both Java and .Net, you may need to specify portable objects - * explicitly by calling {@link PortableMarshaller#setClassNames(Collection)}. - * The only requirement Ignite imposes is that your object has an empty - * constructor. Note, that since server side does not have to know the class definition, - * you only need to list portable objects in configuration on the client side. However, if you - * list them on the server side as well, then you get the ability to deserialize portable objects - * into concrete types on the server as well as on the client. - *

- * Here is an example of portable configuration (note that star (*) notation is supported): - *

- * ...
- * <!-- Explicit portable objects configuration. -->
- * <property name="marshaller">
- *     <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
- *         <property name="classNames">
- *             <list>
- *                 <value>my.package.for.portable.objects.*</value>
- *                 <value>org.apache.ignite.examples.client.portable.Employee</value>
- *             </list>
- *         </property>
- *     </bean>
- * </property>
- * ...
- * 
- * or from code: - *
- * IgniteConfiguration cfg = new IgniteConfiguration();
- *
- * PortableMarshaller marsh = new PortableMarshaller();
- *
- * marsh.setClassNames(Arrays.asList(
- *     Employee.class.getName(),
- *     Address.class.getName())
- * );
- *
- * cfg.setMarshaller(marsh);
- * 
- * You can also specify class name for a portable object via {@link PortableTypeConfiguration}. - * Do it in case if you need to override other configuration properties on per-type level, like - * ID-mapper, or serializer. - *

Custom Affinity Keys

- * Often you need to specify an alternate key (not the cache key) for affinity routing whenever - * storing objects in cache. For example, if you are caching {@code Employee} object with - * {@code Organization}, and want to colocate employees with organization they work for, - * so you can process them together, you need to specify an alternate affinity key. - * With portable objects you would have to do it as following: - *
- * <property name="marshaller">
- *     <bean class="org.gridgain.grid.marshaller.portable.PortableMarshaller">
- *         ...
- *         <property name="typeConfigurations">
- *             <list>
- *                 <bean class="org.apache.ignite.portable.PortableTypeConfiguration">
- *                     <property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/>
- *                     <property name="affinityKeyFieldName" value="organizationId"/>
- *                 </bean>
- *             </list>
- *         </property>
- *         ...
- *     </bean>
- * </property>
- * 
- *

Serialization

- * Serialization and deserialization works out-of-the-box in Ignite. However, you can provide your own custom - * serialization logic by optionally implementing {@link PortableMarshalAware} interface, like so: - *
- * public class Address implements PortableMarshalAware {
- *     private String street;
- *     private int zip;
- *
- *     // Empty constructor required for portable deserialization.
- *     public Address() {}
- *
- *     @Override public void writePortable(PortableWriter writer) throws PortableException {
- *         writer.writeString("street", street);
- *         writer.writeInt("zip", zip);
- *     }
- *
- *     @Override public void readPortable(PortableReader reader) throws PortableException {
- *         street = reader.readString("street");
- *         zip = reader.readInt("zip");
- *     }
- * }
- * 
- * Alternatively, if you cannot change class definitions, you can provide custom serialization - * logic in {@link PortableSerializer} either globally in {@link PortableMarshaller} or - * for a specific type via {@link PortableTypeConfiguration} instance. - *

- * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. - *

- * - *

Custom ID Mappers

- * Ignite implementation uses name hash codes to generate IDs for class names or field names - * internally. However, in cases when you want to provide your own ID mapping schema, - * you can provide your own {@link PortableIdMapper} implementation. - *

- * ID-mapper may be provided either globally in {@link PortableMarshaller}, - * or for a specific type via {@link PortableTypeConfiguration} instance. - *

Query Indexing

- * Portable objects can be indexed for querying by specifying index fields in - * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific - * {@link org.apache.ignite.configuration.CacheConfiguration} instance, - * like so: - *
- * ...
- * <bean class="org.apache.ignite.cache.CacheConfiguration">
- *     ...
- *     <property name="typeMetadata">
- *         <list>
- *             <bean class="CacheTypeMetadata">
- *                 <property name="type" value="Employee"/>
- *
- *                 <!-- Fields to index in ascending order. -->
- *                 <property name="ascendingFields">
- *                     <map>
- *                     <entry key="name" value="java.lang.String"/>
- *
- *                         <!-- Nested portable objects can also be indexed. -->
- *                         <entry key="address.zip" value="java.lang.Integer"/>
- *                     </map>
- *                 </property>
- *             </bean>
- *         </list>
- *     </property>
- * </bean>
- * 
- */ -public interface IgnitePortables { - /** - * Gets type ID for given type name. - * - * @param typeName Type name. - * @return Type ID. - */ - public int typeId(String typeName); - - /** - * Converts provided object to instance of {@link PortableObject}. - * - * @param obj Object to convert. - * @return Converted object. - * @throws PortableException In case of error. - */ - public T toPortable(@Nullable Object obj) throws PortableException; - - /** - * Creates new portable builder. - * - * @param typeId ID of the type. - * @return Newly portable builder. - */ - public PortableBuilder builder(int typeId); - - /** - * Creates new portable builder. - * - * @param typeName Type name. - * @return Newly portable builder. - */ - public PortableBuilder builder(String typeName); - - /** - * Creates portable builder initialized by existing portable object. - * - * @param portableObj Portable object to initialize builder. - * @return Portable builder. - */ - public PortableBuilder builder(PortableObject portableObj); - - /** - * Gets metadata for provided class. - * - * @param cls Class. - * @return Metadata. - * @throws PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(Class cls) throws PortableException; - - /** - * Gets metadata for provided class name. - * - * @param typeName Type name. - * @return Metadata. - * @throws PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(String typeName) throws PortableException; - - /** - * Gets metadata for provided type ID. - * - * @param typeId Type ID. - * @return Metadata. - * @throws PortableException In case of error. - */ - @Nullable public PortableMetadata metadata(int typeId) throws PortableException; - - /** - * Gets metadata for all known types. - * - * @return Metadata. - * @throws PortableException In case of error. - */ - public Collection metadata() throws PortableException; -} diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java index 9fb56bc..59058f8 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java @@ -163,10 +163,6 @@ public class CacheConfiguration extends MutableConfiguration { /** Default size for onheap SQL row cache size. */ public static final int DFLT_SQL_ONHEAP_ROW_CACHE_SIZE = 10 * 1024; - /** Default value for keep portable in store behavior .*/ - @SuppressWarnings({"UnnecessaryBoxing", "BooleanConstructorCall"}) - public static final Boolean DFLT_KEEP_PORTABLE_IN_STORE = new Boolean(true); - /** Cache name. */ private String name; @@ -219,9 +215,6 @@ public class CacheConfiguration extends MutableConfiguration { private Factory storeFactory; /** */ - private Boolean keepPortableInStore = DFLT_KEEP_PORTABLE_IN_STORE; - - /** */ private boolean loadPrevVal = DFLT_LOAD_PREV_VAL; /** Node group resolver. */ @@ -383,8 +376,6 @@ public class CacheConfiguration extends MutableConfiguration { invalidate = cc.isInvalidate(); isReadThrough = cc.isReadThrough(); isWriteThrough = cc.isWriteThrough(); - keepPortableInStore = cc.isKeepPortableInStore() != null ? cc.isKeepPortableInStore() : - DFLT_KEEP_PORTABLE_IN_STORE; listenerConfigurations = cc.listenerConfigurations; loadPrevVal = cc.isLoadPreviousValue(); longQryWarnTimeout = cc.getLongQueryWarningTimeout(); @@ -825,38 +816,6 @@ public class CacheConfiguration extends MutableConfiguration { } /** - * Flag indicating that {@link CacheStore} implementation - * is working with portable objects instead of Java objects. - * Default value of this flag is {@link #DFLT_KEEP_PORTABLE_IN_STORE}, - * because this is recommended behavior from performance standpoint. - *

- * If set to {@code false}, Ignite will deserialize keys and - * values stored in portable format before they are passed - * to cache store. - *

- * Note that setting this flag to {@code false} can simplify - * store implementation in some cases, but it can cause performance - * degradation due to additional serializations and deserializations - * of portable objects. You will also need to have key and value - * classes on all nodes since portables will be deserialized when - * store is called. - * - * @return Keep portables in store flag. - */ - public Boolean isKeepPortableInStore() { - return keepPortableInStore; - } - - /** - * Sets keep portables in store flag. - * - * @param keepPortableInStore Keep portables in store flag. - */ - public void setKeepPortableInStore(boolean keepPortableInStore) { - this.keepPortableInStore = keepPortableInStore; - } - - /** * Gets key topology resolver to provide mapping from keys to nodes. * * @return Key topology resolver to provide mapping from keys to nodes. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java index e3859c5..9443f21 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteEx.java @@ -20,6 +20,7 @@ package org.apache.ignite.internal; import java.util.Collection; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteFileSystem; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.cluster.IgniteClusterEx; import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey; @@ -140,4 +141,12 @@ public interface IgniteEx extends Ignite { * @return Kernal context. */ public GridKernalContext context(); + + + /** + * Gets an instance of {@link IgnitePortables} interface. + * + * @return Instance of {@link IgnitePortables} interface. + */ + public IgnitePortables portables(); } \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 9b615b1..abab1f3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -64,7 +64,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteFileSystem; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteMessaging; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.IgniteQueue; import org.apache.ignite.IgniteScheduler; import org.apache.ignite.IgniteServices; @@ -157,7 +157,7 @@ import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.lifecycle.LifecycleEventType; import org.apache.ignite.marshaller.MarshallerExclusions; import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; import org.apache.ignite.mxbean.ClusterLocalNodeMetricsMXBean; import org.apache.ignite.mxbean.IgniteMXBean; import org.apache.ignite.mxbean.ThreadPoolMXBean; @@ -203,7 +203,6 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM; -import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_RESTART_ENABLED; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE; @@ -1270,9 +1269,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName()); add(ATTR_USER_NAME, System.getProperty("user.name")); add(ATTR_GRID_NAME, gridName); - add(ATTR_PORTABLE_PROTO_VER, cfg.getMarshaller() instanceof PortableMarshaller ? - ((PortableMarshaller)cfg.getMarshaller()).getProtocolVersion().toString() : - PortableMarshaller.DFLT_PORTABLE_PROTO_VER.toString()); add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled()); add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java index 7be2af3..10b8df0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java @@ -135,13 +135,10 @@ public final class IgniteNodeAttributes { /** Node consistent id. */ public static final String ATTR_NODE_CONSISTENT_ID = ATTR_PREFIX + ".consistent.id"; - /** Portable protocol version. */ - public static final String ATTR_PORTABLE_PROTO_VER = ATTR_PREFIX + ".portable.proto.ver"; - /** * Enforces singleton. */ private IgniteNodeAttributes() { /* No-op. */ } -} \ No newline at end of file +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index bc4f756..3a09b2c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -125,7 +125,6 @@ import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DEPLOYMENT_MODE; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING; -import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME; import static org.apache.ignite.internal.IgniteVersionUtils.VER; import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.NOOP; @@ -982,8 +981,6 @@ public class GridDiscoveryManager extends GridManagerAdapter { // Fetch local node attributes once. String locPreferIpV4 = locNode.attribute("java.net.preferIPv4Stack"); - String locPortableProtoVer = locNode.attribute(ATTR_PORTABLE_PROTO_VER); - Object locMode = locNode.attribute(ATTR_DEPLOYMENT_MODE); int locJvmMajVer = nodeJavaMajorVersion(locNode); @@ -1033,13 +1030,6 @@ public class GridDiscoveryManager extends GridManagerAdapter { ", rmtId8=" + U.id8(n.id()) + ", rmtPeerClassLoading=" + rmtP2pEnabled + ", rmtAddrs=" + U.addressesAsString(n) + ']'); } - - String rmtPortableProtoVer = n.attribute(ATTR_PORTABLE_PROTO_VER); - - // In order to support backward compatibility skip the check for nodes that don't have this attribute. - if (rmtPortableProtoVer != null && !F.eq(locPortableProtoVer, rmtPortableProtoVer)) - throw new IgniteCheckedException("Remote node has portable protocol version different from local " + - "[locVersion=" + locPortableProtoVer + ", rmtVersion=" + rmtPortableProtoVer + ']'); } if (log.isDebugEnabled()) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java index c7a9e6f..4bc8545 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java @@ -19,7 +19,7 @@ package org.apache.ignite.internal.portable; import org.apache.ignite.internal.portable.streams.PortableInputStream; import org.apache.ignite.internal.portable.streams.PortableOutputStream; -import org.apache.ignite.portable.PortableException; +import org.apache.ignite.internal.portable.api.PortableException; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java index a2b4b74..e1b7324 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java @@ -40,11 +40,11 @@ import org.apache.ignite.internal.processors.cache.CacheObjectImpl; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.MarshallerExclusions; import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableSerializer; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableIdMapper; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableSerializer; import org.jetbrains.annotations.Nullable; import static java.lang.reflect.Modifier.isStatic; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java index 165ad9a..2ee96b7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java @@ -60,16 +60,16 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; import org.apache.ignite.marshaller.MarshallerContext; import org.apache.ignite.marshaller.optimized.OptimizedMarshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration; import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration; import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableInvalidClassException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableSerializer; -import org.apache.ignite.portable.PortableTypeConfiguration; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableIdMapper; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableSerializer; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentHashMap8; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java index ae5fbf0..05e7f20 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java @@ -27,9 +27,9 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java index e03d67f..fafafad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.portable; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; /** * Portable meta data handler. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java index 1d26007..c0423eb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataImpl.java @@ -27,13 +27,13 @@ import java.util.Map; import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java index fe4b628..229c90f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectEx.java @@ -23,9 +23,9 @@ import java.util.IdentityHashMap; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory; import org.apache.ignite.internal.util.typedef.internal.SB; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java index 47ff1ab..cb81efe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java @@ -34,9 +34,9 @@ import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java index ba8ee83..e788422 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java @@ -30,9 +30,9 @@ import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.plugin.extensions.communication.MessageReader; import org.apache.ignite.plugin.extensions.communication.MessageWriter; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; import sun.misc.Unsafe; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java index e703f2f..e401142 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawReaderEx.java @@ -17,8 +17,8 @@ package org.apache.ignite.internal.portable; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableRawReader; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java index a59f157..43b7650 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableRawWriterEx.java @@ -18,8 +18,8 @@ package org.apache.ignite.internal.portable; import org.apache.ignite.internal.portable.streams.PortableOutputStream; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableRawWriter; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java index 2d4a1c3..2537926 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java @@ -20,7 +20,7 @@ package org.apache.ignite.internal.portable; import java.util.HashMap; import java.util.Map; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java index 4ad125a..a101db5 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java @@ -45,11 +45,11 @@ import org.apache.ignite.internal.util.GridEnumCache; import org.apache.ignite.internal.util.lang.GridMapEntry; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableInvalidClassException; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableReader; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableReader; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java index 7259cc9..ccc1a5b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java @@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListSet; import org.apache.ignite.internal.portable.builder.PortableLazyValue; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentHashMap8; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java index 3152c4b..1d5ca60 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java @@ -18,12 +18,8 @@ package org.apache.ignite.internal.portable; import java.io.IOException; -import java.io.ObjectInputStream; import java.io.ObjectOutput; -import java.io.ObjectOutputStream; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Timestamp; @@ -32,14 +28,13 @@ import java.util.Date; import java.util.IdentityHashMap; import java.util.Map; import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream; import org.apache.ignite.internal.portable.streams.PortableOutputStream; import org.apache.ignite.internal.util.typedef.internal.A; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.jetbrains.annotations.Nullable; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java new file mode 100644 index 0000000..56f3768 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/IgnitePortables.java @@ -0,0 +1,362 @@ +/* + * 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.portable.api; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.TreeMap; +import java.util.UUID; +import org.apache.ignite.IgniteCache; +import org.jetbrains.annotations.Nullable; + +/** + * Defines portable objects functionality. With portable objects you are able to: + *

    + *
  • Seamlessly interoperate between Java, .NET, and C++.
  • + *
  • Make any object portable with zero code change to your existing code.
  • + *
  • Nest portable objects within each other.
  • + *
  • Automatically handle {@code circular} or {@code null} references.
  • + *
  • Automatically convert collections and maps between Java, .NET, and C++.
  • + *
  • + * Optionally avoid deserialization of objects on the server side + * (objects are stored in {@link PortableObject} format). + *
  • + *
  • Avoid need to have concrete class definitions on the server side.
  • + *
  • Dynamically change structure of the classes without having to restart the cluster.
  • + *
  • Index into portable objects for querying purposes.
  • + *
+ *

Working With Portables Directly

+ * Once an object is defined as portable, + * Ignite will always store it in memory in the portable (i.e. binary) format. + * User can choose to work either with the portable format or with the deserialized form + * (assuming that class definitions are present in the classpath). + *

+ * To work with the portable format directly, user should create a special cache projection + * using {@link IgniteCache#withKeepPortable()} method and then retrieve individual fields as needed: + *

+ * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepPortable();
+ *
+ * // Convert instance of MyKey to portable format.
+ * // We could also use PortableBuilder to create the key in portable format directly.
+ * PortableObject key = grid.portables().toPortable(new MyKey());
+ *
+ * PortableObject val = prj.get(key);
+ *
+ * String field = val.field("myFieldName");
+ * 
+ * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized + * typed objects at all times. In this case we do incur the deserialization cost. However, if + * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access + * and will cache the deserialized object, so it does not have to be deserialized again: + *
+ * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
+ *
+ * MyValue val = cache.get(new MyKey());
+ *
+ * // Normal java getter.
+ * String fieldVal = val.getMyFieldName();
+ * 
+ * If we used, for example, one of the automatically handled portable types for a key, like integer, + * and still wanted to work with binary portable format for values, then we would declare cache projection + * as follows: + *
+ * IgniteCache<Integer.class, PortableObject> prj = cache.withKeepPortable();
+ * 
+ *

Automatic Portable Types

+ * Note that only portable classes are converted to {@link PortableObject} format. Following + * classes are never converted (e.g., {@link #toPortable(Object)} method will return original + * object, and instances of these classes will be stored in cache without changes): + *
    + *
  • All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
  • + *
  • Arrays of primitives (byte[], int[], ...)
  • + *
  • {@link String} and array of {@link String}s
  • + *
  • {@link UUID} and array of {@link UUID}s
  • + *
  • {@link Date} and array of {@link Date}s
  • + *
  • {@link Timestamp} and array of {@link Timestamp}s
  • + *
  • Enums and array of enums
  • + *
  • + * Maps, collections and array of objects (but objects inside + * them will still be converted if they are portable) + *
  • + *
+ *

Working With Maps and Collections

+ * All maps and collections in the portable objects are serialized automatically. When working + * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most + * adequate collection or map in either language. For example, {@link ArrayList} in Java will become + * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} + * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} + * in C#, etc. + *

Building Portable Objects

+ * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: + *
+ * PortableBuilder builder = Ignition.ignite().portables().builder();
+ *
+ * builder.typeId("MyObject");
+ *
+ * builder.stringField("fieldA", "A");
+ * build.intField("fieldB", "B");
+ *
+ * PortableObject portableObj = builder.build();
+ * 
+ * For the cases when class definition is present + * in the class path, it is also possible to populate a standard POJO and then + * convert it to portable format, like so: + *
+ * MyObject obj = new MyObject();
+ *
+ * obj.setFieldA("A");
+ * obj.setFieldB(123);
+ *
+ * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
+ * 
+ * NOTE: you don't need to convert typed objects to portable format before storing + * them in cache, Ignite will do that automatically. + *

Portable Metadata

+ * Even though Ignite portable protocol only works with hash codes for type and field names + * to achieve better performance, Ignite provides metadata for all portable types which + * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class)} + * methods. Having metadata also allows for proper formatting of {@code PortableObject#toString()} method, + * even when portable objects are kept in binary format only, which may be necessary for audit reasons. + *

Dynamic Structure Changes

+ * Since objects are always cached in the portable binary format, server does not need to + * be aware of the class definitions. Moreover, if class definitions are not present or not + * used on the server, then clients can continuously change the structure of the portable + * objects without having to restart the cluster. For example, if one client stores a + * certain class with fields A and B, and another client stores the same class with + * fields B and C, then the server-side portable object will have the fields A, B, and C. + * As the structure of a portable object changes, the new fields become available for SQL queries + * automatically. + *

Configuration

+ * By default all your objects are considered as portables and no specific configuration is needed. + * However, in some cases, like when an object is used by both Java and .Net, you may need to specify portable objects + * explicitly by calling {@link PortableMarshaller#setClassNames(Collection)}. + * The only requirement Ignite imposes is that your object has an empty + * constructor. Note, that since server side does not have to know the class definition, + * you only need to list portable objects in configuration on the client side. However, if you + * list them on the server side as well, then you get the ability to deserialize portable objects + * into concrete types on the server as well as on the client. + *

+ * Here is an example of portable configuration (note that star (*) notation is supported): + *

+ * ...
+ * <!-- Explicit portable objects configuration. -->
+ * <property name="marshaller">
+ *     <bean class="org.apache.ignite.internal.portable.api.PortableMarshaller">
+ *         <property name="classNames">
+ *             <list>
+ *                 <value>my.package.for.portable.objects.*</value>
+ *                 <value>org.apache.ignite.examples.client.portable.Employee</value>
+ *             </list>
+ *         </property>
+ *     </bean>
+ * </property>
+ * ...
+ * 
+ * or from code: + *
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * PortableMarshaller marsh = new PortableMarshaller();
+ *
+ * marsh.setClassNames(Arrays.asList(
+ *     Employee.class.getName(),
+ *     Address.class.getName())
+ * );
+ *
+ * cfg.setMarshaller(marsh);
+ * 
+ * You can also specify class name for a portable object via {@link PortableTypeConfiguration}. + * Do it in case if you need to override other configuration properties on per-type level, like + * ID-mapper, or serializer. + *

Custom Affinity Keys

+ * Often you need to specify an alternate key (not the cache key) for affinity routing whenever + * storing objects in cache. For example, if you are caching {@code Employee} object with + * {@code Organization}, and want to colocate employees with organization they work for, + * so you can process them together, you need to specify an alternate affinity key. + * With portable objects you would have to do it as following: + *
+ * <property name="marshaller">
+ *     <bean class="org.gridgain.grid.marshaller.portable.PortableMarshaller">
+ *         ...
+ *         <property name="typeConfigurations">
+ *             <list>
+ *                 <bean class="org.apache.ignite.internal.portable.api.PortableTypeConfiguration">
+ *                     <property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/>
+ *                     <property name="affinityKeyFieldName" value="organizationId"/>
+ *                 </bean>
+ *             </list>
+ *         </property>
+ *         ...
+ *     </bean>
+ * </property>
+ * 
+ *

Serialization

+ * Serialization and deserialization works out-of-the-box in Ignite. However, you can provide your own custom + * serialization logic by optionally implementing {@link PortableMarshalAware} interface, like so: + *
+ * public class Address implements PortableMarshalAware {
+ *     private String street;
+ *     private int zip;
+ *
+ *     // Empty constructor required for portable deserialization.
+ *     public Address() {}
+ *
+ *     @Override public void writePortable(PortableWriter writer) throws PortableException {
+ *         writer.writeString("street", street);
+ *         writer.writeInt("zip", zip);
+ *     }
+ *
+ *     @Override public void readPortable(PortableReader reader) throws PortableException {
+ *         street = reader.readString("street");
+ *         zip = reader.readInt("zip");
+ *     }
+ * }
+ * 
+ * Alternatively, if you cannot change class definitions, you can provide custom serialization + * logic in {@link PortableSerializer} either globally in {@link PortableMarshaller} or + * for a specific type via {@link PortableTypeConfiguration} instance. + *

+ * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods. + *

    + *
  • + * {@code readResolve} is defined as follows: {@code ANY-ACCESS-MODIFIER Object readResolve()}. + * It may be used to replace the de-serialized object by another one of your choice. + *
  • + *
  • + * {@code writeReplace} is defined as follows: {@code ANY-ACCESS-MODIFIER Object writeReplace()}. This method + * allows the developer to provide a replacement object that will be serialized instead of the original one. + *
  • + *
+ * + *

Custom ID Mappers

+ * Ignite implementation uses name hash codes to generate IDs for class names or field names + * internally. However, in cases when you want to provide your own ID mapping schema, + * you can provide your own {@link PortableIdMapper} implementation. + *

+ * ID-mapper may be provided either globally in {@link PortableMarshaller}, + * or for a specific type via {@link PortableTypeConfiguration} instance. + *

Query Indexing

+ * Portable objects can be indexed for querying by specifying index fields in + * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific + * {@link org.apache.ignite.configuration.CacheConfiguration} instance, + * like so: + *
+ * ...
+ * <bean class="org.apache.ignite.cache.CacheConfiguration">
+ *     ...
+ *     <property name="typeMetadata">
+ *         <list>
+ *             <bean class="CacheTypeMetadata">
+ *                 <property name="type" value="Employee"/>
+ *
+ *                 <!-- Fields to index in ascending order. -->
+ *                 <property name="ascendingFields">
+ *                     <map>
+ *                     <entry key="name" value="java.lang.String"/>
+ *
+ *                         <!-- Nested portable objects can also be indexed. -->
+ *                         <entry key="address.zip" value="java.lang.Integer"/>
+ *                     </map>
+ *                 </property>
+ *             </bean>
+ *         </list>
+ *     </property>
+ * </bean>
+ * 
+ */ +public interface IgnitePortables { + /** + * Gets type ID for given type name. + * + * @param typeName Type name. + * @return Type ID. + */ + public int typeId(String typeName); + + /** + * Converts provided object to instance of {@link PortableObject}. + * + * @param obj Object to convert. + * @return Converted object. + * @throws PortableException In case of error. + */ + public T toPortable(@Nullable Object obj) throws PortableException; + + /** + * Creates new portable builder. + * + * @param typeId ID of the type. + * @return Newly portable builder. + */ + public PortableBuilder builder(int typeId); + + /** + * Creates new portable builder. + * + * @param typeName Type name. + * @return Newly portable builder. + */ + public PortableBuilder builder(String typeName); + + /** + * Creates portable builder initialized by existing portable object. + * + * @param portableObj Portable object to initialize builder. + * @return Portable builder. + */ + public PortableBuilder builder(PortableObject portableObj); + + /** + * Gets metadata for provided class. + * + * @param cls Class. + * @return Metadata. + * @throws PortableException In case of error. + */ + @Nullable public PortableMetadata metadata(Class cls) throws PortableException; + + /** + * Gets metadata for provided class name. + * + * @param typeName Type name. + * @return Metadata. + * @throws PortableException In case of error. + */ + @Nullable public PortableMetadata metadata(String typeName) throws PortableException; + + /** + * Gets metadata for provided type ID. + * + * @param typeId Type ID. + * @return Metadata. + * @throws PortableException In case of error. + */ + @Nullable public PortableMetadata metadata(int typeId) throws PortableException; + + /** + * Gets metadata for all known types. + * + * @return Metadata. + * @throws PortableException In case of error. + */ + public Collection metadata() throws PortableException; +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java new file mode 100644 index 0000000..c819f46 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableBuilder.java @@ -0,0 +1,136 @@ +/* + * 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.portable.api; + +import org.jetbrains.annotations.Nullable; + +/** + * Portable object builder. Provides ability to build portable objects dynamically without having class definitions. + *

+ * Here is an example of how a portable object can be built dynamically: + *

+ * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
+ *
+ * builder.setField("fieldA", "A");
+ * builder.setField("fieldB", "B");
+ *
+ * PortableObject portableObj = builder.build();
+ * 
+ * + *

+ * Also builder can be initialized by existing portable object. This allows changing some fields without affecting + * other fields. + *

+ * PortableBuilder builder = Ignition.ignite().portables().builder(person);
+ *
+ * builder.setField("name", "John");
+ *
+ * person = builder.build();
+ * 
+ *

+ * + * If you need to modify nested portable object you can get builder for nested object using + * {@link #getField(String)}, changes made on nested builder will affect parent object, + * for example: + * + *
+ * PortableBuilder personBuilder = grid.portables().createBuilder(personPortableObj);
+ * PortableBuilder addressBuilder = personBuilder.setField("address");
+ *
+ * addressBuilder.setField("city", "New York");
+ *
+ * personPortableObj = personBuilder.build();
+ *
+ * // Should be "New York".
+ * String city = personPortableObj.getField("address").getField("city");
+ * 
+ * + * @see IgnitePortables#builder(int) + * @see IgnitePortables#builder(String) + * @see IgnitePortables#builder(PortableObject) + */ +public interface PortableBuilder { + /** + * Returns value assigned to the specified field. + * If the value is a portable object instance of {@code GridPortableBuilder} will be returned, + * which can be modified. + *

+ * Collections and maps returned from this method are modifiable. + * + * @param name Field name. + * @return Filed value. + */ + public T getField(String name); + + /** + * Sets field value. + * + * @param name Field name. + * @param val Field value (cannot be {@code null}). + * @see PortableObject#metaData() + */ + public PortableBuilder setField(String name, Object val); + + /** + * Sets field value with value type specification. + *

+ * Field type is needed for proper metadata update. + * + * @param name Field name. + * @param val Field value. + * @param type Field type. + * @see PortableObject#metaData() + */ + public PortableBuilder setField(String name, @Nullable T val, Class type); + + /** + * Sets field value. + *

+ * This method should be used if field is portable object. + * + * @param name Field name. + * @param builder Builder for object field. + */ + public PortableBuilder setField(String name, @Nullable PortableBuilder builder); + + /** + * Removes field from this builder. + * + * @param fieldName Field name. + * @return {@code this} instance for chaining. + */ + public PortableBuilder removeField(String fieldName); + + /** + * Sets hash code for resulting portable object returned by {@link #build()} method. + *

+ * If not set {@code 0} is used. + * + * @param hashCode Hash code. + * @return {@code this} instance for chaining. + */ + public PortableBuilder hashCode(int hashCode); + + /** + * Builds portable object. + * + * @return Portable object. + * @throws PortableException In case of error. + */ + public PortableObject build() throws PortableException; +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.java new file mode 100644 index 0000000..f230182 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableException.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.internal.portable.api; + +import org.apache.ignite.IgniteException; +import org.jetbrains.annotations.Nullable; + +/** + * Exception indicating portable object serialization error. + */ +public class PortableException extends IgniteException { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Creates portable exception with error message. + * + * @param msg Error message. + */ + public PortableException(String msg) { + super(msg); + } + + /** + * Creates portable exception with {@link Throwable} as a cause. + * + * @param cause Cause. + */ + public PortableException(Throwable cause) { + super(cause); + } + + /** + * Creates portable exception with error message and {@link Throwable} as a cause. + * + * @param msg Error message. + * @param cause Cause. + */ + public PortableException(String msg, @Nullable Throwable cause) { + super(msg, cause); + } +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java new file mode 100644 index 0000000..1e20f8e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableIdMapper.java @@ -0,0 +1,54 @@ +/* + * 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.portable.api; + +/** + * Type and field ID mapper for portable objects. Ignite never writes full + * strings for field or type names. Instead, for performance reasons, Ignite + * writes integer hash codes for type and field names. It has been tested that + * hash code conflicts for the type names or the field names + * within the same type are virtually non-existent and, to gain performance, it is safe + * to work with hash codes. For the cases when hash codes for different types or fields + * actually do collide {@code PortableIdMapper} allows to override the automatically + * generated hash code IDs for the type and field names. + *

+ * Portable ID mapper can be configured for all portable objects via {@link PortableMarshaller#getIdMapper()} method, + * or for a specific portable type via {@link PortableTypeConfiguration#getIdMapper()} method. + */ +public interface PortableIdMapper { + /** + * Gets type ID for provided class name. + *

+ * If {@code 0} is returned, hash code of class simple name will be used. + * + * @param clsName Class name. + * @return Type ID. + */ + public int typeId(String clsName); + + /** + * Gets ID for provided field. + *

+ * If {@code 0} is returned, hash code of field name will be used. + * + * @param typeId Type ID. + * @param fieldName Field name. + * @return Field ID. + */ + public int fieldId(int typeId, String fieldName); +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java new file mode 100644 index 0000000..82e6697 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableInvalidClassException.java @@ -0,0 +1,58 @@ +/* + * 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.portable.api; + +import org.jetbrains.annotations.Nullable; + +/** + * Exception indicating that class needed for deserialization of portable object does not exist. + *

+ * Thrown from {@link PortableObject#deserialize()} method. + */ +public class PortableInvalidClassException extends PortableException { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Creates invalid class exception with error message. + * + * @param msg Error message. + */ + public PortableInvalidClassException(String msg) { + super(msg); + } + + /** + * Creates invalid class exception with {@link Throwable} as a cause. + * + * @param cause Cause. + */ + public PortableInvalidClassException(Throwable cause) { + super(cause); + } + + /** + * Creates invalid class exception with error message and {@link Throwable} as a cause. + * + * @param msg Error message. + * @param cause Cause. + */ + public PortableInvalidClassException(String msg, @Nullable Throwable cause) { + super(msg, cause); + } +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java new file mode 100644 index 0000000..f304afb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshalAware.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.portable.api; + +/** + * Interface that allows to implement custom serialization + * logic for portable objects. Portable objects are not required + * to implement this interface, in which case Ignite will automatically + * serialize portable objects using reflection. + *

+ * This interface, in a way, is analogous to {@link java.io.Externalizable} + * interface, which allows users to override default serialization logic, + * usually for performance reasons. The only difference here is that portable + * serialization is already very fast and implementing custom serialization + * logic for portables does not provide significant performance gains. + */ +public interface PortableMarshalAware { + /** + * Writes fields to provided writer. + * + * @param writer Portable object writer. + * @throws PortableException In case of error. + */ + public void writePortable(PortableWriter writer) throws PortableException; + + /** + * Reads fields from provided reader. + * + * @param reader Portable object reader. + * @throws PortableException In case of error. + */ + public void readPortable(PortableReader reader) throws PortableException; +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java new file mode 100644 index 0000000..de0df8d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMarshaller.java @@ -0,0 +1,358 @@ +/* + * 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.portable.api; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.portable.GridPortableMarshaller; +import org.apache.ignite.internal.portable.PortableContext; +import org.apache.ignite.marshaller.AbstractMarshaller; +import org.apache.ignite.marshaller.MarshallerContext; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableIdMapper; +import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.internal.portable.api.PortableProtocolVersion; +import org.apache.ignite.internal.portable.api.PortableSerializer; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; +import org.jetbrains.annotations.Nullable; + +/** + * Implementation of {@link org.apache.ignite.marshaller.Marshaller} that lets to serialize and deserialize all objects + * in the portable format. + *

+ * {@code PortableMarshaller} is tested only on Java HotSpot VM on other VMs it could yield unexpected results. + *

+ *

Configuration

+ *

Mandatory

+ * This marshaller has no mandatory configuration parameters. + *

Java Example

+ *
+ * PortableMarshaller marshaller = new PortableMarshaller();
+ *
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * // Override marshaller.
+ * cfg.setMarshaller(marshaller);
+ *
+ * // Starts grid.
+ * G.start(cfg);
+ * 
+ *

Spring Example

+ * PortableMarshaller can be configured from Spring XML configuration file: + *
+ * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
+ *     ...
+ *     <property name="marshaller">
+ *         <bean class="org.apache.ignite.internal.portable.api.PortableMarshaller">
+ *            ...
+ *         </bean>
+ *     </property>
+ *     ...
+ * </bean>
+ * 
+ *

+ * + *
+ * For information about Spring framework visit www.springframework.org + */ +public class PortableMarshaller extends AbstractMarshaller { + /** Default portable protocol version. */ + public static final PortableProtocolVersion DFLT_PORTABLE_PROTO_VER = PortableProtocolVersion.VER_1_4_0; + + /** Class names. */ + private Collection clsNames; + + /** ID mapper. */ + private PortableIdMapper idMapper; + + /** Serializer. */ + private PortableSerializer serializer; + + /** Types. */ + private Collection typeCfgs; + + /** Use timestamp flag. */ + private boolean useTs = true; + + /** Whether to convert string to bytes using UTF-8 encoding. */ + private boolean convertString = true; + + /** Meta data enabled flag. */ + private boolean metaDataEnabled = true; + + /** Keep deserialized flag. */ + private boolean keepDeserialized = true; + + /** Protocol version. */ + private PortableProtocolVersion protoVer = DFLT_PORTABLE_PROTO_VER; + + /** */ + private GridPortableMarshaller impl; + + /** + * Gets class names. + * + * @return Class names. + */ + public Collection getClassNames() { + return clsNames; + } + + /** + * Sets class names of portable objects explicitly. + * + * @param clsNames Class names. + */ + public void setClassNames(Collection clsNames) { + this.clsNames = new ArrayList<>(clsNames.size()); + + for (String clsName : clsNames) + this.clsNames.add(clsName.trim()); + } + + /** + * Gets ID mapper. + * + * @return ID mapper. + */ + public PortableIdMapper getIdMapper() { + return idMapper; + } + + /** + * Sets ID mapper. + * + * @param idMapper ID mapper. + */ + public void setIdMapper(PortableIdMapper idMapper) { + this.idMapper = idMapper; + } + + /** + * Gets serializer. + * + * @return Serializer. + */ + public PortableSerializer getSerializer() { + return serializer; + } + + /** + * Sets serializer. + * + * @param serializer Serializer. + */ + public void setSerializer(PortableSerializer serializer) { + this.serializer = serializer; + } + + /** + * Gets types configuration. + * + * @return Types configuration. + */ + public Collection getTypeConfigurations() { + return typeCfgs; + } + + /** + * Sets type configurations. + * + * @param typeCfgs Type configurations. + */ + public void setTypeConfigurations(Collection typeCfgs) { + this.typeCfgs = typeCfgs; + } + + /** + * If {@code true} then date values converted to {@link Timestamp} on deserialization. + *

+ * Default value is {@code true}. + * + * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. + */ + public boolean isUseTimestamp() { + return useTs; + } + + /** + * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. + */ + public void setUseTimestamp(boolean useTs) { + this.useTs = useTs; + } + + /** + * Gets strings must be converted to or from bytes using UTF-8 encoding. + *

+ * Default value is {@code true}. + * + * @return Flag indicating whether string must be converted to byte array using UTF-8 encoding. + */ + public boolean isConvertStringToBytes() { + return convertString; + } + + /** + * Sets strings must be converted to or from bytes using UTF-8 encoding. + *

+ * Default value is {@code true}. + * + * @param convertString Flag indicating whether string must be converted to byte array using UTF-8 encoding. + */ + public void setConvertStringToBytes(boolean convertString) { + this.convertString = convertString; + } + + /** + * If {@code true}, meta data will be collected or all types. If you need to override this behaviour for + * some specific type, use {@link PortableTypeConfiguration#setMetaDataEnabled(Boolean)} method. + *

+ * Default value if {@code true}. + * + * @return Whether meta data is collected. + */ + public boolean isMetaDataEnabled() { + return metaDataEnabled; + } + + /** + * @param metaDataEnabled Whether meta data is collected. + */ + public void setMetaDataEnabled(boolean metaDataEnabled) { + this.metaDataEnabled = metaDataEnabled; + } + + /** + * If {@code true}, {@link PortableObject} will cache deserialized instance after + * {@link PortableObject#deserialize()} is called. All consequent calls of this + * method on the same instance of {@link PortableObject} will return that cached + * value without actually deserializing portable object. If you need to override this + * behaviour for some specific type, use {@link PortableTypeConfiguration#setKeepDeserialized(Boolean)} + * method. + *

+ * Default value if {@code true}. + * + * @return Whether deserialized value is kept. + */ + public boolean isKeepDeserialized() { + return keepDeserialized; + } + + /** + * @param keepDeserialized Whether deserialized value is kept. + */ + public void setKeepDeserialized(boolean keepDeserialized) { + this.keepDeserialized = keepDeserialized; + } + + /** + * Gets portable protocol version. + *

+ * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}. + * + * @return Portable protocol version. + */ + public PortableProtocolVersion getProtocolVersion() { + return protoVer; + } + + /** + * Sets portable protocol version. + *

+ * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}. + * + * @param protoVer Portable protocol version. + */ + public void setProtocolVersion(PortableProtocolVersion protoVer) { + if (protoVer == null) + throw new IllegalArgumentException("Wrong portable protocol version: " + protoVer); + + this.protoVer = protoVer; + } + + /** + * Returns currently set {@link MarshallerContext}. + * + * @return Marshaller context. + */ + public MarshallerContext getContext() { + return ctx; + } + + /** + * Sets {@link PortableContext}. + *

+ * @param ctx Portable context. + */ + private void setPortableContext(PortableContext ctx) { + ctx.configure(this); + + impl = new GridPortableMarshaller(ctx); + } + + /** {@inheritDoc} */ + @Override public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException { + return impl.marshal(obj, 0); + } + + /** {@inheritDoc} */ + @Override public void marshal(@Nullable Object obj, OutputStream out) throws IgniteCheckedException { + byte[] arr = marshal(obj); + + try { + out.write(arr); + } + catch (IOException e) { + throw new PortableException("Failed to marshal the object: " + obj, e); + } + } + + /** {@inheritDoc} */ + @Override public T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws IgniteCheckedException { + return impl.deserialize(bytes, clsLdr); + } + + /** {@inheritDoc} */ + @Override public T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + + byte[] arr = new byte[4096]; + int cnt; + + // we have to fully read the InputStream because GridPortableMarshaller requires support of a method that + // returns number of bytes remaining. + try { + while ((cnt = in.read(arr)) != -1) + buffer.write(arr, 0, cnt); + + buffer.flush(); + + return impl.deserialize(buffer.toByteArray(), clsLdr); + } + catch (IOException e) { + throw new PortableException("Failed to unmarshal the object from InputStream", e); + } + } +} diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMetadata.java new file mode 100644 index 0000000..a90bdca --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableMetadata.java @@ -0,0 +1,60 @@ +/* + * 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.portable.api; + +import java.util.Collection; +import org.jetbrains.annotations.Nullable; + +/** + * Portable type meta data. Metadata for portable types can be accessed from any of the + * {@link IgnitePortables#metadata(String)} methods. + * Having metadata also allows for proper formatting of {@code PortableObject#toString()} method, + * even when portable objects are kept in binary format only, which may be necessary for audit reasons. + */ +public interface PortableMetadata { + /** + * Gets portable type name. + * + * @return Portable type name. + */ + public String typeName(); + + /** + * Gets collection of all field names for this portable type. + * + * @return Collection of all field names for this portable type. + */ + public Collection fields(); + + /** + * Gets name of the field type for a given field. + * + * @param fieldName Field name. + * @return Field type name. + */ + @Nullable public String fieldTypeName(String fieldName); + + /** + * Portable objects can optionally specify custom key-affinity mapping in the + * configuration. This method returns the name of the field which should be + * used for the key-affinity mapping. + * + * @return Affinity key field name. + */ + @Nullable public String affinityKeyFieldName(); +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableObject.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableObject.java new file mode 100644 index 0000000..ec965c6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableObject.java @@ -0,0 +1,152 @@ +/* + * 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.portable.api; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.TreeMap; +import org.jetbrains.annotations.Nullable; + +/** + * Wrapper for portable object in portable binary format. Once an object is defined as portable, + * Ignite will always store it in memory in the portable (i.e. binary) format. + * User can choose to work either with the portable format or with the deserialized form + * (assuming that class definitions are present in the classpath). + *

+ * NOTE: user does not need to (and should not) implement this interface directly. + *

+ * To work with the portable format directly, user should create a cache projection + * over {@code PortableObject} class and then retrieve individual fields as needed: + *

+ * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepPortable();
+ *
+ * // Convert instance of MyKey to portable format.
+ * // We could also use GridPortableBuilder to create the key in portable format directly.
+ * PortableObject key = grid.portables().toPortable(new MyKey());
+ *
+ * PortableObject val = prj.get(key);
+ *
+ * String field = val.field("myFieldName");
+ * 
+ * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized + * typed objects at all times. In this case we do incur the deserialization cost. However, if + * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access + * and will cache the deserialized object, so it does not have to be deserialized again: + *
+ * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
+ *
+ * MyValue val = cache.get(new MyKey());
+ *
+ * // Normal java getter.
+ * String fieldVal = val.getMyFieldName();
+ * 
+ *

Working With Maps and Collections

+ * All maps and collections in the portable objects are serialized automatically. When working + * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most + * adequate collection or map in either language. For example, {@link ArrayList} in Java will become + * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} + * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} + * in C#, etc. + *

Dynamic Structure Changes

+ * Since objects are always cached in the portable binary format, server does not need to + * be aware of the class definitions. Moreover, if class definitions are not present or not + * used on the server, then clients can continuously change the structure of the portable + * objects without having to restart the cluster. For example, if one client stores a + * certain class with fields A and B, and another client stores the same class with + * fields B and C, then the server-side portable object will have the fields A, B, and C. + * As the structure of a portable object changes, the new fields become available for SQL queries + * automatically. + *

Building Portable Objects

+ * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: + *
+ * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
+ *
+ * builder.setField("fieldA", "A");
+ * builder.setField("fieldB", "B");
+ *
+ * PortableObject portableObj = builder.build();
+ * 
+ * For the cases when class definition is present + * in the class path, it is also possible to populate a standard POJO and then + * convert it to portable format, like so: + *
+ * MyObject obj = new MyObject();
+ *
+ * obj.setFieldA("A");
+ * obj.setFieldB(123);
+ *
+ * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
+ * 
+ *

Portable Metadata

+ * Even though Ignite portable protocol only works with hash codes for type and field names + * to achieve better performance, Ignite provides metadata for all portable types which + * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class)} + * methods. Having metadata also allows for proper formatting of {@code PortableObject.toString()} method, + * even when portable objects are kept in binary format only, which may be necessary for audit reasons. + */ +public interface PortableObject extends Serializable, Cloneable { + /** + * Gets portable object type ID. + * + * @return Type ID. + */ + public int typeId(); + + /** + * Gets meta data for this portable object. + * + * @return Meta data. + * @throws PortableException In case of error. + */ + @Nullable public PortableMetadata metaData() throws PortableException; + + /** + * Gets field value. + * + * @param fieldName Field name. + * @return Field value. + * @throws PortableException In case of any other error. + */ + @Nullable public F field(String fieldName) throws PortableException; + + /** + * Checks whether field is set. + * + * @param fieldName Field name. + * @return {@code true} if field is set. + */ + public boolean hasField(String fieldName); + + /** + * Gets fully deserialized instance of portable object. + * + * @return Fully deserialized instance of portable object. + * @throws PortableInvalidClassException If class doesn't exist. + * @throws PortableException In case of any other error. + */ + @Nullable public T deserialize() throws PortableException; + + /** + * Copies this portable object. + * + * @return Copy of this portable object. + */ + public PortableObject clone() throws CloneNotSupportedException; +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableProtocolVersion.java new file mode 100644 index 0000000..741c2a5 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableProtocolVersion.java @@ -0,0 +1,41 @@ +/* + * 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.portable.api; + +import org.jetbrains.annotations.Nullable; + +/** + * Portable protocol version. + */ +public enum PortableProtocolVersion { + /** Ignite 1.4.0 release. */ + VER_1_4_0; + + /** Enumerated values. */ + private static final PortableProtocolVersion[] VALS = values(); + + /** + * Efficiently gets enumerated value from its ordinal. + * + * @param ord Ordinal value. + * @return Enumerated value or {@code null} if ordinal out of range. + */ + @Nullable public static PortableProtocolVersion fromOrdinal(int ord) { + return ord >= 0 && ord < VALS.length ? VALS[ord] : null; + } +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableRawReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableRawReader.java new file mode 100644 index 0000000..c12aa1a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableRawReader.java @@ -0,0 +1,234 @@ +/* + * 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.portable.api; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Raw reader for portable objects. Raw reader does not use field name hash codes, therefore, + * making the format even more compact. However, if the raw reader is used, + * dynamic structure changes to the portable objects are not supported. + */ +public interface PortableRawReader { + /** + * @return Byte value. + * @throws PortableException In case of error. + */ + public byte readByte() throws PortableException; + + /** + * @return Short value. + * @throws PortableException In case of error. + */ + public short readShort() throws PortableException; + + /** + * @return Integer value. + * @throws PortableException In case of error. + */ + public int readInt() throws PortableException; + + /** + * @return Long value. + * @throws PortableException In case of error. + */ + public long readLong() throws PortableException; + + /** + * @return Float value. + * @throws PortableException In case of error. + */ + public float readFloat() throws PortableException; + + /** + * @return Double value. + * @throws PortableException In case of error. + */ + public double readDouble() throws PortableException; + + /** + * @return Char value. + * @throws PortableException In case of error. + */ + public char readChar() throws PortableException; + + /** + * @return Boolean value. + * @throws PortableException In case of error. + */ + public boolean readBoolean() throws PortableException; + + /** + * @return Decimal value. + * @throws PortableException In case of error. + */ + @Nullable public BigDecimal readDecimal() throws PortableException; + + /** + * @return String value. + * @throws PortableException In case of error. + */ + @Nullable public String readString() throws PortableException; + + /** + * @return UUID. + * @throws PortableException In case of error. + */ + @Nullable public UUID readUuid() throws PortableException; + + /** + * @return Date. + * @throws PortableException In case of error. + */ + @Nullable public Date readDate() throws PortableException; + + /** + * @return Timestamp. + * @throws PortableException In case of error. + */ + @Nullable public Timestamp readTimestamp() throws PortableException; + + /** + * @return Object. + * @throws PortableException In case of error. + */ + @Nullable public T readObject() throws PortableException; + + /** + * @return Byte array. + * @throws PortableException In case of error. + */ + @Nullable public byte[] readByteArray() throws PortableException; + + /** + * @return Short array. + * @throws PortableException In case of error. + */ + @Nullable public short[] readShortArray() throws PortableException; + + /** + * @return Integer array. + * @throws PortableException In case of error. + */ + @Nullable public int[] readIntArray() throws PortableException; + + /** + * @return Long array. + * @throws PortableException In case of error. + */ + @Nullable public long[] readLongArray() throws PortableException; + + /** + * @return Float array. + * @throws PortableException In case of error. + */ + @Nullable public float[] readFloatArray() throws PortableException; + + /** + * @return Byte array. + * @throws PortableException In case of error. + */ + @Nullable public double[] readDoubleArray() throws PortableException; + + /** + * @return Char array. + * @throws PortableException In case of error. + */ + @Nullable public char[] readCharArray() throws PortableException; + + /** + * @return Boolean array. + * @throws PortableException In case of error. + */ + @Nullable public boolean[] readBooleanArray() throws PortableException; + + /** + * @return Decimal array. + * @throws PortableException In case of error. + */ + @Nullable public BigDecimal[] readDecimalArray() throws PortableException; + + /** + * @return String array. + * @throws PortableException In case of error. + */ + @Nullable public String[] readStringArray() throws PortableException; + + /** + * @return UUID array. + * @throws PortableException In case of error. + */ + @Nullable public UUID[] readUuidArray() throws PortableException; + + /** + * @return Date array. + * @throws PortableException In case of error. + */ + @Nullable public Date[] readDateArray() throws PortableException; + + /** + * @return Object array. + * @throws PortableException In case of error. + */ + @Nullable public Object[] readObjectArray() throws PortableException; + + /** + * @return Collection. + * @throws PortableException In case of error. + */ + @Nullable public Collection readCollection() throws PortableException; + + /** + * @param colCls Collection class. + * @return Collection. + * @throws PortableException In case of error. + */ + @Nullable public Collection readCollection(Class> colCls) + throws PortableException; + + /** + * @return Map. + * @throws PortableException In case of error. + */ + @Nullable public Map readMap() throws PortableException; + + /** + * @param mapCls Map class. + * @return Map. + * @throws PortableException In case of error. + */ + @Nullable public Map readMap(Class> mapCls) throws PortableException; + + /** + * @return Value. + * @throws PortableException In case of error. + */ + @Nullable public > T readEnum() throws PortableException; + + /** + * @return Value. + * @throws PortableException In case of error. + */ + @Nullable public > T[] readEnumArray() throws PortableException; +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableRawWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableRawWriter.java new file mode 100644 index 0000000..91f0e3b --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableRawWriter.java @@ -0,0 +1,219 @@ +/* + * 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.portable.api; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Raw writer for portable object. Raw writer does not write field name hash codes, therefore, + * making the format even more compact. However, if the raw writer is used, + * dynamic structure changes to the portable objects are not supported. + */ +public interface PortableRawWriter { + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeByte(byte val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeShort(short val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeInt(int val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeLong(long val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeFloat(float val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDouble(double val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeChar(char val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeBoolean(boolean val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDecimal(@Nullable BigDecimal val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeString(@Nullable String val) throws PortableException; + + /** + * @param val UUID to write. + * @throws PortableException In case of error. + */ + public void writeUuid(@Nullable UUID val) throws PortableException; + + /** + * @param val Date to write. + * @throws PortableException In case of error. + */ + public void writeDate(@Nullable Date val) throws PortableException; + + /** + * @param val Timestamp to write. + * @throws PortableException In case of error. + */ + public void writeTimestamp(@Nullable Timestamp val) throws PortableException; + + /** + * @param obj Value to write. + * @throws PortableException In case of error. + */ + public void writeObject(@Nullable Object obj) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeByteArray(@Nullable byte[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeShortArray(@Nullable short[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeIntArray(@Nullable int[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeLongArray(@Nullable long[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeFloatArray(@Nullable float[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDoubleArray(@Nullable double[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeCharArray(@Nullable char[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeBooleanArray(@Nullable boolean[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDecimalArray(@Nullable BigDecimal[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeStringArray(@Nullable String[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeUuidArray(@Nullable UUID[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDateArray(@Nullable Date[] val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeObjectArray(@Nullable Object[] val) throws PortableException; + + /** + * @param col Collection to write. + * @throws PortableException In case of error. + */ + public void writeCollection(@Nullable Collection col) throws PortableException; + + /** + * @param map Map to write. + * @throws PortableException In case of error. + */ + public void writeMap(@Nullable Map map) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public > void writeEnum(T val) throws PortableException; + + /** + * @param val Value to write. + * @throws PortableException In case of error. + */ + public > void writeEnumArray(T[] val) throws PortableException; +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableReader.java new file mode 100644 index 0000000..ca322e7 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableReader.java @@ -0,0 +1,284 @@ +/* + * 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.portable.api; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Reader for portable objects used in {@link PortableMarshalAware} implementations. + * Useful for the cases when user wants a fine-grained control over serialization. + *

+ * Note that Ignite never writes full strings for field or type names. Instead, + * for performance reasons, Ignite writes integer hash codes for type and field names. + * It has been tested that hash code conflicts for the type names or the field names + * within the same type are virtually non-existent and, to gain performance, it is safe + * to work with hash codes. For the cases when hash codes for different types or fields + * actually do collide, Ignite provides {@link PortableIdMapper} which + * allows to override the automatically generated hash code IDs for the type and field names. + */ +public interface PortableReader { + /** + * @param fieldName Field name. + * @return Byte value. + * @throws PortableException In case of error. + */ + public byte readByte(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Short value. + * @throws PortableException In case of error. + */ + public short readShort(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Integer value. + * @throws PortableException In case of error. + */ + public int readInt(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Long value. + * @throws PortableException In case of error. + */ + public long readLong(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @throws PortableException In case of error. + * @return Float value. + */ + public float readFloat(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Double value. + * @throws PortableException In case of error. + */ + public double readDouble(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Char value. + * @throws PortableException In case of error. + */ + public char readChar(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Boolean value. + * @throws PortableException In case of error. + */ + public boolean readBoolean(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Decimal value. + * @throws PortableException In case of error. + */ + @Nullable public BigDecimal readDecimal(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return String value. + * @throws PortableException In case of error. + */ + @Nullable public String readString(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return UUID. + * @throws PortableException In case of error. + */ + @Nullable public UUID readUuid(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Date. + * @throws PortableException In case of error. + */ + @Nullable public Date readDate(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Timestamp. + * @throws PortableException In case of error. + */ + @Nullable public Timestamp readTimestamp(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Object. + * @throws PortableException In case of error. + */ + @Nullable public T readObject(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Byte array. + * @throws PortableException In case of error. + */ + @Nullable public byte[] readByteArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Short array. + * @throws PortableException In case of error. + */ + @Nullable public short[] readShortArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Integer array. + * @throws PortableException In case of error. + */ + @Nullable public int[] readIntArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Long array. + * @throws PortableException In case of error. + */ + @Nullable public long[] readLongArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Float array. + * @throws PortableException In case of error. + */ + @Nullable public float[] readFloatArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Byte array. + * @throws PortableException In case of error. + */ + @Nullable public double[] readDoubleArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Char array. + * @throws PortableException In case of error. + */ + @Nullable public char[] readCharArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Boolean array. + * @throws PortableException In case of error. + */ + @Nullable public boolean[] readBooleanArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Decimal array. + * @throws PortableException In case of error. + */ + @Nullable public BigDecimal[] readDecimalArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return String array. + * @throws PortableException In case of error. + */ + @Nullable public String[] readStringArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return UUID array. + * @throws PortableException In case of error. + */ + @Nullable public UUID[] readUuidArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Date array. + * @throws PortableException In case of error. + */ + @Nullable public Date[] readDateArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Object array. + * @throws PortableException In case of error. + */ + @Nullable public Object[] readObjectArray(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Collection. + * @throws PortableException In case of error. + */ + @Nullable public Collection readCollection(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @param colCls Collection class. + * @return Collection. + * @throws PortableException In case of error. + */ + @Nullable public Collection readCollection(String fieldName, Class> colCls) + throws PortableException; + + /** + * @param fieldName Field name. + * @return Map. + * @throws PortableException In case of error. + */ + @Nullable public Map readMap(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @param mapCls Map class. + * @return Map. + * @throws PortableException In case of error. + */ + @Nullable public Map readMap(String fieldName, Class> mapCls) + throws PortableException; + + /** + * @param fieldName Field name. + * @return Value. + * @throws PortableException In case of error. + */ + @Nullable public > T readEnum(String fieldName) throws PortableException; + + /** + * @param fieldName Field name. + * @return Value. + * @throws PortableException In case of error. + */ + @Nullable public > T[] readEnumArray(String fieldName) throws PortableException; + + /** + * Gets raw reader. Raw reader does not use field name hash codes, therefore, + * making the format even more compact. However, if the raw reader is used, + * dynamic structure changes to the portable objects are not supported. + * + * @return Raw reader. + */ + public PortableRawReader rawReader(); +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableSerializer.java new file mode 100644 index 0000000..b9e835f --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableSerializer.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.internal.portable.api; + +/** + * Interface that allows to implement custom serialization logic for portable objects. + * Can be used instead of {@link PortableMarshalAware} in case if the class + * cannot be changed directly. + *

+ * Portable serializer can be configured for all portable objects via + * {@link PortableMarshaller#getSerializer()} method, or for a specific + * portable type via {@link PortableTypeConfiguration#getSerializer()} method. + */ +public interface PortableSerializer { + /** + * Writes fields to provided writer. + * + * @param obj Empty object. + * @param writer Portable object writer. + * @throws PortableException In case of error. + */ + public void writePortable(Object obj, PortableWriter writer) throws PortableException; + + /** + * Reads fields from provided reader. + * + * @param obj Empty object + * @param reader Portable object reader. + * @throws PortableException In case of error. + */ + public void readPortable(Object obj, PortableReader reader) throws PortableException; +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableTypeConfiguration.java new file mode 100644 index 0000000..80a043e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableTypeConfiguration.java @@ -0,0 +1,195 @@ +/* + * 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.portable.api; + +import java.sql.Timestamp; +import java.util.Collection; +import org.apache.ignite.internal.util.typedef.internal.S; + +/** + * Defines configuration properties for a specific portable type. Providing per-type + * configuration is optional, as it is generally enough, and also optional, to provide global portable + * configuration using {@link PortableMarshaller#setClassNames(Collection)}. + * However, this class allows you to change configuration properties for a specific + * portable type without affecting configuration for other portable types. + *

+ * Per-type portable configuration can be specified in {@link PortableMarshaller#getTypeConfigurations()} method. + */ +public class PortableTypeConfiguration { + /** Class name. */ + private String clsName; + + /** ID mapper. */ + private PortableIdMapper idMapper; + + /** Serializer. */ + private PortableSerializer serializer; + + /** Use timestamp flag. */ + private Boolean useTs; + + /** Meta data enabled flag. */ + private Boolean metaDataEnabled; + + /** Keep deserialized flag. */ + private Boolean keepDeserialized; + + /** Affinity key field name. */ + private String affKeyFieldName; + + /** + */ + public PortableTypeConfiguration() { + // No-op. + } + + /** + * @param clsName Class name. + */ + public PortableTypeConfiguration(String clsName) { + this.clsName = clsName; + } + + /** + * Gets type name. + * + * @return Type name. + */ + public String getClassName() { + return clsName; + } + + /** + * Sets type name. + * + * @param clsName Type name. + */ + public void setClassName(String clsName) { + this.clsName = clsName; + } + + /** + * Gets ID mapper. + * + * @return ID mapper. + */ + public PortableIdMapper getIdMapper() { + return idMapper; + } + + /** + * Sets ID mapper. + * + * @param idMapper ID mapper. + */ + public void setIdMapper(PortableIdMapper idMapper) { + this.idMapper = idMapper; + } + + /** + * Gets serializer. + * + * @return Serializer. + */ + public PortableSerializer getSerializer() { + return serializer; + } + + /** + * Sets serializer. + * + * @param serializer Serializer. + */ + public void setSerializer(PortableSerializer serializer) { + this.serializer = serializer; + } + + /** + * If {@code true} then date values converted to {@link Timestamp} during unmarshalling. + * + * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. + */ + public Boolean isUseTimestamp() { + return useTs; + } + + /** + * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. + */ + public void setUseTimestamp(Boolean useTs) { + this.useTs = useTs; + } + + /** + * Defines whether meta data is collected for this type. If provided, this value will override + * {@link PortableMarshaller#isMetaDataEnabled()} property. + * + * @return Whether meta data is collected. + */ + public Boolean isMetaDataEnabled() { + return metaDataEnabled; + } + + /** + * @param metaDataEnabled Whether meta data is collected. + */ + public void setMetaDataEnabled(Boolean metaDataEnabled) { + this.metaDataEnabled = metaDataEnabled; + } + + /** + * Defines whether {@link PortableObject} should cache deserialized instance. If provided, + * this value will override {@link PortableMarshaller#isKeepDeserialized()} + * property. + * + * @return Whether deserialized value is kept. + */ + public Boolean isKeepDeserialized() { + return keepDeserialized; + } + + /** + * @param keepDeserialized Whether deserialized value is kept. + */ + public void setKeepDeserialized(Boolean keepDeserialized) { + this.keepDeserialized = keepDeserialized; + } + + /** + * Gets affinity key field name. + * + * @return Affinity key field name. + */ + public String getAffinityKeyFieldName() { + return affKeyFieldName; + } + + /** + * Sets affinity key field name. + * + * @param affKeyFieldName Affinity key field name. + */ + public void setAffinityKeyFieldName(String affKeyFieldName) { + this.affKeyFieldName = affKeyFieldName; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(PortableTypeConfiguration.class, this, super.toString()); + } +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableWriter.java new file mode 100644 index 0000000..8af04a3 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/api/PortableWriter.java @@ -0,0 +1,266 @@ +/* + * 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.portable.api; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Collection; +import java.util.Date; +import java.util.Map; +import java.util.UUID; +import org.jetbrains.annotations.Nullable; + +/** + * Writer for portable object used in {@link PortableMarshalAware} implementations. + * Useful for the cases when user wants a fine-grained control over serialization. + *

+ * Note that Ignite never writes full strings for field or type names. Instead, + * for performance reasons, Ignite writes integer hash codes for type and field names. + * It has been tested that hash code conflicts for the type names or the field names + * within the same type are virtually non-existent and, to gain performance, it is safe + * to work with hash codes. For the cases when hash codes for different types or fields + * actually do collide, Ignite provides {@link PortableIdMapper} which + * allows to override the automatically generated hash code IDs for the type and field names. + */ +public interface PortableWriter { + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeByte(String fieldName, byte val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeShort(String fieldName, short val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeInt(String fieldName, int val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeLong(String fieldName, long val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeFloat(String fieldName, float val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDouble(String fieldName, double val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeChar(String fieldName, char val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeBoolean(String fieldName, boolean val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeString(String fieldName, @Nullable String val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val UUID to write. + * @throws PortableException In case of error. + */ + public void writeUuid(String fieldName, @Nullable UUID val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Date to write. + * @throws PortableException In case of error. + */ + public void writeDate(String fieldName, @Nullable Date val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Timestamp to write. + * @throws PortableException In case of error. + */ + public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException; + + /** + * @param fieldName Field name. + * @param obj Value to write. + * @throws PortableException In case of error. + */ + public void writeObject(String fieldName, @Nullable Object obj) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeByteArray(String fieldName, @Nullable byte[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeShortArray(String fieldName, @Nullable short[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeIntArray(String fieldName, @Nullable int[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeLongArray(String fieldName, @Nullable long[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeFloatArray(String fieldName, @Nullable float[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDoubleArray(String fieldName, @Nullable double[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeCharArray(String fieldName, @Nullable char[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeStringArray(String fieldName, @Nullable String[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeDateArray(String fieldName, @Nullable Date[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException; + + /** + * @param fieldName Field name. + * @param col Collection to write. + * @throws PortableException In case of error. + */ + public void writeCollection(String fieldName, @Nullable Collection col) throws PortableException; + + /** + * @param fieldName Field name. + * @param map Map to write. + * @throws PortableException In case of error. + */ + public void writeMap(String fieldName, @Nullable Map map) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public > void writeEnum(String fieldName, T val) throws PortableException; + + /** + * @param fieldName Field name. + * @param val Value to write. + * @throws PortableException In case of error. + */ + public > void writeEnumArray(String fieldName, T[] val) throws PortableException; + + /** + * Gets raw writer. Raw writer does not write field name hash codes, therefore, + * making the format even more compact. However, if the raw writer is used, + * dynamic structure changes to the portable objects are not supported. + * + * @return Raw writer. + */ + public PortableRawWriter rawWriter(); +} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java index 1472d56..8673b70 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderEnum.java @@ -20,7 +20,7 @@ package org.apache.ignite.internal.portable.builder; import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.PortableWriterExImpl; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java index b2e4c0d..96d10a2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java @@ -25,17 +25,13 @@ import java.util.Set; import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl; import org.apache.ignite.internal.util.GridArgumentCheck; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableInvalidClassException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; import org.apache.ignite.internal.portable.*; -import org.apache.ignite.internal.processors.cache.portable.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.portable.*; import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS; import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java index 45355d7..e93f860 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java @@ -28,7 +28,7 @@ import org.apache.ignite.internal.portable.PortablePrimitives; import org.apache.ignite.internal.portable.PortableReaderExImpl; import org.apache.ignite.internal.portable.PortableUtils; import org.apache.ignite.internal.portable.PortableWriterExImpl; -import org.apache.ignite.portable.PortableException; +import org.apache.ignite.internal.portable.api.PortableException; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java index 2d9c961..6fe8875 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java @@ -21,8 +21,8 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.PortableObjectEx; import org.apache.ignite.internal.portable.PortableUtils; import org.apache.ignite.internal.portable.PortableWriterExImpl; +import org.apache.ignite.internal.portable.api.PortableObject; import org.apache.ignite.internal.util.*; -import org.apache.ignite.portable.*; import java.util.*; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java index d864a6e..15c52e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableEnumArrayLazyValue.java @@ -20,8 +20,8 @@ package org.apache.ignite.internal.portable.builder; import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.PortableWriterExImpl; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java index 1126a3c..96f4944 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableObjectArrayLazyValue.java @@ -20,7 +20,7 @@ package org.apache.ignite.internal.portable.builder; import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.PortableWriterExImpl; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java index 8743fbe..300c4ad 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortablePlainPortableObject.java @@ -20,7 +20,7 @@ package org.apache.ignite.internal.portable.builder; import org.apache.ignite.internal.portable.PortableObjectImpl; import org.apache.ignite.internal.portable.PortableObjectOffheapImpl; import org.apache.ignite.internal.portable.PortableWriterExImpl; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractInputStream.java index 107b02e..80f91be 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractInputStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractInputStream.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.portable.streams; -import org.apache.ignite.portable.PortableException; +import org.apache.ignite.internal.portable.api.PortableException; /** * Portable abstract input stream. diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 75d4c43..59bb5f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -115,7 +115,7 @@ import org.apache.ignite.lang.IgniteUuid; import org.apache.ignite.lifecycle.LifecycleAware; import org.apache.ignite.marshaller.Marshaller; import org.apache.ignite.marshaller.jdk.JdkMarshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; import org.apache.ignite.spi.IgniteNodeValidationResult; import org.jetbrains.annotations.Nullable; @@ -1063,12 +1063,6 @@ public class GridCacheProcessor extends GridProcessorAdapter { CacheConfiguration cfg = cacheCtx.config(); - // Intentionally compare Boolean references using '!=' below to check if the flag has been explicitly set. - if (cfg.isKeepPortableInStore() && cfg.isKeepPortableInStore() != CacheConfiguration.DFLT_KEEP_PORTABLE_IN_STORE - && !(ctx.config().getMarshaller() instanceof PortableMarshaller)) - U.warn(log, "CacheConfiguration.isKeepPortableInStore() configuration property will be ignored because " + - "PortableMarshaller is not used"); - // Start managers. for (GridCacheManager mgr : F.view(cacheCtx.managers(), F.notContains(dhtExcludes(cacheCtx)))) mgr.start(cacheCtx); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index ce0cdd7..cc6c19a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -311,11 +311,6 @@ public class IgniteCacheProxy extends AsyncSupportAdapter IgniteCache withKeepPortable() { - return keepPortable(); - } - - /** {@inheritDoc} */ @Override public IgniteCache withNoRetries() { GridCacheGateway gate = this.gate; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheDefaultPortableAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheDefaultPortableAffinityKeyMapper.java index 23edd9e..0dbf71d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheDefaultPortableAffinityKeyMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheDefaultPortableAffinityKeyMapper.java @@ -21,7 +21,7 @@ import org.apache.ignite.IgniteException; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java index 2e0d37d..d064601 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java @@ -27,7 +27,7 @@ import org.apache.ignite.internal.portable.PortableUtils; import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; /** * diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessor.java index fcd73d2..7f6512b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessor.java @@ -20,11 +20,11 @@ package org.apache.ignite.internal.processors.cache.portable; import java.util.Collection; import java.util.Map; import org.apache.ignite.IgniteException; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java index 1be5aea..4cab3db 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java @@ -39,7 +39,7 @@ import javax.cache.processor.EntryProcessor; import javax.cache.processor.MutableEntry; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.cache.CacheEntryEventSerializableFilter; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; @@ -80,11 +80,11 @@ import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiPredicate; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; import org.jsr166.ConcurrentHashMap8; import sun.misc.Unsafe; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgnitePortablesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgnitePortablesImpl.java index 5ed6505..40c3b70 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgnitePortablesImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/IgnitePortablesImpl.java @@ -18,13 +18,13 @@ package org.apache.ignite.internal.processors.cache.portable; import java.util.Collection; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java index f7f5f4e..ef7dc9a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java @@ -23,7 +23,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.processors.platform.PlatformProcessor; import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheStore; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; /** * Default store manager implementation. @@ -82,6 +82,6 @@ public class CacheOsStoreManager extends GridCacheStoreManagerAdapter { /** {@inheritDoc} */ @Override public boolean configuredConvertPortable() { - return !(ctx.config().getMarshaller() instanceof PortableMarshaller && cfg.isKeepPortableInStore()); + return true; } } \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java index fac69fb..423b5e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfiguration.java @@ -19,12 +19,12 @@ package org.apache.ignite.internal.processors.platform.dotnet; import org.apache.ignite.internal.processors.platform.PlatformConfiguration; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import java.util.ArrayList; import java.util.List; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java index a9b6022..92028b3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableConfiguration.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.processors.platform.dotnet; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import java.util.ArrayList; import java.util.Collection; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java index d7f1ab1..a307860 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetPortableTypeConfiguration.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.processors.platform.dotnet; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.jetbrains.annotations.Nullable; /** diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java deleted file mode 100644 index bfc34cd..0000000 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java +++ /dev/null @@ -1,358 +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.marshaller.portable; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Collection; -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.portable.GridPortableMarshaller; -import org.apache.ignite.internal.portable.PortableContext; -import org.apache.ignite.marshaller.AbstractMarshaller; -import org.apache.ignite.marshaller.MarshallerContext; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableProtocolVersion; -import org.apache.ignite.portable.PortableSerializer; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.jetbrains.annotations.Nullable; - -/** - * Implementation of {@link org.apache.ignite.marshaller.Marshaller} that lets to serialize and deserialize all objects - * in the portable format. - *

- * {@code PortableMarshaller} is tested only on Java HotSpot VM on other VMs it could yield unexpected results. - *

- *

Configuration

- *

Mandatory

- * This marshaller has no mandatory configuration parameters. - *

Java Example

- *
- * PortableMarshaller marshaller = new PortableMarshaller();
- *
- * IgniteConfiguration cfg = new IgniteConfiguration();
- *
- * // Override marshaller.
- * cfg.setMarshaller(marshaller);
- *
- * // Starts grid.
- * G.start(cfg);
- * 
- *

Spring Example

- * PortableMarshaller can be configured from Spring XML configuration file: - *
- * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
- *     ...
- *     <property name="marshaller">
- *         <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
- *            ...
- *         </bean>
- *     </property>
- *     ...
- * </bean>
- * 
- *

- * - *
- * For information about Spring framework visit www.springframework.org - */ -public class PortableMarshaller extends AbstractMarshaller { - /** Default portable protocol version. */ - public static final PortableProtocolVersion DFLT_PORTABLE_PROTO_VER = PortableProtocolVersion.VER_1_4_0; - - /** Class names. */ - private Collection clsNames; - - /** ID mapper. */ - private PortableIdMapper idMapper; - - /** Serializer. */ - private PortableSerializer serializer; - - /** Types. */ - private Collection typeCfgs; - - /** Use timestamp flag. */ - private boolean useTs = true; - - /** Whether to convert string to bytes using UTF-8 encoding. */ - private boolean convertString = true; - - /** Meta data enabled flag. */ - private boolean metaDataEnabled = true; - - /** Keep deserialized flag. */ - private boolean keepDeserialized = true; - - /** Protocol version. */ - private PortableProtocolVersion protoVer = DFLT_PORTABLE_PROTO_VER; - - /** */ - private GridPortableMarshaller impl; - - /** - * Gets class names. - * - * @return Class names. - */ - public Collection getClassNames() { - return clsNames; - } - - /** - * Sets class names of portable objects explicitly. - * - * @param clsNames Class names. - */ - public void setClassNames(Collection clsNames) { - this.clsNames = new ArrayList<>(clsNames.size()); - - for (String clsName : clsNames) - this.clsNames.add(clsName.trim()); - } - - /** - * Gets ID mapper. - * - * @return ID mapper. - */ - public PortableIdMapper getIdMapper() { - return idMapper; - } - - /** - * Sets ID mapper. - * - * @param idMapper ID mapper. - */ - public void setIdMapper(PortableIdMapper idMapper) { - this.idMapper = idMapper; - } - - /** - * Gets serializer. - * - * @return Serializer. - */ - public PortableSerializer getSerializer() { - return serializer; - } - - /** - * Sets serializer. - * - * @param serializer Serializer. - */ - public void setSerializer(PortableSerializer serializer) { - this.serializer = serializer; - } - - /** - * Gets types configuration. - * - * @return Types configuration. - */ - public Collection getTypeConfigurations() { - return typeCfgs; - } - - /** - * Sets type configurations. - * - * @param typeCfgs Type configurations. - */ - public void setTypeConfigurations(Collection typeCfgs) { - this.typeCfgs = typeCfgs; - } - - /** - * If {@code true} then date values converted to {@link Timestamp} on deserialization. - *

- * Default value is {@code true}. - * - * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public boolean isUseTimestamp() { - return useTs; - } - - /** - * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public void setUseTimestamp(boolean useTs) { - this.useTs = useTs; - } - - /** - * Gets strings must be converted to or from bytes using UTF-8 encoding. - *

- * Default value is {@code true}. - * - * @return Flag indicating whether string must be converted to byte array using UTF-8 encoding. - */ - public boolean isConvertStringToBytes() { - return convertString; - } - - /** - * Sets strings must be converted to or from bytes using UTF-8 encoding. - *

- * Default value is {@code true}. - * - * @param convertString Flag indicating whether string must be converted to byte array using UTF-8 encoding. - */ - public void setConvertStringToBytes(boolean convertString) { - this.convertString = convertString; - } - - /** - * If {@code true}, meta data will be collected or all types. If you need to override this behaviour for - * some specific type, use {@link PortableTypeConfiguration#setMetaDataEnabled(Boolean)} method. - *

- * Default value if {@code true}. - * - * @return Whether meta data is collected. - */ - public boolean isMetaDataEnabled() { - return metaDataEnabled; - } - - /** - * @param metaDataEnabled Whether meta data is collected. - */ - public void setMetaDataEnabled(boolean metaDataEnabled) { - this.metaDataEnabled = metaDataEnabled; - } - - /** - * If {@code true}, {@link PortableObject} will cache deserialized instance after - * {@link PortableObject#deserialize()} is called. All consequent calls of this - * method on the same instance of {@link PortableObject} will return that cached - * value without actually deserializing portable object. If you need to override this - * behaviour for some specific type, use {@link PortableTypeConfiguration#setKeepDeserialized(Boolean)} - * method. - *

- * Default value if {@code true}. - * - * @return Whether deserialized value is kept. - */ - public boolean isKeepDeserialized() { - return keepDeserialized; - } - - /** - * @param keepDeserialized Whether deserialized value is kept. - */ - public void setKeepDeserialized(boolean keepDeserialized) { - this.keepDeserialized = keepDeserialized; - } - - /** - * Gets portable protocol version. - *

- * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}. - * - * @return Portable protocol version. - */ - public PortableProtocolVersion getProtocolVersion() { - return protoVer; - } - - /** - * Sets portable protocol version. - *

- * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}. - * - * @param protoVer Portable protocol version. - */ - public void setProtocolVersion(PortableProtocolVersion protoVer) { - if (protoVer == null) - throw new IllegalArgumentException("Wrong portable protocol version: " + protoVer); - - this.protoVer = protoVer; - } - - /** - * Returns currently set {@link MarshallerContext}. - * - * @return Marshaller context. - */ - public MarshallerContext getContext() { - return ctx; - } - - /** - * Sets {@link PortableContext}. - *

- * @param ctx Portable context. - */ - private void setPortableContext(PortableContext ctx) { - ctx.configure(this); - - impl = new GridPortableMarshaller(ctx); - } - - /** {@inheritDoc} */ - @Override public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException { - return impl.marshal(obj, 0); - } - - /** {@inheritDoc} */ - @Override public void marshal(@Nullable Object obj, OutputStream out) throws IgniteCheckedException { - byte[] arr = marshal(obj); - - try { - out.write(arr); - } - catch (IOException e) { - throw new PortableException("Failed to marshal the object: " + obj, e); - } - } - - /** {@inheritDoc} */ - @Override public T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws IgniteCheckedException { - return impl.deserialize(bytes, clsLdr); - } - - /** {@inheritDoc} */ - @Override public T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - - byte[] arr = new byte[4096]; - int cnt; - - // we have to fully read the InputStream because GridPortableMarshaller requires support of a method that - // returns number of bytes remaining. - try { - while ((cnt = in.read(arr)) != -1) - buffer.write(arr, 0, cnt); - - buffer.flush(); - - return impl.deserialize(buffer.toByteArray(), clsLdr); - } - catch (IOException e) { - throw new PortableException("Failed to unmarshal the object from InputStream", e); - } - } -} diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/package-info.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/package-info.java deleted file mode 100644 index 90cc5e6..0000000 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/package-info.java +++ /dev/null @@ -1,22 +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. - */ - -/** - * - * Contains portable marshaller API classes. - */ -package org.apache.ignite.marshaller.portable; \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableBuilder.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableBuilder.java deleted file mode 100644 index 377fcdc..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableBuilder.java +++ /dev/null @@ -1,137 +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.portable; - -import org.apache.ignite.IgnitePortables; -import org.jetbrains.annotations.Nullable; - -/** - * Portable object builder. Provides ability to build portable objects dynamically without having class definitions. - *

- * Here is an example of how a portable object can be built dynamically: - *

- * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
- *
- * builder.setField("fieldA", "A");
- * builder.setField("fieldB", "B");
- *
- * PortableObject portableObj = builder.build();
- * 
- * - *

- * Also builder can be initialized by existing portable object. This allows changing some fields without affecting - * other fields. - *

- * PortableBuilder builder = Ignition.ignite().portables().builder(person);
- *
- * builder.setField("name", "John");
- *
- * person = builder.build();
- * 
- *

- * - * If you need to modify nested portable object you can get builder for nested object using - * {@link #getField(String)}, changes made on nested builder will affect parent object, - * for example: - * - *
- * PortableBuilder personBuilder = grid.portables().createBuilder(personPortableObj);
- * PortableBuilder addressBuilder = personBuilder.setField("address");
- *
- * addressBuilder.setField("city", "New York");
- *
- * personPortableObj = personBuilder.build();
- *
- * // Should be "New York".
- * String city = personPortableObj.getField("address").getField("city");
- * 
- * - * @see IgnitePortables#builder(int) - * @see IgnitePortables#builder(String) - * @see IgnitePortables#builder(PortableObject) - */ -public interface PortableBuilder { - /** - * Returns value assigned to the specified field. - * If the value is a portable object instance of {@code GridPortableBuilder} will be returned, - * which can be modified. - *

- * Collections and maps returned from this method are modifiable. - * - * @param name Field name. - * @return Filed value. - */ - public T getField(String name); - - /** - * Sets field value. - * - * @param name Field name. - * @param val Field value (cannot be {@code null}). - * @see PortableObject#metaData() - */ - public PortableBuilder setField(String name, Object val); - - /** - * Sets field value with value type specification. - *

- * Field type is needed for proper metadata update. - * - * @param name Field name. - * @param val Field value. - * @param type Field type. - * @see PortableObject#metaData() - */ - public PortableBuilder setField(String name, @Nullable T val, Class type); - - /** - * Sets field value. - *

- * This method should be used if field is portable object. - * - * @param name Field name. - * @param builder Builder for object field. - */ - public PortableBuilder setField(String name, @Nullable PortableBuilder builder); - - /** - * Removes field from this builder. - * - * @param fieldName Field name. - * @return {@code this} instance for chaining. - */ - public PortableBuilder removeField(String fieldName); - - /** - * Sets hash code for resulting portable object returned by {@link #build()} method. - *

- * If not set {@code 0} is used. - * - * @param hashCode Hash code. - * @return {@code this} instance for chaining. - */ - public PortableBuilder hashCode(int hashCode); - - /** - * Builds portable object. - * - * @return Portable object. - * @throws PortableException In case of error. - */ - public PortableObject build() throws PortableException; -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableException.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableException.java deleted file mode 100644 index 0f8d78b..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableException.java +++ /dev/null @@ -1,57 +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.portable; - -import org.apache.ignite.IgniteException; -import org.jetbrains.annotations.Nullable; - -/** - * Exception indicating portable object serialization error. - */ -public class PortableException extends IgniteException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates portable exception with error message. - * - * @param msg Error message. - */ - public PortableException(String msg) { - super(msg); - } - - /** - * Creates portable exception with {@link Throwable} as a cause. - * - * @param cause Cause. - */ - public PortableException(Throwable cause) { - super(cause); - } - - /** - * Creates portable exception with error message and {@link Throwable} as a cause. - * - * @param msg Error message. - * @param cause Cause. - */ - public PortableException(String msg, @Nullable Throwable cause) { - super(msg, cause); - } -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableIdMapper.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableIdMapper.java deleted file mode 100644 index 368e415..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableIdMapper.java +++ /dev/null @@ -1,56 +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.portable; - -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * Type and field ID mapper for portable objects. Ignite never writes full - * strings for field or type names. Instead, for performance reasons, Ignite - * writes integer hash codes for type and field names. It has been tested that - * hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide {@code PortableIdMapper} allows to override the automatically - * generated hash code IDs for the type and field names. - *

- * Portable ID mapper can be configured for all portable objects via {@link PortableMarshaller#getIdMapper()} method, - * or for a specific portable type via {@link PortableTypeConfiguration#getIdMapper()} method. - */ -public interface PortableIdMapper { - /** - * Gets type ID for provided class name. - *

- * If {@code 0} is returned, hash code of class simple name will be used. - * - * @param clsName Class name. - * @return Type ID. - */ - public int typeId(String clsName); - - /** - * Gets ID for provided field. - *

- * If {@code 0} is returned, hash code of field name will be used. - * - * @param typeId Type ID. - * @param fieldName Field name. - * @return Field ID. - */ - public int fieldId(int typeId, String fieldName); -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableInvalidClassException.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableInvalidClassException.java deleted file mode 100644 index 0098ec3..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableInvalidClassException.java +++ /dev/null @@ -1,58 +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.portable; - -import org.jetbrains.annotations.Nullable; - -/** - * Exception indicating that class needed for deserialization of portable object does not exist. - *

- * Thrown from {@link PortableObject#deserialize()} method. - */ -public class PortableInvalidClassException extends PortableException { - /** */ - private static final long serialVersionUID = 0L; - - /** - * Creates invalid class exception with error message. - * - * @param msg Error message. - */ - public PortableInvalidClassException(String msg) { - super(msg); - } - - /** - * Creates invalid class exception with {@link Throwable} as a cause. - * - * @param cause Cause. - */ - public PortableInvalidClassException(Throwable cause) { - super(cause); - } - - /** - * Creates invalid class exception with error message and {@link Throwable} as a cause. - * - * @param msg Error message. - * @param cause Cause. - */ - public PortableInvalidClassException(String msg, @Nullable Throwable cause) { - super(msg, cause); - } -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableMarshalAware.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableMarshalAware.java deleted file mode 100644 index 4270885..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableMarshalAware.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.portable; - -/** - * Interface that allows to implement custom serialization - * logic for portable objects. Portable objects are not required - * to implement this interface, in which case Ignite will automatically - * serialize portable objects using reflection. - *

- * This interface, in a way, is analogous to {@link java.io.Externalizable} - * interface, which allows users to override default serialization logic, - * usually for performance reasons. The only difference here is that portable - * serialization is already very fast and implementing custom serialization - * logic for portables does not provide significant performance gains. - */ -public interface PortableMarshalAware { - /** - * Writes fields to provided writer. - * - * @param writer Portable object writer. - * @throws PortableException In case of error. - */ - public void writePortable(PortableWriter writer) throws PortableException; - - /** - * Reads fields from provided reader. - * - * @param reader Portable object reader. - * @throws PortableException In case of error. - */ - public void readPortable(PortableReader reader) throws PortableException; -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableMetadata.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableMetadata.java deleted file mode 100644 index 4ea808b..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableMetadata.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.portable; - -import java.util.Collection; -import org.apache.ignite.IgnitePortables; -import org.jetbrains.annotations.Nullable; - -/** - * Portable type meta data. Metadata for portable types can be accessed from any of the - * {@link IgnitePortables#metadata(String)} methods. - * Having metadata also allows for proper formatting of {@code PortableObject#toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - */ -public interface PortableMetadata { - /** - * Gets portable type name. - * - * @return Portable type name. - */ - public String typeName(); - - /** - * Gets collection of all field names for this portable type. - * - * @return Collection of all field names for this portable type. - */ - public Collection fields(); - - /** - * Gets name of the field type for a given field. - * - * @param fieldName Field name. - * @return Field type name. - */ - @Nullable public String fieldTypeName(String fieldName); - - /** - * Portable objects can optionally specify custom key-affinity mapping in the - * configuration. This method returns the name of the field which should be - * used for the key-affinity mapping. - * - * @return Affinity key field name. - */ - @Nullable public String affinityKeyFieldName(); -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.java deleted file mode 100644 index 66b8f76..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableObject.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.portable; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.TreeMap; -import org.apache.ignite.IgnitePortables; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.jetbrains.annotations.Nullable; - -/** - * Wrapper for portable object in portable binary format. Once an object is defined as portable, - * Ignite will always store it in memory in the portable (i.e. binary) format. - * User can choose to work either with the portable format or with the deserialized form - * (assuming that class definitions are present in the classpath). - *

- * NOTE: user does not need to (and should not) implement this interface directly. - *

- * To work with the portable format directly, user should create a cache projection - * over {@code PortableObject} class and then retrieve individual fields as needed: - *

- * IgniteCache<PortableObject, PortableObject> prj = cache.withKeepPortable();
- *
- * // Convert instance of MyKey to portable format.
- * // We could also use GridPortableBuilder to create the key in portable format directly.
- * PortableObject key = grid.portables().toPortable(new MyKey());
- *
- * PortableObject val = prj.get(key);
- *
- * String field = val.field("myFieldName");
- * 
- * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized - * typed objects at all times. In this case we do incur the deserialization cost. However, if - * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access - * and will cache the deserialized object, so it does not have to be deserialized again: - *
- * IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
- *
- * MyValue val = cache.get(new MyKey());
- *
- * // Normal java getter.
- * String fieldVal = val.getMyFieldName();
- * 
- *

Working With Maps and Collections

- * All maps and collections in the portable objects are serialized automatically. When working - * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most - * adequate collection or map in either language. For example, {@link ArrayList} in Java will become - * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap} - * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary} - * in C#, etc. - *

Dynamic Structure Changes

- * Since objects are always cached in the portable binary format, server does not need to - * be aware of the class definitions. Moreover, if class definitions are not present or not - * used on the server, then clients can continuously change the structure of the portable - * objects without having to restart the cluster. For example, if one client stores a - * certain class with fields A and B, and another client stores the same class with - * fields B and C, then the server-side portable object will have the fields A, B, and C. - * As the structure of a portable object changes, the new fields become available for SQL queries - * automatically. - *

Building Portable Objects

- * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically: - *
- * PortableBuilder builder = Ignition.ignite().portables().builder("org.project.MyObject");
- *
- * builder.setField("fieldA", "A");
- * builder.setField("fieldB", "B");
- *
- * PortableObject portableObj = builder.build();
- * 
- * For the cases when class definition is present - * in the class path, it is also possible to populate a standard POJO and then - * convert it to portable format, like so: - *
- * MyObject obj = new MyObject();
- *
- * obj.setFieldA("A");
- * obj.setFieldB(123);
- *
- * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
- * 
- *

Portable Metadata

- * Even though Ignite portable protocol only works with hash codes for type and field names - * to achieve better performance, Ignite provides metadata for all portable types which - * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class)} - * methods. Having metadata also allows for proper formatting of {@code PortableObject.toString()} method, - * even when portable objects are kept in binary format only, which may be necessary for audit reasons. - */ -public interface PortableObject extends Serializable, Cloneable { - /** - * Gets portable object type ID. - * - * @return Type ID. - */ - public int typeId(); - - /** - * Gets meta data for this portable object. - * - * @return Meta data. - * @throws PortableException In case of error. - */ - @Nullable public PortableMetadata metaData() throws PortableException; - - /** - * Gets field value. - * - * @param fieldName Field name. - * @return Field value. - * @throws PortableException In case of any other error. - */ - @Nullable public F field(String fieldName) throws PortableException; - - /** - * Checks whether field is set. - * - * @param fieldName Field name. - * @return {@code true} if field is set. - */ - public boolean hasField(String fieldName); - - /** - * Gets fully deserialized instance of portable object. - * - * @return Fully deserialized instance of portable object. - * @throws PortableInvalidClassException If class doesn't exist. - * @throws PortableException In case of any other error. - */ - @Nullable public T deserialize() throws PortableException; - - /** - * Copies this portable object. - * - * @return Copy of this portable object. - */ - public PortableObject clone() throws CloneNotSupportedException; -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java deleted file mode 100644 index 9189b28..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableProtocolVersion.java +++ /dev/null @@ -1,41 +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.portable; - -import org.jetbrains.annotations.Nullable; - -/** - * Portable protocol version. - */ -public enum PortableProtocolVersion { - /** Ignite 1.4.0 release. */ - VER_1_4_0; - - /** Enumerated values. */ - private static final PortableProtocolVersion[] VALS = values(); - - /** - * Efficiently gets enumerated value from its ordinal. - * - * @param ord Ordinal value. - * @return Enumerated value or {@code null} if ordinal out of range. - */ - @Nullable public static PortableProtocolVersion fromOrdinal(int ord) { - return ord >= 0 && ord < VALS.length ? VALS[ord] : null; - } -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java deleted file mode 100644 index 3bae2e1..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java +++ /dev/null @@ -1,234 +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.portable; - -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.UUID; -import org.jetbrains.annotations.Nullable; - -/** - * Raw reader for portable objects. Raw reader does not use field name hash codes, therefore, - * making the format even more compact. However, if the raw reader is used, - * dynamic structure changes to the portable objects are not supported. - */ -public interface PortableRawReader { - /** - * @return Byte value. - * @throws PortableException In case of error. - */ - public byte readByte() throws PortableException; - - /** - * @return Short value. - * @throws PortableException In case of error. - */ - public short readShort() throws PortableException; - - /** - * @return Integer value. - * @throws PortableException In case of error. - */ - public int readInt() throws PortableException; - - /** - * @return Long value. - * @throws PortableException In case of error. - */ - public long readLong() throws PortableException; - - /** - * @return Float value. - * @throws PortableException In case of error. - */ - public float readFloat() throws PortableException; - - /** - * @return Double value. - * @throws PortableException In case of error. - */ - public double readDouble() throws PortableException; - - /** - * @return Char value. - * @throws PortableException In case of error. - */ - public char readChar() throws PortableException; - - /** - * @return Boolean value. - * @throws PortableException In case of error. - */ - public boolean readBoolean() throws PortableException; - - /** - * @return Decimal value. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal readDecimal() throws PortableException; - - /** - * @return String value. - * @throws PortableException In case of error. - */ - @Nullable public String readString() throws PortableException; - - /** - * @return UUID. - * @throws PortableException In case of error. - */ - @Nullable public UUID readUuid() throws PortableException; - - /** - * @return Date. - * @throws PortableException In case of error. - */ - @Nullable public Date readDate() throws PortableException; - - /** - * @return Timestamp. - * @throws PortableException In case of error. - */ - @Nullable public Timestamp readTimestamp() throws PortableException; - - /** - * @return Object. - * @throws PortableException In case of error. - */ - @Nullable public T readObject() throws PortableException; - - /** - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public byte[] readByteArray() throws PortableException; - - /** - * @return Short array. - * @throws PortableException In case of error. - */ - @Nullable public short[] readShortArray() throws PortableException; - - /** - * @return Integer array. - * @throws PortableException In case of error. - */ - @Nullable public int[] readIntArray() throws PortableException; - - /** - * @return Long array. - * @throws PortableException In case of error. - */ - @Nullable public long[] readLongArray() throws PortableException; - - /** - * @return Float array. - * @throws PortableException In case of error. - */ - @Nullable public float[] readFloatArray() throws PortableException; - - /** - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public double[] readDoubleArray() throws PortableException; - - /** - * @return Char array. - * @throws PortableException In case of error. - */ - @Nullable public char[] readCharArray() throws PortableException; - - /** - * @return Boolean array. - * @throws PortableException In case of error. - */ - @Nullable public boolean[] readBooleanArray() throws PortableException; - - /** - * @return Decimal array. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal[] readDecimalArray() throws PortableException; - - /** - * @return String array. - * @throws PortableException In case of error. - */ - @Nullable public String[] readStringArray() throws PortableException; - - /** - * @return UUID array. - * @throws PortableException In case of error. - */ - @Nullable public UUID[] readUuidArray() throws PortableException; - - /** - * @return Date array. - * @throws PortableException In case of error. - */ - @Nullable public Date[] readDateArray() throws PortableException; - - /** - * @return Object array. - * @throws PortableException In case of error. - */ - @Nullable public Object[] readObjectArray() throws PortableException; - - /** - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection() throws PortableException; - - /** - * @param colCls Collection class. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection(Class> colCls) - throws PortableException; - - /** - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap() throws PortableException; - - /** - * @param mapCls Map class. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap(Class> mapCls) throws PortableException; - - /** - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T readEnum() throws PortableException; - - /** - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T[] readEnumArray() throws PortableException; -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java deleted file mode 100644 index 53f4f92..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java +++ /dev/null @@ -1,219 +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.portable; - -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.UUID; -import org.jetbrains.annotations.Nullable; - -/** - * Raw writer for portable object. Raw writer does not write field name hash codes, therefore, - * making the format even more compact. However, if the raw writer is used, - * dynamic structure changes to the portable objects are not supported. - */ -public interface PortableRawWriter { - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByte(byte val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShort(short val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeInt(int val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLong(long val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloat(float val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDouble(double val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeChar(char val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBoolean(boolean val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimal(@Nullable BigDecimal val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeString(@Nullable String val) throws PortableException; - - /** - * @param val UUID to write. - * @throws PortableException In case of error. - */ - public void writeUuid(@Nullable UUID val) throws PortableException; - - /** - * @param val Date to write. - * @throws PortableException In case of error. - */ - public void writeDate(@Nullable Date val) throws PortableException; - - /** - * @param val Timestamp to write. - * @throws PortableException In case of error. - */ - public void writeTimestamp(@Nullable Timestamp val) throws PortableException; - - /** - * @param obj Value to write. - * @throws PortableException In case of error. - */ - public void writeObject(@Nullable Object obj) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByteArray(@Nullable byte[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShortArray(@Nullable short[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeIntArray(@Nullable int[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLongArray(@Nullable long[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloatArray(@Nullable float[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDoubleArray(@Nullable double[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeCharArray(@Nullable char[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBooleanArray(@Nullable boolean[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimalArray(@Nullable BigDecimal[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeStringArray(@Nullable String[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeUuidArray(@Nullable UUID[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDateArray(@Nullable Date[] val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeObjectArray(@Nullable Object[] val) throws PortableException; - - /** - * @param col Collection to write. - * @throws PortableException In case of error. - */ - public void writeCollection(@Nullable Collection col) throws PortableException; - - /** - * @param map Map to write. - * @throws PortableException In case of error. - */ - public void writeMap(@Nullable Map map) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnum(T val) throws PortableException; - - /** - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnumArray(T[] val) throws PortableException; -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java deleted file mode 100644 index 58f078d..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java +++ /dev/null @@ -1,284 +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.portable; - -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.UUID; -import org.jetbrains.annotations.Nullable; - -/** - * Reader for portable objects used in {@link PortableMarshalAware} implementations. - * Useful for the cases when user wants a fine-grained control over serialization. - *

- * Note that Ignite never writes full strings for field or type names. Instead, - * for performance reasons, Ignite writes integer hash codes for type and field names. - * It has been tested that hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide, Ignite provides {@link PortableIdMapper} which - * allows to override the automatically generated hash code IDs for the type and field names. - */ -public interface PortableReader { - /** - * @param fieldName Field name. - * @return Byte value. - * @throws PortableException In case of error. - */ - public byte readByte(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Short value. - * @throws PortableException In case of error. - */ - public short readShort(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Integer value. - * @throws PortableException In case of error. - */ - public int readInt(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Long value. - * @throws PortableException In case of error. - */ - public long readLong(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @throws PortableException In case of error. - * @return Float value. - */ - public float readFloat(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Double value. - * @throws PortableException In case of error. - */ - public double readDouble(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Char value. - * @throws PortableException In case of error. - */ - public char readChar(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Boolean value. - * @throws PortableException In case of error. - */ - public boolean readBoolean(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Decimal value. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal readDecimal(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return String value. - * @throws PortableException In case of error. - */ - @Nullable public String readString(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return UUID. - * @throws PortableException In case of error. - */ - @Nullable public UUID readUuid(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Date. - * @throws PortableException In case of error. - */ - @Nullable public Date readDate(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Timestamp. - * @throws PortableException In case of error. - */ - @Nullable public Timestamp readTimestamp(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Object. - * @throws PortableException In case of error. - */ - @Nullable public T readObject(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public byte[] readByteArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Short array. - * @throws PortableException In case of error. - */ - @Nullable public short[] readShortArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Integer array. - * @throws PortableException In case of error. - */ - @Nullable public int[] readIntArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Long array. - * @throws PortableException In case of error. - */ - @Nullable public long[] readLongArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Float array. - * @throws PortableException In case of error. - */ - @Nullable public float[] readFloatArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Byte array. - * @throws PortableException In case of error. - */ - @Nullable public double[] readDoubleArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Char array. - * @throws PortableException In case of error. - */ - @Nullable public char[] readCharArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Boolean array. - * @throws PortableException In case of error. - */ - @Nullable public boolean[] readBooleanArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Decimal array. - * @throws PortableException In case of error. - */ - @Nullable public BigDecimal[] readDecimalArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return String array. - * @throws PortableException In case of error. - */ - @Nullable public String[] readStringArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return UUID array. - * @throws PortableException In case of error. - */ - @Nullable public UUID[] readUuidArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Date array. - * @throws PortableException In case of error. - */ - @Nullable public Date[] readDateArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Object array. - * @throws PortableException In case of error. - */ - @Nullable public Object[] readObjectArray(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @param colCls Collection class. - * @return Collection. - * @throws PortableException In case of error. - */ - @Nullable public Collection readCollection(String fieldName, Class> colCls) - throws PortableException; - - /** - * @param fieldName Field name. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @param mapCls Map class. - * @return Map. - * @throws PortableException In case of error. - */ - @Nullable public Map readMap(String fieldName, Class> mapCls) - throws PortableException; - - /** - * @param fieldName Field name. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T readEnum(String fieldName) throws PortableException; - - /** - * @param fieldName Field name. - * @return Value. - * @throws PortableException In case of error. - */ - @Nullable public > T[] readEnumArray(String fieldName) throws PortableException; - - /** - * Gets raw reader. Raw reader does not use field name hash codes, therefore, - * making the format even more compact. However, if the raw reader is used, - * dynamic structure changes to the portable objects are not supported. - * - * @return Raw reader. - */ - public PortableRawReader rawReader(); -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableSerializer.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableSerializer.java deleted file mode 100644 index 90ee562..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableSerializer.java +++ /dev/null @@ -1,49 +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.portable; - -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * Interface that allows to implement custom serialization logic for portable objects. - * Can be used instead of {@link PortableMarshalAware} in case if the class - * cannot be changed directly. - *

- * Portable serializer can be configured for all portable objects via - * {@link PortableMarshaller#getSerializer()} method, or for a specific - * portable type via {@link PortableTypeConfiguration#getSerializer()} method. - */ -public interface PortableSerializer { - /** - * Writes fields to provided writer. - * - * @param obj Empty object. - * @param writer Portable object writer. - * @throws PortableException In case of error. - */ - public void writePortable(Object obj, PortableWriter writer) throws PortableException; - - /** - * Reads fields from provided reader. - * - * @param obj Empty object - * @param reader Portable object reader. - * @throws PortableException In case of error. - */ - public void readPortable(Object obj, PortableReader reader) throws PortableException; -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java deleted file mode 100644 index 5e6e09d..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java +++ /dev/null @@ -1,196 +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.portable; - -import java.sql.Timestamp; -import java.util.Collection; -import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * Defines configuration properties for a specific portable type. Providing per-type - * configuration is optional, as it is generally enough, and also optional, to provide global portable - * configuration using {@link PortableMarshaller#setClassNames(Collection)}. - * However, this class allows you to change configuration properties for a specific - * portable type without affecting configuration for other portable types. - *

- * Per-type portable configuration can be specified in {@link PortableMarshaller#getTypeConfigurations()} method. - */ -public class PortableTypeConfiguration { - /** Class name. */ - private String clsName; - - /** ID mapper. */ - private PortableIdMapper idMapper; - - /** Serializer. */ - private PortableSerializer serializer; - - /** Use timestamp flag. */ - private Boolean useTs; - - /** Meta data enabled flag. */ - private Boolean metaDataEnabled; - - /** Keep deserialized flag. */ - private Boolean keepDeserialized; - - /** Affinity key field name. */ - private String affKeyFieldName; - - /** - */ - public PortableTypeConfiguration() { - // No-op. - } - - /** - * @param clsName Class name. - */ - public PortableTypeConfiguration(String clsName) { - this.clsName = clsName; - } - - /** - * Gets type name. - * - * @return Type name. - */ - public String getClassName() { - return clsName; - } - - /** - * Sets type name. - * - * @param clsName Type name. - */ - public void setClassName(String clsName) { - this.clsName = clsName; - } - - /** - * Gets ID mapper. - * - * @return ID mapper. - */ - public PortableIdMapper getIdMapper() { - return idMapper; - } - - /** - * Sets ID mapper. - * - * @param idMapper ID mapper. - */ - public void setIdMapper(PortableIdMapper idMapper) { - this.idMapper = idMapper; - } - - /** - * Gets serializer. - * - * @return Serializer. - */ - public PortableSerializer getSerializer() { - return serializer; - } - - /** - * Sets serializer. - * - * @param serializer Serializer. - */ - public void setSerializer(PortableSerializer serializer) { - this.serializer = serializer; - } - - /** - * If {@code true} then date values converted to {@link Timestamp} during unmarshalling. - * - * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public Boolean isUseTimestamp() { - return useTs; - } - - /** - * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling. - */ - public void setUseTimestamp(Boolean useTs) { - this.useTs = useTs; - } - - /** - * Defines whether meta data is collected for this type. If provided, this value will override - * {@link PortableMarshaller#isMetaDataEnabled()} property. - * - * @return Whether meta data is collected. - */ - public Boolean isMetaDataEnabled() { - return metaDataEnabled; - } - - /** - * @param metaDataEnabled Whether meta data is collected. - */ - public void setMetaDataEnabled(Boolean metaDataEnabled) { - this.metaDataEnabled = metaDataEnabled; - } - - /** - * Defines whether {@link PortableObject} should cache deserialized instance. If provided, - * this value will override {@link PortableMarshaller#isKeepDeserialized()} - * property. - * - * @return Whether deserialized value is kept. - */ - public Boolean isKeepDeserialized() { - return keepDeserialized; - } - - /** - * @param keepDeserialized Whether deserialized value is kept. - */ - public void setKeepDeserialized(Boolean keepDeserialized) { - this.keepDeserialized = keepDeserialized; - } - - /** - * Gets affinity key field name. - * - * @return Affinity key field name. - */ - public String getAffinityKeyFieldName() { - return affKeyFieldName; - } - - /** - * Sets affinity key field name. - * - * @param affKeyFieldName Affinity key field name. - */ - public void setAffinityKeyFieldName(String affKeyFieldName) { - this.affKeyFieldName = affKeyFieldName; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return S.toString(PortableTypeConfiguration.class, this, super.toString()); - } -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java deleted file mode 100644 index 0d7160f..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java +++ /dev/null @@ -1,266 +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.portable; - -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Collection; -import java.util.Date; -import java.util.Map; -import java.util.UUID; -import org.jetbrains.annotations.Nullable; - -/** - * Writer for portable object used in {@link PortableMarshalAware} implementations. - * Useful for the cases when user wants a fine-grained control over serialization. - *

- * Note that Ignite never writes full strings for field or type names. Instead, - * for performance reasons, Ignite writes integer hash codes for type and field names. - * It has been tested that hash code conflicts for the type names or the field names - * within the same type are virtually non-existent and, to gain performance, it is safe - * to work with hash codes. For the cases when hash codes for different types or fields - * actually do collide, Ignite provides {@link PortableIdMapper} which - * allows to override the automatically generated hash code IDs for the type and field names. - */ -public interface PortableWriter { - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByte(String fieldName, byte val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShort(String fieldName, short val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeInt(String fieldName, int val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLong(String fieldName, long val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloat(String fieldName, float val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDouble(String fieldName, double val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeChar(String fieldName, char val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBoolean(String fieldName, boolean val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeString(String fieldName, @Nullable String val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val UUID to write. - * @throws PortableException In case of error. - */ - public void writeUuid(String fieldName, @Nullable UUID val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Date to write. - * @throws PortableException In case of error. - */ - public void writeDate(String fieldName, @Nullable Date val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Timestamp to write. - * @throws PortableException In case of error. - */ - public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException; - - /** - * @param fieldName Field name. - * @param obj Value to write. - * @throws PortableException In case of error. - */ - public void writeObject(String fieldName, @Nullable Object obj) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeByteArray(String fieldName, @Nullable byte[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeShortArray(String fieldName, @Nullable short[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeIntArray(String fieldName, @Nullable int[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeLongArray(String fieldName, @Nullable long[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeFloatArray(String fieldName, @Nullable float[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDoubleArray(String fieldName, @Nullable double[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeCharArray(String fieldName, @Nullable char[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeStringArray(String fieldName, @Nullable String[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeDateArray(String fieldName, @Nullable Date[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException; - - /** - * @param fieldName Field name. - * @param col Collection to write. - * @throws PortableException In case of error. - */ - public void writeCollection(String fieldName, @Nullable Collection col) throws PortableException; - - /** - * @param fieldName Field name. - * @param map Map to write. - * @throws PortableException In case of error. - */ - public void writeMap(String fieldName, @Nullable Map map) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnum(String fieldName, T val) throws PortableException; - - /** - * @param fieldName Field name. - * @param val Value to write. - * @throws PortableException In case of error. - */ - public > void writeEnumArray(String fieldName, T[] val) throws PortableException; - - /** - * Gets raw writer. Raw writer does not write field name hash codes, therefore, - * making the format even more compact. However, if the raw writer is used, - * dynamic structure changes to the portable objects are not supported. - * - * @return Raw writer. - */ - public PortableRawWriter rawWriter(); -} \ No newline at end of file diff --git a/modules/core/src/main/java/org/apache/ignite/portable/package-info.java b/modules/core/src/main/java/org/apache/ignite/portable/package-info.java deleted file mode 100644 index 0105b15..0000000 --- a/modules/core/src/main/java/org/apache/ignite/portable/package-info.java +++ /dev/null @@ -1,22 +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. - */ - -/** - * - * Contains portable objects API classes. - */ -package org.apache.ignite.portable; \ No newline at end of file diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 70c32e5..36ac156 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -1572,10 +1572,10 @@ org.apache.ignite.plugin.security.SecuritySubject org.apache.ignite.plugin.security.SecuritySubjectType org.apache.ignite.plugin.segmentation.SegmentationPolicy org.apache.ignite.plugin.segmentation.SegmentationResolver -org.apache.ignite.portable.PortableException -org.apache.ignite.portable.PortableInvalidClassException -org.apache.ignite.portable.PortableObject -org.apache.ignite.portable.PortableProtocolVersion +org.apache.ignite.internal.portable.api.PortableException +org.apache.ignite.internal.portable.api.PortableInvalidClassException +org.apache.ignite.internal.portable.api.PortableObject +org.apache.ignite.internal.portable.api.PortableProtocolVersion org.apache.ignite.services.Service org.apache.ignite.services.ServiceConfiguration org.apache.ignite.services.ServiceContext diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java index 82da10f..dc73cff 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java @@ -159,51 +159,6 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends GridCommonA } /** - * @throws Exception If failed. - */ - public void testDifferentPortableProtocolVersions() throws Exception { - startGridWithPortableProtocolVer("VER_99_99_99"); - - try { - startGrid(1); - - fail(); - } - catch (IgniteCheckedException e) { - if (!e.getCause().getMessage().startsWith("Remote node has portable protocol version different from local")) - throw e; - } - } - - /** - * @throws Exception If failed. - */ - public void testNullPortableProtocolVersion() throws Exception { - startGridWithPortableProtocolVer(null); - - // Must not fail in order to preserve backward compatibility with the nodes that don't have this property yet. - startGrid(1); - } - - /** - * @throws Exception If failed. - */ - private void startGridWithPortableProtocolVer(String ver) throws Exception { - Ignite ignite = startGrid(0); - - ClusterNode clusterNode = ignite.cluster().localNode(); - - Field f = clusterNode.getClass().getDeclaredField("attrs"); - f.setAccessible(true); - - Map attrs = new HashMap<>((Map)f.get(clusterNode)); - - attrs.put(IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER, ver); - - f.set(clusterNode, attrs); - } - - /** * @param preferIpV4 {@code java.net.preferIPv4Stack} system property value. * @throws Exception If failed. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java index 59084db..36b43f6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java @@ -31,8 +31,8 @@ import org.apache.ignite.internal.processors.cache.CacheObjectContext; import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; import org.apache.ignite.lang.IgniteCallable; import org.apache.ignite.lang.IgniteRunnable; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableTypeConfiguration; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; import org.apache.ignite.resources.IgniteInstanceResource; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java index 61ec714..6b9751a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java @@ -36,7 +36,7 @@ import java.util.Objects; import java.util.Set; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.portable.builder.PortableBuilderEnum; @@ -45,10 +45,10 @@ import org.apache.ignite.internal.portable.mutabletest.GridPortableMarshalerAwar import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl; import org.apache.ignite.internal.processors.cache.portable.IgnitePortablesImpl; import org.apache.ignite.internal.util.lang.GridMapEntry; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Assert; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java index 7f23c1f..bceec9d 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.portable.builder.PortableBuilderImpl; import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes; @@ -37,12 +37,12 @@ import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.T import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableTypeConfiguration; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableIdMapper; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import sun.misc.Unsafe; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java index bd9612c..71a11b1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java @@ -25,12 +25,12 @@ import java.util.Arrays; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.internal.MarshallerContextAdapter; import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java index 21fc81c..dc16c94 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java @@ -49,20 +49,20 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.MarshallerContextTestImpl; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableInvalidClassException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableSerializer; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableIdMapper; +import org.apache.ignite.internal.portable.api.PortableInvalidClassException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableSerializer; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jsr166.ConcurrentHashMap8; diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java index 05df23b..825d678 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataDisabledSelfTest.java @@ -17,15 +17,15 @@ package org.apache.ignite.internal.portable; import java.util.Arrays; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableBuilder; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java index fa3c9a7..bec70cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java @@ -22,17 +22,17 @@ import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.HashMap; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java index 349f152..25ff7d0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java @@ -21,10 +21,10 @@ import java.util.Arrays; import java.util.Map; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.MarshallerContextTestImpl; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableIdMapper; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableTypeConfiguration; +import org.apache.ignite.internal.portable.api.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableIdMapper; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableTypeConfiguration; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java index 3244331..53d84a1 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableMarshalerAwareTestClass.java @@ -18,12 +18,12 @@ package org.apache.ignite.internal.portable.mutabletest; import org.apache.ignite.internal.util.typedef.internal.S; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableRawReader; -import org.apache.ignite.portable.PortableRawWriter; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMarshalAware; +import org.apache.ignite.internal.portable.api.PortableRawReader; +import org.apache.ignite.internal.portable.api.PortableRawWriter; +import org.apache.ignite.internal.portable.api.PortableReader; +import org.apache.ignite.internal.portable.api.PortableWriter; import org.apache.ignite.testframework.GridTestUtils; /** diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java index e49514b..13f51ba 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.TreeMap; import java.util.UUID; import org.apache.ignite.internal.util.lang.GridMapEntry; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; /** * diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java deleted file mode 100644 index 1ba3d4d..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataMultinodeTest.java +++ /dev/null @@ -1,295 +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.cache.portable; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgnitePortables; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.util.lang.GridAbsPredicate; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.GridTestUtils; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.eclipse.jetty.util.ConcurrentHashSet; - -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * - */ -public class GridCacheClientNodePortableMetadataMultinodeTest extends GridCommonAbstractTest { - /** */ - protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private boolean client; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setPeerClassLoadingEnabled(false); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true); - - cfg.setMarshaller(new PortableMarshaller()); - - CacheConfiguration ccfg = new CacheConfiguration(); - - ccfg.setWriteSynchronizationMode(FULL_SYNC); - - cfg.setCacheConfiguration(ccfg); - - cfg.setClientMode(client); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - super.afterTest(); - - stopAllGrids(); - } - - /** - * @throws Exception If failed. - */ - public void testClientMetadataInitialization() throws Exception { - startGrids(2); - - final AtomicBoolean stop = new AtomicBoolean(); - - final ConcurrentHashSet allTypes = new ConcurrentHashSet<>(); - - IgniteInternalFuture fut; - - try { - // Update portable metadata concurrently with client nodes start. - fut = GridTestUtils.runMultiThreadedAsync(new Callable() { - @Override public Object call() throws Exception { - IgnitePortables portables = ignite(0).portables(); - - IgniteCache cache = ignite(0).cache(null).withKeepPortable(); - - ThreadLocalRandom rnd = ThreadLocalRandom.current(); - - for (int i = 0; i < 1000; i++) { - log.info("Iteration: " + i); - - String type = "portable-type-" + i; - - allTypes.add(type); - - for (int f = 0; f < 10; f++) { - PortableBuilder builder = portables.builder(type); - - String fieldName = "f" + f; - - builder.setField(fieldName, i); - - cache.put(rnd.nextInt(0, 100_000), builder.build()); - - if (f % 100 == 0) - log.info("Put iteration: " + f); - } - - if (stop.get()) - break; - } - - return null; - } - }, 5, "update-thread"); - } - finally { - stop.set(true); - } - - client = true; - - startGridsMultiThreaded(2, 5); - - fut.get(); - - assertFalse(allTypes.isEmpty()); - - log.info("Expected portable types: " + allTypes.size()); - - assertEquals(7, ignite(0).cluster().nodes().size()); - - for (int i = 0; i < 7; i++) { - log.info("Check metadata on node: " + i); - - boolean client = i > 1; - - assertEquals((Object)client, ignite(i).configuration().isClientMode()); - - IgnitePortables portables = ignite(i).portables(); - - Collection metaCol = portables.metadata(); - - assertEquals(allTypes.size(), metaCol.size()); - - Set names = new HashSet<>(); - - for (PortableMetadata meta : metaCol) { - assertTrue(names.add(meta.typeName())); - - assertNull(meta.affinityKeyFieldName()); - - assertEquals(10, meta.fields().size()); - } - - assertEquals(allTypes.size(), names.size()); - } - } - - /** - * @throws Exception If failed. - */ - public void testFailoverOnStart() throws Exception { - startGrids(4); - - IgnitePortables portables = ignite(0).portables(); - - IgniteCache cache = ignite(0).cache(null).withKeepPortable(); - - for (int i = 0; i < 1000; i++) { - PortableBuilder builder = portables.builder("type-" + i); - - builder.setField("f0", i); - - cache.put(i, builder.build()); - } - - client = true; - - final CyclicBarrier barrier = new CyclicBarrier(6); - - final AtomicInteger startIdx = new AtomicInteger(4); - - IgniteInternalFuture fut = GridTestUtils.runMultiThreadedAsync(new Callable() { - @Override public Object call() throws Exception { - barrier.await(); - - Ignite ignite = startGrid(startIdx.getAndIncrement()); - - assertTrue(ignite.configuration().isClientMode()); - - log.info("Started node: " + ignite.name()); - - return null; - } - }, 5, "start-thread"); - - barrier.await(); - - U.sleep(ThreadLocalRandom.current().nextInt(10, 100)); - - for (int i = 0; i < 3; i++) - stopGrid(i); - - fut.get(); - - assertEquals(6, ignite(3).cluster().nodes().size()); - - for (int i = 3; i < 7; i++) { - log.info("Check metadata on node: " + i); - - boolean client = i > 3; - - assertEquals((Object) client, ignite(i).configuration().isClientMode()); - - portables = ignite(i).portables(); - - final IgnitePortables p0 = portables; - - GridTestUtils.waitForCondition(new GridAbsPredicate() { - @Override public boolean apply() { - Collection metaCol = p0.metadata(); - - return metaCol.size() == 1000; - } - }, getTestTimeout()); - - Collection metaCol = portables.metadata(); - - assertEquals(1000, metaCol.size()); - - Set names = new HashSet<>(); - - for (PortableMetadata meta : metaCol) { - assertTrue(names.add(meta.typeName())); - - assertNull(meta.affinityKeyFieldName()); - - assertEquals(1, meta.fields().size()); - } - - assertEquals(1000, names.size()); - } - } - - /** - * @throws Exception If failed. - */ - public void testClientStartsFirst() throws Exception { - client = true; - - Ignite ignite0 = startGrid(0); - - assertTrue(ignite0.configuration().isClientMode()); - - client = false; - - Ignite ignite1 = startGrid(1); - - assertFalse(ignite1.configuration().isClientMode()); - - IgnitePortables portables = ignite(1).portables(); - - IgniteCache cache = ignite(1).cache(null).withKeepPortable(); - - for (int i = 0; i < 100; i++) { - PortableBuilder builder = portables.builder("type-" + i); - - builder.setField("f0", i); - - cache.put(i, builder.build()); - } - - assertEquals(100, ignite(0).portables().metadata().size()); - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataTest.java deleted file mode 100644 index a66d940..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodePortableMetadataTest.java +++ /dev/null @@ -1,286 +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.cache.portable; - -import java.util.Arrays; -import java.util.Collection; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.affinity.Affinity; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; - -/** - * - */ -public class GridCacheClientNodePortableMetadataTest extends GridCacheAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; - } - - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return CacheMode.PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName())); - - PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(); - - typeCfg.setClassName(TestObject1.class.getName()); - typeCfg.setAffinityKeyFieldName("val2"); - - marsh.setTypeConfigurations(Arrays.asList(typeCfg)); - - if (gridName.equals(getTestGridName(gridCount() - 1))) - cfg.setClientMode(true); - - cfg.setMarshaller(marsh); - - ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); - - return cfg; - } - - /** - * @throws Exception If failed. - */ - public void testPortableMetadataOnClient() throws Exception { - Ignite ignite0 = ignite(gridCount() - 1); - - assertTrue(ignite0.configuration().isClientMode()); - - Ignite ignite1 = ignite(0); - - assertFalse(ignite1.configuration().isClientMode()); - - Affinity aff0 = ignite0.affinity(null); - Affinity aff1 = ignite1.affinity(null); - - for (int i = 0 ; i < 100; i++) { - TestObject1 obj1 = new TestObject1(i, i + 1); - - assertEquals(aff1.mapKeyToPrimaryAndBackups(obj1), - aff0.mapKeyToPrimaryAndBackups(obj1)); - - TestObject2 obj2 = new TestObject2(i, i + 1); - - assertEquals(aff1.mapKeyToPrimaryAndBackups(obj2), - aff0.mapKeyToPrimaryAndBackups(obj2)); - } - - { - PortableBuilder builder = ignite0.portables().builder("TestObject3"); - - builder.setField("f1", 1); - - ignite0.cache(null).put(0, builder.build()); - - IgniteCache cache = ignite0.cache(null).withKeepPortable(); - - PortableObject obj = cache.get(0); - - PortableMetadata meta = obj.metaData(); - - assertNotNull(meta); - assertEquals(1, meta.fields().size()); - - meta = ignite0.portables().metadata(TestObject1.class); - - assertNotNull(meta); - assertEquals("val2", meta.affinityKeyFieldName()); - - meta = ignite0.portables().metadata(TestObject2.class); - - assertNotNull(meta); - assertNull(meta.affinityKeyFieldName()); - } - - { - PortableBuilder builder = ignite1.portables().builder("TestObject3"); - - builder.setField("f2", 2); - - ignite1.cache(null).put(1, builder.build()); - - IgniteCache cache = ignite1.cache(null).withKeepPortable(); - - PortableObject obj = cache.get(0); - - PortableMetadata meta = obj.metaData(); - - assertNotNull(meta); - assertEquals(2, meta.fields().size()); - - meta = ignite1.portables().metadata(TestObject1.class); - - assertNotNull(meta); - assertEquals("val2", meta.affinityKeyFieldName()); - - meta = ignite1.portables().metadata(TestObject2.class); - - assertNotNull(meta); - assertNull(meta.affinityKeyFieldName()); - } - - PortableMetadata meta = ignite0.portables().metadata("TestObject3"); - - assertNotNull(meta); - assertEquals(2, meta.fields().size()); - - IgniteCache cache = ignite0.cache(null).withKeepPortable(); - - PortableObject obj = cache.get(1); - - assertEquals(Integer.valueOf(2), obj.field("f2")); - assertNull(obj.field("f1")); - - meta = obj.metaData(); - - assertNotNull(meta); - assertEquals(2, meta.fields().size()); - - Collection meta1 = ignite1.portables().metadata(); - Collection meta2 = ignite1.portables().metadata(); - - assertEquals(meta1.size(), meta2.size()); - - for (PortableMetadata m1 : meta1) { - boolean found = false; - - for (PortableMetadata m2 : meta1) { - if (m1.typeName().equals(m2.typeName())) { - assertEquals(m1.affinityKeyFieldName(), m2.affinityKeyFieldName()); - assertEquals(m1.fields(), m2.fields()); - - found = true; - - break; - } - } - - assertTrue(found); - } - } - - /** - * - */ - static class TestObject1 { - /** */ - private int val1; - - /** */ - private int val2; - - /** - * @param val1 Value 1. - * @param val2 Value 2. - */ - public TestObject1(int val1, int val2) { - this.val1 = val1; - this.val2 = val2; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - TestObject1 that = (TestObject1)o; - - return val1 == that.val1; - - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val1; - } - } - - /** - * - */ - static class TestObject2 { - /** */ - private int val1; - - /** */ - private int val2; - - /** - * @param val1 Value 1. - * @param val2 Value 2. - */ - public TestObject2(int val1, int val2) { - this.val1 = val1; - this.val2 = val2; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - TestObject2 that = (TestObject2)o; - - return val2 == that.val2; - - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val2; - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java deleted file mode 100644 index 9ba38d9..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractDataStreamerSelfTest.java +++ /dev/null @@ -1,190 +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.cache.portable; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jsr166.LongAdder8; - -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; - -/** - * Test for portable objects stored in cache. - */ -public abstract class GridCachePortableObjectsAbstractDataStreamerSelfTest extends GridCommonAbstractTest { - /** */ - private static final int THREAD_CNT = 64; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheMode(cacheMode()); - cacheCfg.setAtomicityMode(atomicityMode()); - cacheCfg.setNearConfiguration(nearConfiguration()); - cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode()); - - cfg.setCacheConfiguration(cacheCfg); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setTypeConfigurations(Arrays.asList( - new PortableTypeConfiguration(TestObject.class.getName()))); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** - * @return Sync mode. - */ - protected CacheWriteSynchronizationMode writeSynchronizationMode() { - return PRIMARY_SYNC; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(gridCount()); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** - * @return Cache mode. - */ - protected abstract CacheMode cacheMode(); - - /** - * @return Atomicity mode. - */ - protected abstract CacheAtomicityMode atomicityMode(); - - /** - * @return Near configuration. - */ - protected abstract NearCacheConfiguration nearConfiguration(); - - /** - * @return Grid count. - */ - protected int gridCount() { - return 1; - } - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("BusyWait") - public void testGetPut() throws Exception { - final AtomicBoolean flag = new AtomicBoolean(); - - final LongAdder8 cnt = new LongAdder8(); - - try (IgniteDataStreamer ldr = grid(0).dataStreamer(null)) { - IgniteInternalFuture f = multithreadedAsync( - new Callable() { - @Override public Object call() throws Exception { - ThreadLocalRandom rnd = ThreadLocalRandom.current(); - - while (!flag.get()) { - ldr.addData(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000))); - - cnt.add(1); - } - - return null; - } - }, - THREAD_CNT - ); - - for (int i = 0; i < 30 && !f.isDone(); i++) - Thread.sleep(1000); - - flag.set(true); - - f.get(); - } - - info("Operations in 30 sec: " + cnt.sum()); - } - - /** - */ - private static class TestObject implements PortableMarshalAware, Serializable { - /** */ - private int val; - - /** - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof TestObject && ((TestObject)obj).val == val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java deleted file mode 100644 index 67f0e52..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractMultiThreadedSelfTest.java +++ /dev/null @@ -1,231 +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.cache.portable; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheWriteSynchronizationMode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableTypeConfiguration; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jsr166.LongAdder8; - -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC; - -/** - * Test for portable objects stored in cache. - */ -public abstract class GridCachePortableObjectsAbstractMultiThreadedSelfTest extends GridCommonAbstractTest { - /** */ - private static final int THREAD_CNT = 64; - - /** */ - private static final AtomicInteger idxGen = new AtomicInteger(); - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheMode(cacheMode()); - cacheCfg.setAtomicityMode(atomicityMode()); - cacheCfg.setNearConfiguration(nearConfiguration()); - cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode()); - - cfg.setCacheConfiguration(cacheCfg); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setTypeConfigurations(Arrays.asList( - new PortableTypeConfiguration(TestObject.class.getName()))); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** - * @return Sync mode. - */ - protected CacheWriteSynchronizationMode writeSynchronizationMode() { - return PRIMARY_SYNC; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(gridCount()); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** - * @return Cache mode. - */ - protected abstract CacheMode cacheMode(); - - /** - * @return Atomicity mode. - */ - protected abstract CacheAtomicityMode atomicityMode(); - - /** - * @return Distribution mode. - */ - protected abstract NearCacheConfiguration nearConfiguration(); - - /** - * @return Grid count. - */ - protected int gridCount() { - return 1; - } - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("BusyWait") public void testGetPut() throws Exception { - final AtomicBoolean flag = new AtomicBoolean(); - - final LongAdder8 cnt = new LongAdder8(); - - IgniteInternalFuture f = multithreadedAsync( - new Callable() { - @Override public Object call() throws Exception { - int threadId = idxGen.getAndIncrement() % 2; - - ThreadLocalRandom rnd = ThreadLocalRandom.current(); - - while (!flag.get()) { - IgniteCache c = jcache(rnd.nextInt(gridCount())); - - switch (threadId) { - case 0: - // Put/get/remove portable -> portable. - - c.put(new TestObject(rnd.nextInt(10000)), new TestObject(rnd.nextInt(10000))); - - IgniteCache p2 = ((IgniteCacheProxy)c).keepPortable(); - - PortableObject v = (PortableObject)p2.get(new TestObject(rnd.nextInt(10000))); - - if (v != null) - v.deserialize(); - - c.remove(new TestObject(rnd.nextInt(10000))); - - break; - - case 1: - // Put/get int -> portable. - c.put(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000))); - - IgniteCache p4 = ((IgniteCacheProxy)c).keepPortable(); - - PortableObject v1 = p4.get(rnd.nextInt(10000)); - - if (v1 != null) - v1.deserialize(); - - p4.remove(rnd.nextInt(10000)); - - break; - - default: - assert false; - } - - cnt.add(3); - } - - return null; - } - }, - THREAD_CNT - ); - - for (int i = 0; i < 30 && !f.isDone(); i++) - Thread.sleep(1000); - - flag.set(true); - - f.get(); - - info("Operations in 30 sec: " + cnt.sum()); - } - - /** - */ - private static class TestObject implements PortableMarshalAware, Serializable { - /** */ - private int val; - - /** - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof TestObject && ((TestObject)obj).val == val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java deleted file mode 100644 index 7ac8712..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java +++ /dev/null @@ -1,978 +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.cache.portable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import javax.cache.Cache; -import javax.cache.processor.EntryProcessor; -import javax.cache.processor.MutableEntry; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgnitePortables; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.cache.store.CacheStoreAdapter; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.portable.PortableObjectImpl; -import org.apache.ignite.internal.processors.cache.GridCacheAdapter; -import org.apache.ignite.internal.processors.cache.GridCacheEntryEx; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.internal.util.typedef.P2; -import org.apache.ignite.internal.util.typedef.internal.CU; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiInClosure; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableBuilder; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.apache.ignite.transactions.Transaction; -import org.jetbrains.annotations.Nullable; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; -import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; -import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; - -/** - * Test for portable objects stored in cache. - */ -public abstract class GridCachePortableObjectsAbstractSelfTest extends GridCommonAbstractTest { - /** */ - public static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final int ENTRY_CNT = 100; - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheMode(cacheMode()); - cacheCfg.setAtomicityMode(atomicityMode()); - cacheCfg.setNearConfiguration(nearConfiguration()); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setCacheStoreFactory(singletonFactory(new TestStore())); - cacheCfg.setReadThrough(true); - cacheCfg.setWriteThrough(true); - cacheCfg.setLoadPreviousValue(true); - cacheCfg.setBackups(1); - - if (offheapTiered()) { - cacheCfg.setMemoryMode(OFFHEAP_TIERED); - cacheCfg.setOffHeapMaxMemory(0); - } - - cfg.setCacheConfiguration(cacheCfg); - - cfg.setMarshaller(new PortableMarshaller()); - - return cfg; - } - - /** - * @return {@code True} if should use OFFHEAP_TIERED mode. - */ - protected boolean offheapTiered() { - return false; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGridsMultiThreaded(gridCount()); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopAllGrids(); - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - for (int i = 0; i < gridCount(); i++) { - GridCacheAdapter c = ((IgniteKernal)grid(i)).internalCache(); - - for (GridCacheEntryEx e : c.map().entries0()) { - Object key = e.key().value(c.context().cacheObjectContext(), false); - Object val = CU.value(e.rawGet(), c.context(), false); - - if (key instanceof PortableObject) - assert ((PortableObjectImpl)key).detached() : val; - - if (val instanceof PortableObject) - assert ((PortableObjectImpl)val).detached() : val; - } - } - - IgniteCache c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.remove(i); - - if (offheapTiered()) { - for (int k = 0; k < 100; k++) - c.remove(k); - } - - assertEquals(0, c.size()); - } - - /** - * @return Cache mode. - */ - protected abstract CacheMode cacheMode(); - - /** - * @return Atomicity mode. - */ - protected abstract CacheAtomicityMode atomicityMode(); - - /** - * @return Distribution mode. - */ - protected abstract NearCacheConfiguration nearConfiguration(); - - /** - * @return Grid count. - */ - protected abstract int gridCount(); - - /** - * @throws Exception If failed. - */ - @SuppressWarnings("unchecked") - public void testCircularReference() throws Exception { - IgniteCache c = keepPortableCache(); - - TestReferenceObject obj1 = new TestReferenceObject(); - - obj1.obj = new TestReferenceObject(obj1); - - c.put(1, obj1); - - PortableObject po = (PortableObject)c.get(1); - - String str = po.toString(); - - log.info("toString: " + str); - - assertNotNull(str); - - assertTrue("Unexpected toString: " + str, - str.startsWith("TestReferenceObject") && str.contains("obj=TestReferenceObject [")); - - TestReferenceObject obj1_r = po.deserialize(); - - assertNotNull(obj1_r); - - TestReferenceObject obj2_r = obj1_r.obj; - - assertNotNull(obj2_r); - - assertSame(obj1_r, obj2_r.obj); - } - - /** - * @throws Exception If failed. - */ - public void testGet() throws Exception { - IgniteCache c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - TestObject obj = c.get(i); - - assertEquals(i, obj.val); - } - - IgniteCache kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - PortableObject po = kpc.get(i); - - assertEquals(i, (int)po.field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testIterator() throws Exception { - IgniteCache c = jcache(0); - - Map entries = new HashMap<>(); - - for (int i = 0; i < ENTRY_CNT; i++) { - TestObject val = new TestObject(i); - - c.put(i, val); - - entries.put(i, val); - } - - IgniteCache prj = ((IgniteCacheProxy)c).keepPortable(); - - Iterator> it = prj.iterator(); - - assertTrue(it.hasNext()); - - while (it.hasNext()) { - Cache.Entry entry = it.next(); - - assertTrue(entries.containsKey(entry.getKey())); - - TestObject o = entries.get(entry.getKey()); - - PortableObject po = entry.getValue(); - - assertEquals(o.val, (int)po.field("val")); - - entries.remove(entry.getKey()); - } - - assertEquals(0, entries.size()); - } - - /** - * @throws Exception If failed. - */ - public void testCollection() throws Exception { - IgniteCache> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) { - Collection col = new ArrayList<>(3); - - for (int j = 0; j < 3; j++) - col.add(new TestObject(i * 10 + j)); - - c.put(i, col); - } - - for (int i = 0; i < ENTRY_CNT; i++) { - Collection col = c.get(i); - - assertEquals(3, col.size()); - - Iterator it = col.iterator(); - - for (int j = 0; j < 3; j++) { - assertTrue(it.hasNext()); - - assertEquals(i * 10 + j, it.next().val); - } - } - - IgniteCache> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - Collection col = kpc.get(i); - - assertEquals(3, col.size()); - - Iterator it = col.iterator(); - - for (int j = 0; j < 3; j++) { - assertTrue(it.hasNext()); - - assertEquals(i * 10 + j, (int)it.next().field("val")); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testMap() throws Exception { - IgniteCache> c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) { - Map map = U.newHashMap(3); - - for (int j = 0; j < 3; j++) { - int idx = i * 10 + j; - - map.put(idx, new TestObject(idx)); - } - - c.put(i, map); - } - - for (int i = 0; i < ENTRY_CNT; i++) { - Map map = c.get(i); - - assertEquals(3, map.size()); - - for (int j = 0; j < 3; j++) { - int idx = i * 10 + j; - - assertEquals(idx, map.get(idx).val); - } - } - - IgniteCache> kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - Map map = kpc.get(i); - - assertEquals(3, map.size()); - - for (int j = 0; j < 3; j++) { - int idx = i * 10 + j; - - assertEquals(idx, (int)map.get(idx).field("val")); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAsync() throws Exception { - IgniteCache c = jcache(0); - - IgniteCache cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - cacheAsync.get(i); - TestObject obj = cacheAsync.future().get(); - - assertEquals(i, obj.val); - } - - IgniteCache kpc = keepPortableCache(); - - IgniteCache cachePortableAsync = kpc.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) { - cachePortableAsync.get(i); - - PortableObject po = cachePortableAsync.future().get(); - - assertEquals(i, (int)po.field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testGetTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - TestObject obj = c.get(i); - - assertEquals(i, obj.val); - - tx.commit(); - } - } - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - TestObject obj = c.get(i); - - assertEquals(i, obj.val); - - tx.commit(); - } - } - - IgniteCache kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - PortableObject po = kpc.get(i); - - assertEquals(i, (int)po.field("val")); - - tx.commit(); - } - } - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - PortableObject po = kpc.get(i); - - assertEquals(i, (int)po.field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAsyncTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache c = jcache(0); - - IgniteCache cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cacheAsync.get(i); - - TestObject obj = cacheAsync.future().get(); - - assertEquals(i, obj.val); - - tx.commit(); - } - } - - IgniteCache kpc = keepPortableCache(); - IgniteCache cachePortableAsync = kpc.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) { - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cachePortableAsync.get(i); - - PortableObject po = cachePortableAsync.future().get(); - - assertEquals(i, (int)po.field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAll() throws Exception { - IgniteCache c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - Map objs = c.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - } - - IgniteCache kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - Map objs = kpc.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAllAsync() throws Exception { - IgniteCache c = jcache(0); - - IgniteCache cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - cacheAsync.getAll(keys); - - Map objs = cacheAsync.>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - } - - IgniteCache kpc = keepPortableCache(); - IgniteCache cachePortableAsync = kpc.withAsync(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - - cachePortableAsync.getAll(keys); - - Map objs = cachePortableAsync.>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAllTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache c = jcache(0); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - Map objs = c.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - - tx.commit(); - } - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - Map objs = c.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - - tx.commit(); - } - } - - IgniteCache kpc = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - Map objs = kpc.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - - tx.commit(); - } - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) { - Map objs = kpc.getAll(keys); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testGetAllAsyncTx() throws Exception { - if (atomicityMode() != TRANSACTIONAL) - return; - - IgniteCache c = jcache(0); - IgniteCache cacheAsync = c.withAsync(); - - for (int i = 0; i < ENTRY_CNT; i++) - c.put(i, new TestObject(i)); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - cacheAsync.getAll(keys); - - Map objs = cacheAsync.>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(e.getKey().intValue(), e.getValue().val); - - tx.commit(); - } - } - - IgniteCache cache = keepPortableCache(); - - for (int i = 0; i < ENTRY_CNT; ) { - Set keys = new HashSet<>(); - - for (int j = 0; j < 10; j++) - keys.add(i++); - - IgniteCache asyncCache = cache.withAsync(); - - try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - asyncCache.getAll(keys); - - Map objs = asyncCache.>future().get(); - - assertEquals(10, objs.size()); - - for (Map.Entry e : objs.entrySet()) - assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val")); - - tx.commit(); - } - } - } - - /** - * @throws Exception If failed. - */ - public void testLoadCache() throws Exception { - for (int i = 0; i < gridCount(); i++) - jcache(i).localLoadCache(null); - - IgniteCache cache = jcache(0); - - assertEquals(3, cache.size(CachePeekMode.PRIMARY)); - - assertEquals(1, cache.get(1).val); - assertEquals(2, cache.get(2).val); - assertEquals(3, cache.get(3).val); - } - - /** - * @throws Exception If failed. - */ - public void testLoadCacheAsync() throws Exception { - for (int i = 0; i < gridCount(); i++) { - IgniteCache jcache = jcache(i).withAsync(); - - jcache.loadCache(null); - - jcache.future().get(); - } - - IgniteCache cache = jcache(0); - - assertEquals(3, cache.size(CachePeekMode.PRIMARY)); - - assertEquals(1, cache.get(1).val); - assertEquals(2, cache.get(2).val); - assertEquals(3, cache.get(3).val); - } - - /** - * @throws Exception If failed. - */ - public void testLoadCacheFilteredAsync() throws Exception { - for (int i = 0; i < gridCount(); i++) { - IgniteCache c = this.jcache(i).withAsync(); - - c.loadCache(new P2() { - @Override public boolean apply(Integer key, TestObject val) { - return val.val < 3; - } - }); - - c.future().get(); - } - - IgniteCache cache = jcache(0); - - assertEquals(2, cache.size(CachePeekMode.PRIMARY)); - - assertEquals(1, cache.get(1).val); - assertEquals(2, cache.get(2).val); - - assertNull(cache.get(3)); - } - - /** - * @throws Exception If failed. - */ - public void testTransform() throws Exception { - IgniteCache c = keepPortableCache(); - - checkTransform(primaryKey(c)); - - if (cacheMode() != CacheMode.LOCAL) { - checkTransform(backupKey(c)); - - if (nearConfiguration() != null) - checkTransform(nearKey(c)); - } - } - - /** - * @return Cache with keep portable flag. - */ - private IgniteCache keepPortableCache() { - return ignite(0).cache(null).withKeepPortable(); - } - - /** - * @param key Key. - * @throws Exception If failed. - */ - private void checkTransform(Integer key) throws Exception { - log.info("Transform: " + key); - - IgniteCache c = keepPortableCache(); - - try { - c.invoke(key, new EntryProcessor() { - @Override public Void process(MutableEntry e, Object... args) { - PortableObject val = e.getValue(); - - assertNull("Unexpected value: " + val, val); - - return null; - } - }); - - jcache(0).put(key, new TestObject(1)); - - c.invoke(key, new EntryProcessor() { - @Override public Void process(MutableEntry e, Object... args) { - PortableObject val = e.getValue(); - - assertNotNull("Unexpected value: " + val, val); - - assertEquals(new Integer(1), val.field("val")); - - Ignite ignite = e.unwrap(Ignite.class); - - IgnitePortables portables = ignite.portables(); - - PortableBuilder builder = portables.builder(val); - - builder.setField("val", 2); - - e.setValue(builder.build()); - - return null; - } - }); - - PortableObject obj = c.get(key); - - assertEquals(new Integer(2), obj.field("val")); - - c.invoke(key, new EntryProcessor() { - @Override public Void process(MutableEntry e, Object... args) { - PortableObject val = e.getValue(); - - assertNotNull("Unexpected value: " + val, val); - - assertEquals(new Integer(2), val.field("val")); - - e.setValue(val); - - return null; - } - }); - - obj = c.get(key); - - assertEquals(new Integer(2), obj.field("val")); - - c.invoke(key, new EntryProcessor() { - @Override public Void process(MutableEntry e, Object... args) { - PortableObject val = e.getValue(); - - assertNotNull("Unexpected value: " + val, val); - - assertEquals(new Integer(2), val.field("val")); - - e.remove(); - - return null; - } - }); - - assertNull(c.get(key)); - } - finally { - c.remove(key); - } - } - - /** - * - */ - private static class TestObject implements PortableMarshalAware { - /** */ - private int val; - - /** - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } - - /** - * - */ - private static class TestReferenceObject implements PortableMarshalAware { - /** */ - private TestReferenceObject obj; - - /** - */ - private TestReferenceObject() { - // No-op. - } - - /** - * @param obj Object. - */ - private TestReferenceObject(TestReferenceObject obj) { - this.obj = obj; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeObject("obj", obj); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - obj = reader.readObject("obj"); - } - } - - /** - * - */ - private static class TestStore extends CacheStoreAdapter { - /** {@inheritDoc} */ - @Override public void loadCache(IgniteBiInClosure clo, Object... args) { - for (int i = 1; i <= 3; i++) - clo.apply(i, new TestObject(i)); - } - - /** {@inheritDoc} */ - @Nullable @Override public Object load(Integer key) { - return null; - } - - /** {@inheritDoc} */ - @Override public void write(Cache.Entry e) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) { - // No-op. - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java deleted file mode 100644 index 7c605b5..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java +++ /dev/null @@ -1,297 +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.cache.portable; - -import com.google.common.collect.ImmutableSet; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import javax.cache.Cache; -import org.apache.ignite.cache.store.CacheStoreAdapter; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; -import org.jetbrains.annotations.Nullable; -import org.jsr166.ConcurrentHashMap8; - -/** - * Tests for cache store with portables. - */ -public abstract class GridCachePortableStoreAbstractSelfTest extends GridCommonAbstractTest { - /** */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final TestStore STORE = new TestStore(); - - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName())); - - cfg.setMarshaller(marsh); - - CacheConfiguration cacheCfg = new CacheConfiguration(); - - cacheCfg.setCacheStoreFactory(singletonFactory(STORE)); - cacheCfg.setKeepPortableInStore(keepPortableInStore()); - cacheCfg.setReadThrough(true); - cacheCfg.setWriteThrough(true); - cacheCfg.setLoadPreviousValue(true); - - cfg.setCacheConfiguration(cacheCfg); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - return cfg; - } - - /** - * @return Keep portables in store flag. - */ - protected abstract boolean keepPortableInStore(); - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - startGrid(); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - stopGrid(); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - STORE.map().clear(); - - jcache().clear(); - - assert jcache().size() == 0; - } - - /** - * @throws Exception If failed. - */ - public void testPut() throws Exception { - jcache().put(new Key(1), new Value(1)); - - checkMap(STORE.map(), 1); - } - - /** - * @throws Exception If failed. - */ - public void testPutAll() throws Exception { - Map map = new HashMap<>(); - - for (int i = 1; i <= 3; i++) - map.put(new Key(i), new Value(i)); - - jcache().putAll(map); - - checkMap(STORE.map(), 1, 2, 3); - } - - /** - * @throws Exception If failed. - */ - public void testLoad() throws Exception { - populateMap(STORE.map(), 1); - - Object val = jcache().get(new Key(1)); - - assertTrue(String.valueOf(val), val instanceof Value); - - assertEquals(1, ((Value)val).index()); - } - - /** - * @throws Exception If failed. - */ - public void testLoadAll() throws Exception { - populateMap(STORE.map(), 1, 2, 3); - - Set keys = new HashSet<>(); - - for (int i = 1; i <= 3; i++) - keys.add(new Key(i)); - - Map res = jcache().getAll(keys); - - assertEquals(3, res.size()); - - for (int i = 1; i <= 3; i++) { - Object val = res.get(new Key(i)); - - assertTrue(String.valueOf(val), val instanceof Value); - - assertEquals(i, ((Value)val).index()); - } - } - - /** - * @throws Exception If failed. - */ - public void testRemove() throws Exception { - for (int i = 1; i <= 3; i++) - jcache().put(new Key(i), new Value(i)); - - jcache().remove(new Key(1)); - - checkMap(STORE.map(), 2, 3); - } - - /** - * @throws Exception If failed. - */ - public void testRemoveAll() throws Exception { - for (int i = 1; i <= 3; i++) - jcache().put(new Key(i), new Value(i)); - - jcache().removeAll(ImmutableSet.of(new Key(1), new Key(2))); - - checkMap(STORE.map(), 3); - } - - /** - * @param map Map. - * @param idxs Indexes. - */ - protected abstract void populateMap(Map map, int... idxs); - - /** - * @param map Map. - * @param idxs Indexes. - */ - protected abstract void checkMap(Map map, int... idxs); - - /** - */ - protected static class Key { - /** */ - private int idx; - - /** - * @param idx Index. - */ - public Key(int idx) { - this.idx = idx; - } - - /** - * @return Index. - */ - int index() { - return idx; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - Key key = (Key)o; - - return idx == key.idx; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return idx; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Key [idx=" + idx + ']'; - } - } - - /** - */ - protected static class Value { - /** */ - private int idx; - - /** - * @param idx Index. - */ - public Value(int idx) { - this.idx = idx; - } - - /** - * @return Index. - */ - int index() { - return idx; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Value [idx=" + idx + ']'; - } - } - - /** - * - */ - private static class TestStore extends CacheStoreAdapter { - /** */ - private final Map map = new ConcurrentHashMap8<>(); - - /** {@inheritDoc} */ - @Nullable @Override public Object load(Object key) { - return map.get(key); - } - - /** {@inheritDoc} */ - @Override public void write(Cache.Entry e) { - map.put(e.getKey(), e.getValue()); - } - - /** {@inheritDoc} */ - @Override public void delete(Object key) { - map.remove(key); - } - - /** - * @return Map. - */ - Map map() { - return map; - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreObjectsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreObjectsSelfTest.java deleted file mode 100644 index 1c1c99e..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreObjectsSelfTest.java +++ /dev/null @@ -1,55 +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.cache.portable; - -import java.util.Map; - -/** - * Tests for cache store with portables. - */ -public class GridCachePortableStoreObjectsSelfTest extends GridCachePortableStoreAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected boolean keepPortableInStore() { - return false; - } - - /** {@inheritDoc} */ - @Override protected void populateMap(Map map, int... idxs) { - assert map != null; - assert idxs != null; - - for (int idx : idxs) - map.put(new Key(idx), new Value(idx)); - } - - /** {@inheritDoc} */ - @Override protected void checkMap(Map map, int... idxs) { - assert map != null; - assert idxs != null; - - assertEquals(idxs.length, map.size()); - - for (int idx : idxs) { - Object val = map.get(new Key(idx)); - - assertTrue(String.valueOf(val), val instanceof Value); - - assertEquals(idx, ((Value)val).index()); - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java deleted file mode 100644 index 5c0fc8e..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStorePortablesSelfTest.java +++ /dev/null @@ -1,66 +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.cache.portable; - -import java.util.Map; -import org.apache.ignite.portable.PortableObject; - -/** - * Tests for cache store with portables. - */ -public class GridCachePortableStorePortablesSelfTest extends GridCachePortableStoreAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected boolean keepPortableInStore() { - return true; - } - - /** {@inheritDoc} */ - @Override protected void populateMap(Map map, int... idxs) { - assert map != null; - assert idxs != null; - - for (int idx : idxs) - map.put(portable(new Key(idx)), portable(new Value(idx))); - } - - /** {@inheritDoc} */ - @Override protected void checkMap(Map map, int... idxs) { - assert map != null; - assert idxs != null; - - assertEquals(idxs.length, map.size()); - - for (int idx : idxs) { - Object val = map.get(portable(new Key(idx))); - - assertTrue(String.valueOf(val), val instanceof PortableObject); - - PortableObject po = (PortableObject)val; - - assertEquals("Value", po.metaData().typeName()); - assertEquals(new Integer(idx), po.field("idx")); - } - } - - /** - * @param obj Object. - * @return Portable object. - */ - private Object portable(Object obj) { - return grid().portables().toPortable(obj); - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java deleted file mode 100644 index 0db650e..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java +++ /dev/null @@ -1,55 +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.cache.portable; - -import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.portable.PortableContext; -import org.apache.ignite.internal.portable.PortableMetaDataHandler; -import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfTest; -import org.apache.ignite.internal.util.IgniteUtils; -import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.marshaller.MarshallerContextTestImpl; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; - -/** - * - */ -public class GridPortableCacheEntryMemorySizeSelfTest extends GridCacheEntryMemorySizeSelfTest { - /** {@inheritDoc} */ - @Override protected Marshaller createMarshaller() throws IgniteCheckedException { - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setContext(new MarshallerContextTestImpl(null)); - - PortableContext pCtx = new PortableContext(new PortableMetaDataHandler() { - @Override public void addMeta(int typeId, PortableMetadata meta) throws PortableException { - // No-op - } - - @Override public PortableMetadata metadata(int typeId) throws PortableException { - return null; - } - }, null); - - IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", pCtx); - - return marsh; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java deleted file mode 100644 index a1a623b..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java +++ /dev/null @@ -1,158 +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.cache.portable; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.cache.CacheTypeMetadata; -import org.apache.ignite.cache.query.SqlFieldsQuery; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest; -import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableObject; - -/** - * Tests that portable object is the same in cache entry and in index. - */ -public abstract class GridPortableDuplicateIndexObjectsAbstractSelfTest extends GridCacheAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Collections.singletonList(TestPortable.class.getName())); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { - CacheConfiguration ccfg = super.cacheConfiguration(gridName); - - ccfg.setCopyOnRead(false); - - CacheTypeMetadata meta = new CacheTypeMetadata(); - - meta.setKeyType(Integer.class); - meta.setValueType(TestPortable.class.getName()); - - Map> idx = new HashMap<>(); - - idx.put("fieldOne", String.class); - idx.put("fieldTwo", Integer.class); - - meta.setAscendingFields(idx); - - ccfg.setTypeMetadata(Collections.singletonList(meta)); - - return ccfg; - } - - /** {@inheritDoc} */ - @Override public abstract CacheAtomicityMode atomicityMode(); - - /** {@inheritDoc} */ - @Override public abstract CacheMode cacheMode(); - - /** - * @throws Exception If failed. - */ - public void testIndexReferences() throws Exception { - IgniteCache cache = grid(0).cache(null); - - String fieldOneVal = "123"; - int fieldTwoVal = 123; - int key = 0; - - cache.put(key, new TestPortable(fieldOneVal, fieldTwoVal)); - - IgniteCache prj = grid(0).cache(null).withKeepPortable(); - - PortableObject cacheVal = prj.get(key); - - assertEquals(fieldOneVal, cacheVal.field("fieldOne")); - assertEquals(new Integer(fieldTwoVal), cacheVal.field("fieldTwo")); - - List row = F.first(prj.query(new SqlFieldsQuery("select _val from " + - "TestPortable where _key = ?").setArgs(key)).getAll()); - - assertEquals(1, row.size()); - - PortableObject qryVal = (PortableObject)row.get(0); - - assertEquals(fieldOneVal, qryVal.field("fieldOne")); - assertEquals(new Integer(fieldTwoVal), qryVal.field("fieldTwo")); - assertSame(cacheVal, qryVal); - } - - /** - * Test portable object. - */ - private static class TestPortable { - /** */ - private String fieldOne; - - /** */ - private int fieldTwo; - - /** - * - */ - private TestPortable() { - // No-op. - } - - /** - * @param fieldOne Field one. - * @param fieldTwo Field two. - */ - private TestPortable(String fieldOne, int fieldTwo) { - this.fieldOne = fieldOne; - this.fieldTwo = fieldTwo; - } - - /** - * @return Field one. - */ - public String fieldOne() { - return fieldOne; - } - - /** - * @return Field two. - */ - public int fieldTwo() { - return fieldTwo; - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java deleted file mode 100644 index 836440a..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java +++ /dev/null @@ -1,66 +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.cache.portable.datastreaming; - -import java.util.Collection; -import java.util.Map; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.stream.StreamReceiver; - -/** - * - */ -public class DataStreamProcessorPortableSelfTest extends DataStreamProcessorSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected StreamReceiver getStreamReceiver() { - return new TestDataReceiver(); - } - - /** - * - */ - private static class TestDataReceiver implements StreamReceiver { - /** {@inheritDoc} */ - @Override public void receive(IgniteCache cache, - Collection> entries) { - for (Map.Entry e : entries) { - assertTrue(e.getKey() instanceof String); - assertTrue(e.getValue() instanceof PortableObject); - - TestObject obj = ((PortableObject)e.getValue()).deserialize(); - - cache.put(e.getKey(), new TestObject(obj.val + 1)); - } - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java deleted file mode 100644 index 2f7bdb0..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java +++ /dev/null @@ -1,345 +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.cache.portable.datastreaming; - -import java.io.Serializable; -import java.util.Map; -import java.util.Random; -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.IgniteDataStreamer; -import org.apache.ignite.cache.CachePeekMode; -import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.configuration.CacheConfiguration; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.IgniteCacheProxy; -import org.apache.ignite.internal.util.typedef.G; -import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMarshalAware; -import org.apache.ignite.portable.PortableObject; -import org.apache.ignite.portable.PortableReader; -import org.apache.ignite.portable.PortableWriter; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; -import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; - -import static org.apache.ignite.cache.CacheMode.PARTITIONED; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; - -/** - * Tests for {@code IgniteDataStreamerImpl}. - */ -public class GridDataStreamerImplSelfTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - - /** Number of keys to load via data streamer. */ - private static final int KEYS_COUNT = 1000; - - /** Flag indicating should be cache configured with portables or not. */ - private static boolean portables; - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); - discoSpi.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(discoSpi); - - if (portables) { - PortableMarshaller marsh = new PortableMarshaller(); - - cfg.setMarshaller(marsh); - } - - cfg.setCacheConfiguration(cacheConfiguration()); - - return cfg; - } - - /** - * Gets cache configuration. - * - * @return Cache configuration. - */ - private CacheConfiguration cacheConfiguration() { - CacheConfiguration cacheCfg = defaultCacheConfiguration(); - - cacheCfg.setCacheMode(PARTITIONED); - cacheCfg.setNearConfiguration(null); - cacheCfg.setBackups(0); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - - return cacheCfg; - } - - /** - * Data streamer should correctly load entries from HashMap in case of grids with more than one node - * and with GridOptimizedMarshaller that requires serializable. - * - * @throws Exception If failed. - */ - public void testAddDataFromMap() throws Exception { - try { - portables = false; - - startGrids(2); - - awaitPartitionMapExchange(); - - Ignite g0 = grid(0); - - IgniteDataStreamer dataLdr = g0.dataStreamer(null); - - Map map = U.newHashMap(KEYS_COUNT); - - for (int i = 0; i < KEYS_COUNT; i ++) - map.put(i, String.valueOf(i)); - - dataLdr.addData(map); - - dataLdr.close(); - - checkDistribution(grid(0)); - - checkDistribution(grid(1)); - - // Check several random keys in cache. - Random rnd = new Random(); - - IgniteCache c0 = g0.cache(null); - - for (int i = 0; i < 100; i ++) { - Integer k = rnd.nextInt(KEYS_COUNT); - - String v = c0.get(k); - - assertEquals(k.toString(), v); - } - } - finally { - G.stopAll(true); - } - } - - /** - * Data streamer should add portable object that weren't registered explicitly. - * - * @throws Exception If failed. - */ - public void testAddMissingPortable() throws Exception { - try { - portables = true; - - startGrids(2); - - awaitPartitionMapExchange(); - - Ignite g0 = grid(0); - - IgniteDataStreamer dataLdr = g0.dataStreamer(null); - - dataLdr.perNodeBufferSize(1); - dataLdr.autoFlushFrequency(1L); - - Map map = U.newHashMap(KEYS_COUNT); - - for (int i = 0; i < KEYS_COUNT; i ++) - map.put(i, new TestObject2(i)); - - dataLdr.addData(map).get(); - - dataLdr.close(); - } - finally { - G.stopAll(true); - } - } - - /** - * Data streamer should correctly load portable entries from HashMap in case of grids with more than one node - * and with GridOptimizedMarshaller that requires serializable. - * - * @throws Exception If failed. - */ - public void testAddPortableDataFromMap() throws Exception { - try { - portables = true; - - startGrids(2); - - awaitPartitionMapExchange(); - - Ignite g0 = grid(0); - - IgniteDataStreamer dataLdr = g0.dataStreamer(null); - - Map map = U.newHashMap(KEYS_COUNT); - - for (int i = 0; i < KEYS_COUNT; i ++) - map.put(i, new TestObject(i)); - - dataLdr.addData(map); - - dataLdr.close(false); - - checkDistribution(grid(0)); - - checkDistribution(grid(1)); - - // Read random keys. Take values as TestObject. - Random rnd = new Random(); - - IgniteCache c = g0.cache(null); - - for (int i = 0; i < 100; i ++) { - Integer k = rnd.nextInt(KEYS_COUNT); - - TestObject v = c.get(k); - - assertEquals(k, v.val()); - } - - // Read random keys. Take values as PortableObject. - IgniteCache c2 = ((IgniteCacheProxy)c).keepPortable(); - - for (int i = 0; i < 100; i ++) { - Integer k = rnd.nextInt(KEYS_COUNT); - - PortableObject v = c2.get(k); - - assertEquals(k, v.field("val")); - } - } - finally { - G.stopAll(true); - } - } - - /** - * Check that keys correctly destributed by nodes after data streamer. - * - * @param g Grid to check. - */ - private void checkDistribution(Ignite g) { - ClusterNode n = g.cluster().localNode(); - IgniteCache c = g.cache(null); - - // Check that data streamer correctly split data by nodes. - for (int i = 0; i < KEYS_COUNT; i ++) { - if (g.affinity(null).isPrimary(n, i)) - assertNotNull(c.localPeek(i, CachePeekMode.ONHEAP)); - else - assertNull(c.localPeek(i, CachePeekMode.ONHEAP)); - } - } - - /** - */ - private static class TestObject implements PortableMarshalAware, Serializable { - /** */ - private int val; - - /** - * - */ - private TestObject() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject(int val) { - this.val = val; - } - - public Integer val() { - return val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof TestObject && ((TestObject)obj).val == val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } - - /** - */ - private static class TestObject2 implements PortableMarshalAware, Serializable { - /** */ - private int val; - - /** - */ - private TestObject2() { - // No-op. - } - - /** - * @param val Value. - */ - private TestObject2(int val) { - this.val = val; - } - - public Integer val() { - return val; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return val; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return obj instanceof TestObject2 && ((TestObject2)obj).val == val; - } - - /** {@inheritDoc} */ - @Override public void writePortable(PortableWriter writer) throws PortableException { - writer.writeInt("val", val); - } - - /** {@inheritDoc} */ - @Override public void readPortable(PortableReader reader) throws PortableException { - val = reader.readInt("val"); - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java deleted file mode 100644 index 155ba48..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java +++ /dev/null @@ -1,47 +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.cache.portable.distributed.dht; - -import java.util.Collections; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableTypeConfiguration; - -/** - * - */ -public class GridCacheAffinityRoutingPortableSelfTest extends GridCacheAffinityRoutingSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableTypeConfiguration typeCfg = new PortableTypeConfiguration(); - - typeCfg.setClassName(AffinityTestKey.class.getName()); - typeCfg.setAffinityKeyFieldName("affKey"); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setTypeConfigurations(Collections.singleton(typeCfg)); - - cfg.setMarshaller(marsh); - - return cfg; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest.java deleted file mode 100644 index b3b988e..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest.java +++ /dev/null @@ -1,29 +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.cache.portable.distributed.dht; - -/** - * - */ -public class GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest extends - GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest { - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest.java deleted file mode 100644 index 3f8cd1c..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest.java +++ /dev/null @@ -1,47 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractDataStreamerSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * - */ -public class GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest extends - GridCachePortableObjectsAbstractDataStreamerSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest.java deleted file mode 100644 index a53a5ea..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest.java +++ /dev/null @@ -1,28 +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.cache.portable.distributed.dht; - -/** - * - */ -public class GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest extends - GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest { - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 4; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest.java deleted file mode 100644 index 8f3a05f..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest.java +++ /dev/null @@ -1,47 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractMultiThreadedSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * - */ -public class GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest extends - GridCachePortableObjectsAbstractMultiThreadedSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java deleted file mode 100644 index ab6b0dd..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.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.internal.processors.cache.portable.distributed.dht; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheMemoryModeSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * Memory models test. - */ -public class GridCacheMemoryModePortableSelfTest extends GridCacheMemoryModeSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setMarshaller(new PortableMarshaller()); - - return cfg; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java deleted file mode 100644 index c845257..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java +++ /dev/null @@ -1,47 +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.cache.portable.distributed.dht; - -import java.util.Arrays; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredAtomicSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * - */ -public class GridCacheOffHeapTieredAtomicPortableSelfTest extends GridCacheOffHeapTieredAtomicSelfTest { - /** {@inheritDoc} */ - @Override protected boolean portableEnabled() { - return true; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - // Enable portables. - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList(TestValue.class.getName())); - - cfg.setMarshaller(marsh); - - return cfg; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java deleted file mode 100644 index 1a0d601..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java +++ /dev/null @@ -1,95 +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.cache.portable.distributed.dht; - -import java.util.Arrays; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionAtomicSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableObject; - -/** - * - */ -public class GridCacheOffHeapTieredEvictionAtomicPortableSelfTest extends GridCacheOffHeapTieredEvictionAtomicSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - // Enable portables. - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList(TestValue.class.getName())); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected TestPredicate testPredicate(String expVal, boolean acceptNull) { - return new PortableValuePredicate(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override protected TestProcessor testClosure(String expVal, boolean acceptNull) { - return new PortableValueClosure(expVal, acceptNull); - } - - /** - * - */ - @SuppressWarnings("PackageVisibleInnerClass") - static class PortableValuePredicate extends TestPredicate { - /** - * @param expVal Expected value. - * @param acceptNull If {@code true} value can be null; - */ - PortableValuePredicate(String expVal, boolean acceptNull) { - super(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override public void checkValue(Object val) { - PortableObject obj = (PortableObject)val; - - assertEquals(expVal, obj.field("val")); - } - } - - /** - * - */ - @SuppressWarnings("PackageVisibleInnerClass") - static class PortableValueClosure extends TestProcessor { - /** - * @param expVal Expected value. - * @param acceptNull If {@code true} value can be null; - */ - PortableValueClosure(String expVal, boolean acceptNull) { - super(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override public void checkValue(Object val) { - PortableObject obj = (PortableObject)val; - - assertEquals(expVal, obj.field("val")); - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java deleted file mode 100644 index 60eed45..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java +++ /dev/null @@ -1,95 +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.cache.portable.distributed.dht; - -import java.util.Arrays; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.portable.PortableObject; - -/** - * - */ -public class GridCacheOffHeapTieredEvictionPortableSelfTest extends GridCacheOffHeapTieredEvictionSelfTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - // Enable portables. - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList(TestValue.class.getName())); - - cfg.setMarshaller(marsh); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected TestPredicate testPredicate(String expVal, boolean acceptNull) { - return new PortableValuePredicate(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override protected TestProcessor testClosure(String expVal, boolean acceptNull) { - return new PortableValueClosure(expVal, acceptNull); - } - - /** - * - */ - @SuppressWarnings("PackageVisibleInnerClass") - static class PortableValuePredicate extends TestPredicate { - /** - * @param expVal Expected value. - * @param acceptNull If {@code true} value can be null; - */ - PortableValuePredicate(String expVal, boolean acceptNull) { - super(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override public void checkValue(Object val) { - PortableObject obj = (PortableObject)val; - - assertEquals(expVal, obj.field("val")); - } - } - - /** - * - */ - @SuppressWarnings("PackageVisibleInnerClass") - static class PortableValueClosure extends TestProcessor { - /** - * @param expVal Expected value. - * @param acceptNull If {@code true} value can be null; - */ - PortableValueClosure(String expVal, boolean acceptNull) { - super(expVal, acceptNull); - } - - /** {@inheritDoc} */ - @Override public void checkValue(Object val) { - PortableObject obj = (PortableObject)val; - - assertEquals(expVal, obj.field("val")); - } - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java deleted file mode 100644 index 6170e39..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java +++ /dev/null @@ -1,47 +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.cache.portable.distributed.dht; - -import java.util.Arrays; -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * - */ -public class GridCacheOffHeapTieredPortableSelfTest extends GridCacheOffHeapTieredSelfTest { - /** {@inheritDoc} */ - @Override protected boolean portableEnabled() { - return true; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - // Enable portables. - IgniteConfiguration cfg = super.getConfiguration(gridName); - - PortableMarshaller marsh = new PortableMarshaller(); - - marsh.setClassNames(Arrays.asList(TestValue.class.getName())); - - cfg.setMarshaller(marsh); - - return cfg; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest.java deleted file mode 100644 index e6f7499..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest.java +++ /dev/null @@ -1,38 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.internal.processors.cache.portable.GridPortableDuplicateIndexObjectsAbstractSelfTest; - -/** - * Test PARTITIONED ATOMIC. - */ -public class GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest extends - GridPortableDuplicateIndexObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override public CacheAtomicityMode atomicityMode() { - return CacheAtomicityMode.ATOMIC; - } - - /** {@inheritDoc} */ - @Override public CacheMode cacheMode() { - return CacheMode.PARTITIONED; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest.java deleted file mode 100644 index b5dc4e9..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest.java +++ /dev/null @@ -1,41 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.internal.processors.cache.portable.GridPortableDuplicateIndexObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * Test PARTITIONED and TRANSACTIONAL. - */ -public class GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest extends - GridPortableDuplicateIndexObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override public CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override public CacheMode cacheMode() { - return PARTITIONED; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest.java deleted file mode 100644 index a5c28f3..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest.java +++ /dev/null @@ -1,29 +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.cache.portable.distributed.dht; - -/** - * - */ -public class GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest - extends GridCachePortableObjectsAtomicNearDisabledSelfTest { - /** {@inheritDoc} */ - @Override protected boolean offheapTiered() { - return true; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicNearDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicNearDisabledSelfTest.java deleted file mode 100644 index 696c3ed..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicNearDisabledSelfTest.java +++ /dev/null @@ -1,51 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * Test for portable objects stored in cache. - */ -public class GridCachePortableObjectsAtomicNearDisabledSelfTest extends GridCachePortableObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 3; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicOffheapTieredSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicOffheapTieredSelfTest.java deleted file mode 100644 index 8e04fa1..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicOffheapTieredSelfTest.java +++ /dev/null @@ -1,29 +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.cache.portable.distributed.dht; - -/** - * - */ -public class GridCachePortableObjectsAtomicOffheapTieredSelfTest extends GridCachePortableObjectsAtomicSelfTest { - /** {@inheritDoc} */ - @Override protected boolean offheapTiered() { - return true; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicSelfTest.java deleted file mode 100644 index 106e59b..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsAtomicSelfTest.java +++ /dev/null @@ -1,51 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * Test for portable objects stored in cache. - */ -public class GridCachePortableObjectsAtomicSelfTest extends GridCachePortableObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return new NearCacheConfiguration(); - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 3; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest.java deleted file mode 100644 index 5bc4672..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest.java +++ /dev/null @@ -1,30 +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.cache.portable.distributed.dht; - -/** - * - */ -public class GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest - extends GridCachePortableObjectsPartitionedNearDisabledSelfTest{ - /** {@inheritDoc} */ - @Override protected boolean offheapTiered() { - return true; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedNearDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedNearDisabledSelfTest.java deleted file mode 100644 index df55de7..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedNearDisabledSelfTest.java +++ /dev/null @@ -1,51 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * Test for portable objects stored in cache. - */ -public class GridCachePortableObjectsPartitionedNearDisabledSelfTest extends GridCachePortableObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 3; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedOffheapTieredSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedOffheapTieredSelfTest.java deleted file mode 100644 index a6bc0b4..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedOffheapTieredSelfTest.java +++ /dev/null @@ -1,30 +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.cache.portable.distributed.dht; - -/** - * - */ -public class GridCachePortableObjectsPartitionedOffheapTieredSelfTest - extends GridCachePortableObjectsPartitionedSelfTest { - /** {@inheritDoc} */ - @Override protected boolean offheapTiered() { - return true; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedSelfTest.java deleted file mode 100644 index 8c248be..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortableObjectsPartitionedSelfTest.java +++ /dev/null @@ -1,51 +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.cache.portable.distributed.dht; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.PARTITIONED; - -/** - * Test for portable objects stored in cache. - */ -public class GridCachePortableObjectsPartitionedSelfTest extends GridCachePortableObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return PARTITIONED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return new NearCacheConfiguration(); - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 3; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java deleted file mode 100644 index d984756..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java +++ /dev/null @@ -1,41 +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.cache.portable.distributed.dht; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAbstractNearPartitionedByteArrayValuesSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * - */ -public class GridCachePortablesNearPartitionedByteArrayValuesSelfTest - extends GridCacheAbstractNearPartitionedByteArrayValuesSelfTest { - /** {@inheritDoc} */ - @Override protected boolean peerClassLoading() { - return false; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setMarshaller(new PortableMarshaller()); - - return cfg; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java deleted file mode 100644 index 5830b12..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java +++ /dev/null @@ -1,42 +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.cache.portable.distributed.dht; - -import org.apache.ignite.configuration.IgniteConfiguration; -import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; - -/** - * - */ -public class GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest - extends GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest { - /** {@inheritDoc} */ - @Override protected boolean peerClassLoading() { - return false; - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setMarshaller(new PortableMarshaller()); - - return cfg; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/replicated/GridCachePortableObjectsReplicatedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/replicated/GridCachePortableObjectsReplicatedSelfTest.java deleted file mode 100644 index 953fbfa..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/replicated/GridCachePortableObjectsReplicatedSelfTest.java +++ /dev/null @@ -1,51 +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.cache.portable.distributed.replicated; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.REPLICATED; - -/** - * Test for portable objects stored in cache. - */ -public class GridCachePortableObjectsReplicatedSelfTest extends GridCachePortableObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return REPLICATED; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 3; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsAtomicLocalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsAtomicLocalSelfTest.java deleted file mode 100644 index 3f3a350..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsAtomicLocalSelfTest.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.internal.processors.cache.portable.local; - -import org.apache.ignite.cache.CacheAtomicityMode; - -import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC; - -/** - * - */ -public class GridCachePortableObjectsAtomicLocalSelfTest extends GridCachePortableObjectsLocalSelfTest { - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return ATOMIC; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsLocalOffheapTieredSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsLocalOffheapTieredSelfTest.java deleted file mode 100644 index 53713ce..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsLocalOffheapTieredSelfTest.java +++ /dev/null @@ -1,29 +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.cache.portable.local; - -/** - * - */ -public class GridCachePortableObjectsLocalOffheapTieredSelfTest extends GridCachePortableObjectsLocalSelfTest { - /** {@inheritDoc} */ - @Override protected boolean offheapTiered() { - return true; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsLocalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsLocalSelfTest.java deleted file mode 100644 index 1a87865..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/local/GridCachePortableObjectsLocalSelfTest.java +++ /dev/null @@ -1,51 +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.cache.portable.local; - -import org.apache.ignite.cache.CacheAtomicityMode; -import org.apache.ignite.cache.CacheMode; -import org.apache.ignite.configuration.NearCacheConfiguration; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableObjectsAbstractSelfTest; - -import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; -import static org.apache.ignite.cache.CacheMode.LOCAL; - -/** - * Test for portable objects stored in cache. - */ -public class GridCachePortableObjectsLocalSelfTest extends GridCachePortableObjectsAbstractSelfTest { - /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { - return LOCAL; - } - - /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { - return TRANSACTIONAL; - } - - /** {@inheritDoc} */ - @Override protected NearCacheConfiguration nearConfiguration() { - return null; - } - - /** {@inheritDoc} */ - @Override protected int gridCount() { - return 1; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java index 1e4c828..6299fe8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java @@ -35,7 +35,7 @@ import org.apache.ignite.IgniteEvents; import org.apache.ignite.IgniteFileSystem; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteMessaging; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.IgniteQueue; import org.apache.ignite.IgniteScheduler; import org.apache.ignite.IgniteServices; @@ -271,11 +271,6 @@ public class IgniteMock implements Ignite { } /** {@inheritDoc} */ - @Override public IgnitePortables portables() { - return null; - } - - /** {@inheritDoc} */ @Override public void close() {} @Nullable @Override public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create) { diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java index 2b448f8..dfbb0ae 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java @@ -153,11 +153,6 @@ public class IgniteCacheProcessProxy implements IgniteCache { } /** {@inheritDoc} */ - @Override public IgniteCache withKeepPortable() { - throw new UnsupportedOperationException("Method should be supported."); - } - - /** {@inheritDoc} */ @Override public void loadCache(@Nullable IgniteBiPredicate p, @Nullable Object... args) throws CacheException { throw new UnsupportedOperationException("Method should be supported."); } diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java index 3522407..ec7dab7 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java @@ -41,7 +41,7 @@ import org.apache.ignite.IgniteFileSystem; import org.apache.ignite.IgniteIllegalStateException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.IgniteMessaging; -import org.apache.ignite.IgnitePortables; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.IgniteQueue; import org.apache.ignite.IgniteScheduler; import org.apache.ignite.IgniteServices; diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java deleted file mode 100644 index d7dda61..0000000 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.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.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.testframework.config.GridTestProperties; - -/** - * Cache full API suite with portable marshaller. - */ -public class IgnitePortableCacheFullApiTestSuite extends TestSuite { - /** - * @return Suite. - * @throws Exception In case of error. - */ - public static TestSuite suite() throws Exception { - GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName()); - - return IgniteCacheFullApiSelfTestSuite.suite(); - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java deleted file mode 100644 index db20e48..0000000 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java +++ /dev/null @@ -1,103 +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.testsuites; - -import java.util.HashSet; -import junit.framework.TestSuite; -import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheMvccSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredSelfTest; -import org.apache.ignite.internal.processors.cache.expiry.IgniteCacheAtomicLocalExpiryPolicyTest; -import org.apache.ignite.internal.processors.cache.expiry.IgniteCacheExpiryPolicyTestSuite; -import org.apache.ignite.internal.processors.cache.portable.GridPortableCacheEntryMemorySizeSelfTest; -import org.apache.ignite.internal.processors.cache.portable.datastreaming.DataStreamProcessorPortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.datastreaming.GridDataStreamerImplSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheAffinityRoutingPortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheMemoryModePortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheOffHeapTieredAtomicPortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheOffHeapTieredEvictionAtomicPortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheOffHeapTieredEvictionPortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCacheOffHeapTieredPortableSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortablesNearPartitionedByteArrayValuesSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest; -import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.testframework.config.GridTestProperties; - -/** - * Cache suite with portable marshaller. - */ -public class IgnitePortableCacheTestSuite extends TestSuite { - /** - * @return Suite. - * @throws Exception In case of error. - */ - public static TestSuite suite() throws Exception { - GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName()); - - TestSuite suite = new TestSuite("Portable Cache Test Suite"); - - HashSet ignoredTests = new HashSet<>(); - - // Tests below have a special version for Portable Marshaller - ignoredTests.add(DataStreamProcessorSelfTest.class); - ignoredTests.add(GridCacheOffHeapTieredEvictionAtomicSelfTest.class); - ignoredTests.add(GridCacheOffHeapTieredEvictionSelfTest.class); - ignoredTests.add(GridCacheOffHeapTieredSelfTest.class); - ignoredTests.add(GridCacheOffHeapTieredAtomicSelfTest.class); - ignoredTests.add(GridCacheAffinityRoutingSelfTest.class); - ignoredTests.add(IgniteCacheAtomicLocalExpiryPolicyTest.class); - ignoredTests.add(GridCacheEntryMemorySizeSelfTest.class); - - // Tests that are not ready to be used with PortableMarshaller - ignoredTests.add(GridCacheMvccSelfTest.class); - - suite.addTest(IgniteCacheTestSuite.suite(ignoredTests)); - suite.addTest(IgniteCacheExpiryPolicyTestSuite.suite()); - - suite.addTestSuite(GridCacheMemoryModePortableSelfTest.class); - suite.addTestSuite(GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.class); - suite.addTestSuite(GridCacheOffHeapTieredEvictionPortableSelfTest.class); - - suite.addTestSuite(GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCachePortablesNearPartitionedByteArrayValuesSelfTest.class); - suite.addTestSuite(GridCacheOffHeapTieredPortableSelfTest.class); - suite.addTestSuite(GridCacheOffHeapTieredAtomicPortableSelfTest.class); - - suite.addTestSuite(GridDataStreamerImplSelfTest.class); - suite.addTestSuite(DataStreamProcessorPortableSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableDataStreamerMultiNodeSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableDataStreamerMultithreadedSelfTest.class); - - suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableMultiNodeSelfTest.class); - suite.addTestSuite(GridCacheAtomicPartitionedOnlyPortableMultithreadedSelfTest.class); - - suite.addTestSuite(GridCacheAffinityRoutingPortableSelfTest.class); - suite.addTestSuite(GridPortableCacheEntryMemorySizeSelfTest.class); - - return suite; - } -} \ No newline at end of file diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java deleted file mode 100644 index ecd25e1..0000000 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java +++ /dev/null @@ -1,92 +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.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.internal.portable.GridPortableAffinityKeySelfTest; -import org.apache.ignite.internal.portable.GridPortableBuilderAdditionalSelfTest; -import org.apache.ignite.internal.portable.GridPortableBuilderSelfTest; -import org.apache.ignite.internal.portable.GridPortableBuilderStringAsCharsAdditionalSelfTest; -import org.apache.ignite.internal.portable.GridPortableBuilderStringAsCharsSelfTest; -import org.apache.ignite.internal.portable.GridPortableMarshallerCtxDisabledSelfTest; -import org.apache.ignite.internal.portable.GridPortableMarshallerSelfTest; -import org.apache.ignite.internal.portable.GridPortableMetaDataDisabledSelfTest; -import org.apache.ignite.internal.portable.GridPortableMetaDataSelfTest; -import org.apache.ignite.internal.portable.GridPortableWildcardsSelfTest; -import org.apache.ignite.internal.processors.cache.portable.GridCacheClientNodePortableMetadataMultinodeTest; -import org.apache.ignite.internal.processors.cache.portable.GridCacheClientNodePortableMetadataTest; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableStoreObjectsSelfTest; -import org.apache.ignite.internal.processors.cache.portable.GridCachePortableStorePortablesSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsAtomicNearDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsAtomicOffheapTieredSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsPartitionedNearDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsPartitionedOffheapTieredSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableObjectsPartitionedSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.replicated.GridCachePortableObjectsReplicatedSelfTest; -import org.apache.ignite.internal.processors.cache.portable.local.GridCachePortableObjectsAtomicLocalSelfTest; -import org.apache.ignite.internal.processors.cache.portable.local.GridCachePortableObjectsLocalOffheapTieredSelfTest; -import org.apache.ignite.internal.processors.cache.portable.local.GridCachePortableObjectsLocalSelfTest; - -/** - * Test for portable objects stored in cache. - */ -public class IgnitePortableObjectsTestSuite extends TestSuite { - /** - * @return Suite. - * @throws Exception If failed. - */ - public static TestSuite suite() throws Exception { - TestSuite suite = new TestSuite("GridGain Portable Objects Test Suite"); - - suite.addTestSuite(GridPortableMarshallerSelfTest.class); - suite.addTestSuite(GridPortableMarshallerCtxDisabledSelfTest.class); - suite.addTestSuite(GridPortableBuilderSelfTest.class); - suite.addTestSuite(GridPortableBuilderStringAsCharsSelfTest.class); - suite.addTestSuite(GridPortableMetaDataSelfTest.class); - suite.addTestSuite(GridPortableMetaDataDisabledSelfTest.class); - suite.addTestSuite(GridPortableAffinityKeySelfTest.class); - suite.addTestSuite(GridPortableWildcardsSelfTest.class); - suite.addTestSuite(GridPortableBuilderAdditionalSelfTest.class); - suite.addTestSuite(GridPortableBuilderStringAsCharsAdditionalSelfTest.class); - - suite.addTestSuite(GridCachePortableObjectsLocalSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsAtomicLocalSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsReplicatedSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsPartitionedSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsPartitionedNearDisabledSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsAtomicSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsAtomicNearDisabledSelfTest.class); - - suite.addTestSuite(GridCachePortableObjectsLocalOffheapTieredSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsAtomicOffheapTieredSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsAtomicNearDisabledOffheapTieredSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsPartitionedOffheapTieredSelfTest.class); - suite.addTestSuite(GridCachePortableObjectsPartitionedNearDisabledOffheapTieredSelfTest.class); - - suite.addTestSuite(GridCachePortableStoreObjectsSelfTest.class); - suite.addTestSuite(GridCachePortableStorePortablesSelfTest.class); - - suite.addTestSuite(GridCacheClientNodePortableMetadataTest.class); - suite.addTestSuite(GridCacheClientNodePortableMetadataMultinodeTest.class); - - return suite; - } -} diff --git a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.jar b/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.jar deleted file mode 100644 index 863350d..0000000 Binary files a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.jar and /dev/null differ diff --git a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.pom b/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.pom deleted file mode 100644 index c79dfbf..0000000 --- a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.pom +++ /dev/null @@ -1,9 +0,0 @@ - - - 4.0.0 - org.apache.ignite.portable - test1 - 1.1 - POM was created from install:install-file - diff --git a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/maven-metadata-local.xml b/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/maven-metadata-local.xml deleted file mode 100644 index 33f5abf..0000000 --- a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test1/maven-metadata-local.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - org.apache.ignite.portable - test1 - - 1.1 - - 1.1 - - 20140806090184 - - diff --git a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.jar b/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.jar deleted file mode 100644 index ccf4ea2..0000000 Binary files a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.jar and /dev/null differ diff --git a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.pom b/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.pom deleted file mode 100644 index 37621e1..0000000 --- a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.pom +++ /dev/null @@ -1,9 +0,0 @@ - - - 4.0.0 - org.apache.ignite.portable - test2 - 1.1 - POM was created from install:install-file - diff --git a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/maven-metadata-local.xml b/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/maven-metadata-local.xml deleted file mode 100644 index 9c705ef..0000000 --- a/modules/core/src/test/portables/repo/org/apache/ignite/portable/test2/maven-metadata-local.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - org.apache.ignite.portable - test2 - - 1.1 - - 1.1 - - 20140806090410 - - diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java index 2bdf28c..833e49e 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopDefaultMapReducePlannerSelfTest.java @@ -43,6 +43,7 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.cluster.IgniteClusterEx; +import org.apache.ignite.internal.portable.api.IgnitePortables; import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey; import org.apache.ignite.internal.processors.cache.IgniteInternalCache; import org.apache.ignite.internal.processors.igfs.IgfsBlockLocationImpl; @@ -1024,5 +1025,10 @@ public class HadoopDefaultMapReducePlannerSelfTest extends HadoopAbstractSelfTes @Override public GridKernalContext context() { return null; } + + /** {@inheritDoc} */ + @Override public IgnitePortables portables() { + return null; + } } } \ No newline at end of file diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java deleted file mode 100644 index 27ac436..0000000 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java +++ /dev/null @@ -1,117 +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.testsuites; - -import junit.framework.TestSuite; -import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest; -import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest; -import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest; -import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsDistributedSelfTest; -import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsLocalSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapTieredMultithreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingQueryErrorTest; -import org.apache.ignite.internal.processors.cache.IgniteCachePartitionedQueryMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryEvictsMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapMultiThreadedSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicP2PDisabledSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest; -import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest; -import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest; -import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest; -import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest; -import org.apache.ignite.marshaller.portable.PortableMarshaller; -import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest; -import org.apache.ignite.testframework.config.GridTestProperties; - -/** - * Cache query suite with portable marshaller. - */ -public class IgnitePortableCacheQueryTestSuite extends TestSuite { - /** - * @return Suite. - * @throws Exception In case of error. - */ - public static TestSuite suite() throws Exception { - GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName()); - - TestSuite suite = new TestSuite("Grid Cache Query Test Suite using PortableMarshaller"); - - // Parsing - suite.addTestSuite(GridQueryParsingTest.class); - - // Queries tests. - suite.addTestSuite(GridCacheQueryIndexDisabledSelfTest.class); - suite.addTestSuite(IgniteCachePartitionedQueryMultiThreadedSelfTest.class); - suite.addTestSuite(IgniteCacheLargeResultSelfTest.class); - suite.addTestSuite(IgniteCacheQueryMultiThreadedSelfTest.class); - suite.addTestSuite(IgniteCacheQueryEvictsMultiThreadedSelfTest.class); - suite.addTestSuite(IgniteCacheQueryOffheapMultiThreadedSelfTest.class); - - suite.addTestSuite(IgniteCacheOffheapTieredMultithreadedSelfTest.class); - suite.addTestSuite(GridCacheReduceQueryMultithreadedSelfTest.class); - - - // Fields queries. - suite.addTestSuite(IgniteCacheFieldsQueryNoDataSelfTest.class); - - // Continuous queries. - suite.addTestSuite(GridCacheContinuousQueryLocalAtomicSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryPartitionedOnlySelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class); - suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class); - - suite.addTestSuite(GridCacheQueryIndexingDisabledSelfTest.class); - - //Should be adjusted. Not ready to be used with PortableMarshaller. - //suite.addTestSuite(GridCachePortableSwapScanQuerySelfTest.class); - - suite.addTestSuite(GridOrderedMessageCancelSelfTest.class); - - // Ignite cache and H2 comparison. - suite.addTestSuite(BaseH2CompareQueryTest.class); - suite.addTestSuite(H2CompareBigQueryTest.class); - - // Metrics tests - suite.addTestSuite(CacheLocalQueryMetricsSelfTest.class); - suite.addTestSuite(CachePartitionedQueryMetricsDistributedSelfTest.class); - suite.addTestSuite(CachePartitionedQueryMetricsLocalSelfTest.class); - suite.addTestSuite(CacheReplicatedQueryMetricsDistributedSelfTest.class); - suite.addTestSuite(CacheReplicatedQueryMetricsLocalSelfTest.class); - - //Unmarshallig query test. - suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class); - - suite.addTestSuite(GridCachePortableDuplicateIndexObjectPartitionedAtomicSelfTest.class); - suite.addTestSuite(GridCachePortableDuplicateIndexObjectPartitionedTransactionalSelfTest.class); - - return suite; - } -} \ No newline at end of file diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java index 3895506..738f910 100644 --- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java +++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java @@ -37,6 +37,7 @@ import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.PortableMetaDataImpl; import org.apache.ignite.internal.portable.PortableRawReaderEx; import org.apache.ignite.internal.portable.PortableRawWriterEx; +import org.apache.ignite.internal.portable.api.PortableMetadata; import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl; import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter; import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilterImpl; @@ -70,7 +71,6 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.T4; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import org.apache.ignite.portable.PortableMetadata; import org.jetbrains.annotations.Nullable; import java.util.Collection; @@ -373,7 +373,7 @@ public class PlatformContextImpl implements PlatformContext { writer.writeInt(metas.size()); - for (org.apache.ignite.portable.PortableMetadata m : metas) + for (PortableMetadata m : metas) writeMetadata0(writer, cacheObjProc.typeId(m.typeName()), m); } diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java index 638b4b1..9e092c5 100644 --- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java +++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/compute/PlatformCompute.java @@ -33,7 +33,7 @@ import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.util.typedef.C1; import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableObject; import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBGRID; diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java index d95a82b..ee8f9a3 100644 --- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java +++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java @@ -25,7 +25,7 @@ import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurat import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; import org.apache.ignite.platform.cpp.PlatformCppConfiguration; import java.util.Collections; diff --git a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java index 6e03dfe..21cd01a 100644 --- a/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java +++ b/modules/platform/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java @@ -36,10 +36,10 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lifecycle.LifecycleBean; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.marshaller.portable.PortableMarshaller; +import org.apache.ignite.internal.portable.api.PortableMarshaller; import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean; -import org.apache.ignite.portable.PortableException; -import org.apache.ignite.portable.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableException; +import org.apache.ignite.internal.portable.api.PortableMetadata; import java.util.ArrayList; import java.util.Collections; diff --git a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml index 183676b..6164ef3 100644 --- a/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml +++ b/modules/platform/src/test/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml @@ -69,16 +69,16 @@ - + - + - + - + diff --git a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java index 0e8b825..9b90209 100644 --- a/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java +++ b/modules/platform/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java @@ -24,9 +24,10 @@ 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.IgniteEx; import org.apache.ignite.internal.util.typedef.F; -import org.apache.ignite.portable.PortableMetadata; -import org.apache.ignite.portable.PortableObject; +import org.apache.ignite.internal.portable.api.PortableMetadata; +import org.apache.ignite.internal.portable.api.PortableObject; import org.apache.ignite.resources.IgniteInstanceResource; import org.jetbrains.annotations.Nullable; @@ -89,7 +90,8 @@ public class PlatformComputePortableArgTask extends ComputeTaskAdapterorg.apache.ignite.marshaller* - Portable Objects API - org.apache.ignite.portable* - - Visor Plugins org.apache.ignite.visor.plugin @@ -712,10 +708,6 @@ dev-tools/.gradle/**/* dev-tools/gradle/wrapper/**/* dev-tools/gradlew - src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.pom - src/test/portables/repo/org/apache/ignite/portable/test2/maven-metadata-local.xml - src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.pom - src/test/portables/repo/org/apache/ignite/portable/test1/maven-metadata-local.xml ipc/shmem/**/Makefile.in ipc/shmem/**/Makefile @@ -745,8 +737,6 @@ src/main/java/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory src/main/resources/META-INF/services/org.apache.ignite.internal.processors.platform.PlatformBootstrapFactory src/test/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj - src/test/portables/repo/org/apache/ignite/portable/test1/1.1/test1-1.1.jar - src/test/portables/repo/org/apache/ignite/portable/test2/1.1/test2-1.1.jar **/Makefile.am **/configure.ac **/*.pc.in