Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
15e64ae
IGNITE-10075: Test to reproduce issue
nizhikov Nov 29, 2020
ee27b97
IGNITE-10075: Test to reproduce issue
nizhikov Nov 29, 2020
af665b4
IGNITE-10075: Test + patch.
nizhikov Nov 30, 2020
d8d4590
IGNITE-10075: Test + patch.
nizhikov Nov 30, 2020
c82b4f8
IGNITE-10075: Test + patch.
nizhikov Nov 30, 2020
59defd1
IGNITE-10075: Compilation error fix.
nizhikov Nov 30, 2020
f7275d3
IGNITE-10075: Tests fix
nizhikov Nov 30, 2020
f01ffdf
IGNITE-10075: Tests fix
nizhikov Nov 30, 2020
7f3429b
IGNITE-10075: Tests fix
nizhikov Nov 30, 2020
6ba6af0
IGNITE-10075: Tests fix
nizhikov Nov 30, 2020
18e1e16
IGNITE-10075: Inspection fix.
nizhikov Dec 1, 2020
ea5c209
IGNITE-10075: Tests fix
nizhikov Dec 1, 2020
c8e40b9
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
a0e3d50
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
9ba075c
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
68ff425
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
41b5e42
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
f561572
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
0e4f4ec
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
22ab566
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
cca4b98
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
96b7866
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
73df4f8
IGNITE-10075: Code review fix.
nizhikov Dec 1, 2020
9df3e3d
Merge branch 'master' into IGNITE-10075
nizhikov Dec 1, 2020
15d376a
IGNITE-10075: Fix tests.
nizhikov Dec 1, 2020
dc068e3
IGNITE-10075: Fix tests.
nizhikov Dec 2, 2020
9af231f
IGNITE-10075: Fix tests.
nizhikov Dec 2, 2020
a547023
Merge branch 'master' into IGNITE-10075
nizhikov Dec 2, 2020
b92eb31
IGNITE-10075: Fix reworked.
nizhikov Dec 3, 2020
8d7f4bb
IGNITE-10075: Fix reworked.
nizhikov Dec 3, 2020
d71e15f
IGNITE-10075: Fix reworked.
nizhikov Dec 3, 2020
6ce6490
IGNITE-10075: Fix reworked.
nizhikov Dec 3, 2020
6c528c8
IGNITE-10075: Fix reworked.
nizhikov Dec 3, 2020
91c9553
IGNITE-10075: WIP
nizhikov Dec 4, 2020
d9df160
IGNITE-10075: WIP
nizhikov Dec 4, 2020
96373c9
IGNITE-10075: WIP
nizhikov Dec 4, 2020
c31749e
IGNITE-10075: Code review fix.
nizhikov Dec 7, 2020
c17528d
IGNITE-10075: Code review fix.
nizhikov Dec 7, 2020
6d9ecb2
IGNITE-10075: Code review fix.
nizhikov Dec 7, 2020
3b3199f
IGNITE-10075: Code review fix.
nizhikov Dec 7, 2020
38fb925
IGNITE-10075: Code review fix.
nizhikov Dec 7, 2020
c1f94c1
IGNITE-10075: Code review fix.
nizhikov Dec 7, 2020
24b51a7
IGNITE-10075: Compilation fix.
nizhikov Dec 7, 2020
52ffd39
IGNITE-10075: Compilation fix.
nizhikov Dec 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
Expand All @@ -59,6 +60,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.internal.MarshallerPlatformIds.DOTNET_ID;
import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID;
import static org.apache.ignite.internal.MarshallerPlatformIds.otherPlatforms;
import static org.apache.ignite.internal.MarshallerPlatformIds.platformName;
Expand Down Expand Up @@ -368,37 +370,55 @@ public void onMappingAccepted(final MarshallerMappingItem item) {

/** {@inheritDoc} */
@Override public Class getClass(int typeId, ClassLoader ldr) throws ClassNotFoundException, IgniteCheckedException {
String clsName = getClassName(JAVA_ID, typeId);
String err = null;

if (clsName == null)
throw new ClassNotFoundException("Unknown type ID: " + typeId);
for (byte platformId : new byte[] {DOTNET_ID, JAVA_ID}) {
T2<String, String> res = getClassName(platformId, typeId, false);

return U.forName(clsName, ldr, clsFilter);
if (res.get1() != null) {
try {
return U.forName(res.get1(), ldr, clsFilter);
}
catch (ClassNotFoundException e) {
err = e.getMessage();
}
}
else
err = res.get2();
}

if (err != null)
throw new ClassNotFoundException(err);

throw new ClassNotFoundException("Unknown type ID: " + typeId);
}

/** {@inheritDoc} */
@Override public String getClassName(
byte platformId,
int typeId
) throws ClassNotFoundException, IgniteCheckedException {
return getClassName(platformId, typeId, false);
T2<String, String> res = getClassName(platformId, typeId, false);

if (res.get1() == null)
throw new ClassNotFoundException(res.get2());

return res.get1();
}

/**
* Gets class name for provided (platformId, typeId) pair.
* Gets T2(class name, error message) for provided (platformId, typeId) pair.
*
* @param platformId id of a platform the class was registered for.
* @param typeId Type ID.
* @param skipOtherPlatforms Whether to skip other platforms check (recursion guard).
* @return Class name
* @throws ClassNotFoundException If class was not found.
* @throws IgniteCheckedException In case of any other error.
* @return Tuple. First is class name, second is error message.
*/
private String getClassName(
byte platformId,
int typeId,
boolean skipOtherPlatforms
) throws ClassNotFoundException, IgniteCheckedException {
public T2<String, String> getClassName(
byte platformId,
int typeId,
boolean skipOtherPlatforms
) throws IgniteCheckedException {
ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);

MappedName mappedName = cache.get(typeId);
Expand Down Expand Up @@ -426,45 +446,44 @@ else if (clientNode) {
clsName = mappedName.className();

if (clsName == null)
throw new ClassNotFoundException(
return new T2<>(null,
"Requesting mapping from grid failed for [platformId="
+ platformId
+ ", typeId="
+ typeId + "]");

return clsName;
return new T2<>(clsName, null);
}
else {
String platformName = platformName(platformId);

if (!skipOtherPlatforms) {
// Look for this class in other platforms to provide a better error message.
for (byte otherPlatformId : otherPlatforms(platformId)) {
try {
clsName = getClassName(otherPlatformId, typeId, true);
} catch (ClassNotFoundException ignored) {
T2<String, String> res = getClassName(otherPlatformId, typeId, true);

if (res.get1() == null)
continue;
}

String otherPlatformName = platformName(otherPlatformId);

throw new ClassNotFoundException(
"Failed to resolve " + otherPlatformName + " class '" + clsName
return new T2<>(null,
"Failed to resolve " + otherPlatformName + " class '" + res.get1()
+ "' in " + platformName
+ " [platformId=" + platformId
+ ", typeId=" + typeId + "].");
}
}

throw new ClassNotFoundException(
return new T2<>(null,
"Failed to resolve class name [" +
"platformId=" + platformId
+ ", platform=" + platformName
+ ", typeId=" + typeId + "]");
}
}

return clsName;
return new T2<>(clsName, null);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.internal.MarshallerPlatformIds;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.util.typedef.T2;

import static org.apache.ignite.internal.MarshallerPlatformIds.DOTNET_ID;
import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID;

/**
* Platform binary processor.
Expand Down Expand Up @@ -78,7 +81,7 @@ public PlatformBinaryProcessor(PlatformContext platformCtx) {
String typeName = reader.readString();

return platformContext().kernalContext().marshallerContext()
.registerClassName(MarshallerPlatformIds.DOTNET_ID, typeId, typeName, false)
.registerClassName(DOTNET_ID, typeId, typeName, false)
? TRUE : FALSE;
}
}
Expand Down Expand Up @@ -126,16 +129,26 @@ public PlatformBinaryProcessor(PlatformContext platformCtx) {
case OP_GET_TYPE: {
int typeId = reader.readInt();

try {
String typeName = platformContext().kernalContext().marshallerContext()
.getClassName(MarshallerPlatformIds.DOTNET_ID, typeId);
String err = null;

writer.writeString(typeName);
}
catch (ClassNotFoundException e) {
throw new BinaryObjectException(e);
for (byte platformId : new byte[] {DOTNET_ID, JAVA_ID}) {
T2<String, String> res = platformContext().kernalContext().marshallerContext()
.getClassName(platformId, typeId, false);

if (res.get1() != null) {
writer.writeString(res.get1());

err = null;

break;
}
else if (err == null)
err = res.get2();
}

if (err != null)
throw new BinaryObjectException(err);

break;
}

Expand Down
47 changes: 47 additions & 0 deletions modules/core/src/test/java/org/apache/ignite/platform/Address.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.platform;

/** Test value object. */
public class Address {
/** */
private String zip;

/** */
private String addr;

/** */
public String getZip() {
return zip;
}

/** */
public void setZip(String zip) {
this.zip = zip;
}

/** */
public String getAddr() {
return addr;
}

/** */
public void setAddr(String addr) {
this.addr = addr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.jetbrains.annotations.Nullable;

import static java.util.Calendar.JANUARY;
import static org.junit.Assert.assertEquals;

/**
* Task that deploys a Java service.
Expand Down Expand Up @@ -414,6 +415,20 @@ public BinaryObject testBinaryObject(BinaryObject o) {
return o.toBuilder().setField("field", 15).build();
}

/** */
public Address testAddress(Address addr) {
if (addr == null)
return null;

assertEquals("000", addr.getZip());
assertEquals("Moscow", addr.getAddr());

addr.setZip("127000");
addr.setAddr("Moscow Akademika Koroleva 12");

return addr;
}

/** */
public void sleep(long delayMs) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
<Compile Include="Plugin\TestIgnitePluginConfiguration.cs" />
<Compile Include="Plugin\TestIgnitePluginException.cs" />
<Compile Include="Plugin\TestIgnitePluginProvider.cs" />
<Compile Include="Services\Address.cs" />
<Compile Include="Services\IJavaService.cs" />
<Compile Include="Ssl\SslConfigurationTest.cs" />
<Compile Include="TaskExtensions.cs" />
Expand Down Expand Up @@ -397,6 +398,7 @@
<Compile Include="Services\ServicesTestAsync.cs" />
<Compile Include="Services\ServiceProxyTest.cs" />
<Compile Include="Services\ServicesAsyncWrapper.cs" />
<Compile Include="Services\ServiceTypeAutoResolveTest.cs" />
<Compile Include="TestRunner.cs" />
<Compile Include="TestUtils.cs" />
<Compile Include="TestUtilsJni.cs" />
Expand Down Expand Up @@ -617,4 +619,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* 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.
Expand All @@ -15,24 +15,17 @@
* limitations under the License.
*/

namespace Apache.Ignite.Core.Impl.Client.Cache
namespace org.apache.ignite.platform
{
using System;

/// <summary>
/// Cache operation flags.
/// A class is a clone of Java class Address with the same namespace.
/// </summary>
[Flags]
internal enum CacheFlags : byte
public class Address
{
/// <summary>
/// No flags.
/// </summary>
None = 0x00,
/** */
public string Zip { get; set; }

/// <summary>
/// Keep binary.
/// </summary>
KeepBinary = 0x01
/** */
public string Addr { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Tests.Services
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
using org.apache.ignite.platform;

/// <summary>
/// Java service proxy interface.
Expand Down Expand Up @@ -163,6 +164,9 @@ public interface IJavaService
/** */
IBinaryObject testBinaryObject(IBinaryObject x);

/** */
Address testAddress(Address addr);

/** */
void sleep(long delayMs);
}
Expand Down
Loading