Merged IGNITE-950-new into IGNITE-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b783d2b7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b783d2b7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b783d2b7 Branch: refs/heads/ignite-1282 Commit: b783d2b71a3b05cecc62d114283e8d92dffcb126 Parents: 76b65b2 Author: Alexey Goncharuk <[email protected]> Authored: Thu Nov 5 16:09:03 2015 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Thu Nov 5 16:09:09 2015 +0300 ---------------------------------------------------------------------- .../config/binary/example-ignite-binary.xml | 44 + .../config/portable/example-ignite-portable.xml | 44 - .../apache/ignite/examples/binary/Address.java | 72 + .../apache/ignite/examples/binary/Employee.java | 93 + .../ignite/examples/binary/EmployeeKey.java | 90 + .../binary/ExampleBinaryNodeStartup.java | 36 + .../ignite/examples/binary/Organization.java | 93 + .../examples/binary/OrganizationType.java | 32 + ...ComputeClientBinaryTaskExecutionExample.java | 153 + .../binary/computegrid/ComputeClientTask.java | 116 + .../binary/computegrid/package-info.java | 21 + .../CacheClientBinaryPutGetExample.java | 230 ++ .../datagrid/CacheClientBinaryQueryExample.java | 330 +++ .../examples/binary/datagrid/package-info.java | 21 + .../ignite/examples/binary/package-info.java | 21 + .../ignite/examples/portable/Address.java | 72 - .../ignite/examples/portable/Employee.java | 93 - .../ignite/examples/portable/EmployeeKey.java | 90 - .../portable/ExamplePortableNodeStartup.java | 36 - .../ignite/examples/portable/Organization.java | 93 - .../examples/portable/OrganizationType.java | 32 - ...mputeClientPortableTaskExecutionExample.java | 154 - .../portable/computegrid/ComputeClientTask.java | 116 - .../portable/computegrid/package-info.java | 21 - .../CacheClientPortablePutGetExample.java | 230 -- .../CacheClientPortableQueryExample.java | 325 -- .../portable/datagrid/package-info.java | 21 - .../ignite/examples/portable/package-info.java | 21 - .../CacheClientPortableExampleTest.java | 8 +- .../ComputeClientPortableExampleTest.java | 4 +- .../ignite/codegen/MessageCodeGenerator.java | 5 +- .../src/main/java/org/apache/ignite/Ignite.java | 6 +- .../java/org/apache/ignite/IgniteBinary.java | 366 +++ .../java/org/apache/ignite/IgniteCache.java | 14 +- .../org/apache/ignite/IgniteDataStreamer.java | 16 + .../java/org/apache/ignite/IgnitePortables.java | 370 --- .../org/apache/ignite/binary/BinaryField.java | 46 + .../binary/BinaryInvalidTypeException.java | 58 + .../org/apache/ignite/binary/BinaryObject.java | 163 + .../ignite/binary/BinaryObjectBuilder.java | 136 + .../ignite/binary/BinaryObjectException.java | 57 + .../apache/ignite/binary/BinaryRawReader.java | 240 ++ .../apache/ignite/binary/BinaryRawWriter.java | 225 ++ .../org/apache/ignite/binary/BinaryReader.java | 290 ++ .../apache/ignite/binary/BinarySerializer.java | 49 + .../org/apache/ignite/binary/BinaryType.java | 59 + .../ignite/binary/BinaryTypeConfiguration.java | 156 + .../ignite/binary/BinaryTypeIdMapper.java | 56 + .../org/apache/ignite/binary/BinaryWriter.java | 273 ++ .../org/apache/ignite/binary/Binarylizable.java | 48 + .../org/apache/ignite/binary/package-info.java | 22 + .../ignite/cache/CacheKeyConfiguration.java | 92 + .../apache/ignite/cache/CacheTypeMetadata.java | 67 +- .../org/apache/ignite/cache/IgniteObject.java | 60 - .../org/apache/ignite/cache/QueryEntity.java | 217 ++ .../org/apache/ignite/cache/QueryIndex.java | 192 ++ .../org/apache/ignite/cache/QueryIndexType.java | 38 + .../configuration/CacheConfiguration.java | 662 ++++- .../configuration/IgniteConfiguration.java | 24 + .../ignite/internal/GridKernalContextImpl.java | 4 +- .../apache/ignite/internal/IgniteKernal.java | 17 +- .../internal/client/GridClientCompute.java | 2 +- .../impl/connection/GridClientConnection.java | 2 +- .../GridClientConnectionManagerAdapter.java | 2 +- .../connection/GridClientNioTcpConnection.java | 6 +- .../communication/GridIoMessageFactory.java | 4 +- .../swapspace/GridSwapSpaceManager.java | 34 - .../internal/portable/BinaryFieldImpl.java | 104 + .../portable/BinaryMetaDataCollector.java | 263 ++ .../internal/portable/BinaryMetaDataImpl.java | 150 + .../internal/portable/BinaryObjectEx.java | 245 ++ .../internal/portable/BinaryObjectImpl.java | 606 ++++ .../portable/BinaryObjectOffheapImpl.java | 470 +++ .../internal/portable/BinaryRawReaderEx.java | 33 + .../internal/portable/BinaryRawWriterEx.java | 60 + .../internal/portable/BinaryReaderExImpl.java | 2774 +++++++++++++++++ .../internal/portable/BinaryWriterExImpl.java | 1915 ++++++++++++ .../portable/GridPortableMarshaller.java | 32 +- .../portable/PortableClassDescriptor.java | 146 +- .../internal/portable/PortableContext.java | 184 +- .../internal/portable/PortableFieldImpl.java | 104 - .../portable/PortableMetaDataCollector.java | 263 -- .../portable/PortableMetaDataHandler.java | 12 +- .../internal/portable/PortableMetaDataImpl.java | 150 - .../internal/portable/PortableObjectEx.java | 245 -- .../internal/portable/PortableObjectImpl.java | 586 ---- .../portable/PortableObjectOffheapImpl.java | 458 --- .../internal/portable/PortableRawReaderEx.java | 33 - .../internal/portable/PortableRawWriterEx.java | 60 - .../portable/PortableReaderContext.java | 8 +- .../internal/portable/PortableReaderExImpl.java | 2775 ------------------ .../ignite/internal/portable/PortableUtils.java | 14 +- .../internal/portable/PortableWriterExImpl.java | 1915 ------------ .../builder/BinaryObjectBuilderImpl.java | 569 ++++ .../portable/builder/PortableBuilderEnum.java | 8 +- .../portable/builder/PortableBuilderImpl.java | 570 ---- .../portable/builder/PortableBuilderReader.java | 56 +- .../PortableBuilderSerializationAware.java | 2 +- .../builder/PortableBuilderSerializer.java | 30 +- .../builder/PortableEnumArrayLazyValue.java | 12 +- .../portable/builder/PortableLazyArrayList.java | 2 +- .../builder/PortableLazyLinkedList.java | 2 +- .../portable/builder/PortableLazyMap.java | 2 +- .../portable/builder/PortableLazyMapEntry.java | 2 +- .../portable/builder/PortableLazySet.java | 4 +- .../builder/PortableModifiableLazyValue.java | 2 +- .../builder/PortableObjectArrayLazyValue.java | 8 +- .../builder/PortablePlainLazyValue.java | 2 +- .../builder/PortablePlainPortableObject.java | 22 +- .../portable/builder/PortableValueWithType.java | 8 +- .../streams/PortableAbstractInputStream.java | 6 +- .../affinity/GridAffinityAssignmentCache.java | 3 +- .../affinity/GridAffinityProcessor.java | 5 +- .../processors/cache/CacheInvokeEntry.java | 11 +- .../processors/cache/CacheLazyEntry.java | 23 +- .../internal/processors/cache/CacheObject.java | 11 +- .../processors/cache/CacheObjectAdapter.java | 2 +- .../cache/CacheObjectByteArrayImpl.java | 7 +- .../processors/cache/CacheObjectContext.java | 128 +- .../processors/cache/CacheObjectImpl.java | 5 + .../processors/cache/CacheOperationContext.java | 22 +- .../processors/cache/GridCacheAdapter.java | 98 +- .../cache/GridCacheConcurrentMap.java | 10 +- .../processors/cache/GridCacheContext.java | 14 +- .../processors/cache/GridCacheEntryEx.java | 15 +- .../processors/cache/GridCacheEventManager.java | 31 +- .../cache/GridCacheEvictionManager.java | 5 +- .../processors/cache/GridCacheMapEntry.java | 153 +- .../processors/cache/GridCacheProxyImpl.java | 4 +- .../processors/cache/GridCacheReturn.java | 27 +- .../processors/cache/GridCacheSwapManager.java | 37 +- .../processors/cache/GridCacheUtils.java | 3 + .../processors/cache/IgniteCacheProxy.java | 8 +- .../processors/cache/IgniteInternalCache.java | 6 +- .../processors/cache/KeyCacheObjectImpl.java | 5 + .../CacheDataStructuresManager.java | 4 +- .../GridDistributedCacheAdapter.java | 40 +- .../distributed/GridDistributedCacheEntry.java | 9 +- .../distributed/GridDistributedLockRequest.java | 17 + .../GridDistributedTxRemoteAdapter.java | 3 + .../distributed/dht/GridDhtCacheEntry.java | 5 +- .../distributed/dht/GridDhtLocalPartition.java | 3 +- .../distributed/dht/GridDhtLockFuture.java | 10 +- .../distributed/dht/GridDhtLockRequest.java | 3 + .../dht/GridDhtTransactionalCacheAdapter.java | 23 +- .../distributed/dht/GridDhtTxLocalAdapter.java | 17 +- .../distributed/dht/GridDhtTxPrepareFuture.java | 15 +- .../cache/distributed/dht/GridDhtTxRemote.java | 12 +- .../dht/GridPartitionedGetFuture.java | 6 +- .../dht/atomic/GridDhtAtomicCache.java | 75 +- .../dht/atomic/GridDhtAtomicUpdateFuture.java | 6 +- .../dht/atomic/GridDhtAtomicUpdateRequest.java | 82 +- .../dht/atomic/GridNearAtomicUpdateFuture.java | 15 +- .../dht/atomic/GridNearAtomicUpdateRequest.java | 68 +- .../atomic/GridNearAtomicUpdateResponse.java | 5 +- .../dht/colocated/GridDhtColocatedCache.java | 29 +- .../colocated/GridDhtColocatedLockFuture.java | 14 +- .../dht/preloader/GridDhtForceKeysFuture.java | 2 +- .../preloader/GridDhtPartitionDemandPool.java | 2 +- .../distributed/near/GridNearAtomicCache.java | 4 + .../distributed/near/GridNearCacheEntry.java | 17 +- .../distributed/near/GridNearGetFuture.java | 47 +- .../distributed/near/GridNearLockFuture.java | 14 +- .../distributed/near/GridNearLockRequest.java | 2 + .../near/GridNearTransactionalCache.java | 8 +- .../cache/distributed/near/GridNearTxLocal.java | 9 +- .../distributed/near/GridNearTxRemote.java | 12 +- .../cache/local/GridLocalCacheEntry.java | 16 +- .../cache/local/GridLocalLockFuture.java | 3 +- .../local/atomic/GridLocalAtomicCache.java | 108 +- .../CacheDefaultPortableAffinityKeyMapper.java | 8 +- .../portable/CacheObjectBinaryProcessor.java | 103 + .../CacheObjectBinaryProcessorImpl.java | 1046 +++++++ .../portable/CacheObjectPortableContext.java | 133 - .../portable/CacheObjectPortableProcessor.java | 103 - .../CacheObjectPortableProcessorImpl.java | 1043 ------- .../cache/portable/IgniteBinaryImpl.java | 177 ++ .../cache/portable/IgnitePortablesImpl.java | 177 -- .../cache/query/GridCacheQueryManager.java | 13 +- .../cache/query/GridCacheQueryRequest.java | 4 +- .../continuous/CacheContinuousQueryEvent.java | 7 +- .../store/GridCacheStoreManagerAdapter.java | 47 +- .../transactions/IgniteTransactionsImpl.java | 10 +- .../cache/transactions/IgniteTxAdapter.java | 5 +- .../cache/transactions/IgniteTxEntry.java | 54 +- .../transactions/IgniteTxLocalAdapter.java | 109 +- .../cache/transactions/IgniteTxLocalEx.java | 1 + .../cache/transactions/IgniteTxManager.java | 2 +- .../cacheobject/IgniteCacheObjectProcessor.java | 6 + .../IgniteCacheObjectProcessorImpl.java | 9 + .../processors/cacheobject/NoOpBinary.java | 80 + .../datastreamer/DataStreamProcessor.java | 1 + .../datastreamer/DataStreamerEntry.java | 6 +- .../datastreamer/DataStreamerImpl.java | 16 +- .../datastreamer/DataStreamerRequest.java | 58 +- .../datastreamer/DataStreamerUpdateJob.java | 10 +- .../platform/PlatformAbstractTarget.java | 30 +- .../processors/platform/PlatformContext.java | 26 +- .../platform/PlatformContextImpl.java | 55 +- .../platform/PlatformExtendedException.java | 4 +- .../platform/PlatformProcessorImpl.java | 6 +- .../platform/cache/PlatformCache.java | 45 +- .../cache/PlatformCacheEntryFilterImpl.java | 6 +- .../cache/PlatformCacheEntryProcessorImpl.java | 12 +- .../platform/cache/PlatformCacheIterator.java | 4 +- .../PlatformCachePartialUpdateException.java | 4 +- .../cache/affinity/PlatformAffinity.java | 8 +- .../query/PlatformAbstractQueryCursor.java | 10 +- .../PlatformContinuousQueryRemoteFilter.java | 4 +- .../cache/query/PlatformFieldsQueryCursor.java | 4 +- .../cache/query/PlatformQueryCursor.java | 4 +- .../cache/store/PlatformCacheStoreCallback.java | 6 +- .../platform/cluster/PlatformClusterGroup.java | 12 +- .../cluster/PlatformClusterNodeFilterImpl.java | 4 +- .../platform/compute/PlatformAbstractJob.java | 4 +- .../platform/compute/PlatformAbstractTask.java | 6 +- .../platform/compute/PlatformClosureJob.java | 4 +- .../platform/compute/PlatformCompute.java | 26 +- .../platform/compute/PlatformFullJob.java | 6 +- .../platform/compute/PlatformFullTask.java | 12 +- .../datastreamer/PlatformDataStreamer.java | 5 +- .../PlatformStreamReceiverImpl.java | 4 +- .../dotnet/PlatformDotNetCacheStore.java | 50 +- .../PlatformDotNetConfigurationClosure.java | 16 +- .../events/PlatformEventFilterListenerImpl.java | 6 +- .../platform/events/PlatformEvents.java | 18 +- .../messaging/PlatformMessageFilterImpl.java | 6 +- .../messaging/PlatformMessageLocalFilter.java | 4 +- .../platform/messaging/PlatformMessaging.java | 8 +- .../services/PlatformAbstractService.java | 16 +- .../platform/services/PlatformServices.java | 20 +- .../transactions/PlatformTransactions.java | 5 +- .../platform/utils/PlatformFutureUtils.java | 10 +- .../platform/utils/PlatformReaderBiClosure.java | 4 +- .../platform/utils/PlatformReaderClosure.java | 4 +- .../platform/utils/PlatformUtils.java | 60 +- .../platform/utils/PlatformWriterBiClosure.java | 4 +- .../platform/utils/PlatformWriterClosure.java | 4 +- .../processors/query/GridQueryIndexing.java | 18 +- .../processors/query/GridQueryProcessor.java | 618 ++-- .../client/message/GridClientTaskRequest.java | 6 +- .../ignite/internal/util/IgniteUtils.java | 9 +- .../marshaller/portable/PortableMarshaller.java | 42 +- .../apache/ignite/portable/PortableBuilder.java | 137 - .../ignite/portable/PortableException.java | 57 - .../apache/ignite/portable/PortableField.java | 46 - .../ignite/portable/PortableIdMapper.java | 56 - .../portable/PortableInvalidClassException.java | 58 - .../ignite/portable/PortableMarshalAware.java | 48 - .../ignite/portable/PortableMetadata.java | 61 - .../apache/ignite/portable/PortableObject.java | 163 - .../ignite/portable/PortableRawReader.java | 240 -- .../ignite/portable/PortableRawWriter.java | 225 -- .../apache/ignite/portable/PortableReader.java | 291 -- .../ignite/portable/PortableSerializer.java | 49 - .../portable/PortableTypeConfiguration.java | 177 -- .../apache/ignite/portable/PortableWriter.java | 273 -- .../apache/ignite/portable/package-info.java | 22 - .../spi/discovery/tcp/TcpDiscoverySpi.java | 2 + .../apache/ignite/spi/swapspace/SwapKey.java | 9 +- .../org/apache/ignite/stream/StreamAdapter.java | 3 +- .../portable/BinaryFieldsAbstractSelfTest.java | 730 +++++ .../portable/BinaryFieldsHeapSelfTest.java | 32 + .../portable/BinaryFieldsOffheapSelfTest.java | 61 + ...idBinaryObjectBuilderAdditionalSelfTest.java | 1289 ++++++++ .../GridBinaryObjectBuilderSelfTest.java | 1069 +++++++ ...tBuilderStringAsCharsAdditionalSelfTest.java | 28 + ...inaryObjectBuilderStringAsCharsSelfTest.java | 28 + .../GridPortableAffinityKeySelfTest.java | 10 +- .../GridPortableBuilderAdditionalSelfTest.java | 1289 -------- .../portable/GridPortableBuilderSelfTest.java | 1069 ------- ...eBuilderStringAsCharsAdditionalSelfTest.java | 28 - ...ridPortableBuilderStringAsCharsSelfTest.java | 28 - ...idPortableMarshallerCtxDisabledSelfTest.java | 27 +- .../GridPortableMarshallerSelfTest.java | 478 +-- .../GridPortableMetaDataDisabledSelfTest.java | 64 +- .../portable/GridPortableMetaDataSelfTest.java | 52 +- .../portable/GridPortableWildcardsSelfTest.java | 73 +- .../PortableCompactOffsetsAbstractSelfTest.java | 26 +- .../PortableCompactOffsetsHeapSelfTest.java | 4 +- .../PortableCompactOffsetsOffheapSelfTest.java | 4 +- .../PortableFieldsAbstractSelfTest.java | 729 ----- .../portable/PortableFieldsHeapSelfTest.java | 32 - .../portable/PortableFieldsOffheapSelfTest.java | 61 - .../GridBinaryMarshalerAwareTestClass.java | 67 + .../GridPortableMarshalerAwareTestClass.java | 67 - .../mutabletest/GridPortableTestClasses.java | 6 +- .../cache/CacheNearReaderUpdateTest.java | 62 +- .../cache/GridCacheAbstractSelfTest.java | 9 +- ...heOffHeapTieredEvictionAbstractSelfTest.java | 2 +- .../processors/cache/GridCacheTestEntryEx.java | 13 +- .../cache/IgniteCachePeekModesAbstractTest.java | 30 +- ...IgniteCacheAbstractExecutionContextTest.java | 5 + .../IgniteCacheTxExecutionContextTest.java | 2 + ...tractDistributedByteArrayValuesSelfTest.java | 4 + ...naryObjectsAbstractDataStreamerSelfTest.java | 190 ++ ...aryObjectsAbstractMultiThreadedSelfTest.java | 231 ++ .../GridCacheBinaryObjectsAbstractSelfTest.java | 981 +++++++ ...ntNodeBinaryObjectMetadataMultinodeTest.java | 295 ++ ...CacheClientNodeBinaryObjectMetadataTest.java | 290 ++ ...ClientNodePortableMetadataMultinodeTest.java | 295 -- ...GridCacheClientNodePortableMetadataTest.java | 286 -- ...ableObjectsAbstractDataStreamerSelfTest.java | 190 -- ...bleObjectsAbstractMultiThreadedSelfTest.java | 231 -- ...ridCachePortableObjectsAbstractSelfTest.java | 978 ------ .../GridCachePortableStoreAbstractSelfTest.java | 4 +- .../GridCachePortableStoreObjectsSelfTest.java | 2 +- ...GridCachePortableStorePortablesSelfTest.java | 12 +- ...ridPortableCacheEntryMemorySizeSelfTest.java | 11 +- ...leDuplicateIndexObjectsAbstractSelfTest.java | 8 +- .../DataStreamProcessorPortableSelfTest.java | 11 +- .../GridDataStreamerImplSelfTest.java | 28 +- ...ridCacheAffinityRoutingPortableSelfTest.java | 10 +- ...rtableDataStreamerMultithreadedSelfTest.java | 4 +- ...tionedOnlyPortableMultithreadedSelfTest.java | 4 +- ...AtomicNearDisabledOffheapTieredSelfTest.java | 29 + ...BinaryObjectsAtomicNearDisabledSelfTest.java | 51 + ...inaryObjectsAtomicOffheapTieredSelfTest.java | 29 + .../GridCacheBinaryObjectsAtomicSelfTest.java | 51 + ...tionedNearDisabledOffheapTieredSelfTest.java | 30 + ...yObjectsPartitionedNearDisabledSelfTest.java | 51 + ...ObjectsPartitionedOffheapTieredSelfTest.java | 30 + ...idCacheBinaryObjectsPartitionedSelfTest.java | 51 + ...acheOffHeapTieredAtomicPortableSelfTest.java | 2 +- ...eapTieredEvictionAtomicPortableSelfTest.java | 8 +- ...heOffHeapTieredEvictionPortableSelfTest.java | 8 +- .../GridCacheOffHeapTieredPortableSelfTest.java | 2 +- ...AtomicNearDisabledOffheapTieredSelfTest.java | 29 - ...rtableObjectsAtomicNearDisabledSelfTest.java | 51 - ...tableObjectsAtomicOffheapTieredSelfTest.java | 29 - .../GridCachePortableObjectsAtomicSelfTest.java | 51 - ...tionedNearDisabledOffheapTieredSelfTest.java | 30 - ...eObjectsPartitionedNearDisabledSelfTest.java | 51 - ...ObjectsPartitionedOffheapTieredSelfTest.java | 30 - ...CachePortableObjectsPartitionedSelfTest.java | 51 - ...ridCacheBinaryObjectsReplicatedSelfTest.java | 51 + ...dCachePortableObjectsReplicatedSelfTest.java | 51 - ...idCacheBinaryObjectsAtomicLocalSelfTest.java | 32 + ...BinaryObjectsLocalOffheapTieredSelfTest.java | 29 + .../GridCacheBinaryObjectsLocalSelfTest.java | 51 + ...CachePortableObjectsAtomicLocalSelfTest.java | 32 - ...rtableObjectsLocalOffheapTieredSelfTest.java | 29 - .../GridCachePortableObjectsLocalSelfTest.java | 51 - .../DataStreamProcessorSelfTest.java | 8 + .../loadtests/hashmap/GridHashMapLoadTest.java | 3 +- .../PlatformComputePortableArgTask.java | 8 +- .../platform/PlatformEventsWriteEventTask.java | 6 +- .../file/GridFileSwapSpaceSpiSelfTest.java | 11 +- .../ignite/testframework/junits/IgniteMock.java | 4 +- .../multijvm/IgniteCacheProcessProxy.java | 4 +- .../junits/multijvm/IgniteProcessProxy.java | 4 +- .../IgnitePortableObjectsTestSuite.java | 80 +- .../processors/query/h2/IgniteH2Indexing.java | 25 +- .../query/h2/opt/GridH2ValueCacheObject.java | 8 +- .../query/h2/opt/GridLuceneIndex.java | 4 +- .../IgniteCacheAbstractFieldsQuerySelfTest.java | 3 +- ...CacheOffheapTieredMultithreadedSelfTest.java | 25 +- ...niteCacheP2pUnmarshallingQueryErrorTest.java | 19 +- ...hePartitionedQueryMultiThreadedSelfTest.java | 22 +- .../h2/GridIndexingSpiAbstractSelfTest.java | 7 +- .../Cache/CacheAbstractTest.cs | 2 +- .../Config/Compute/compute-grid1.xml | 6 +- .../org/apache/ignite/IgniteSpringBean.java | 4 +- .../yardstick/cache/model/Organization.java | 14 +- .../ignite/yardstick/cache/model/Person.java | 14 +- .../ignite/yardstick/cache/model/SampleKey.java | 14 +- .../yardstick/cache/model/SampleValue.java | 14 +- parent/pom.xml | 7 +- 368 files changed, 22090 insertions(+), 20179 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/config/binary/example-ignite-binary.xml ---------------------------------------------------------------------- diff --git a/examples/config/binary/example-ignite-binary.xml b/examples/config/binary/example-ignite-binary.xml new file mode 100644 index 0000000..cde15ea --- /dev/null +++ b/examples/config/binary/example-ignite-binary.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + Ignite configuration with all defaults and enabled p2p deployment, events and portable marshaller. + + Use this configuration file when running HTTP REST examples (see 'examples/rest' folder). + + When starting a standalone node, you need to execute the following command: + {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/portable/example-ignite-portable.xml + + When starting Ignite from Java IDE, pass path to this file to Ignition: + Ignition.start("examples/config/portable/example-ignite-portable.xml"); +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <!-- Imports default Ignite configuration --> + <import resource="../example-default.xml"/> + + <bean parent="ignite.cfg"> + <!-- Enables portable marshaller --> + <property name="marshaller"> + <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"/> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/config/portable/example-ignite-portable.xml ---------------------------------------------------------------------- diff --git a/examples/config/portable/example-ignite-portable.xml b/examples/config/portable/example-ignite-portable.xml deleted file mode 100644 index cde15ea..0000000 --- a/examples/config/portable/example-ignite-portable.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<!-- - Ignite configuration with all defaults and enabled p2p deployment, events and portable marshaller. - - Use this configuration file when running HTTP REST examples (see 'examples/rest' folder). - - When starting a standalone node, you need to execute the following command: - {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/portable/example-ignite-portable.xml - - When starting Ignite from Java IDE, pass path to this file to Ignition: - Ignition.start("examples/config/portable/example-ignite-portable.xml"); ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> - <!-- Imports default Ignite configuration --> - <import resource="../example-default.xml"/> - - <bean parent="ignite.cfg"> - <!-- Enables portable marshaller --> - <property name="marshaller"> - <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"/> - </property> - </bean> -</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/Address.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/Address.java b/examples/src/main/java/org/apache/ignite/examples/binary/Address.java new file mode 100644 index 0000000..76d8774 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/Address.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary; + +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.Binarylizable; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; + +/** + * Employee address. + * <p> + * This class implements {@link org.apache.ignite.binary.Binarylizable} only for example purposes, + * in order to show how to customize serialization and deserialization of + * binary objects. + */ +public class Address implements Binarylizable { + /** Street. */ + private String street; + + /** ZIP code. */ + private int zip; + + /** + * Required for binary deserialization. + */ + public Address() { + // No-op. + } + + /** + * @param street Street. + * @param zip ZIP code. + */ + public Address(String street, int zip) { + this.street = street; + this.zip = zip; + } + + /** {@inheritDoc} */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeString("street", street); + writer.writeInt("zip", zip); + } + + /** {@inheritDoc} */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + street = reader.readString("street"); + zip = reader.readInt("zip"); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Address [street=" + street + + ", zip=" + zip + ']'; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java b/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java new file mode 100644 index 0000000..744b44f --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/Employee.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary; + +import java.util.Collection; + +/** + * This class represents employee object. + */ +public class Employee { + /** Name. */ + private String name; + + /** Salary. */ + private long salary; + + /** Address. */ + private Address address; + + /** Departments. */ + private Collection<String> departments; + + /** + * Required for binary deserialization. + */ + public Employee() { + // No-op. + } + + /** + * @param name Name. + * @param salary Salary. + * @param address Address. + * @param departments Departments. + */ + public Employee(String name, long salary, Address address, Collection<String> departments) { + this.name = name; + this.salary = salary; + this.address = address; + this.departments = departments; + } + + /** + * @return Name. + */ + public String name() { + return name; + } + + /** + * @return Salary. + */ + public long salary() { + return salary; + } + + /** + * @return Address. + */ + public Address address() { + return address; + } + + /** + * @return Departments. + */ + public Collection<String> departments() { + return departments; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Employee [name=" + name + + ", salary=" + salary + + ", address=" + address + + ", departments=" + departments + ']'; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java b/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java new file mode 100644 index 0000000..2794230 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/EmployeeKey.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary; + +/** + * This class represents key for employee object. + * <p> + * Used in query example to collocate employees + * with their organizations. + */ +public class EmployeeKey { + /** ID. */ + private int id; + + /** Organization ID. */ + private int organizationId; + + /** + * Required for binary deserialization. + */ + public EmployeeKey() { + // No-op. + } + + /** + * @param id ID. + * @param organizationId Organization ID. + */ + public EmployeeKey(int id, int organizationId) { + this.id = id; + this.organizationId = organizationId; + } + + /** + * @return ID. + */ + public int id() { + return id; + } + + /** + * @return Organization ID. + */ + public int organizationId() { + return organizationId; + } + + /** {@inheritDoc} */ + @Override public boolean equals(Object o) { + if (this == o) + return true; + + if (o == null || getClass() != o.getClass()) + return false; + + EmployeeKey key = (EmployeeKey)o; + + return id == key.id && organizationId == key.organizationId; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + int res = id; + + res = 31 * res + organizationId; + + return res; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "EmployeeKey [id=" + id + + ", organizationId=" + organizationId + ']'; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java new file mode 100644 index 0000000..30a015b --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/ExampleBinaryNodeStartup.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary; + +import org.apache.ignite.IgniteException; +import org.apache.ignite.Ignition; + +/** + * Starts up an empty node with example configuration and binary marshaller enabled. + */ +public class ExampleBinaryNodeStartup { + /** + * Start up an empty node with example configuration and binary marshaller enabled. + * + * @param args Command line arguments, none required. + * @throws IgniteException If failed. + */ + public static void main(String[] args) throws IgniteException { + Ignition.start("examples/config/binary/example-ignite-binary.xml"); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java b/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java new file mode 100644 index 0000000..b42bb27 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/Organization.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary; + +import java.sql.Timestamp; + +/** + * This class represents organization object. + */ +public class Organization { + /** Name. */ + private String name; + + /** Address. */ + private Address address; + + /** Type. */ + private OrganizationType type; + + /** Last update time. */ + private Timestamp lastUpdated; + + /** + * Required for binary deserialization. + */ + public Organization() { + // No-op. + } + + /** + * @param name Name. + * @param address Address. + * @param type Type. + * @param lastUpdated Last update time. + */ + public Organization(String name, Address address, OrganizationType type, Timestamp lastUpdated) { + this.name = name; + this.address = address; + this.type = type; + this.lastUpdated = lastUpdated; + } + + /** + * @return Name. + */ + public String name() { + return name; + } + + /** + * @return Address. + */ + public Address address() { + return address; + } + + /** + * @return Type. + */ + public OrganizationType type() { + return type; + } + + /** + * @return Last update time. + */ + public Timestamp lastUpdated() { + return lastUpdated; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Organization [name=" + name + + ", address=" + address + + ", type=" + type + + ", lastUpdated=" + lastUpdated + ']'; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java b/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java new file mode 100644 index 0000000..6548210 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/OrganizationType.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary; + +/** + * Organization type enum. + */ +public enum OrganizationType { + /** Non-profit organization. */ + NON_PROFIT, + + /** Private organization. */ + PRIVATE, + + /** Government organization. */ + GOVERNMENT +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java new file mode 100644 index 0000000..ae5d169 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientBinaryTaskExecutionExample.java @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary.computegrid; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.examples.binary.Address; +import org.apache.ignite.examples.binary.Employee; +import org.apache.ignite.binary.BinaryObject; + +/** + * This example demonstrates use of binary objects with task execution. + * Specifically it shows that binary objects are simple Java POJOs and do not require any special treatment. + * <p> + * The example executes map-reduce task that accepts collection of binary objects as an argument. + * Since these objects are never deserialized on remote nodes, classes are not required on classpath + * of these nodes. + * <p> + * Remote nodes should always be started with special configuration file which + * enables the binary marshaller: {@code 'ignite.{sh|bat} examples/config/binary/example-ignite-binary.xml'}. + * <p> + * Alternatively you can run {@link org.apache.ignite.examples.binary.ExampleBinaryNodeStartup} in another JVM which will + * start node with {@code examples/config/binary/example-ignite-binary.xml} configuration. + */ +public class ComputeClientBinaryTaskExecutionExample { + /** + * Executes example. + * + * @param args Command line arguments, none required. + */ + public static void main(String[] args) { + try (Ignite ignite = Ignition.start("examples/config/binary/example-ignite-binary.xml")) { + System.out.println(); + System.out.println(">>> Binary objects task execution example started."); + + if (ignite.cluster().forRemotes().nodes().isEmpty()) { + System.out.println(); + System.out.println(">>> This example requires remote nodes to be started."); + System.out.println(">>> Please start at least 1 remote node."); + System.out.println(">>> Refer to example's javadoc for details on configuration."); + System.out.println(); + + return; + } + + // Generate employees to calculate average salary for. + Collection<Employee> employees = employees(); + + System.out.println(); + System.out.println(">>> Calculating average salary for employees:"); + + for (Employee employee : employees) + System.out.println(">>> " + employee); + + // Convert collection of employees to collection of binary objects. + // This allows to send objects across nodes without requiring to have + // Employee class on classpath of these nodes. + Collection<BinaryObject> binaries = ignite.binary().toBinary(employees); + + // Execute task and get average salary. + Long avgSalary = ignite.compute(ignite.cluster().forRemotes()).execute(new ComputeClientTask(), binaries); + + System.out.println(); + System.out.println(">>> Average salary for all employees: " + avgSalary); + System.out.println(); + } + } + + /** + * Creates collection of employees. + * + * @return Collection of employees. + */ + private static Collection<Employee> employees() { + Collection<Employee> employees = new ArrayList<>(); + + employees.add(new Employee( + "James Wilson", + 12500, + new Address("1096 Eddy Street, San Francisco, CA", 94109), + Arrays.asList("Human Resources", "Customer Service") + )); + + employees.add(new Employee( + "Daniel Adams", + 11000, + new Address("184 Fidler Drive, San Antonio, TX", 78205), + Arrays.asList("Development", "QA") + )); + + employees.add(new Employee( + "Cristian Moss", + 12500, + new Address("667 Jerry Dove Drive, Florence, SC", 29501), + Arrays.asList("Logistics") + )); + + employees.add(new Employee( + "Allison Mathis", + 25300, + new Address("2702 Freedom Lane, Hornitos, CA", 95325), + Arrays.asList("Development") + )); + + employees.add(new Employee( + "Breana Robbin", + 6500, + new Address("3960 Sundown Lane, Austin, TX", 78758), + Arrays.asList("Sales") + )); + + employees.add(new Employee( + "Philip Horsley", + 19800, + new Address("2803 Elsie Drive, Sioux Falls, SD", 57104), + Arrays.asList("Sales") + )); + + employees.add(new Employee( + "Brian Peters", + 10600, + new Address("1407 Pearlman Avenue, Boston, MA", 12110), + Arrays.asList("Development", "QA") + )); + + employees.add(new Employee( + "Jack Yang", + 12900, + new Address("4425 Parrish Avenue Smithsons Valley, TX", 78130), + Arrays.asList("Sales") + )); + + return employees; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java new file mode 100644 index 0000000..36d6734 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/ComputeClientTask.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary.computegrid; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.apache.ignite.compute.ComputeJob; +import org.apache.ignite.compute.ComputeJobAdapter; +import org.apache.ignite.compute.ComputeJobResult; +import org.apache.ignite.compute.ComputeTaskSplitAdapter; +import org.apache.ignite.lang.IgniteBiTuple; +import org.apache.ignite.binary.BinaryObject; +import org.jetbrains.annotations.Nullable; + +/** + * Task that is used for {@link ComputeClientBinaryTaskExecutionExample} and + * similar examples in .NET and C++. + * <p> + * This task calculates average salary for provided collection of employees. + * It splits the collection into batches of size {@code 3} and creates a job + * for each batch. After all jobs are executed, there results are reduced to + * get the average salary. + */ +public class ComputeClientTask extends ComputeTaskSplitAdapter<Collection<BinaryObject>, Long> { + /** {@inheritDoc} */ + @Override protected Collection<? extends ComputeJob> split( + int gridSize, + Collection<BinaryObject> arg + ) { + Collection<ComputeClientJob> jobs = new ArrayList<>(); + + Collection<BinaryObject> employees = new ArrayList<>(); + + // Split provided collection into batches and + // create a job for each batch. + for (BinaryObject employee : arg) { + employees.add(employee); + + if (employees.size() == 3) { + jobs.add(new ComputeClientJob(employees)); + + employees = new ArrayList<>(3); + } + } + + if (!employees.isEmpty()) + jobs.add(new ComputeClientJob(employees)); + + return jobs; + } + + /** {@inheritDoc} */ + @Nullable @Override public Long reduce(List<ComputeJobResult> results) { + long sum = 0; + int cnt = 0; + + for (ComputeJobResult res : results) { + IgniteBiTuple<Long, Integer> t = res.getData(); + + sum += t.get1(); + cnt += t.get2(); + } + + return sum / cnt; + } + + /** + * Remote job for {@link ComputeClientTask}. + */ + private static class ComputeClientJob extends ComputeJobAdapter { + /** Collection of employees. */ + private final Collection<BinaryObject> employees; + + /** + * @param employees Collection of employees. + */ + private ComputeClientJob(Collection<BinaryObject> employees) { + this.employees = employees; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object execute() { + long sum = 0; + int cnt = 0; + + for (BinaryObject employee : employees) { + System.out.println(">>> Processing employee: " + employee.field("name")); + + // Get salary from binary object. Note that object + // doesn't need to be fully deserialized. + long salary = employee.field("salary"); + + sum += salary; + cnt++; + } + + return new IgniteBiTuple<>(sum, cnt); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java new file mode 100644 index 0000000..e5e9d7f --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/computegrid/package-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Demonstrates the usage of binary objects with task execution. + */ +package org.apache.ignite.examples.binary.computegrid; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java new file mode 100644 index 0000000..bb88ee0 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryPutGetExample.java @@ -0,0 +1,230 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary.datagrid; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.Ignition; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.examples.binary.Address; +import org.apache.ignite.examples.binary.Organization; +import org.apache.ignite.examples.binary.OrganizationType; +import org.apache.ignite.binary.BinaryObject; + +/** + * This example demonstrates use of binary objects with Ignite cache. + * Specifically it shows that binary objects are simple Java POJOs and do not require any special treatment. + * <p> + * The example executes several put-get operations on Ignite cache with binary values. Note that + * it demonstrates how binary object can be retrieved in fully-deserialized form or in binary object + * format using special cache projection. + * <p> + * Remote nodes should always be started with special configuration file which + * enables the binary marshaller: {@code 'ignite.{sh|bat} examples/config/binary/example-ignite-binary.xml'}. + * <p> + * Alternatively you can run {@link org.apache.ignite.examples.binary.ExampleBinaryNodeStartup} in another JVM which will + * start node with {@code examples/config/binary/example-ignite-binary.xml} configuration. + */ +@SuppressWarnings("TypeMayBeWeakened") +public class CacheClientBinaryPutGetExample { + /** Cache name. */ + private static final String CACHE_NAME = CacheClientBinaryPutGetExample.class.getSimpleName(); + + /** + * Executes example. + * + * @param args Command line arguments, none required. + */ + public static void main(String[] args) { + try (Ignite ignite = Ignition.start("examples/config/binary/example-ignite-binary.xml")) { + System.out.println(); + System.out.println(">>> Binary objects cache put-get example started."); + + CacheConfiguration<Integer, Organization> cfg = new CacheConfiguration<>(); + + cfg.setCacheMode(CacheMode.PARTITIONED); + cfg.setName(CACHE_NAME); + cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + + try (IgniteCache<Integer, Organization> cache = ignite.createCache(cfg)) { + if (ignite.cluster().forDataNodes(cache.getName()).nodes().isEmpty()) { + System.out.println(); + System.out.println(">>> This example requires remote cache node nodes to be started."); + System.out.println(">>> Please start at least 1 remote cache node."); + System.out.println(">>> Refer to example's javadoc for details on configuration."); + System.out.println(); + + return; + } + + putGet(cache); + putGetBinary(cache); + putGetAll(cache); + putGetAllBinary(cache); + + System.out.println(); + } + finally { + // Delete cache with its content completely. + ignite.destroyCache(CACHE_NAME); + } + } + } + + /** + * Execute individual put and get. + * + * @param cache Cache. + */ + private static void putGet(IgniteCache<Integer, Organization> cache) { + // Create new Organization binary object to store in cache. + Organization org = new Organization( + "Microsoft", // Name. + new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address. + OrganizationType.PRIVATE, // Type. + new Timestamp(System.currentTimeMillis())); // Last update time. + + // Put created data entry to cache. + cache.put(1, org); + + // Get recently created organization as a strongly-typed fully de-serialized instance. + Organization orgFromCache = cache.get(1); + + System.out.println(); + System.out.println(">>> Retrieved organization instance from cache: " + orgFromCache); + } + + /** + * Execute individual put and get, getting value in binary format, without de-serializing it. + * + * @param cache Cache. + */ + private static void putGetBinary(IgniteCache<Integer, Organization> cache) { + // Create new Organization binary object to store in cache. + Organization org = new Organization( + "Microsoft", // Name. + new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address. + OrganizationType.PRIVATE, // Type. + new Timestamp(System.currentTimeMillis())); // Last update time. + + // Put created data entry to cache. + cache.put(1, org); + + // Get cache that will get values as binary objects. + IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary(); + + // Get recently created organization as a binary object. + BinaryObject po = binaryCache.get(1); + + // Get organization's name from binary object (note that + // object doesn't need to be fully deserialized). + String name = po.field("name"); + + System.out.println(); + System.out.println(">>> Retrieved organization name from binary object: " + name); + } + + /** + * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations. + * + * @param cache Cache. + */ + private static void putGetAll(IgniteCache<Integer, Organization> cache) { + // Create new Organization binary objects to store in cache. + Organization org1 = new Organization( + "Microsoft", // Name. + new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address. + OrganizationType.PRIVATE, // Type. + new Timestamp(System.currentTimeMillis())); // Last update time. + + Organization org2 = new Organization( + "Red Cross", // Name. + new Address("184 Fidler Drive, San Antonio, TX", 78205), // Address. + OrganizationType.NON_PROFIT, // Type. + new Timestamp(System.currentTimeMillis())); // Last update time. + + Map<Integer, Organization> map = new HashMap<>(); + + map.put(1, org1); + map.put(2, org2); + + // Put created data entries to cache. + cache.putAll(map); + + // Get recently created organizations as a strongly-typed fully de-serialized instances. + Map<Integer, Organization> mapFromCache = cache.getAll(map.keySet()); + + System.out.println(); + System.out.println(">>> Retrieved organization instances from cache:"); + + for (Organization org : mapFromCache.values()) + System.out.println(">>> " + org); + } + + /** + * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations, + * getting values in binary format, without de-serializing it. + * + * @param cache Cache. + */ + private static void putGetAllBinary(IgniteCache<Integer, Organization> cache) { + // Create new Organization binary objects to store in cache. + Organization org1 = new Organization( + "Microsoft", // Name. + new Address("1096 Eddy Street, San Francisco, CA", 94109), // Address. + OrganizationType.PRIVATE, // Type. + new Timestamp(System.currentTimeMillis())); // Last update time. + + Organization org2 = new Organization( + "Red Cross", // Name. + new Address("184 Fidler Drive, San Antonio, TX", 78205), // Address. + OrganizationType.NON_PROFIT, // Type. + new Timestamp(System.currentTimeMillis())); // Last update time. + + Map<Integer, Organization> map = new HashMap<>(); + + map.put(1, org1); + map.put(2, org2); + + // Put created data entries to cache. + cache.putAll(map); + + // Get cache that will get values as binary objects. + IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary(); + + // Get recently created organizations as binary objects. + Map<Integer, BinaryObject> poMap = binaryCache.getAll(map.keySet()); + + Collection<String> names = new ArrayList<>(); + + // Get organizations' names from binary objects (note that + // objects don't need to be fully deserialized). + for (BinaryObject po : poMap.values()) + names.add(po.<String>field("name")); + + System.out.println(); + System.out.println(">>> Retrieved organization names from binary objects: " + names); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java new file mode 100644 index 0000000..c93848c --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/CacheClientBinaryQueryExample.java @@ -0,0 +1,330 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.binary.datagrid; + +import java.sql.Timestamp; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import javax.cache.Cache; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.Ignition; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.QueryIndex; +import org.apache.ignite.cache.QueryIndexType; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlFieldsQuery; +import org.apache.ignite.cache.query.SqlQuery; +import org.apache.ignite.cache.query.TextQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.examples.binary.Address; +import org.apache.ignite.examples.binary.Employee; +import org.apache.ignite.examples.binary.EmployeeKey; +import org.apache.ignite.examples.binary.Organization; +import org.apache.ignite.examples.binary.OrganizationType; +import org.apache.ignite.binary.BinaryObject; + +/** + * This example demonstrates use of binary objects with cache queries. + * The example populates cache with sample data and runs several SQL and full text queries over this data. + * <p> + * Remote nodes should always be started with {@link org.apache.ignite.examples.binary.ExampleBinaryNodeStartup} which starts a node with + * {@code examples/config/binary/example-ignite-binary.xml} configuration. + */ +public class CacheClientBinaryQueryExample { + /** Organization cache name. */ + private static final String ORGANIZATION_CACHE_NAME = CacheClientBinaryQueryExample.class.getSimpleName() + + "Organizations"; + + /** Employee cache name. */ + private static final String EMPLOYEE_CACHE_NAME = CacheClientBinaryQueryExample.class.getSimpleName() + + "Employees"; + + /** + * Executes example. + * + * @param args Command line arguments, none required. + */ + public static void main(String[] args) { + try (Ignite ignite = Ignition.start("examples/config/binary/example-ignite-binary.xml")) { + System.out.println(); + System.out.println(">>> Binary objects cache query example started."); + + CacheConfiguration<Integer, Organization> orgCacheCfg = new CacheConfiguration<>(); + + orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); + orgCacheCfg.setName(ORGANIZATION_CACHE_NAME); + + orgCacheCfg.setQueryEntities(Arrays.asList(createOrganizationQueryEntity())); + + CacheConfiguration<EmployeeKey, Employee> employeeCacheCfg = new CacheConfiguration<>(); + + employeeCacheCfg.setCacheMode(CacheMode.PARTITIONED); + employeeCacheCfg.setName(EMPLOYEE_CACHE_NAME); + + employeeCacheCfg.setQueryEntities(Arrays.asList(createEmployeeQueryEntity())); + + try (IgniteCache<Integer, Organization> orgCache = ignite.createCache(orgCacheCfg); + IgniteCache<EmployeeKey, Employee> employeeCache = ignite.createCache(employeeCacheCfg) + ) { + if (ignite.cluster().forDataNodes(orgCache.getName()).nodes().isEmpty()) { + System.out.println(); + System.out.println(">>> This example requires remote cache nodes to be started."); + System.out.println(">>> Please start at least 1 remote cache node."); + System.out.println(">>> Refer to example's javadoc for details on configuration."); + System.out.println(); + + return; + } + + // Populate cache with sample data entries. + populateCache(orgCache, employeeCache); + + // Get cache that will work with binary objects. + IgniteCache<BinaryObject, BinaryObject> binaryCache = employeeCache.withKeepBinary(); + + // Run SQL query example. + sqlQuery(binaryCache); + + // Run SQL query with join example. + sqlJoinQuery(binaryCache); + + // Run SQL fields query example. + sqlFieldsQuery(binaryCache); + + // Run full text query example. + textQuery(binaryCache); + + System.out.println(); + } + finally { + // Delete caches with their content completely. + ignite.destroyCache(ORGANIZATION_CACHE_NAME); + ignite.destroyCache(EMPLOYEE_CACHE_NAME); + } + } + } + + /** + * Create cache type metadata for {@link Employee}. + * + * @return Cache type metadata. + */ + private static QueryEntity createEmployeeQueryEntity() { + QueryEntity employeeEntity = new QueryEntity(); + + employeeEntity.setValueType(Employee.class.getName()); + employeeEntity.setKeyType(EmployeeKey.class.getName()); + + LinkedHashMap<String, String> fields = new LinkedHashMap<>(); + + fields.put("name", String.class.getName()); + fields.put("salary", Long.class.getName()); + fields.put("address.zip", Integer.class.getName()); + fields.put("organizationId", Integer.class.getName()); + fields.put("address.street", Integer.class.getName()); + + employeeEntity.setFields(fields); + + employeeEntity.setIndexes(Arrays.asList( + new QueryIndex("name"), + new QueryIndex("salary"), + new QueryIndex("zip"), + new QueryIndex("organizationId"), + new QueryIndex("street", QueryIndexType.FULLTEXT) + )); + + return employeeEntity; + } + + /** + * Create cache type metadata for {@link Organization}. + * + * @return Cache type metadata. + */ + private static QueryEntity createOrganizationQueryEntity() { + QueryEntity organizationEntity = new QueryEntity(); + + organizationEntity.setValueType(Organization.class.getName()); + organizationEntity.setKeyType(Integer.class.getName()); + + LinkedHashMap<String, String> fields = new LinkedHashMap<>(); + + fields.put("name", String.class.getName()); + fields.put("address.street", String.class.getName()); + + organizationEntity.setFields(fields); + + organizationEntity.setIndexes(Arrays.asList( + new QueryIndex("name") + )); + + return organizationEntity; + } + + /** + * Queries employees that have provided ZIP code in address. + * + * @param cache Ignite cache. + */ + private static void sqlQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Employee.class, "zip = ?"); + + int zip = 94109; + + QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query.setArgs(zip)); + + System.out.println(); + System.out.println(">>> Employees with zip " + zip + ':'); + + for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll()) + System.out.println(">>> " + e.getValue().deserialize()); + } + + /** + * Queries employees that work for organization with provided name. + * + * @param cache Ignite cache. + */ + private static void sqlJoinQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + SqlQuery<BinaryObject, BinaryObject> query = new SqlQuery<>(Employee.class, + "from Employee, \"" + ORGANIZATION_CACHE_NAME + "\".Organization as org " + + "where Employee.organizationId = org._key and org.name = ?"); + + String organizationName = "GridGain"; + + QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = + cache.query(query.setArgs(organizationName)); + + System.out.println(); + System.out.println(">>> Employees working for " + organizationName + ':'); + + for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll()) + System.out.println(">>> " + e.getValue()); + } + + /** + * Queries names and salaries for all employees. + * + * @param cache Ignite cache. + */ + private static void sqlFieldsQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + SqlFieldsQuery query = new SqlFieldsQuery("select name, salary from Employee"); + + QueryCursor<List<?>> employees = cache.query(query); + + System.out.println(); + System.out.println(">>> Employee names and their salaries:"); + + for (List<?> row : employees.getAll()) + System.out.println(">>> [Name=" + row.get(0) + ", salary=" + row.get(1) + ']'); + } + + /** + * Queries employees that live in Texas using full-text query API. + * + * @param cache Ignite cache. + */ + private static void textQuery(IgniteCache<BinaryObject, BinaryObject> cache) { + TextQuery<BinaryObject, BinaryObject> query = new TextQuery<>(Employee.class, "TX"); + + QueryCursor<Cache.Entry<BinaryObject, BinaryObject>> employees = cache.query(query); + + System.out.println(); + System.out.println(">>> Employees living in Texas:"); + + for (Cache.Entry<BinaryObject, BinaryObject> e : employees.getAll()) + System.out.println(">>> " + e.getValue().deserialize()); + } + + /** + * Populates cache with data. + * + * @param orgCache Organization cache. + * @param employeeCache Employee cache. + */ + @SuppressWarnings("TypeMayBeWeakened") + private static void populateCache(IgniteCache<Integer, Organization> orgCache, + IgniteCache<EmployeeKey, Employee> employeeCache) { + orgCache.put(1, new Organization( + "GridGain", + new Address("1065 East Hillsdale Blvd, Foster City, CA", 94404), + OrganizationType.PRIVATE, + new Timestamp(System.currentTimeMillis()) + )); + + orgCache.put(2, new Organization( + "Microsoft", + new Address("1096 Eddy Street, San Francisco, CA", 94109), + OrganizationType.PRIVATE, + new Timestamp(System.currentTimeMillis()) + )); + + employeeCache.put(new EmployeeKey(1, 1), new Employee( + "James Wilson", + 12500, + new Address("1096 Eddy Street, San Francisco, CA", 94109), + Arrays.asList("Human Resources", "Customer Service") + )); + + employeeCache.put(new EmployeeKey(2, 1), new Employee( + "Daniel Adams", + 11000, + new Address("184 Fidler Drive, San Antonio, TX", 78130), + Arrays.asList("Development", "QA") + )); + + employeeCache.put(new EmployeeKey(3, 1), new Employee( + "Cristian Moss", + 12500, + new Address("667 Jerry Dove Drive, Florence, SC", 29501), + Arrays.asList("Logistics") + )); + + employeeCache.put(new EmployeeKey(4, 2), new Employee( + "Allison Mathis", + 25300, + new Address("2702 Freedom Lane, San Francisco, CA", 94109), + Arrays.asList("Development") + )); + + employeeCache.put(new EmployeeKey(5, 2), new Employee( + "Breana Robbin", + 6500, + new Address("3960 Sundown Lane, Austin, TX", 78130), + Arrays.asList("Sales") + )); + + employeeCache.put(new EmployeeKey(6, 2), new Employee( + "Philip Horsley", + 19800, + new Address("2803 Elsie Drive, Sioux Falls, SD", 57104), + Arrays.asList("Sales") + )); + + employeeCache.put(new EmployeeKey(7, 2), new Employee( + "Brian Peters", + 10600, + new Address("1407 Pearlman Avenue, Boston, MA", 12110), + Arrays.asList("Development", "QA") + )); + } +} + http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java new file mode 100644 index 0000000..da65bf6 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/package-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Demonstrates the usage of binary objects with cache. + */ +package org.apache.ignite.examples.binary.datagrid; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java b/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java new file mode 100644 index 0000000..17bdbb5 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/binary/package-info.java @@ -0,0 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Contains Ignite Binary objects classes and examples. + */ +package org.apache.ignite.examples.binary; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/portable/Address.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Address.java b/examples/src/main/java/org/apache/ignite/examples/portable/Address.java deleted file mode 100644 index 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. - * <p> - * 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 + ']'; - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/b783d2b7/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java b/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java deleted file mode 100644 index 9614168..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/portable/Employee.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.examples.portable; - -import java.util.Collection; - -/** - * This class represents employee object. - */ -public class Employee { - /** Name. */ - private String name; - - /** Salary. */ - private long salary; - - /** Address. */ - private Address address; - - /** Departments. */ - private Collection<String> departments; - - /** - * Required for portable deserialization. - */ - public Employee() { - // No-op. - } - - /** - * @param name Name. - * @param salary Salary. - * @param address Address. - * @param departments Departments. - */ - public Employee(String name, long salary, Address address, Collection<String> departments) { - this.name = name; - this.salary = salary; - this.address = address; - this.departments = departments; - } - - /** - * @return Name. - */ - public String name() { - return name; - } - - /** - * @return Salary. - */ - public long salary() { - return salary; - } - - /** - * @return Address. - */ - public Address address() { - return address; - } - - /** - * @return Departments. - */ - public Collection<String> departments() { - return departments; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Employee [name=" + name + - ", salary=" + salary + - ", address=" + address + - ", departments=" + departments + ']'; - } -}
