http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java index 25521dc..c41ca6e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java @@ -21,8 +21,8 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.cache.store.CacheStore; import org.apache.ignite.cache.store.CacheStoreSession; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheStore; import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheStoreCallback; @@ -481,4 +481,4 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor clo.apply((K) reader.readObjectDetached(), (V) reader.readObjectDetached()); } } -} \ No newline at end of file +}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java index c506a35..caea840 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java @@ -23,10 +23,10 @@ import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.PlatformConfiguration; import org.apache.ignite.internal.MarshallerContextImpl; -import org.apache.ignite.internal.portable.BinaryNoopMetadataHandler; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; -import org.apache.ignite.internal.portable.GridPortableMarshaller; -import org.apache.ignite.internal.portable.PortableContext; +import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.GridPortableMarshaller; +import org.apache.ignite.internal.binary.PortableContext; import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure; import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean; import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream; @@ -38,7 +38,7 @@ 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.platform.dotnet.PlatformDotNetConfiguration; -import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean; import java.util.ArrayList; @@ -255,4 +255,4 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur throw U.convertException(e); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEventFilterListenerImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEventFilterListenerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEventFilterListenerImpl.java index a19f07e..624870a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEventFilterListenerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEventFilterListenerImpl.java @@ -19,7 +19,7 @@ package org.apache.ignite.internal.processors.platform.events; import org.apache.ignite.events.Event; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.processors.platform.PlatformEventFilterListener; import org.apache.ignite.internal.processors.platform.memory.PlatformMemory; @@ -183,4 +183,4 @@ public class PlatformEventFilterListenerImpl implements PlatformEventFilterListe pred = in.readObject(); types = (int[])in.readObject(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java index a1af469..9bf0a8d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEvents.java @@ -24,8 +24,8 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteEvents; import org.apache.ignite.events.Event; import org.apache.ignite.events.EventAdapter; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +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.PlatformEventFilterListener; import org.apache.ignite.internal.processors.platform.PlatformContext; http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java index 55c524e..321e592 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStream.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.platform.memory; -import org.apache.ignite.internal.portable.streams.PortableInputStream; +import org.apache.ignite.internal.binary.streams.PortableInputStream; /** * Interop output stream, @@ -27,4 +27,4 @@ public interface PlatformInputStream extends PortableInputStream { * Synchronize input. Must be called before start reading data from a memory changed by another platform. */ public void synchronize(); -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java index e3ef0b2..7894f0c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStream.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.platform.memory; -import org.apache.ignite.internal.portable.streams.PortableOutputStream; +import org.apache.ignite.internal.binary.streams.PortableOutputStream; /** * Interop output stream. @@ -27,4 +27,4 @@ public interface PlatformOutputStream extends PortableOutputStream { * Synchronize output stream with underlying memory */ public void synchronize(); -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java index 9e1b086..a737442 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageFilterImpl.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.platform.messaging; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.platform.PlatformAbstractPredicate; import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.processors.platform.memory.PlatformMemory; @@ -107,4 +107,4 @@ public class PlatformMessageFilterImpl extends PlatformAbstractPredicate impleme ptr = 0; } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java index de3f255..54bbaeb 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessageLocalFilter.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.platform.messaging; import org.apache.ignite.internal.GridKernalContext; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.processors.platform.memory.PlatformMemory; import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream; http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java index 603d3db..88ea3c8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/messaging/PlatformMessaging.java @@ -19,8 +19,8 @@ package org.apache.ignite.internal.processors.platform.messaging; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteMessaging; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +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.processors.platform.message.PlatformMessageFilter; @@ -163,4 +163,4 @@ public class PlatformMessaging extends PlatformAbstractTarget { @Override protected IgniteFuture currentFuture() throws IgniteCheckedException { return messaging.future(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java index df71a24..6d143aa 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformAbstractService.java @@ -23,8 +23,8 @@ import java.io.ObjectInput; import java.io.ObjectOutput; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream; import org.apache.ignite.internal.processors.platform.memory.PlatformMemory; @@ -227,4 +227,4 @@ public abstract class PlatformAbstractService implements PlatformService, Extern out.writeObject(svc); out.writeBoolean(srvKeepPortable); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java index 320d5a9..ff09357 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java @@ -22,8 +22,8 @@ import java.util.Map; import java.util.UUID; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteServices; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +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.processors.platform.dotnet.PlatformDotNetService; @@ -272,4 +272,4 @@ public class PlatformServices extends PlatformAbstractTarget { @Override protected IgniteFuture currentFuture() throws IgniteCheckedException { return services.future(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java index d97e071..8afabac 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java @@ -23,7 +23,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteTransactions; import org.apache.ignite.configuration.TransactionConfiguration; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +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.processors.platform.utils.PlatformFutureUtils; @@ -256,4 +256,4 @@ public class PlatformTransactions extends PlatformAbstractTarget { super.processOutStream(type, writer); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java index 335be4d..e6f28c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformFutureUtils.java @@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.platform.utils; import org.apache.ignite.internal.IgniteInternalFuture; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +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.processors.platform.callback.PlatformCallbackGateway; @@ -394,4 +394,4 @@ public class PlatformFutureUtils { } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java index 199cf72..6506aed 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderBiClosure.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.platform.utils; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; +import org.apache.ignite.internal.binary.BinaryRawReaderEx; import org.apache.ignite.lang.IgniteBiTuple; /** @@ -31,4 +31,4 @@ public interface PlatformReaderBiClosure<T1, T2> { * @return Object. */ IgniteBiTuple<T1, T2> read(BinaryRawReaderEx reader); -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java index 9330606..b281966 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformReaderClosure.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.platform.utils; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; +import org.apache.ignite.internal.binary.BinaryRawReaderEx; /** * Reader closure. @@ -31,4 +31,4 @@ public interface PlatformReaderClosure<T> { * @return Object. */ T read(BinaryRawReaderEx reader); -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java index 6572764..4a29637 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java @@ -24,8 +24,8 @@ import org.apache.ignite.IgniteLogger; import org.apache.ignite.cache.CachePeekMode; import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.IgniteKernal; -import org.apache.ignite.internal.portable.BinaryRawReaderEx; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawReaderEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; import org.apache.ignite.internal.processors.platform.PlatformContext; import org.apache.ignite.internal.processors.platform.PlatformExtendedException; import org.apache.ignite.internal.processors.platform.PlatformNativeException; @@ -807,4 +807,4 @@ public class PlatformUtils { private PlatformUtils() { // No-op. } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java index b0e6a65..f97991a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterBiClosure.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.platform.utils; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; /** * Interop writer bi-closure. @@ -31,4 +31,4 @@ public interface PlatformWriterBiClosure<T1, T2> { * @param val2 Value 2. */ public void write(BinaryRawWriterEx writer, T1 val1, T2 val2); -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java index c55c209..f7d9861 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformWriterClosure.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.platform.utils; -import org.apache.ignite.internal.portable.BinaryRawWriterEx; +import org.apache.ignite.internal.binary.BinaryRawWriterEx; /** * Interop writer closure. @@ -30,4 +30,4 @@ public interface PlatformWriterClosure<T> { * @param val Value. */ public void write(BinaryRawWriterEx writer, T val); -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java index 3a25455..36a4ea6 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java @@ -28,7 +28,7 @@ import java.util.Queue; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; -import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.binary.BinaryMarshaller; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.S; @@ -507,4 +507,4 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements Checkpoin @Override public String toString() { return S.toString(SharedFsCheckpointSpi.class, this); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/main/resources/META-INF/classnames.properties ---------------------------------------------------------------------- diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index 8ac3278..c1bac44 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -294,16 +294,16 @@ org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage org.apache.ignite.internal.managers.indexing.GridIndexingManager$1 org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerAdapter org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1 -org.apache.ignite.internal.portable.BinaryMetadata -org.apache.ignite.internal.portable.BinaryObjectEx -org.apache.ignite.internal.portable.BinaryObjectImpl -org.apache.ignite.internal.portable.BinaryObjectOffheapImpl -org.apache.ignite.internal.portable.BinaryReaderExImpl$Flag -org.apache.ignite.internal.portable.BinaryWriteMode -org.apache.ignite.internal.portable.PortableContext -org.apache.ignite.internal.portable.PortableSchema -org.apache.ignite.internal.portable.PortableSchema$Confirmation -org.apache.ignite.internal.portable.builder.PortableLazyMap$1$1$1 +org.apache.ignite.internal.binary.BinaryMetadata +org.apache.ignite.internal.binary.BinaryObjectEx +org.apache.ignite.internal.binary.BinaryObjectImpl +org.apache.ignite.internal.binary.BinaryObjectOffheapImpl +org.apache.ignite.internal.binary.BinaryReaderExImpl$Flag +org.apache.ignite.internal.binary.BinaryWriteMode +org.apache.ignite.internal.binary.PortableContext +org.apache.ignite.internal.binary.PortableSchema +org.apache.ignite.internal.binary.PortableSchema$Confirmation +org.apache.ignite.internal.binary.builder.PortableLazyMap$1$1$1 org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion org.apache.ignite.internal.processors.affinity.GridAffinityAssignment org.apache.ignite.internal.processors.affinity.GridAffinityMessage @@ -745,14 +745,14 @@ org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$4 org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$5 org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$6 org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$9 -org.apache.ignite.internal.processors.cache.portable.CacheDefaultPortableAffinityKeyMapper -org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$1 -org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$4 -org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$5 -org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetaDataEntryFilter -org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetaDataPredicate -org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetadataProcessor -org.apache.ignite.internal.processors.cache.portable.PortableMetadataKey +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheDefaultPortableAffinityKeyMapper +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl$1 +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl$4 +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl$5 +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl$MetaDataEntryFilter +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl$MetaDataPredicate +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl$MetadataProcessor +org.apache.ignite.internal.binaryorg.apache.ignite.internal.processors.cache.binary.PortableMetadataKey org.apache.ignite.internal.processors.cache.query.CacheQueryType org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryFuture$1 org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryFuture$3 http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java index 659efb0..b825a24 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreBinaryMarshallerSelfTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.cache.store.jdbc; import org.apache.ignite.marshaller.Marshaller; -import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.binary.BinaryMarshaller; /** * Class for {@code PojoCacheStore} tests. http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java new file mode 100644 index 0000000..e503e07 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java @@ -0,0 +1,446 @@ +/* + * 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.binary; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.binary.BinaryTypeConfiguration; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import java.io.Serializable; +import java.util.Arrays; + +/** + * Contains tests for binary enums. + */ +@SuppressWarnings("unchecked") +public class BinaryEnumsSelfTest extends GridCommonAbstractTest { + /** Cache name. */ + private static String CACHE_NAME = "cache"; + + /** Whether to register types or not. */ + private boolean register; + + /** Node 1. */ + private Ignite node1; + + /** Node 2. */ + private Ignite node2; + + /** Cache 1. */ + private IgniteCache cache1; + + /** Cache 2. */ + private IgniteCache cache2; + + /** Binary cache 1. */ + private IgniteCache cacheBinary1; + + /** Binary cache 2. */ + private IgniteCache cacheBinary2; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + register = false; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + if (register) { + BinaryConfiguration bCfg = new BinaryConfiguration(); + + BinaryTypeConfiguration enumCfg = new BinaryTypeConfiguration(EnumType.class.getName()); + enumCfg.setEnum(true); + + bCfg.setTypeConfigurations(Arrays.asList(enumCfg, new BinaryTypeConfiguration(EnumHolder.class.getName()))); + + cfg.setBinaryConfiguration(bCfg); + } + + cfg.setMarshaller(new BinaryMarshaller()); + + CacheConfiguration ccfg = new CacheConfiguration(); + ccfg.setName(CACHE_NAME); + ccfg.setCacheMode(CacheMode.PARTITIONED); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** + * Start up routine. + * + * @throws Exception If failed. + */ + private void startUp(boolean register) throws Exception { + this.register = register; + + node1 = startGrid(0); + cache1 = node1.cache(CACHE_NAME); + cacheBinary1 = cache1.withKeepBinary(); + + node2 = startGrid(1); + cache2 = node2.cache(CACHE_NAME); + cacheBinary2 = cache2.withKeepBinary(); + } + + /** + * Test operations on simple type which is registered in advance. + * + * @throws Exception If failed. + */ + public void testSimpleRegistered() throws Exception { + checkSimple(true); + } + + /** + * Test operations on simple type which is not registered in advance. + * + * @throws Exception If failed. + */ + public void testSimpleNotRegistered() throws Exception { + checkSimple(false); + } + + /** + * Test operations when enum is nested into an object (registered). + * + * @throws Exception If failed. + */ + public void testNestedRegistered() throws Exception { + checkNested(true); + } + + /** + * Test operations when enum is nested into an object (not registered). + * + * @throws Exception If failed. + */ + public void testNestedNotRegistered() throws Exception { + checkNested(false); + } + + /** + * Test builder operations on simple type which is registered in advance. + * + * @throws Exception If failed. + */ + public void testSimpleBuilderRegistered() throws Exception { + checkSimpleBuilder(true); + } + + /** + * Test builder operations on simple type which is not registered in advance. + * + * @throws Exception If failed. + */ + public void testSimpleBuilderNotRegistered() throws Exception { + checkSimpleBuilder(false); + } + + /** + * Test builder operations when enum is nested into an object (registered). + * + * @throws Exception If failed. + */ + public void testNestedBuilderRegistered() throws Exception { + checkNestedBuilder(true); + } + + /** + * Test builder operations when enum is nested into an object (not registered). + * + * @throws Exception If failed. + */ + public void testNestedBuilderNotRegistered() throws Exception { + checkNestedBuilder(false); + } + + /** + * Check simple serialization - deserialization. + * + * @param registered If type should be registered in advance. + * @throws Exception If failed. + */ + public void checkSimple(boolean registered) throws Exception { + startUp(registered); + + cache1.put(1, EnumType.ONE); + + validateSimple(1, EnumType.ONE, registered); + } + + /** + * Check nested serialization - deserialization. + * + * @param registered If type should be registered in advance. + * @throws Exception If failed. + */ + private void checkNested(boolean registered) throws Exception { + startUp(registered); + + cache1.put(1, new EnumHolder(EnumType.ONE)); + + validateNested(1, EnumType.ONE, registered); + } + + /** + * Check nested builder serialization - deserialization. + * + * @param registered If type should be registered in advance. + * @throws Exception If failed. + */ + private void checkNestedBuilder(boolean registered) throws Exception { + startUp(registered); + + BinaryObject obj = node1.binary().builder("EnumHolder").setField("val", EnumType.ONE).build(); + + assert node1.binary().type("EnumHolder") != null; + assert node1.binary().type("EnumType") != null; + + cacheBinary1.put(1, obj); + + validateNested(1, EnumType.ONE, registered); + + obj = (BinaryObject)cacheBinary1.get(1); + obj = node1.binary().builder(obj).setField("val", EnumType.TWO).build(); + + cacheBinary1.put(1, obj); + + validateNested(1, EnumType.TWO, registered); + } + + /** + * Validate nested object. + * + * @param key Key. + * @param val Value. + * @param registered Registered flag. + * @throws Exception If failed. + */ + private void validateNested(int key, EnumType val, boolean registered) throws Exception { + if (registered) { + EnumHolder res1 = (EnumHolder) cache1.get(key); + EnumHolder res2 = (EnumHolder) cache2.get(key); + + assertEquals(val, res1.val); + assertEquals(val, res2.val); + } + + BinaryObject resBinary1 = (BinaryObject)cacheBinary1.get(key); + BinaryObject resBinary2 = (BinaryObject)cacheBinary2.get(key); + + validate((BinaryObject)resBinary1.field("val"), val); + validate((BinaryObject)resBinary2.field("val"), val); + } + + /** + * Check simple serialization - deserialization using builder. + * + * @param registered If type should be registered in advance. + * @throws Exception If failed. + */ + public void checkSimpleBuilder(boolean registered) throws Exception { + startUp(registered); + + BinaryObject binary = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.ONE.ordinal()); + + cacheBinary1.put(1, binary); + + validateSimple(1, EnumType.ONE, registered); + } + + /** + * Test enum array (registered). + * + * @throws Exception If failed. + */ + public void testSimpleArrayRegistered() throws Exception { + checkSimpleArray(true); + } + + /** + * Test enum array (not registered). + * + * @throws Exception If failed. + */ + public void testSimpleArrayNotRegistered() throws Exception { + checkSimpleArray(false); + } + + /** + * Test enum array created using builder (registered). + * + * @throws Exception If failed. + */ + public void testSimpleBuilderArrayRegistered() throws Exception { + checkSimpleBuilderArray(true); + } + + /** + * Test enum array created using builder (not registered). + * + * @throws Exception If failed. + */ + public void testSimpleBuilderArrayNotRegistered() throws Exception { + checkSimpleBuilderArray(false); + } + + /** + * Check arrays with builder. + * + * @param registered Registered flag. + * @throws Exception If failed. + */ + public void checkSimpleArray(boolean registered) throws Exception { + startUp(registered); + + cache1.put(1, new EnumType[] { EnumType.ONE, EnumType.TWO }); + + validateSimpleArray(registered); + } + + /** + * Check arrays with builder. + * + * @param registered Registered flag. + * @throws Exception If failed. + */ + public void checkSimpleBuilderArray(boolean registered) throws Exception { + startUp(registered); + + BinaryObject binaryOne = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.ONE.ordinal()); + BinaryObject binaryTwo = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.TWO.ordinal()); + + cacheBinary1.put(1, new BinaryObject[] { binaryOne, binaryTwo }); + + validateSimpleArray(registered); + } + + /** + * Validate simple array. + * + * @param registered Registered flag. + */ + private void validateSimpleArray(boolean registered) { + if (registered) { + Object[] arr1 = (Object[])cache1.get(1); + Object[] arr2 = (Object[])cache2.get(1); + + assertEquals(2, arr1.length); + assertEquals(2, arr2.length); + + assertEquals(EnumType.ONE, arr1[0]); + assertEquals(EnumType.TWO, arr1[1]); + + assertEquals(EnumType.ONE, arr2[0]); + assertEquals(EnumType.TWO, arr2[1]); + } + + Object[] arrBinary1 = (Object[])cacheBinary1.get(1); + Object[] arrBinary2 = (Object[])cacheBinary2.get(1); + + assertEquals(2, arrBinary1.length); + assertEquals(2, arrBinary2.length); + + validate((BinaryObject) arrBinary1[0], EnumType.ONE); + validate((BinaryObject) arrBinary1[1], EnumType.TWO); + + validate((BinaryObject) arrBinary2[0], EnumType.ONE); + validate((BinaryObject) arrBinary2[1], EnumType.TWO); + } + + /** + * Internal check routine for simple scenario. + * + * @param key Key. + * @param val Value. + * @param registered Registered flag. + * @throws Exception If failed. + */ + private void validateSimple(int key, EnumType val, boolean registered) throws Exception { + if (registered) { + assertEquals(val, cache1.get(key)); + assertEquals(val, cache2.get(key)); + } + + validate((BinaryObject) cacheBinary1.get(key), val); + validate((BinaryObject) cacheBinary2.get(key), val); + } + + /** + * Validate single value. + * + * @param obj Binary value. + * @param val Expected value. + */ + private void validate(BinaryObject obj, EnumType val) { + assertTrue(obj.type().isEnum()); + + assertEquals(node1.binary().typeId(EnumType.class.getName()), obj.type().typeId()); + assertEquals(node2.binary().typeId(EnumType.class.getName()), obj.type().typeId()); + + assertEquals(val.ordinal(), obj.enumOrdinal()); + } + + /** + * Enumeration holder. + */ + public static class EnumHolder implements Serializable { + /** Value. */ + public EnumType val; + + /** + * Default constructor. + */ + @SuppressWarnings("UnusedDeclaration") + public EnumHolder() { + // No-op. + } + + /** + * Constructor. + * + * @param val Value. + */ + public EnumHolder(EnumType val) { + this.val = val; + } + } + + /** + * Enumeration for tests. + */ + public static enum EnumType { + ONE, + TWO + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java new file mode 100644 index 0000000..f12bb92 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsAbstractSelfTest.java @@ -0,0 +1,718 @@ +/* + * 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.binary; + +import org.apache.ignite.binary.BinaryField; +import org.apache.ignite.binary.BinaryObject; +import org.apache.ignite.binary.BinaryTypeConfiguration; +import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.marshaller.MarshallerContextTestImpl; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Arrays; +import java.util.Date; +import java.util.UUID; + +/** + * Contains tests for portable object fields. + */ +public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTest { + /** Marshaller. */ + protected BinaryMarshaller dfltMarsh; + + /** + * Create marshaller. + * + * @return Portable marshaller. + * @throws Exception If failed. + */ + protected BinaryMarshaller createMarshaller() throws Exception { + PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration()); + + BinaryMarshaller marsh = new BinaryMarshaller(); + + BinaryConfiguration bCfg = new BinaryConfiguration(); + + bCfg.setCompactFooter(compactFooter()); + + bCfg.setTypeConfigurations(Arrays.asList( + new BinaryTypeConfiguration(TestObject.class.getName()), + new BinaryTypeConfiguration(TestOuterObject.class.getName()), + new BinaryTypeConfiguration(TestInnerObject.class.getName()) + )); + + IgniteConfiguration iCfg = new IgniteConfiguration(); + + iCfg.setBinaryConfiguration(bCfg); + + marsh.setContext(new MarshallerContextTestImpl(null)); + + IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg); + + return marsh; + } + + /** + * @return Whether to use compact footer. + */ + protected boolean compactFooter() { + return true; + } + + /** + * Get portable context for the current marshaller. + * + * @param marsh Marshaller. + * @return Portable context. + */ + protected static PortableContext portableContext(BinaryMarshaller marsh) { + GridPortableMarshaller impl = U.field(marsh, "impl"); + + return impl.context(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + dfltMarsh = createMarshaller(); + } + + /** + * Test byte field. + * + * @throws Exception If failed. + */ + public void testByte() throws Exception { + check("fByte"); + } + + /** + * Test byte array field. + * + * @throws Exception If failed. + */ + public void testByteArray() throws Exception { + check("fByteArr"); + } + + /** + * Test boolean field. + * + * @throws Exception If failed. + */ + public void testBoolean() throws Exception { + check("fBool"); + } + + /** + * Test boolean array field. + * + * @throws Exception If failed. + */ + public void testBooleanArray() throws Exception { + check("fBoolArr"); + } + + /** + * Test short field. + * + * @throws Exception If failed. + */ + public void testShort() throws Exception { + check("fShort"); + } + + /** + * Test short array field. + * + * @throws Exception If failed. + */ + public void testShortArray() throws Exception { + check("fShortArr"); + } + + /** + * Test char field. + * + * @throws Exception If failed. + */ + public void testChar() throws Exception { + check("fChar"); + } + + /** + * Test char array field. + * + * @throws Exception If failed. + */ + public void testCharArray() throws Exception { + check("fCharArr"); + } + + /** + * Test int field. + * + * @throws Exception If failed. + */ + public void testInt() throws Exception { + check("fInt"); + } + + /** + * Test int array field. + * + * @throws Exception If failed. + */ + public void testIntArray() throws Exception { + check("fIntArr"); + } + + /** + * Test long field. + * + * @throws Exception If failed. + */ + public void testLong() throws Exception { + check("fLong"); + } + + /** + * Test long array field. + * + * @throws Exception If failed. + */ + public void testLongArray() throws Exception { + check("fLongArr"); + } + + /** + * Test float field. + * + * @throws Exception If failed. + */ + public void testFloat() throws Exception { + check("fFloat"); + } + + /** + * Test float array field. + * + * @throws Exception If failed. + */ + public void testFloatArray() throws Exception { + check("fFloatArr"); + } + + /** + * Test double field. + * + * @throws Exception If failed. + */ + public void testDouble() throws Exception { + check("fDouble"); + } + + /** + * Test double array field. + * + * @throws Exception If failed. + */ + public void testDoubleArray() throws Exception { + check("fDoubleArr"); + } + + /** + * Test string field. + * + * @throws Exception If failed. + */ + public void testString() throws Exception { + check("fString"); + } + + /** + * Test string array field. + * + * @throws Exception If failed. + */ + public void testStringArray() throws Exception { + check("fStringArr"); + } + + /** + * Test date field. + * + * @throws Exception If failed. + */ + public void testDate() throws Exception { + check("fDate"); + } + + /** + * Test date array field. + * + * @throws Exception If failed. + */ + public void testDateArray() throws Exception { + check("fDateArr"); + } + + /** + * Test timestamp field. + * + * @throws Exception If failed. + */ + public void testTimestamp() throws Exception { + check("fTimestamp"); + } + + /** + * Test timestamp array field. + * + * @throws Exception If failed. + */ + public void testTimestampArray() throws Exception { + check("fTimestampArr"); + } + + /** + * Test UUID field. + * + * @throws Exception If failed. + */ + public void testUuid() throws Exception { + check("fUuid"); + } + + /** + * Test UUID array field. + * + * @throws Exception If failed. + */ + public void testUuidArray() throws Exception { + check("fUuidArr"); + } + + /** + * Test decimal field. + * + * @throws Exception If failed. + */ + public void testDecimal() throws Exception { + check("fDecimal"); + } + + /** + * Test decimal array field. + * + * @throws Exception If failed. + */ + public void testDecimalArray() throws Exception { + check("fDecimalArr"); + } + + /** + * Test object field. + * + * @throws Exception If failed. + */ + public void testObject() throws Exception { + check("fObj"); + } + + /** + * Test object array field. + * + * @throws Exception If failed. + */ + public void testObjectArray() throws Exception { + check("fObjArr"); + } + + /** + * Test null field. + * + * @throws Exception If failed. + */ + public void testNull() throws Exception { + check("fNull"); + } + + /** + * Test missing field. + * + * @throws Exception If failed. + */ + public void testMissing() throws Exception { + String fieldName = "fMissing"; + + checkNormal(dfltMarsh, fieldName, false); + checkNested(dfltMarsh, fieldName, false); + } + + /** + * Check field resolution in both normal and nested modes. + * + * @param fieldName Field name. + * @throws Exception If failed. + */ + public void check(String fieldName) throws Exception { + checkNormal(dfltMarsh, fieldName, true); + checkNested(dfltMarsh, fieldName, true); + } + + /** + * Check field. + * + * @param marsh Marshaller. + * @param fieldName Field name. + * @param exists Whether field should exist. + * @throws Exception If failed. + */ + private void checkNormal(BinaryMarshaller marsh, String fieldName, boolean exists) throws Exception { + TestContext testCtx = context(marsh, fieldName); + + check0(fieldName, testCtx, exists); + } + + /** + * Check nested field. + * + * @param marsh Marshaller. + * @param fieldName Field name. + * @param exists Whether field should exist. + * @throws Exception If failed. + */ + private void checkNested(BinaryMarshaller marsh, String fieldName, boolean exists) throws Exception { + TestContext testCtx = nestedContext(marsh, fieldName); + + check0(fieldName, testCtx, exists); + } + + /** + * Internal check routine. + * + * @param fieldName Field name. + * @param ctx Context. + * @param exists Whether field should exist. + * @throws Exception If failed. + */ + private void check0(String fieldName, TestContext ctx, boolean exists) throws Exception { + Object val = ctx.field.value(ctx.portObj); + + if (exists) { + assertTrue(ctx.field.exists(ctx.portObj)); + + Object expVal = U.field(ctx.obj, fieldName); + + if (val instanceof BinaryObject) + val = ((BinaryObject) val).deserialize(); + + if (val != null && val.getClass().isArray()) { + assertNotNull(expVal); + + if (val instanceof byte[]) + assertTrue(Arrays.equals((byte[]) expVal, (byte[]) val)); + else if (val instanceof boolean[]) + assertTrue(Arrays.equals((boolean[]) expVal, (boolean[]) val)); + else if (val instanceof short[]) + assertTrue(Arrays.equals((short[]) expVal, (short[]) val)); + else if (val instanceof char[]) + assertTrue(Arrays.equals((char[]) expVal, (char[]) val)); + else if (val instanceof int[]) + assertTrue(Arrays.equals((int[]) expVal, (int[]) val)); + else if (val instanceof long[]) + assertTrue(Arrays.equals((long[]) expVal, (long[]) val)); + else if (val instanceof float[]) + assertTrue(Arrays.equals((float[]) expVal, (float[]) val)); + else if (val instanceof double[]) + assertTrue(Arrays.equals((double[]) expVal, (double[]) val)); + else { + Object[] expVal0 = (Object[])expVal; + Object[] val0 = (Object[])val; + + assertEquals(expVal0.length, val0.length); + + for (int i = 0; i < expVal0.length; i++) { + Object expItem = expVal0[i]; + Object item = val0[i]; + + if (item instanceof BinaryObject) + item = ((BinaryObject)item).deserialize(); + + assertEquals(expItem, item); + } + } + } + else + assertEquals(expVal, val); + } + else { + assertFalse(ctx.field.exists(ctx.portObj)); + + assert val == null; + } + } + + /** + * Get test context. + * + * @param marsh Portable marshaller. + * @param fieldName Field name. + * @return Test context. + * @throws Exception If failed. + */ + private TestContext context(BinaryMarshaller marsh, String fieldName) throws Exception { + TestObject obj = createObject(); + + BinaryObjectExImpl portObj = toPortable(marsh, obj); + + BinaryField field = portObj.type().field(fieldName); + + return new TestContext(obj, portObj, field); + } + + /** + * Get test context with nested test object. + * + * @param marsh Portable marshaller. + * @param fieldName Field name. + * @return Test context. + * @throws Exception If failed. + */ + private TestContext nestedContext(BinaryMarshaller marsh, String fieldName) + throws Exception { + TestObject obj = createObject(); + TestOuterObject outObj = new TestOuterObject(obj); + + BinaryObjectExImpl portOutObj = toPortable(marsh, outObj); + BinaryObjectExImpl portObj = portOutObj.field("fInner"); + + assert portObj != null; + + BinaryField field = portObj.type().field(fieldName); + + return new TestContext(obj, portObj, field); + } + + /** + * Create test object. + * + * @return Test object. + */ + private TestObject createObject() { + return new TestObject(0); + } + + /** + * Convert object to portable object. + * + * @param marsh Marshaller. + * @param obj Object. + * @return Portable object. + * @throws Exception If failed. + */ + protected abstract BinaryObjectExImpl toPortable(BinaryMarshaller marsh, Object obj) throws Exception; + + /** + * Outer test object. + */ + @SuppressWarnings("UnusedDeclaration") + public static class TestOuterObject { + /** Inner object. */ + public TestObject fInner; + + /** + * Default constructor. + */ + public TestOuterObject() { + // No-op. + } + + /** + * Constructor. + * + * @param fInner Inner object. + */ + public TestOuterObject(TestObject fInner) { + this.fInner = fInner; + } + } + + /** + * Test object class, c + */ + @SuppressWarnings("UnusedDeclaration") + public static class TestObject { + /** Primitive fields. */ + public byte fByte; + public boolean fBool; + public short fShort; + public char fChar; + public int fInt; + public long fLong; + public float fFloat; + public double fDouble; + + public byte[] fByteArr; + public boolean[] fBoolArr; + public short[] fShortArr; + public char[] fCharArr; + public int[] fIntArr; + public long[] fLongArr; + public float[] fFloatArr; + public double[] fDoubleArr; + + /** Special fields. */ + public String fString; + public Date fDate; + public Timestamp fTimestamp; + public UUID fUuid; + public BigDecimal fDecimal; + + public String[] fStringArr; + public Date[] fDateArr; + public Timestamp[] fTimestampArr; + public UUID[] fUuidArr; + public BigDecimal[] fDecimalArr; + + /** Nested object. */ + public TestInnerObject fObj; + + public TestInnerObject[] fObjArr; + + /** Field which is always set to null. */ + public Object fNull; + + /** + * Default constructor. + */ + public TestObject() { + // No-op. + } + + /** + * Non-default constructor. + * + * @param ignore Ignored. + */ + public TestObject(int ignore) { + fByte = 1; + fBool = true; + fShort = 2; + fChar = 3; + fInt = 4; + fLong = 5; + fFloat = 6.6f; + fDouble = 7.7; + + fByteArr = new byte[] { 1, 2 }; + fBoolArr = new boolean[] { true, false }; + fShortArr = new short[] { 2, 3 }; + fCharArr = new char[] { 3, 4 }; + fIntArr = new int[] { 4, 5 }; + fLongArr = new long[] { 5, 6 }; + fFloatArr = new float[] { 6.6f, 7.7f }; + fDoubleArr = new double[] { 7.7, 8.8 }; + + fString = "8"; + fDate = new Date(); + fTimestamp = new Timestamp(new Date().getTime() + 1); + fUuid = UUID.randomUUID(); + fDecimal = new BigDecimal(9); + + fStringArr = new String[] { "8", "9" }; + fDateArr = new Date[] { new Date(), new Date(new Date().getTime() + 1) }; + fTimestampArr = + new Timestamp[] { new Timestamp(new Date().getTime() + 1), new Timestamp(new Date().getTime() + 2) }; + fUuidArr = new UUID[] { UUID.randomUUID(), UUID.randomUUID() }; + fDecimalArr = new BigDecimal[] { new BigDecimal(9), new BigDecimal(10) }; + + fObj = new TestInnerObject(10); + fObjArr = new TestInnerObject[] { new TestInnerObject(10), new TestInnerObject(11) }; + } + } + + /** + * Inner test object. + */ + @SuppressWarnings("UnusedDeclaration") + public static class TestInnerObject { + /** Value. */ + private int val; + + /** + * Default constructor. + */ + public TestInnerObject() { + // No-op. + } + + /** + * Constructor. + * + * @param val Value. + */ + public TestInnerObject(int val) { + this.val = val; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + return val; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object other) { + return other != null && other instanceof TestInnerObject && val == ((TestInnerObject)(other)).val; + } + } + + /** + * Test context. + */ + public static class TestContext { + /** Object. */ + public final TestObject obj; + + /** Portable object. */ + public final BinaryObjectExImpl portObj; + + /** Field. */ + public final BinaryField field; + + /** + * Constructor. + * + * @param obj Object. + * @param portObj Portable object. + * @param field Field. + */ + public TestContext(TestObject obj, BinaryObjectExImpl portObj, BinaryField field) { + this.obj = obj; + this.portObj = portObj; + this.field = field; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsHeapSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsHeapSelfTest.java new file mode 100644 index 0000000..0e92bf4 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsHeapSelfTest.java @@ -0,0 +1,30 @@ +/* + * 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.binary; + +/** + * Field tests for heap-based portables. + */ +public class BinaryFieldsHeapSelfTest extends BinaryFieldsAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected BinaryObjectExImpl toPortable(BinaryMarshaller marsh, Object obj) throws Exception { + byte[] bytes = marsh.marshal(obj); + + return new BinaryObjectImpl(portableContext(marsh), bytes, 0); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java new file mode 100644 index 0000000..d24d898 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.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.binary; + +import org.apache.ignite.internal.util.GridUnsafe; +import org.eclipse.jetty.util.ConcurrentHashSet; +import sun.misc.Unsafe; + +/** + * Field tests for heap-based portables. + */ +public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest { + /** Unsafe instance. */ + private static final Unsafe UNSAFE = GridUnsafe.unsafe(); + + /** Byte array offset for unsafe mechanics. */ + protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); + + /** Allocated unsafe pointer. */ + private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>(); + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + // Cleanup allocated objects. + for (Long ptr : ptrs) + UNSAFE.freeMemory(ptr); + + ptrs.clear(); + } + + /** {@inheritDoc} */ + @Override protected BinaryObjectExImpl toPortable(BinaryMarshaller marsh, Object obj) throws Exception { + byte[] arr = marsh.marshal(obj); + + long ptr = UNSAFE.allocateMemory(arr.length); + + ptrs.add(ptr); + + UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length); + + return new BinaryObjectOffheapImpl(portableContext(marsh), ptr, 0, arr.length); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java new file mode 100644 index 0000000..1e0f375 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsAbstractSelfTest.java @@ -0,0 +1,205 @@ +/* + * 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.binary; + +import java.util.Arrays; +import org.apache.ignite.binary.BinaryField; +import org.apache.ignite.binary.BinaryTypeConfiguration; +import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.IgniteUtils; +import org.apache.ignite.marshaller.MarshallerContextTestImpl; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * Contains tests for compact offsets. + */ +public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbstractTest { + /** 2 pow 8. */ + private static int POW_8 = 1 << 8; + + /** 2 pow 16. */ + private static int POW_16 = 1 << 16; + + /** Marshaller. */ + protected BinaryMarshaller marsh; + + /** Portable context. */ + protected PortableContext ctx; + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration()); + + marsh = new BinaryMarshaller(); + + IgniteConfiguration iCfg = new IgniteConfiguration(); + + BinaryConfiguration bCfg = new BinaryConfiguration(); + + bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName()))); + + bCfg.setCompactFooter(compactFooter()); + + iCfg.setBinaryConfiguration(bCfg); + + marsh.setContext(new MarshallerContextTestImpl(null)); + + IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg); + } + + /** + * @return Whether to use compact footers. + */ + protected boolean compactFooter() { + return true; + } + + /** + * Test 1 byte. + * + * @throws Exception If failed. + */ + public void test1Byte() throws Exception { + check(POW_8 >> 2); + } + + /** + * Test 1 byte with sign altering. + * + * @throws Exception If failed. + */ + public void test1ByteSign() throws Exception { + check(POW_8 >> 1); + } + + /** + * Test 2 bytes. + * + * @throws Exception If failed. + */ + public void test2Bytes() throws Exception { + check(POW_16 >> 2); + } + + /** + * Test 2 bytes with sign altering. + * + * @throws Exception If failed. + */ + public void test2BytesSign() throws Exception { + check(POW_16 >> 1); + } + + /** + * Test 4 bytes. + * + * @throws Exception If failed. + */ + public void test4Bytes() throws Exception { + check(POW_16 << 2); + } + + /** + * Main check routine. + * + * @param len Length of the first field. + * + * @throws Exception If failed. + */ + private void check(int len) throws Exception { + TestObject obj = new TestObject(len); + + BinaryObjectExImpl portObj = toPortable(marsh, obj); + + // 1. Test portable object content. + assert portObj.hasField("field1"); + assert portObj.hasField("field2"); + + byte[] field1 = portObj.field("field1"); + Integer field2 = portObj.field("field2"); + + assert field1 != null; + assert field2 != null; + + assert Arrays.equals(obj.field1, field1); + assert obj.field2 == field2; + + // 2. Test fields API. + BinaryField field1Desc = portObj.type().field("field1"); + BinaryField field2Desc = portObj.type().field("field2"); + + assert field1Desc.exists(portObj); + assert field2Desc.exists(portObj); + + assert Arrays.equals(obj.field1, (byte[])field1Desc.value(portObj)); + assert obj.field2 == (Integer)field2Desc.value(portObj); + + // 3. Test deserialize. + TestObject objRestored = portObj.deserialize(); + + assert objRestored != null; + + assert Arrays.equals(obj.field1, objRestored.field1); + assert obj.field2 == objRestored.field2; + } + + /** + * Convert object to portable object. + * + * @param marsh Marshaller. + * @param obj Object. + * @return Portable object. + * @throws Exception If failed. + */ + protected abstract BinaryObjectExImpl toPortable(BinaryMarshaller marsh, Object obj) throws Exception; + + /** + * Test object. + */ + public static class TestObject { + /** First field with variable length. */ + public byte[] field1; + + /** Second field. */ + public int field2; + + /** + * Default constructor. + */ + public TestObject() { + // No-op. + } + + /** + * Constructor. + * + * @param len Array length. + */ + public TestObject(int len) { + field1 = new byte[len]; + + field1[0] = 1; + field1[len - 1] = 2; + + field2 = len; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsHeapSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsHeapSelfTest.java new file mode 100644 index 0000000..68e897e --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsHeapSelfTest.java @@ -0,0 +1,30 @@ +/* + * 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.binary; + +/** + * Compact offsets tests for heap portable objects. + */ +public class BinaryFooterOffsetsHeapSelfTest extends BinaryFooterOffsetsAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected BinaryObjectExImpl toPortable(BinaryMarshaller marsh, Object obj) throws Exception { + byte[] bytes = marsh.marshal(obj); + + return new BinaryObjectImpl(ctx, bytes, 0); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/1dbf20e0/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java new file mode 100644 index 0000000..f0f0396 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.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.binary; + +import org.apache.ignite.internal.util.GridUnsafe; +import org.eclipse.jetty.util.ConcurrentHashSet; +import sun.misc.Unsafe; + +/** + * Compact offsets tests for offheap portable objects. + */ +public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstractSelfTest { + /** Unsafe instance. */ + private static final Unsafe UNSAFE = GridUnsafe.unsafe(); + + /** Byte array offset for unsafe mechanics. */ + protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class); + + /** Allocated unsafe pointer. */ + private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>(); + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + // Cleanup allocated objects. + for (Long ptr : ptrs) + UNSAFE.freeMemory(ptr); + + ptrs.clear(); + } + + /** {@inheritDoc} */ + @Override protected BinaryObjectExImpl toPortable(BinaryMarshaller marsh, Object obj) throws Exception { + byte[] arr = marsh.marshal(obj); + + long ptr = UNSAFE.allocateMemory(arr.length); + + ptrs.add(ptr); + + UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length); + + return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length); + } +}
