You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2017/01/26 14:53:00 UTC
[01/15] ignite git commit: IGNITE-4588 .NET: Simplify BinaryReader
frame handling
Repository: ignite
Updated Branches:
refs/heads/ignite-comm-balance-master 1b88631d1 -> 9c1c02851
IGNITE-4588 .NET: Simplify BinaryReader frame handling
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d5b27488
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d5b27488
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d5b27488
Branch: refs/heads/ignite-comm-balance-master
Commit: d5b274883b2047069457af60ad313ad9096f5641
Parents: b7997fc
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Jan 23 13:08:15 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Jan 23 13:08:15 2017 +0300
----------------------------------------------------------------------
.../Impl/Binary/BinaryReader.cs | 131 ++++++++++---------
1 file changed, 68 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d5b27488/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index d9facc3..70417f7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -41,29 +41,14 @@ namespace Apache.Ignite.Core.Impl.Binary
/** Handles. */
private BinaryReaderHandleDictionary _hnds;
- /** Current position. */
- private int _curPos;
-
- /** Current raw flag. */
- private bool _curRaw;
-
/** Detach flag. */
private bool _detach;
/** Binary read mode. */
private BinaryMode _mode;
- /** Current type structure tracker. */
- private BinaryStructureTracker _curStruct;
-
- /** Current schema. */
- private int[] _curSchema;
-
- /** Current schema with positions. */
- private Dictionary<int, int> _curSchemaMap;
-
- /** Current header. */
- private BinaryObjectHeader _curHdr;
+ /** Current frame. */
+ private Frame _frame;
/// <summary>
/// Constructor.
@@ -81,7 +66,7 @@ namespace Apache.Ignite.Core.Impl.Binary
_marsh = marsh;
_mode = mode;
_builder = builder;
- _curPos = stream.Position;
+ _frame.Pos = stream.Position;
Stream = stream;
}
@@ -438,7 +423,7 @@ namespace Apache.Ignite.Core.Impl.Binary
/** <inheritdoc /> */
public T ReadObject<T>(string fieldName)
{
- if (_curRaw)
+ if (_frame.Raw)
throw new BinaryObjectException("Cannot read named fields after raw data is read.");
if (SeekField(fieldName))
@@ -712,34 +697,22 @@ namespace Apache.Ignite.Core.Impl.Binary
}
// Preserve old frame.
- var oldHdr = _curHdr;
- int oldPos = _curPos;
- var oldStruct = _curStruct;
- bool oldRaw = _curRaw;
- var oldSchema = _curSchema;
- var oldSchemaMap = _curSchemaMap;
+ var oldFrame = _frame;
// Set new frame.
- _curHdr = hdr;
- _curPos = pos;
+ _frame.Hdr = hdr;
+ _frame.Pos = pos;
SetCurSchema(desc);
- _curStruct = new BinaryStructureTracker(desc, desc.ReaderTypeStructure);
- _curRaw = false;
+ _frame.Struct = new BinaryStructureTracker(desc, desc.ReaderTypeStructure);
+ _frame.Raw = false;
// Read object.
- Stream.Seek(pos + BinaryObjectHeader.Size, SeekOrigin.Begin);
-
var obj = desc.Serializer.ReadBinary<T>(this, desc.Type, pos);
- _curStruct.UpdateReaderStructure();
+ _frame.Struct.UpdateReaderStructure();
// Restore old frame.
- _curHdr = oldHdr;
- _curPos = oldPos;
- _curStruct = oldStruct;
- _curRaw = oldRaw;
- _curSchema = oldSchema;
- _curSchemaMap = oldSchemaMap;
+ _frame = oldFrame;
return obj;
}
@@ -756,15 +729,15 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
private void SetCurSchema(IBinaryTypeDescriptor desc)
{
- if (_curHdr.HasSchema)
+ if (_frame.Hdr.HasSchema)
{
- _curSchema = desc.Schema.Get(_curHdr.SchemaId);
+ _frame.Schema = desc.Schema.Get(_frame.Hdr.SchemaId);
- if (_curSchema == null)
+ if (_frame.Schema == null)
{
- _curSchema = ReadSchema();
+ _frame.Schema = ReadSchema(desc.TypeId);
- desc.Schema.Add(_curHdr.SchemaId, _curSchema);
+ desc.Schema.Add(_frame.Hdr.SchemaId, _frame.Schema);
}
}
}
@@ -772,25 +745,31 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <summary>
/// Reads the schema.
/// </summary>
- private int[] ReadSchema()
+ private int[] ReadSchema(int typeId)
{
- if (_curHdr.IsCompactFooter)
+ if (_frame.Hdr.IsCompactFooter)
{
// Get schema from Java
- var schema = Marshaller.Ignite.BinaryProcessor.GetSchema(_curHdr.TypeId, _curHdr.SchemaId);
+ var ignite = Marshaller.Ignite;
+
+ var schema = ignite == null
+ ? null
+ : ignite.BinaryProcessor.GetSchema(_frame.Hdr.TypeId, _frame.Hdr.SchemaId);
if (schema == null)
throw new BinaryObjectException("Cannot find schema for object with compact footer [" +
- "typeId=" + _curHdr.TypeId + ", schemaId=" + _curHdr.SchemaId + ']');
+ "typeId=" + typeId + ", schemaId=" + _frame.Hdr.SchemaId + ']');
return schema;
}
- Stream.Seek(_curPos + _curHdr.SchemaOffset, SeekOrigin.Begin);
+ var pos = Stream.Position;
+
+ Stream.Seek(_frame.Pos + _frame.Hdr.SchemaOffset, SeekOrigin.Begin);
- var count = _curHdr.SchemaFieldCount;
+ var count = _frame.Hdr.SchemaFieldCount;
- var offsetSize = _curHdr.SchemaFieldOffsetSize;
+ var offsetSize = _frame.Hdr.SchemaFieldOffsetSize;
var res = new int[count];
@@ -800,6 +779,8 @@ namespace Apache.Ignite.Core.Impl.Binary
Stream.Seek(offsetSize, SeekOrigin.Current);
}
+ Stream.Seek(pos, SeekOrigin.Begin);
+
return res;
}
/// <summary>
@@ -867,11 +848,11 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
private void MarkRaw()
{
- if (!_curRaw)
+ if (!_frame.Raw)
{
- _curRaw = true;
+ _frame.Raw = true;
- Stream.Seek(_curPos + _curHdr.GetRawOffset(Stream, _curPos), SeekOrigin.Begin);
+ Stream.Seek(_frame.Pos + _frame.Hdr.GetRawOffset(Stream, _frame.Pos), SeekOrigin.Begin);
}
}
@@ -880,29 +861,29 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
private bool SeekField(string fieldName)
{
- if (_curRaw)
+ if (_frame.Raw)
throw new BinaryObjectException("Cannot read named fields after raw data is read.");
- if (!_curHdr.HasSchema)
+ if (!_frame.Hdr.HasSchema)
return false;
- var actionId = _curStruct.CurStructAction;
+ var actionId = _frame.Struct.CurStructAction;
- var fieldId = _curStruct.GetFieldId(fieldName);
+ var fieldId = _frame.Struct.GetFieldId(fieldName);
- if (_curSchema == null || actionId >= _curSchema.Length || fieldId != _curSchema[actionId])
+ if (_frame.Schema == null || actionId >= _frame.Schema.Length || fieldId != _frame.Schema[actionId])
{
- _curSchemaMap = _curSchemaMap ?? BinaryObjectSchemaSerializer.ReadSchema(Stream, _curPos, _curHdr,
- () => _curSchema).ToDictionary();
+ _frame.SchemaMap = _frame.SchemaMap ?? BinaryObjectSchemaSerializer.ReadSchema(Stream, _frame.Pos,
+ _frame.Hdr, () => _frame.Schema).ToDictionary();
- _curSchema = null; // read order is different, ignore schema for future reads
+ _frame.Schema = null; // read order is different, ignore schema for future reads
int pos;
- if (!_curSchemaMap.TryGetValue(fieldId, out pos))
+ if (!_frame.SchemaMap.TryGetValue(fieldId, out pos))
return false;
- Stream.Seek(pos + _curPos, SeekOrigin.Begin);
+ Stream.Seek(pos + _frame.Pos, SeekOrigin.Begin);
}
return true;
@@ -982,5 +963,29 @@ namespace Apache.Ignite.Core.Impl.Binary
return TypeCaster<T>.Cast(new BinaryEnum(enumType, enumValue, reader.Marshaller));
}
+
+ /// <summary>
+ /// Stores current reader stack frame.
+ /// </summary>
+ private struct Frame
+ {
+ /** Current position. */
+ public int Pos;
+
+ /** Current raw flag. */
+ public bool Raw;
+
+ /** Current type structure tracker. */
+ public BinaryStructureTracker Struct;
+
+ /** Current schema. */
+ public int[] Schema;
+
+ /** Current schema with positions. */
+ public Dictionary<int, int> SchemaMap;
+
+ /** Current header. */
+ public BinaryObjectHeader Hdr;
+ }
}
}
[05/15] ignite git commit: IGNITE-3699 CreatedExpiryPolicy doesn't
work if entry is loaded from store
Posted by yz...@apache.org.
IGNITE-3699 CreatedExpiryPolicy doesn't work if entry is loaded from store
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28d66dbc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28d66dbc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28d66dbc
Branch: refs/heads/ignite-comm-balance-master
Commit: 28d66dbc100b7ba299a48cce0f001a4070566978
Parents: c42b50c
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Jan 24 12:28:42 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Jan 24 12:28:42 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 30 +++---
.../GridDistributedCacheAdapter.java | 6 +-
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../distributed/dht/GridDhtLockFuture.java | 28 +++---
.../dht/GridDhtTransactionalCacheAdapter.java | 7 ++
.../distributed/dht/GridDhtTxLocalAdapter.java | 8 +-
.../dht/GridPartitionedGetFuture.java | 1 +
.../dht/GridPartitionedSingleGetFuture.java | 2 +
.../dht/atomic/GridDhtAtomicCache.java | 1 +
.../dht/colocated/GridDhtColocatedCache.java | 10 ++
.../colocated/GridDhtColocatedLockFuture.java | 10 +-
.../distributed/near/GridNearAtomicCache.java | 1 +
.../distributed/near/GridNearGetFuture.java | 1 +
.../distributed/near/GridNearGetRequest.java | 77 +++++++++-----
.../distributed/near/GridNearLockFuture.java | 7 ++
.../distributed/near/GridNearLockRequest.java | 81 ++++++++++-----
.../near/GridNearSingleGetRequest.java | 57 ++++++++---
.../near/GridNearTransactionalCache.java | 2 +
.../cache/distributed/near/GridNearTxLocal.java | 17 +++-
.../processors/cache/local/GridLocalCache.java | 1 +
.../local/atomic/GridLocalAtomicCache.java | 1 +
.../transactions/IgniteTxLocalAdapter.java | 36 +++++--
.../cache/transactions/IgniteTxLocalEx.java | 3 +
...eCacheExpiryPolicyWithStoreAbstractTest.java | 100 +++++++++++++++----
.../IgniteCacheTxExpiryPolicyWithStoreTest.java | 21 ++++
25 files changed, 381 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index e414160..ecf9ea9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -528,6 +528,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param retval Flag to return value.
* @param isolation Transaction isolation.
* @param invalidate Invalidate flag.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @return Locks future.
*/
@@ -539,6 +540,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
boolean retval,
TransactionIsolation isolation,
boolean invalidate,
+ long createTtl,
long accessTtl);
/**
@@ -5754,28 +5756,28 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/**
- * @param ttl Access TTL.
+ * @param createTtl Create TTL.
+ * @param accessTtl Access TTL.
* @return Access expire policy.
*/
- @Nullable public static CacheExpiryPolicy forAccess(final long ttl) {
- if (ttl == CU.TTL_NOT_CHANGED)
+ @Nullable public static CacheExpiryPolicy fromRemote(final long createTtl, final long accessTtl) {
+ if (createTtl == CU.TTL_NOT_CHANGED && accessTtl == CU.TTL_NOT_CHANGED)
return null;
return new CacheExpiryPolicy() {
- @Override public long forAccess() {
- return ttl;
+ @Override public long forCreate() {
+ return createTtl;
}
- };
- }
- /** {@inheritDoc} */
- @Override public long forCreate() {
- return CU.TTL_NOT_CHANGED;
- }
+ @Override public long forAccess() {
+ return accessTtl;
+ }
- /** {@inheritDoc} */
- @Override public long forUpdate() {
- return CU.TTL_NOT_CHANGED;
+ /** {@inheritDoc} */
+ @Override public long forUpdate() {
+ return CU.TTL_NOT_CHANGED;
+ }
+ };
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
index 03f6474..d89a468 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheAdapter.java
@@ -102,11 +102,12 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
boolean retval,
TransactionIsolation isolation,
boolean isInvalidate,
+ long createTtl,
long accessTtl
) {
assert tx != null;
- return lockAllAsync(keys, timeout, tx, isInvalidate, isRead, retval, isolation, accessTtl);
+ return lockAllAsync(keys, timeout, tx, isInvalidate, isRead, retval, isolation, createTtl, accessTtl);
}
/** {@inheritDoc} */
@@ -121,6 +122,7 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
false,
/*retval*/true,
null,
+ -1L,
-1L);
}
@@ -132,6 +134,7 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
* @param isRead Indicates whether value is read or written.
* @param retval Flag to return value.
* @param isolation Transaction isolation.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @return Future for locks.
*/
@@ -142,6 +145,7 @@ public abstract class GridDistributedCacheAdapter<K, V> extends GridCacheAdapter
boolean isRead,
boolean retval,
@Nullable TransactionIsolation isolation,
+ long createTtl,
long accessTtl);
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 63213e1..c9f7c5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -758,7 +758,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
protected void processNearSingleGetRequest(final UUID nodeId, final GridNearSingleGetRequest req) {
assert ctx.affinityNode();
- final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.forAccess(req.accessTtl());
+ final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.fromRemote(req.createTtl(), req.accessTtl());
IgniteInternalFuture<GridCacheEntryInfo> fut =
getDhtSingleAsync(
@@ -858,9 +858,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
assert ctx.affinityNode();
assert !req.reload() : req;
- long ttl = req.accessTtl();
-
- final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.forAccess(ttl);
+ final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.fromRemote(req.createTtl(), req.accessTtl());
IgniteInternalFuture<Collection<GridCacheEntryInfo>> fut =
getDhtAsync(nodeId,
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 3f35305..125b4f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -28,7 +28,6 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
-import javax.cache.expiry.ExpiryPolicy;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -157,6 +156,9 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
/** Pending locks. */
private final Collection<KeyCacheObject> pendingLocks;
+ /** TTL for create operation. */
+ private long createTtl;
+
/** TTL for read operation. */
private long accessTtl;
@@ -195,6 +197,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
long timeout,
GridDhtTxLocalAdapter tx,
long threadId,
+ long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
@@ -215,6 +218,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
this.timeout = timeout;
this.filter = filter;
this.tx = tx;
+ this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.skipStore = skipStore;
this.keepBinary = keepBinary;
@@ -1062,22 +1066,16 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
try {
CacheObject val0 = cctx.toCacheObject(val);
- long ttl = CU.TTL_ETERNAL;
- long expireTime = CU.EXPIRE_TIME_ETERNAL;
-
- ExpiryPolicy expiry = cctx.expiry();
-
- if (expiry != null) {
- ttl = CU.toTtl(expiry.getExpiryForCreation());
+ long ttl = createTtl;
+ long expireTime;
- if (ttl == CU.TTL_ZERO)
- expireTime = CU.expireTimeInPast();
- else {
- if (ttl == CU.TTL_NOT_CHANGED)
- ttl = CU.TTL_ETERNAL;
+ if (ttl == CU.TTL_ZERO)
+ expireTime = CU.expireTimeInPast();
+ else {
+ if (ttl == CU.TTL_NOT_CHANGED)
+ ttl = CU.TTL_ETERNAL;
- expireTime = CU.toExpireTime(ttl);
- }
+ expireTime = CU.toExpireTime(ttl);
}
entry0.initialValue(val0,
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 01bc4e0..a9e3bc4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -677,6 +677,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
boolean isRead,
boolean retval,
TransactionIsolation isolation,
+ long createTtl,
long accessTtl) {
CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -688,6 +689,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
isRead,
retval,
isolation,
+ createTtl,
accessTtl,
CU.empty0(),
opCtx != null && opCtx.skipStore(),
@@ -704,6 +706,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
* @param isRead Read flag.
* @param retval Return value flag.
* @param isolation Transaction isolation.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Optional filter.
* @param skipStore Skip store flag.
@@ -716,6 +719,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
boolean isRead,
boolean retval,
TransactionIsolation isolation,
+ long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
@@ -738,6 +742,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
timeout,
tx,
tx.threadId(),
+ createTtl,
accessTtl,
filter,
skipStore,
@@ -859,6 +864,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.timeout(),
tx,
req.threadId(),
+ req.createTtl(),
req.accessTtl(),
filter,
req.skipStore(),
@@ -1007,6 +1013,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.messageId(),
req.txRead(),
req.needReturnValue(),
+ req.createTtl(),
req.accessTtl(),
req.skipStore(),
req.keepBinary());
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 1d88d84..1823cce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -148,7 +148,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
storeEnabled,
onePhaseCommit,
txSize,
- subjId,
+ subjId,
taskNameHash
);
@@ -533,6 +533,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
* @param entries Entries to lock.
* @param msgId Message ID.
* @param read Read flag.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param needRetVal Return value flag.
* @param skipStore Skip store flag.
@@ -545,6 +546,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
long msgId,
final boolean read,
final boolean needRetVal,
+ long createTtl,
long accessTtl,
boolean skipStore,
boolean keepBinary
@@ -651,6 +653,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
passedKeys,
read,
needRetVal,
+ createTtl,
accessTtl,
null,
skipStore,
@@ -669,6 +672,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
* @param passedKeys Passed keys.
* @param read {@code True} if read.
* @param needRetVal Return value flag.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Entry write filter.
* @param skipStore Skip store flag.
@@ -680,6 +684,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
final Collection<KeyCacheObject> passedKeys,
final boolean read,
final boolean needRetVal,
+ final long createTtl,
final long accessTtl,
@Nullable final CacheEntryPredicate[] filter,
boolean skipStore,
@@ -705,6 +710,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
read,
needRetVal,
isolation,
+ createTtl,
accessTtl,
CU.empty0(),
skipStore,
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 2e22d9e..7efe841 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -340,6 +340,7 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
topVer,
subjId,
taskName == null ? 0 : taskName.hashCode(),
+ expiryPlc != null ? expiryPlc.forCreate() : -1L,
expiryPlc != null ? expiryPlc.forAccess() : -1L,
skipVals,
cctx.deploymentEnabled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index aeb7eba..a0b7940 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -280,6 +280,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
topVer,
subjId,
taskName == null ? 0 : taskName.hashCode(),
+ expiryPlc != null ? expiryPlc.forCreate() : -1L,
expiryPlc != null ? expiryPlc.forAccess() : -1L,
skipVals,
/**add reader*/false,
@@ -299,6 +300,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
topVer,
subjId,
taskName == null ? 0 : taskName.hashCode(),
+ expiryPlc != null ? expiryPlc.forCreate() : -1L,
expiryPlc != null ? expiryPlc.forAccess() : -1L,
skipVals,
cctx.deploymentEnabled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 07b9dad..acfe141 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -885,6 +885,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
boolean isRead,
boolean retval,
@Nullable TransactionIsolation isolation,
+ long createTtl,
long accessTtl) {
return new FinishedLockFuture(new UnsupportedOperationException("Locks are not supported for " +
"CacheAtomicityMode.ATOMIC mode (use CacheAtomicityMode.TRANSACTIONAL instead)"));
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 9cf400d..2d18a47 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -600,6 +600,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
boolean isRead,
boolean retval,
@Nullable TransactionIsolation isolation,
+ long createTtl,
long accessTtl
) {
assert tx == null || tx instanceof GridNearTxLocal : tx;
@@ -614,6 +615,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
isRead,
retval,
timeout,
+ createTtl,
accessTtl,
CU.empty0(),
opCtx != null && opCtx.skipStore(),
@@ -861,6 +863,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
* @param txRead Tx read.
* @param retval Return value flag.
* @param timeout Lock timeout.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter filter Optional filter.
* @param skipStore Skip store flag.
@@ -876,6 +879,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
final boolean txRead,
final boolean retval,
final long timeout,
+ final long createTtl,
final long accessTtl,
@Nullable final CacheEntryPredicate[] filter,
final boolean skipStore,
@@ -900,6 +904,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
txRead,
retval,
timeout,
+ createTtl,
accessTtl,
filter,
skipStore,
@@ -921,6 +926,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
txRead,
retval,
timeout,
+ createTtl,
accessTtl,
filter,
skipStore,
@@ -941,6 +947,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
* @param txRead Tx read.
* @param retval Return value flag.
* @param timeout Lock timeout.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter filter Optional filter.
* @param skipStore Skip store flag.
@@ -956,6 +963,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
final boolean txRead,
boolean retval,
final long timeout,
+ final long createTtl,
final long accessTtl,
@Nullable final CacheEntryPredicate[] filter,
boolean skipStore,
@@ -973,6 +981,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
timeout,
tx,
threadId,
+ createTtl,
accessTtl,
filter,
skipStore,
@@ -1041,6 +1050,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
keys,
retval,
txRead,
+ createTtl,
accessTtl,
skipStore,
keepBinary);
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 742f004..69b66f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -145,6 +145,9 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
/** Trackable flag (here may be non-volatile). */
private boolean trackable;
+ /** TTL for create operation. */
+ private final long createTtl;
+
/** TTL for read operation. */
private final long accessTtl;
@@ -164,6 +167,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
* @param read Read flag.
* @param retval Flag to return value or not.
* @param timeout Lock acquisition timeout.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Filter.
* @param skipStore Skip store flag.
@@ -175,6 +179,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
boolean read,
boolean retval,
long timeout,
+ long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
@@ -189,6 +194,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
this.read = read;
this.retval = retval;
this.timeout = timeout;
+ this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.filter = filter;
this.skipStore = skipStore;
@@ -928,6 +934,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
inTx() && tx.syncMode() == FULL_SYNC,
inTx() ? tx.subjectId() : null,
inTx() ? tx.taskNameHash() : 0,
+ read ? createTtl : -1L,
read ? accessTtl : -1L,
skipStore,
keepBinary,
@@ -1104,7 +1111,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
/**
* Locks given keys directly through dht cache.
- * @param keys Collection of keys.
+ * @param keys Collection of keys.
* @param topVer Topology version to lock on.
*/
private void lockLocally(
@@ -1123,6 +1130,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
read,
retval,
timeout,
+ createTtl,
accessTtl,
filter,
skipStore,
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index 4350b3e..b843e4e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -586,6 +586,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
boolean isRead,
boolean retval,
@Nullable TransactionIsolation isolation,
+ long createTtl,
long accessTtl) {
return dht.lockAllAsync(null, timeout);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index b7fcbbd..6ac55f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -374,6 +374,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
topVer,
subjId,
taskName == null ? 0 : taskName.hashCode(),
+ expiryPlc != null ? expiryPlc.forCreate() : -1L,
expiryPlc != null ? expiryPlc.forAccess() : -1L,
skipVals,
cctx.deploymentEnabled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
index 4272a4d..7ca2635 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetRequest.java
@@ -100,6 +100,9 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
private int taskNameHash;
/** TTL for read operation. */
+ private long createTtl;
+
+ /** TTL for read operation. */
private long accessTtl;
/**
@@ -121,6 +124,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
* @param topVer Topology version.
* @param subjId Subject ID.
* @param taskNameHash Task name hash.
+ * @param createTtl New TTL to set after entry is created, -1 to leave unchanged.
* @param accessTtl New TTL to set after entry is accessed, -1 to leave unchanged.
* @param addDepInfo Deployment info.
*/
@@ -134,6 +138,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
@NotNull AffinityTopologyVersion topVer,
UUID subjId,
int taskNameHash,
+ long createTtl,
long accessTtl,
boolean skipVals,
boolean addDepInfo
@@ -161,6 +166,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
this.topVer = topVer;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
+ this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.skipVals = skipVals;
this.addDepInfo = addDepInfo;
@@ -238,6 +244,13 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
}
/**
+ * @return New TTL to set after entry is created, -1 to leave unchanged.
+ */
+ public long createTtl() {
+ return createTtl;
+ }
+
+ /**
* @return New TTL to set after entry is accessed, -1 to leave unchanged.
*/
public long accessTtl() {
@@ -325,73 +338,79 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
writer.incrementState();
case 4:
- if (!writer.writeCollection("flags", flags, MessageCollectionItemType.BOOLEAN))
+ if (!writer.writeLong("createTtl", createTtl))
return false;
writer.incrementState();
case 5:
- if (!writer.writeIgniteUuid("futId", futId))
+ if (!writer.writeCollection("flags", flags, MessageCollectionItemType.BOOLEAN))
return false;
writer.incrementState();
case 6:
- if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
+ if (!writer.writeIgniteUuid("futId", futId))
return false;
writer.incrementState();
case 7:
- if (!writer.writeIgniteUuid("miniId", miniId))
+ if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 8:
- if (!writer.writeBoolean("readThrough", readThrough))
+ if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
case 9:
- if (!writer.writeBoolean("reload", reload))
+ if (!writer.writeCollection("partIds", partIds, MessageCollectionItemType.INT))
return false;
writer.incrementState();
case 10:
- if (!writer.writeBoolean("skipVals", skipVals))
+ if (!writer.writeBoolean("readThrough", readThrough))
return false;
writer.incrementState();
case 11:
- if (!writer.writeUuid("subjId", subjId))
+ if (!writer.writeBoolean("reload", reload))
return false;
writer.incrementState();
case 12:
- if (!writer.writeInt("taskNameHash", taskNameHash))
+ if (!writer.writeBoolean("skipVals", skipVals))
return false;
writer.incrementState();
case 13:
- if (!writer.writeMessage("topVer", topVer))
+ if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
case 14:
- if (!writer.writeMessage("ver", ver))
+ if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
case 15:
- if (!writer.writeCollection("partIds", partIds, MessageCollectionItemType.INT))
+ if (!writer.writeMessage("topVer", topVer))
+ return false;
+
+ writer.incrementState();
+
+ case 16:
+ if (!writer.writeMessage("ver", ver))
return false;
writer.incrementState();
@@ -421,7 +440,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 4:
- flags = reader.readCollection("flags", MessageCollectionItemType.BOOLEAN);
+ createTtl = reader.readLong("createTtl");
if (!reader.isLastRead())
return false;
@@ -429,7 +448,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 5:
- futId = reader.readIgniteUuid("futId");
+ flags = reader.readCollection("flags", MessageCollectionItemType.BOOLEAN);
if (!reader.isLastRead())
return false;
@@ -437,7 +456,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 6:
- keys = reader.readCollection("keys", MessageCollectionItemType.MSG);
+ futId = reader.readIgniteUuid("futId");
if (!reader.isLastRead())
return false;
@@ -445,7 +464,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 7:
- miniId = reader.readIgniteUuid("miniId");
+ keys = reader.readCollection("keys", MessageCollectionItemType.MSG);
if (!reader.isLastRead())
return false;
@@ -453,7 +472,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 8:
- readThrough = reader.readBoolean("readThrough");
+ miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
return false;
@@ -461,7 +480,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 9:
- reload = reader.readBoolean("reload");
+ partIds = reader.readCollection("partIds", MessageCollectionItemType.INT);
if (!reader.isLastRead())
return false;
@@ -469,7 +488,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 10:
- skipVals = reader.readBoolean("skipVals");
+ readThrough = reader.readBoolean("readThrough");
if (!reader.isLastRead())
return false;
@@ -477,7 +496,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 11:
- subjId = reader.readUuid("subjId");
+ reload = reader.readBoolean("reload");
if (!reader.isLastRead())
return false;
@@ -485,7 +504,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 12:
- taskNameHash = reader.readInt("taskNameHash");
+ skipVals = reader.readBoolean("skipVals");
if (!reader.isLastRead())
return false;
@@ -493,7 +512,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 13:
- topVer = reader.readMessage("topVer");
+ subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
return false;
@@ -501,7 +520,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 14:
- ver = reader.readMessage("ver");
+ taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
return false;
@@ -509,7 +528,15 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
reader.incrementState();
case 15:
- partIds = reader.readCollection("partIds", MessageCollectionItemType.INT);
+ topVer = reader.readMessage("topVer");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 16:
+ ver = reader.readMessage("ver");
if (!reader.isLastRead())
return false;
@@ -528,7 +555,7 @@ public class GridNearGetRequest extends GridCacheMessage implements GridCacheDep
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 16;
+ return 17;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 3d350f6..d7a0fb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -148,6 +148,9 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
@GridToStringExclude
private List<GridDistributedCacheEntry> entries;
+ /** TTL for create operation. */
+ private long createTtl;
+
/** TTL for read operation. */
private long accessTtl;
@@ -168,6 +171,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
* @param read Read flag.
* @param retval Flag to return value or not.
* @param timeout Lock acquisition timeout.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param filter Filter.
* @param skipStore skipStore
@@ -180,6 +184,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
boolean read,
boolean retval,
long timeout,
+ long createTtl,
long accessTtl,
CacheEntryPredicate[] filter,
boolean skipStore,
@@ -195,6 +200,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
this.read = read;
this.retval = retval;
this.timeout = timeout;
+ this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.filter = filter;
this.skipStore = skipStore;
@@ -1056,6 +1062,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
inTx() && tx.syncMode() == FULL_SYNC,
inTx() ? tx.subjectId() : null,
inTx() ? tx.taskNameHash() : 0,
+ read ? createTtl : -1L,
read ? accessTtl : -1L,
skipStore,
keepBinary,
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index 2e8cd6e..9e12153 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@ -80,6 +80,9 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** Sync commit flag. */
private boolean syncCommit;
+ /** TTL for create operation. */
+ private long createTtl;
+
/** TTL for read operation. */
private long accessTtl;
@@ -116,6 +119,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
* @param syncCommit Synchronous commit flag.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
+ * @param createTtl TTL for create operation.
* @param accessTtl TTL for read operation.
* @param skipStore Skip store flag.
* @param firstClientReq {@code True} if first lock request for lock operation sent from client node.
@@ -141,6 +145,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
boolean syncCommit,
@Nullable UUID subjId,
int taskNameHash,
+ long createTtl,
long accessTtl,
boolean skipStore,
boolean keepBinary,
@@ -174,6 +179,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
this.syncCommit = syncCommit;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
+ this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.retVal = retVal;
this.firstClientReq = firstClientReq;
@@ -312,6 +318,13 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
}
/**
+ * @return New TTL to set after entry is created, -1 to leave unchanged.
+ */
+ public long createTtl() {
+ return createTtl;
+ }
+
+ /**
* @return TTL for read operation.
*/
public long accessTtl() {
@@ -368,84 +381,90 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
writer.incrementState();
case 21:
- if (!writer.writeObjectArray("dhtVers", dhtVers, MessageCollectionItemType.MSG))
+ if (!writer.writeLong("createTtl", createTtl))
return false;
writer.incrementState();
case 22:
- if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG))
+ if (!writer.writeObjectArray("dhtVers", dhtVers, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 23:
- if (!writer.writeBoolean("firstClientReq", firstClientReq))
+ if (!writer.writeObjectArray("filter", filter, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 24:
- if (!writer.writeBoolean("hasTransforms", hasTransforms))
+ if (!writer.writeBoolean("firstClientReq", firstClientReq))
return false;
writer.incrementState();
case 25:
- if (!writer.writeBoolean("implicitSingleTx", implicitSingleTx))
+ if (!writer.writeBoolean("hasTransforms", hasTransforms))
return false;
writer.incrementState();
case 26:
- if (!writer.writeBoolean("implicitTx", implicitTx))
+ if (!writer.writeBoolean("implicitSingleTx", implicitSingleTx))
return false;
writer.incrementState();
case 27:
- if (!writer.writeIgniteUuid("miniId", miniId))
+ if (!writer.writeBoolean("implicitTx", implicitTx))
return false;
writer.incrementState();
case 28:
- if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit))
+ if (!writer.writeIgniteUuid("miniId", miniId))
return false;
writer.incrementState();
case 29:
- if (!writer.writeBoolean("retVal", retVal))
+ if (!writer.writeBoolean("onePhaseCommit", onePhaseCommit))
return false;
writer.incrementState();
case 30:
- if (!writer.writeUuid("subjId", subjId))
+ if (!writer.writeBoolean("retVal", retVal))
return false;
writer.incrementState();
case 31:
- if (!writer.writeBoolean("syncCommit", syncCommit))
+ if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
case 32:
- if (!writer.writeInt("taskNameHash", taskNameHash))
+ if (!writer.writeBoolean("syncCommit", syncCommit))
return false;
writer.incrementState();
case 33:
- if (!writer.writeMessage("topVer", topVer))
+ if (!writer.writeInt("taskNameHash", taskNameHash))
return false;
writer.incrementState();
case 34:
+ if (!writer.writeMessage("topVer", topVer))
+ return false;
+
+ writer.incrementState();
+
+ case 35:
if (!writer.writeCollection("partIds", partIds, MessageCollectionItemType.INT))
return false;
@@ -476,7 +495,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 21:
- dhtVers = reader.readObjectArray("dhtVers", MessageCollectionItemType.MSG, GridCacheVersion.class);
+ createTtl = reader.readLong("createTtl");
if (!reader.isLastRead())
return false;
@@ -484,7 +503,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 22:
- filter = reader.readObjectArray("filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class);
+ dhtVers = reader.readObjectArray("dhtVers", MessageCollectionItemType.MSG, GridCacheVersion.class);
if (!reader.isLastRead())
return false;
@@ -492,7 +511,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 23:
- firstClientReq = reader.readBoolean("firstClientReq");
+ filter = reader.readObjectArray("filter", MessageCollectionItemType.MSG, CacheEntryPredicate.class);
if (!reader.isLastRead())
return false;
@@ -500,7 +519,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 24:
- hasTransforms = reader.readBoolean("hasTransforms");
+ firstClientReq = reader.readBoolean("firstClientReq");
if (!reader.isLastRead())
return false;
@@ -508,7 +527,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 25:
- implicitSingleTx = reader.readBoolean("implicitSingleTx");
+ hasTransforms = reader.readBoolean("hasTransforms");
if (!reader.isLastRead())
return false;
@@ -516,7 +535,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 26:
- implicitTx = reader.readBoolean("implicitTx");
+ implicitSingleTx = reader.readBoolean("implicitSingleTx");
if (!reader.isLastRead())
return false;
@@ -524,7 +543,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 27:
- miniId = reader.readIgniteUuid("miniId");
+ implicitTx = reader.readBoolean("implicitTx");
if (!reader.isLastRead())
return false;
@@ -532,7 +551,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 28:
- onePhaseCommit = reader.readBoolean("onePhaseCommit");
+ miniId = reader.readIgniteUuid("miniId");
if (!reader.isLastRead())
return false;
@@ -540,7 +559,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 29:
- retVal = reader.readBoolean("retVal");
+ onePhaseCommit = reader.readBoolean("onePhaseCommit");
if (!reader.isLastRead())
return false;
@@ -548,7 +567,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 30:
- subjId = reader.readUuid("subjId");
+ retVal = reader.readBoolean("retVal");
if (!reader.isLastRead())
return false;
@@ -556,7 +575,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 31:
- syncCommit = reader.readBoolean("syncCommit");
+ subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
return false;
@@ -564,7 +583,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 32:
- taskNameHash = reader.readInt("taskNameHash");
+ syncCommit = reader.readBoolean("syncCommit");
if (!reader.isLastRead())
return false;
@@ -572,7 +591,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 33:
- topVer = reader.readMessage("topVer");
+ taskNameHash = reader.readInt("taskNameHash");
if (!reader.isLastRead())
return false;
@@ -580,6 +599,14 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
reader.incrementState();
case 34:
+ topVer = reader.readMessage("topVer");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 35:
partIds = reader.readCollection("partIds", MessageCollectionItemType.INT);
if (!reader.isLastRead())
@@ -599,7 +626,7 @@ public class GridNearLockRequest extends GridDistributedLockRequest {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 35;
+ return 36;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java
index 7fc2b1e..8fe33d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java
@@ -80,6 +80,9 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
private int taskNameHash;
/** TTL for read operation. */
+ private long createTtl;
+
+ /** TTL for read operation. */
private long accessTtl;
/**
@@ -99,6 +102,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
* @param topVer Topology version.
* @param subjId Subject ID.
* @param taskNameHash Task name hash.
+ * @param createTtl New TTL to set after entry is created, -1 to leave unchanged.
* @param accessTtl New TTL to set after entry is accessed, -1 to leave unchanged.
* @param addReader Add reader flag.
* @param needVer {@code True} if entry version is needed.
@@ -112,6 +116,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
@NotNull AffinityTopologyVersion topVer,
UUID subjId,
int taskNameHash,
+ long createTtl,
long accessTtl,
boolean skipVals,
boolean addReader,
@@ -127,6 +132,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
this.topVer = topVer;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
+ this.createTtl = createTtl;
this.accessTtl = accessTtl;
this.addDepInfo = addDepInfo;
@@ -181,6 +187,13 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
}
/**
+ * @return New TTL to set after entry is created, -1 to leave unchanged.
+ */
+ public long createTtl() {
+ return createTtl;
+ }
+
+ /**
* @return New TTL to set after entry is accessed, -1 to leave unchanged.
*/
public long accessTtl() {
@@ -266,7 +279,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 4:
- flags = reader.readByte("flags");
+ createTtl = reader.readLong("createTtl");
if (!reader.isLastRead())
return false;
@@ -274,7 +287,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 5:
- futId = reader.readLong("futId");
+ flags = reader.readByte("flags");
if (!reader.isLastRead())
return false;
@@ -282,7 +295,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 6:
- key = reader.readMessage("key");
+ futId = reader.readLong("futId");
if (!reader.isLastRead())
return false;
@@ -290,7 +303,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 7:
- subjId = reader.readUuid("subjId");
+ key = reader.readMessage("key");
if (!reader.isLastRead())
return false;
@@ -298,7 +311,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 8:
- taskNameHash = reader.readInt("taskNameHash");
+ partId = reader.readInt("partId", -1);
if (!reader.isLastRead())
return false;
@@ -306,7 +319,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 9:
- topVer = reader.readMessage("topVer");
+ subjId = reader.readUuid("subjId");
if (!reader.isLastRead())
return false;
@@ -314,7 +327,15 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
reader.incrementState();
case 10:
- partId = reader.readInt("partId", -1);
+ taskNameHash = reader.readInt("taskNameHash");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
+
+ case 11:
+ topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
return false;
@@ -348,43 +369,49 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
writer.incrementState();
case 4:
- if (!writer.writeByte("flags", flags))
+ if (!writer.writeLong("createTtl", createTtl))
return false;
writer.incrementState();
case 5:
- if (!writer.writeLong("futId", futId))
+ if (!writer.writeByte("flags", flags))
return false;
writer.incrementState();
case 6:
- if (!writer.writeMessage("key", key))
+ if (!writer.writeLong("futId", futId))
return false;
writer.incrementState();
case 7:
- if (!writer.writeUuid("subjId", subjId))
+ if (!writer.writeMessage("key", key))
return false;
writer.incrementState();
case 8:
- if (!writer.writeInt("taskNameHash", taskNameHash))
+ if (!writer.writeInt("partId", partId))
return false;
writer.incrementState();
case 9:
- if (!writer.writeMessage("topVer", topVer))
+ if (!writer.writeUuid("subjId", subjId))
return false;
writer.incrementState();
case 10:
- if (!writer.writeInt("partId", partId))
+ if (!writer.writeInt("taskNameHash", taskNameHash))
+ return false;
+
+ writer.incrementState();
+
+ case 11:
+ if (!writer.writeMessage("topVer", topVer))
return false;
writer.incrementState();
@@ -406,7 +433,7 @@ public class GridNearSingleGetRequest extends GridCacheMessage implements GridCa
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 11;
+ return 12;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index 7ac3295..b3eb755 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -445,6 +445,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
boolean isRead,
boolean retval,
TransactionIsolation isolation,
+ long createTtl,
long accessTtl
) {
CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -455,6 +456,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
isRead,
retval,
timeout,
+ createTtl,
accessTtl,
CU.empty0(),
opCtx != null && opCtx.skipStore(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 0730300..094c5fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -329,15 +329,20 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
final boolean skipVals,
final boolean needVer,
boolean keepBinary,
+ final ExpiryPolicy expiryPlc,
final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c
) {
+ IgniteCacheExpiryPolicy expiryPlc0 = optimistic() ?
+ accessPolicy(cacheCtx, keys) :
+ cacheCtx.cache().expiryPolicy(expiryPlc);
+
if (cacheCtx.isNear()) {
return cacheCtx.nearTx().txLoadAsync(this,
topVer,
keys,
readThrough,
/*deserializeBinary*/false,
- accessPolicy(cacheCtx, keys),
+ expiryPlc0,
skipVals,
needVer).chain(new C1<IgniteInternalFuture<Map<Object, Object>>, Void>() {
@Override public Void apply(IgniteInternalFuture<Map<Object, Object>> f) {
@@ -368,7 +373,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
CU.subjectId(this, cctx),
resolveTaskName(),
/*deserializeBinary*/false,
- accessPolicy(cacheCtx, keys),
+ expiryPlc0,
skipVals,
/*can remap*/true,
needVer,
@@ -399,7 +404,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
CU.subjectId(this, cctx),
resolveTaskName(),
/*deserializeBinary*/false,
- accessPolicy(cacheCtx, keys),
+ expiryPlc0,
skipVals,
/*can remap*/true,
needVer,
@@ -433,6 +438,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
skipVals,
keepBinary,
needVer,
+ expiryPlc,
c);
}
}
@@ -1161,6 +1167,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
* @param keys Keys.
* @param retval Return value flag.
* @param read Read flag.
+ * @param accessTtl Create ttl.
* @param accessTtl Access ttl.
* @param <K> Key type.
* @param skipStore Skip store flag.
@@ -1171,6 +1178,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
final Collection<? extends K> keys,
boolean retval,
boolean read,
+ long createTtl,
long accessTtl,
boolean skipStore,
boolean keepBinary) {
@@ -1205,6 +1213,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
read,
retval,
isolation,
+ createTtl,
accessTtl,
CU.empty0(),
skipStore,
@@ -1303,6 +1312,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
/** {@inheritDoc} */
@Override protected IgniteCacheExpiryPolicy accessPolicy(GridCacheContext cacheCtx, Collection<KeyCacheObject> keys) {
+ assert optimistic();
+
if (accessMap != null) {
for (Map.Entry<IgniteTxKey, IgniteCacheExpiryPolicy> e : accessMap.entrySet()) {
if (e.getKey().cacheId() == cacheCtx.cacheId() && keys.contains(e.getKey().key()))
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
index 16a35d3..5b44d75 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
@@ -118,6 +118,7 @@ public class GridLocalCache<K, V> extends GridCacheAdapter<K, V> {
boolean retval,
TransactionIsolation isolation,
boolean invalidate,
+ long createTtl,
long accessTtl) {
return lockAllAsync(keys, timeout, tx, CU.empty0());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index a26d2f3..656b52c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -1429,6 +1429,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
boolean retval,
TransactionIsolation isolation,
boolean invalidate,
+ long createTtl,
long accessTtl) {
return new GridFinishedFuture<>(new UnsupportedOperationException("Locks are not supported for " +
"CacheAtomicityMode.ATOMIC mode (use CacheAtomicityMode.TRANSACTIONAL instead)"));
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index f665eb8..3043ecc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -399,6 +399,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
boolean skipVals,
boolean needVer,
boolean keepBinary,
+ final ExpiryPolicy expiryPlc,
final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c
) {
assert cacheCtx.isLocal() : cacheCtx.name();
@@ -411,7 +412,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
try {
- IgniteCacheExpiryPolicy expiryPlc = accessPolicy(cacheCtx, keys);
+ IgniteCacheExpiryPolicy expiryPlc0 = optimistic() ?
+ accessPolicy(cacheCtx, keys) :
+ cacheCtx.cache().expiryPolicy(expiryPlc);
Map<KeyCacheObject, GridCacheVersion> misses = null;
@@ -436,7 +439,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
CU.subjectId(this, cctx),
null,
resolveTaskName(),
- expiryPlc,
+ expiryPlc0,
txEntry == null ? keepBinary : txEntry.keepBinary());
if (res == null) {
@@ -1434,6 +1437,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
* @param skipVals Skip values flag.
* @param keepCacheObjects Keep cache objects flag.
* @param skipStore Skip store flag.
+ * @param expiryPlc Expiry policy.
* @return Loaded key-value pairs.
*/
private <K, V> IgniteInternalFuture<Map<K, V>> checkMissed(
@@ -1445,7 +1449,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
final boolean skipVals,
final boolean keepCacheObjects,
final boolean skipStore,
- final boolean needVer
+ final boolean needVer,
+ final ExpiryPolicy expiryPlc
) {
if (log.isDebugEnabled())
@@ -1474,6 +1479,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
needReadVer,
!deserializeBinary,
+ expiryPlc,
new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
@Override public void apply(KeyCacheObject key, Object val, GridCacheVersion loadVer) {
if (isRollbackOnly()) {
@@ -1598,6 +1604,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
expiryPlc = cacheCtx.expiry();
long accessTtl = expiryPlc != null ? CU.toTtl(expiryPlc.getExpiryForAccess()) : CU.TTL_NOT_CHANGED;
+ long createTtl = expiryPlc != null ? CU.toTtl(expiryPlc.getExpiryForCreation()) : CU.TTL_NOT_CHANGED;
long timeout = remainingTime();
@@ -1611,8 +1618,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
true,
isolation,
isInvalidate(),
+ createTtl,
accessTtl);
+ final ExpiryPolicy expiryPlc0 = expiryPlc;
+
PLC2<Map<K, V>> plc2 = new PLC2<Map<K, V>>() {
@Override public IgniteInternalFuture<Map<K, V>> postLock() throws IgniteCheckedException {
if (log.isDebugEnabled())
@@ -1734,7 +1744,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
skipStore,
- needVer);
+ needVer,
+ expiryPlc0);
}
return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -1807,7 +1818,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
skipStore,
- needVer);
+ needVer,
+ expiryPlc);
}
return new GridFinishedFuture<>(retMap);
@@ -2014,7 +2026,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
hasFilters,
/*read through*/(entryProcessor != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore,
retval,
- keepBinary);
+ keepBinary,
+ expiryPlc);
}
return new GridFinishedFuture<>();
@@ -2183,7 +2196,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
hasFilters,
/*read through*/(invokeMap != null || cacheCtx.config().isLoadPreviousValue()) && !skipStore,
retval,
- keepBinary);
+ keepBinary,
+ expiryPlc);
}
return new GridFinishedFuture<>();
@@ -2203,6 +2217,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
* @param hasFilters {@code True} if filters not empty.
* @param readThrough Read through flag.
* @param retval Return value flag.
+ * @param expiryPlc Expiry policy.
* @return Load future.
*/
private IgniteInternalFuture<Void> loadMissing(
@@ -2216,7 +2231,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
final boolean hasFilters,
final boolean readThrough,
final boolean retval,
- final boolean keepBinary) {
+ final boolean keepBinary,
+ final ExpiryPolicy expiryPlc) {
GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c =
new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
@Override public void apply(KeyCacheObject key,
@@ -2290,6 +2306,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
/*skipVals*/singleRmv,
needReadVer,
keepBinary,
+ expiryPlc,
c);
}
@@ -2952,6 +2969,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
retval,
isolation,
isInvalidate(),
+ -1L,
-1L);
PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
@@ -3130,6 +3148,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
retval,
isolation,
isInvalidate(),
+ -1L,
-1L);
PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
@@ -3424,6 +3443,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
retval,
isolation,
isInvalidate(),
+ -1L,
-1L);
PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
index 9fb3558..f5687a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.transactions;
import java.util.Collection;
import java.util.Map;
import javax.cache.Cache;
+import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -181,6 +182,7 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
* @param skipVals Skip values flag.
* @param needVer If {@code true} version is required for loaded values.
* @param c Closure to be applied for loaded values.
+ * @param expiryPlc Expiry policy.
* @return Future with {@code True} value if loading took place.
*/
public IgniteInternalFuture<Void> loadMissing(
@@ -192,5 +194,6 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
boolean skipVals,
boolean needVer,
boolean keepBinary,
+ final ExpiryPolicy expiryPlc,
GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
index 58e6b02..1f6ec2d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java
@@ -17,8 +17,11 @@
package org.apache.ignite.internal.processors.cache.expiry;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.cache.configuration.Factory;
import javax.cache.expiry.Duration;
@@ -27,6 +30,7 @@ import javax.cache.integration.CompletionListenerFuture;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.store.CacheStore;
@@ -38,6 +42,9 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
/**
*
@@ -179,38 +186,93 @@ public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends Ignit
* @throws Exception If failed.
*/
public void testGetReadThrough() throws Exception {
+ getReadThrough(false, null, null);
+ getReadThrough(true, null, null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ protected void getReadThrough(boolean withExcPlc,
+ TransactionConcurrency txConcurrency,
+ TransactionIsolation txIsolation) throws Exception {
IgniteCache<Integer, Integer> cache = jcache(0);
- List<Integer> keys = new ArrayList<>();
+ if (withExcPlc)
+ cache = cache.withExpiryPolicy(new ExpiryPolicy() {
+ @Override public Duration getExpiryForCreation() {
+ return new Duration(TimeUnit.MILLISECONDS, 501);
+ }
+
+ @Override public Duration getExpiryForAccess() {
+ return new Duration(TimeUnit.MILLISECONDS, 601);
+ }
+
+ @Override public Duration getExpiryForUpdate() {
+ return new Duration(TimeUnit.MILLISECONDS, 701);
+ }
+ });
- keys.add(primaryKeys(cache, 1, 100_000).get(0));
- // TODO https://issues.apache.org/jira/browse/IGNITE-3699
- // TODO: test 'get' inside transactions, 'get' for cache.withAsyncPolicy.
- //keys.add(backupKeys(cache, 1, 100_000).get(0));
- //keys.add(nearKeys(cache, 1, 100_000).get(0));
+ Integer prim = primaryKeys(cache, 1, 1000).get(0);
+ Integer back = backupKeys(cache, 1, 1000).get(0);
+ Integer near = nearKeys(cache, 1, 1000).get(0);
+
+ Set<Integer> prims = new HashSet<>(primaryKeys(cache, 10, prim + 1));
+ Set<Integer> backs = new HashSet<>(backupKeys(cache, 10, back + 1));
+ Set<Integer> nears = new HashSet<>(nearKeys(cache, 10, near + 1));
+
+ Set<Integer> keys = new HashSet<>();
+
+ keys.add(prim);
+ keys.add(back);
+ keys.add(near);
+
+ keys.addAll(prims);
+ keys.addAll(backs);
+ keys.addAll(nears);
for (Integer key : keys)
- storeMap.put(key, 100);
+ storeMap.put(key, key);
+
+ IgniteTransactions transactions = grid(0).transactions();
+
+ Transaction tx = txConcurrency != null ? transactions.txStart(txConcurrency, txIsolation) : null;
try {
- for (Integer key : keys) {
- Integer res = cache.get(key);
+ Collection<Integer> singleKeys = new HashSet<>();
- assertEquals((Integer)100, res);
+ singleKeys.add(prim);
+ singleKeys.add(back);
+ singleKeys.add(near);
- checkTtl(key, 500, true);
+ assertEquals(3, singleKeys.size());
- assertEquals((Integer)100, res);
- }
+ for (Integer key : singleKeys)
+ assertEquals(key, cache.get(key));
- U.sleep(600);
+ Map<Integer, Integer> res = new HashMap<>();
+
+ res.putAll(cache.getAll(prims));
+ res.putAll(cache.getAll(backs));
+ res.putAll(cache.getAll(nears));
- for (Integer key : keys)
- checkExpired(key);
+ assertEquals(30, res.size());
+
+ for (Map.Entry<Integer, Integer> e : res.entrySet())
+ assertEquals(e.getKey(), e.getValue());
}
finally {
- cache.removeAll();
+ if (tx != null)
+ tx.rollback();
}
+
+ for (Integer key : keys)
+ checkTtl(key, withExcPlc ? 501 : 500, true);
+
+ U.sleep(600);
+
+ for (Integer key : keys)
+ checkExpired(key);
}
/**
[11/15] ignite git commit: IGNITE-4614 .NET: Reset binary schema in
BinaryReader new frame
Posted by yz...@apache.org.
IGNITE-4614 .NET: Reset binary schema in BinaryReader new frame
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e8067a6a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e8067a6a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e8067a6a
Branch: refs/heads/ignite-comm-balance-master
Commit: e8067a6a38d8d1bea43cc47d1867fcc2a804f969
Parents: 885dc32
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Jan 25 20:33:11 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Jan 25 20:33:11 2017 +0300
----------------------------------------------------------------------
.../Binary/BinaryStructureTest.cs | 122 +++++++++++++++++++
.../Impl/Binary/BinaryReader.cs | 6 +
2 files changed, 128 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8067a6a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
index 1ab81c5..1bd2bf4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Tests.Binary
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+ using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Binary;
@@ -102,6 +103,49 @@ namespace Apache.Ignite.Core.Tests.Binary
desc.WriterTypeStructure.FieldTypes.Keys);
}
}
+
+ /// <summary>
+ /// Tests that nested raw object does not inherit outer schema.
+ /// </summary>
+ [Test]
+ public void TestNestedRaw()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration(typeof(RawContainer), typeof(RawNested)));
+
+ var obj = new RawContainer {Int = 3, Raw = new RawNested {Int = 5}};
+
+ var res = marsh.Unmarshal<RawContainer>(marsh.Marshal(obj));
+
+ Assert.AreEqual(obj.Int, res.Int);
+ Assert.AreEqual(0, res.Raw.Int); // Int is not written and can't be read.
+ }
+
+ /// <summary>
+ /// Tests that nested object schemas do not interfere.
+ /// </summary>
+ [Test]
+ public void TestNested()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration(typeof(Container), typeof(Nested)));
+
+ var obj = new Container
+ {
+ Foo = 2,
+ Bar = 4,
+ Nested = new Nested
+ {
+ Baz = 3,
+ Qux = 5
+ }
+ };
+
+ var res = marsh.Unmarshal<Container>(marsh.Marshal(obj));
+
+ Assert.AreEqual(2, res.Foo);
+ Assert.AreEqual(4, res.Bar);
+ Assert.AreEqual(3, res.Nested.Baz);
+ Assert.AreEqual(5, res.Nested.Qux);
+ }
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
@@ -263,4 +307,82 @@ namespace Apache.Ignite.Core.Tests.Binary
f6 == other.f6 && f7 == other.f7 && f8 == other.f8;
}
}
+
+ public class RawContainer : IBinarizable
+ {
+ public int Int { get; set; }
+
+ public RawNested Raw { get; set; }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("int", Int);
+ writer.WriteObject("raw", Raw);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Int = reader.ReadInt("int");
+ Raw = reader.ReadObject<RawNested>("raw");
+ }
+ }
+
+ public class RawNested : IBinarizable
+ {
+ public int Int { get; set; }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ // Write only raw data.
+ writer.GetRawWriter().WriteIntArray(Enumerable.Range(1, 100).ToArray());
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ // Attempt to read even though we did not write fields.
+ // If schema is carried over, there will be a broken result.
+ Int = reader.ReadInt("int");
+ }
+ }
+
+ public class Container : IBinarizable
+ {
+ public int Foo { get; set; }
+ public int Bar { get; set; }
+ public Nested Nested { get; set; }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("foo", Foo);
+ writer.WriteInt("bar", Bar);
+ writer.WriteObject("nested", Nested);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ // Read in reverse order to defeat structure optimization.
+ Bar = reader.ReadInt("bar");
+ Foo = reader.ReadInt("foo");
+ Nested = reader.ReadObject<Nested>("nested");
+ }
+ }
+
+ public class Nested : IBinarizable
+ {
+ public int Baz { get; set; }
+ public int Qux { get; set; }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("baz", Baz);
+ writer.WriteInt("qux", Qux);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ // Read in reverse order to defeat structure optimization.
+ Qux = reader.ReadInt("qux");
+ Baz = reader.ReadInt("baz");
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e8067a6a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 70417f7..2a59c06 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -729,6 +729,8 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
private void SetCurSchema(IBinaryTypeDescriptor desc)
{
+ _frame.SchemaMap = null;
+
if (_frame.Hdr.HasSchema)
{
_frame.Schema = desc.Schema.Get(_frame.Hdr.SchemaId);
@@ -740,6 +742,10 @@ namespace Apache.Ignite.Core.Impl.Binary
desc.Schema.Add(_frame.Hdr.SchemaId, _frame.Schema);
}
}
+ else
+ {
+ _frame.Schema = null;
+ }
}
/// <summary>
[08/15] ignite git commit: IGNITE-1596 Fixed version sort.
Posted by yz...@apache.org.
IGNITE-1596 Fixed version sort.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/128ba073
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/128ba073
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/128ba073
Branch: refs/heads/ignite-comm-balance-master
Commit: 128ba0733692178de05eae183b97355b81715a1b
Parents: ef04f35
Author: Andrey Novikov <an...@gridgain.com>
Authored: Wed Jan 25 16:48:05 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Wed Jan 25 16:48:05 2017 +0700
----------------------------------------------------------------------
modules/web-console/backend/app/agent.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/128ba073/modules/web-console/backend/app/agent.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/agent.js b/modules/web-console/backend/app/agent.js
index 791ea50..961253f 100644
--- a/modules/web-console/backend/app/agent.js
+++ b/modules/web-console/backend/app/agent.js
@@ -650,14 +650,14 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo)
const bParts = b.split('.');
for (let i = 0; i < aParts.length; ++i) {
- if (bParts.length === i)
- return 1;
+ if (aParts[i] !== bParts[i])
+ return aParts[i] < bParts[i] ? 1 : -1;
+ }
- if (aParts[i] === aParts[i])
- continue;
+ if (aParts.length === bParts.length)
+ return 0;
- return aParts[i] > bParts[i] ? 1 : -1;
- }
+ return aParts.length < bParts.length ? 1 : -1;
}));
// Latest version of agent distribution.
[03/15] ignite git commit: IGNITE-1943 Review.
Posted by yz...@apache.org.
IGNITE-1943 Review.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c42b50cf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c42b50cf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c42b50cf
Branch: refs/heads/ignite-comm-balance-master
Commit: c42b50cfa0ff992debe773307a7cf25ecc141a31
Parents: 24e14b6
Author: Andrey Novikov <an...@gridgain.com>
Authored: Tue Jan 24 15:15:48 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jan 24 15:23:46 2017 +0700
----------------------------------------------------------------------
.../scala/org/apache/ignite/visor/visor.scala | 39 ++++++++------------
.../commands/mem/VisorMemoryCommandSpec.scala | 25 +++++++++++--
.../commands/node/VisorNodeCommandSpec.scala | 10 -----
3 files changed, 38 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c42b50cf/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 0aa8549..e4e7918 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -352,16 +352,16 @@ object visor extends VisorTag {
addHelp(
name = "mcompact",
- shortInfo = "Fills gap in Visor console memory variable.",
+ shortInfo = "Fills gap in Visor console memory variables.",
longInfo = Seq(
- "Finds and fills gap in Visor console memory variable."
+ "Finds and fills gap in Visor console memory variables."
),
spec = Seq(
"mcompact"
),
examples = Seq(
"mcompact" ->
- "Fills gap in Visor console memory variable."
+ "Fills gap in Visor console memory variables."
),
emptyArgs = mcompact,
withArgs = _ => wrongArgs("mcompact")
@@ -597,22 +597,22 @@ object visor extends VisorTag {
/**
* ==Command==
- * Fills gap in Visor console memory variable.
+ * Fills gap in Visor console memory variables.
*
* ==Examples==
* <ex>mcompact</ex>
- * Fills gap in Visor console memory variable.
+ * Fills gap in Visor console memory variables.
*/
def mcompact() {
- var elements = Array("e", "a", "c", "n", "t", "s")
- for (element <- elements){
- val r = mem.filter { case (k, _) => (element.contains(k.charAt(0)) && k != "nl" && k != "nr") }
-
- if (r.isEmpty)
- NA
- else {
- clearNamespace(element)
- r.toSeq.sortBy(_._1).foreach { case (k, v) => setVar(v, element) }
+ val namespaces = Array("a", "c", "e", "n", "s", "t")
+
+ for (namespace <- namespaces) {
+ val vars = mem.filter { case (k, _) => k.matches(s"$namespace\\d+") }
+
+ if (vars.nonEmpty) {
+ clearNamespace(namespace)
+
+ vars.toSeq.sortBy(_._1).foreach { case (_, v) => setVar(v, namespace) }
}
}
}
@@ -645,15 +645,8 @@ object visor extends VisorTag {
assert(namespace != null)
mem.keySet.foreach(k => {
- if (k.startsWith(namespace))
- try {
- k.substring(1).toInt
-
- mem.remove(k)
- }
- catch {
- case ignored: Throwable => // No-op.
- }
+ if (k.matches(s"$namespace\\d+"))
+ mem.remove(k)
})
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c42b50cf/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
index a360ea3..278bace 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
@@ -82,14 +82,33 @@ class VisorMemoryCommandSpec extends FunSpec with Matchers {
describe("A 'mcompact' visor command") {
it("should compact variable") {
-
visor.mset("key1", "value1")
- visor.mset("key2", "value2")
visor.mset("key3", "value3")
- visor mclear "key2"
+ visor.mset("n0", "value0")
+ visor.mset("n1", "value1")
+ visor.mset("n2", "value2")
+ visor.mset("n3", "value3")
+
+ visor.mset("c1", "value1")
+ visor.mset("c3", "value3")
visor.mcompact()
+
+ assertResult(None)(visor.mgetOpt("key0"))
+ assertResult(Some("value1"))(visor.mgetOpt("key1"))
+ assertResult(None)(visor.mgetOpt("key2"))
+ assertResult(Some("value3"))(visor.mgetOpt("key3"))
+
+ assertResult(Some("value0"))(visor.mgetOpt("n0"))
+ assertResult(Some("value1"))(visor.mgetOpt("n1"))
+ assertResult(Some("value2"))(visor.mgetOpt("n2"))
+ assertResult(Some("value3"))(visor.mgetOpt("n3"))
+
+ assertResult(Some("value1"))(visor.mgetOpt("c0"))
+ assertResult(Some("value3"))(visor.mgetOpt("c1"))
+ assertResult(None)(visor.mgetOpt("c3"))
+
visor.mlist()
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c42b50cf/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
index 0ef4814..c0983c0 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
@@ -38,15 +38,5 @@ class VisorNodeCommandSpec extends VisorRuntimeBaseSpec(1) {
visor.node("") // Arguments are ignored.
}
-
- visor.mclear()
-
- it("should properly execute with valid node ID value post mclear") {
- visor.node("-id8=@n1")
- }
-
- it("should list all variables") {
- visor.mlist()
- }
}
}
[09/15] ignite git commit: IGNITE-4212 Ignite Benchmarking
Simplification and Automation
Posted by yz...@apache.org.
IGNITE-4212 Ignite Benchmarking Simplification and Automation
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/eed9d669
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/eed9d669
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/eed9d669
Branch: refs/heads/ignite-comm-balance-master
Commit: eed9d669353d51774afdac6d99b01ebd569b8708
Parents: 128ba07
Author: oleg-ostanin <oo...@gridgain.com>
Authored: Wed Jan 25 14:08:00 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Jan 25 14:08:00 2017 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 3 +
assembly/dependencies-fabric-lgpl.xml | 1 +
assembly/dependencies-fabric.xml | 1 +
modules/yardstick/DEVNOTES.txt | 16 +++
modules/yardstick/README.txt | 10 +-
modules/yardstick/pom-standalone.xml | 209 +++++++++++++++++++++++++++++
modules/yardstick/pom.xml | 10 +-
pom.xml | 95 ++++++++++++-
8 files changed, 342 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index e920b79..6a275fc 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -12,6 +12,9 @@ With LGPL dependencies:
With LGPL dependencies and Scala 2.10:
mvn clean package -DskipTests -Prelease,lgpl -Dignite.edition=fabric-lgpl -Dscala-2.10
+With LGPL dependencies and Scala 2.10 and Ignite-Yardstick:
+ mvn clean package -DskipTests -Prelease,lgpl,yardstick -Dignite.edition=fabric-lgpl -Dscala-2.10
+
With Apache Ignite.NET:
Build Apache Ignite.NET as described at modules/platforms/dotnet/DEVNOTES.txt.
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/assembly/dependencies-fabric-lgpl.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-fabric-lgpl.xml b/assembly/dependencies-fabric-lgpl.xml
index 82f63d8..6d547c4 100644
--- a/assembly/dependencies-fabric-lgpl.xml
+++ b/assembly/dependencies-fabric-lgpl.xml
@@ -133,6 +133,7 @@
<exclude>org.apache.ignite:ignite-appserver-test</exclude>
<exclude>org.apache.ignite:ignite-websphere-test</exclude>
<exclude>org.apache.ignite:ignite-cassandra</exclude>
+ <exclude>org.apache.ignite:ignite-yardstick</exclude>
</excludes>
<sources>
<includeModuleDirectory>true</includeModuleDirectory>
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/assembly/dependencies-fabric.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-fabric.xml b/assembly/dependencies-fabric.xml
index 63e6ac8..d4000d6 100644
--- a/assembly/dependencies-fabric.xml
+++ b/assembly/dependencies-fabric.xml
@@ -136,6 +136,7 @@
<exclude>org.apache.ignite:ignite-appserver-test</exclude>
<exclude>org.apache.ignite:ignite-websphere-test</exclude>
<exclude>org.apache.ignite:ignite-cassandra</exclude>
+ <exclude>org.apache.ignite:ignite-yardstick</exclude>
</excludes>
<sources>
<includeModuleDirectory>true</includeModuleDirectory>
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/modules/yardstick/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/modules/yardstick/DEVNOTES.txt b/modules/yardstick/DEVNOTES.txt
new file mode 100644
index 0000000..6921243
--- /dev/null
+++ b/modules/yardstick/DEVNOTES.txt
@@ -0,0 +1,16 @@
+Yardstick Ignite Maven Build Instructions
+=========================================
+
+Yardstick can be build from standalone sources using following maven command:
+
+mvn clean package
+
+Artifacts can be found in /target/assembly directory.
+
+To build yardstick from Apache Ignite sources use:
+
+mvn clean package -Pyardstick -pl modules/yardstick -am -DskipTests
+
+in Apache Ignite root directory
+
+Artifacts can be found in modules/yardstick/target/assembly directory.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/modules/yardstick/README.txt
----------------------------------------------------------------------
diff --git a/modules/yardstick/README.txt b/modules/yardstick/README.txt
index 0b8e678..353ddd8 100644
--- a/modules/yardstick/README.txt
+++ b/modules/yardstick/README.txt
@@ -8,7 +8,7 @@ Visit Yardstick Repository (https://github.com/gridgain/yardstick) for detailed
The documentation below describes configuration parameters in addition to standard Yardstick parameters.
-Installation
+Building from Ignite sources
============
1. Create a local clone of Ignite repository
2. Run
@@ -17,6 +17,14 @@ mvn package
command for Yardstick Ignite POM
+Building from standalone sources
+=====================
+Run
+
+mvn package
+
+command for Yardstick Ignite POM
+
Provided Benchmarks
===================
The following benchmarks are provided:
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/modules/yardstick/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom-standalone.xml b/modules/yardstick/pom-standalone.xml
new file mode 100644
index 0000000..0bd5a0f
--- /dev/null
+++ b/modules/yardstick/pom-standalone.xml
@@ -0,0 +1,209 @@
+<?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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-yardstick</artifactId>
+ <version>to_be_replaced_by_ignite_version</version>
+ <url>http://ignite.apache.org</url>
+
+ <properties>
+ <yardstick.version>0.8.0</yardstick.version>
+ <spring.version>4.1.0.RELEASE</spring.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.yardstickframework</groupId>
+ <artifactId>yardstick</artifactId>
+ <version>${yardstick.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.beust</groupId>
+ <artifactId>jcommander</artifactId>
+ <version>1.32</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-expression</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>2.8</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.7</source>
+ <target>1.7</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.8</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/target/assembly/libs</outputDirectory>
+ <excludeTypes>pom</excludeTypes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>unpack</id>
+ <phase>package</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.yardstickframework</groupId>
+ <artifactId>yardstick</artifactId>
+ <version>${yardstick.version}</version>
+ <type>zip</type>
+ <classifier>resources</classifier>
+ <outputDirectory>${basedir}/target/assembly</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <outputDirectory>${basedir}/target/assembly/libs</outputDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.9.1</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>copy-yardstick-cfg-ignite</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <target>
+ <copy todir="${basedir}/target/assembly/config">
+ <fileset dir="${basedir}/config" />
+ </copy>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8.2</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index 970348b..4c4d138 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -36,6 +36,7 @@
<properties>
<yardstick.version>0.8.0</yardstick.version>
+ <spring.version>4.1.0.RELEASE</spring.version>
</properties>
<dependencies>
@@ -108,7 +109,6 @@
<build>
<plugins>
-
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
@@ -202,6 +202,14 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8.2</version>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed9d669/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4be1bcb..790cd4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -458,10 +458,103 @@
</profile>
<profile>
+ <id>yardstick</id>
+ <modules>
+ <module>modules/yardstick</module>
+ </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <inherited>false</inherited>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-tools</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>release-yardstick</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${basedir}/target/release-package/benchmarks" />
+
+ <copy todir="${basedir}/target/release-package/benchmarks/">
+ <fileset dir="${basedir}/modules/yardstick/target/assembly/"/>
+ </copy>
+
+ <!--todo: only required jars should be exported to /benchmarks/libs during compilation-->
+ <delete>
+ <fileset dir="${basedir}/target/release-package/benchmarks/libs/">
+ <include name="junit-*.jar" />
+ <include name="ignite-apache-license-gen-*.jar" />
+ <include name="hamcrest-core-*.jar" />
+ <include name="tools-*.jar" />
+ </fileset>
+ </delete>
+
+ <!--todo: config structure should be refactored to be the same at "sources" and "released sources"-->
+ <delete>
+ <fileset dir="${basedir}/target/release-package/benchmarks/config/">
+ <include name="*.*" />
+ <exclude name="benchmark.properties"/>
+ <exclude name="benchmark-multicast.properties"/>
+ <exclude name="ignite-base-config.xml"/>
+ <exclude name="ignite-localhost-config.xml"/>
+ <exclude name="ignite-multicast-config.xml"/>
+ </fileset>
+ </delete>
+
+ <mkdir dir="${basedir}/target/release-package/benchmarks/sources/src" />
+
+ <copy todir="${basedir}/target/release-package/benchmarks/sources/src/">
+ <fileset dir="${basedir}/modules/yardstick/src"/>
+ </copy>
+
+ <mkdir dir="${basedir}/target/release-package/benchmarks/sources/config" />
+
+ <copy todir="${basedir}/target/release-package/benchmarks/sources/config/">
+ <fileset dir="${basedir}/target/release-package/benchmarks/config"/>
+ </copy>
+
+ <copy file="${basedir}/modules/yardstick/pom-standalone.xml"
+ tofile="${basedir}/target/release-package/benchmarks/sources/pom.xml"/>
+
+ <replaceregexp byline="true">
+ <regexp pattern="to_be_replaced_by_ignite_version"/>
+ <substitution expression="${project.version}"/>
+ <fileset dir="${basedir}/target/release-package/benchmarks/sources/" >
+ <include name="pom.xml"/>
+ </fileset>
+ </replaceregexp>
+
+ <copy file="${basedir}/modules/yardstick/README.txt"
+ tofile="${basedir}/target/release-package/benchmarks/README.txt" overwrite="true">
+ </copy>
+
+ <copy file="${basedir}/modules/yardstick/DEVNOTES.txt"
+ tofile="${basedir}/target/release-package/benchmarks/sources/DEVNOTES.txt"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
<id>benchmarks</id>
<modules>
<module>modules/benchmarks</module>
- <module>modules/yardstick</module>
</modules>
</profile>
[15/15] ignite git commit: all cheats rolled back,
except version manager
Posted by yz...@apache.org.
all cheats rolled back, except version manager
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9c1c0285
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9c1c0285
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9c1c0285
Branch: refs/heads/ignite-comm-balance-master
Commit: 9c1c02851711369a63dfd1ae5cde478443a6f740
Parents: 9bfdd7b
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Jan 26 17:52:50 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Jan 26 17:52:50 2017 +0300
----------------------------------------------------------------------
.../cache/distributed/GridDistributedTxFinishResponse.java | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c1c0285/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
index c5cf332..109d665 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxFinishResponse.java
@@ -86,12 +86,6 @@ public class GridDistributedTxFinishResponse extends GridCacheMessage {
}
/** {@inheritDoc} */
- @Override public int partition() {
- // TODO https://issues.apache.org/jira/browse/IGNITE-4371
- return Integer.MIN_VALUE;
- }
-
- /** {@inheritDoc} */
@Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
writer.setBuffer(buf);
[04/15] ignite git commit: IGNITE-3699 CreatedExpiryPolicy doesn't
work if entry is loaded from store
Posted by yz...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d66dbc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java
index 4b9b61a..f5888f8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxExpiryPolicyWithStoreTest.java
@@ -19,6 +19,8 @@ package org.apache.ignite.internal.processors.cache.expiry;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -41,4 +43,23 @@ public class IgniteCacheTxExpiryPolicyWithStoreTest extends IgniteCacheExpiryPol
@Override protected CacheAtomicityMode atomicityMode() {
return TRANSACTIONAL;
}
+
+ /** {@inheritDoc} */
+ @Override public void testGetReadThrough() throws Exception {
+ super.testGetReadThrough();
+
+ getReadThrough(false, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ getReadThrough(true, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
+ getReadThrough(false, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ getReadThrough(true, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ getReadThrough(false, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+ getReadThrough(true, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+
+ getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ getReadThrough(false, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+ getReadThrough(true, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
+ }
}
\ No newline at end of file
[06/15] ignite git commit: IGNITE-4598: Hadoop: implemented raw
comparator for BytesWritable key type. This closes #1457.
Posted by yz...@apache.org.
IGNITE-4598: Hadoop: implemented raw comparator for BytesWritable key type. This closes #1457.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d4d5976d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d4d5976d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d4d5976d
Branch: refs/heads/ignite-comm-balance-master
Commit: d4d5976dd354e05f6ac5fa2e2faf1ac66f3b7dec
Parents: 28d66db
Author: devozerov <vo...@gridgain.com>
Authored: Tue Jan 24 16:45:59 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Jan 24 16:45:59 2017 +0300
----------------------------------------------------------------------
.../io/BytesWritablePartiallyRawComparator.java | 51 +++++++++++++++
.../hadoop/io/TextPartiallyRawComparator.java | 68 +-------------------
.../processors/hadoop/impl/HadoopUtils.java | 66 +++++++++++++++++++
.../hadoop/impl/v2/HadoopV2TaskContext.java | 13 +++-
4 files changed, 129 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d4d5976d/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/BytesWritablePartiallyRawComparator.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/BytesWritablePartiallyRawComparator.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/BytesWritablePartiallyRawComparator.java
new file mode 100644
index 0000000..da9240b
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/BytesWritablePartiallyRawComparator.java
@@ -0,0 +1,51 @@
+/*
+ * 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.hadoop.io;
+
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils;
+import org.apache.ignite.internal.processors.hadoop.io.OffheapRawMemory;
+import org.apache.ignite.internal.processors.hadoop.io.PartiallyOffheapRawComparatorEx;
+
+/**
+ * Partial raw comparator for {@link BytesWritable} data type.
+ * <p>
+ * Implementation is borrowed from {@code org.apache.hadoop.io.FastByteComparisons} and adopted to Ignite
+ * infrastructure.
+ */
+public class BytesWritablePartiallyRawComparator implements PartiallyRawComparator<BytesWritable>,
+ PartiallyOffheapRawComparatorEx<BytesWritable> {
+ /** Length bytes. */
+ private static final int LEN_BYTES = 4;
+
+ /** {@inheritDoc} */
+ @Override public int compare(BytesWritable val1, RawMemory val2Buf) {
+ if (val2Buf instanceof OffheapRawMemory) {
+ OffheapRawMemory val2Buf0 = (OffheapRawMemory)val2Buf;
+
+ return compare(val1, val2Buf0.pointer(), val2Buf0.length());
+ }
+ else
+ throw new UnsupportedOperationException("Text can be compared only with offheap memory.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compare(BytesWritable val1, long val2Ptr, int val2Len) {
+ return HadoopUtils.compareBytes(val1.getBytes(), val1.getLength(), val2Ptr + LEN_BYTES, val2Len - LEN_BYTES);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d4d5976d/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/TextPartiallyRawComparator.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/TextPartiallyRawComparator.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/TextPartiallyRawComparator.java
index a2bc3d4..e82f5e4 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/TextPartiallyRawComparator.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/io/TextPartiallyRawComparator.java
@@ -17,10 +17,9 @@
package org.apache.ignite.hadoop.io;
-import com.google.common.primitives.Longs;
-import com.google.common.primitives.UnsignedBytes;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableUtils;
+import org.apache.ignite.internal.processors.hadoop.impl.HadoopUtils;
import org.apache.ignite.internal.processors.hadoop.io.OffheapRawMemory;
import org.apache.ignite.internal.processors.hadoop.io.PartiallyOffheapRawComparatorEx;
import org.apache.ignite.internal.util.GridUnsafe;
@@ -47,69 +46,6 @@ public class TextPartiallyRawComparator implements PartiallyRawComparator<Text>,
@Override public int compare(Text val1, long val2Ptr, int val2Len) {
int len2 = WritableUtils.decodeVIntSize(GridUnsafe.getByte(val2Ptr));
- return compareBytes(val1.getBytes(), val1.getLength(), val2Ptr + len2, val2Len - len2);
- }
-
- /**
- * Internal comparison routine.
- *
- * @param buf1 Bytes 1.
- * @param len1 Length 1.
- * @param ptr2 Pointer 2.
- * @param len2 Length 2.
- * @return Result.
- */
- @SuppressWarnings("SuspiciousNameCombination")
- private static int compareBytes(byte[] buf1, int len1, long ptr2, int len2) {
- int minLength = Math.min(len1, len2);
-
- int minWords = minLength / Longs.BYTES;
-
- for (int i = 0; i < minWords * Longs.BYTES; i += Longs.BYTES) {
- long lw = GridUnsafe.getLong(buf1, GridUnsafe.BYTE_ARR_OFF + i);
- long rw = GridUnsafe.getLong(ptr2 + i);
-
- long diff = lw ^ rw;
-
- if (diff != 0) {
- if (GridUnsafe.BIG_ENDIAN)
- return (lw + Long.MIN_VALUE) < (rw + Long.MIN_VALUE) ? -1 : 1;
-
- // Use binary search
- int n = 0;
- int y;
- int x = (int) diff;
-
- if (x == 0) {
- x = (int) (diff >>> 32);
-
- n = 32;
- }
-
- y = x << 16;
-
- if (y == 0)
- n += 16;
- else
- x = y;
-
- y = x << 8;
-
- if (y == 0)
- n += 8;
-
- return (int) (((lw >>> n) & 0xFFL) - ((rw >>> n) & 0xFFL));
- }
- }
-
- // The epilogue to cover the last (minLength % 8) elements.
- for (int i = minWords * Longs.BYTES; i < minLength; i++) {
- int res = UnsignedBytes.compare(buf1[i], GridUnsafe.getByte(ptr2 + i));
-
- if (res != 0)
- return res;
- }
-
- return len1 - len2;
+ return HadoopUtils.compareBytes(val1.getBytes(), val1.getLength(), val2Ptr + len2, val2Len - len2);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d4d5976d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
index a34388d..767e10a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/HadoopUtils.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.hadoop.impl;
+import com.google.common.primitives.Longs;
+import com.google.common.primitives.UnsignedBytes;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Writable;
@@ -32,6 +34,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobId;
import org.apache.ignite.internal.processors.hadoop.HadoopJobStatus;
import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapper;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskInfo;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.internal.U;
import java.io.ByteArrayInputStream;
@@ -328,4 +331,67 @@ public class HadoopUtils {
HadoopCommonUtils.restoreContextClassLoader(oldLdr);
}
}
+
+ /**
+ * Internal comparison routine.
+ *
+ * @param buf1 Bytes 1.
+ * @param len1 Length 1.
+ * @param ptr2 Pointer 2.
+ * @param len2 Length 2.
+ * @return Result.
+ */
+ @SuppressWarnings("SuspiciousNameCombination")
+ public static int compareBytes(byte[] buf1, int len1, long ptr2, int len2) {
+ int minLength = Math.min(len1, len2);
+
+ int minWords = minLength / Longs.BYTES;
+
+ for (int i = 0; i < minWords * Longs.BYTES; i += Longs.BYTES) {
+ long lw = GridUnsafe.getLong(buf1, GridUnsafe.BYTE_ARR_OFF + i);
+ long rw = GridUnsafe.getLong(ptr2 + i);
+
+ long diff = lw ^ rw;
+
+ if (diff != 0) {
+ if (GridUnsafe.BIG_ENDIAN)
+ return (lw + Long.MIN_VALUE) < (rw + Long.MIN_VALUE) ? -1 : 1;
+
+ // Use binary search
+ int n = 0;
+ int y;
+ int x = (int) diff;
+
+ if (x == 0) {
+ x = (int) (diff >>> 32);
+
+ n = 32;
+ }
+
+ y = x << 16;
+
+ if (y == 0)
+ n += 16;
+ else
+ x = y;
+
+ y = x << 8;
+
+ if (y == 0)
+ n += 8;
+
+ return (int) (((lw >>> n) & 0xFFL) - ((rw >>> n) & 0xFFL));
+ }
+ }
+
+ // The epilogue to cover the last (minLength % 8) elements.
+ for (int i = minWords * Longs.BYTES; i < minLength; i++) {
+ int res = UnsignedBytes.compare(buf1[i], GridUnsafe.getByte(ptr2 + i));
+
+ if (res != 0)
+ return res;
+ }
+
+ return len1 - len2;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d4d5976d/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
index 8acc7aa..b8d4cac 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/v2/HadoopV2TaskContext.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.ByteWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.serializer.Deserializer;
@@ -40,6 +41,7 @@ import org.apache.hadoop.mapreduce.TaskType;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.ReflectionUtils;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.hadoop.io.BytesWritablePartiallyRawComparator;
import org.apache.ignite.hadoop.io.PartiallyRawComparator;
import org.apache.ignite.hadoop.io.TextPartiallyRawComparator;
import org.apache.ignite.internal.processors.hadoop.HadoopCommonUtils;
@@ -48,7 +50,6 @@ import org.apache.ignite.internal.processors.hadoop.HadoopInputSplit;
import org.apache.ignite.internal.processors.hadoop.HadoopJob;
import org.apache.ignite.internal.processors.hadoop.HadoopJobId;
import org.apache.ignite.internal.processors.hadoop.HadoopJobProperty;
-import org.apache.ignite.internal.processors.hadoop.HadoopMapperAwareTaskOutput;
import org.apache.ignite.internal.processors.hadoop.HadoopPartitioner;
import org.apache.ignite.internal.processors.hadoop.HadoopSerialization;
import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapper;
@@ -155,6 +156,7 @@ public class HadoopV2TaskContext extends HadoopTaskContext {
COMBINE_KEY_GROUPING_SUPPORTED = ok;
+ PARTIAL_COMPARATORS.put(ByteWritable.class.getName(), BytesWritablePartiallyRawComparator.class.getName());
PARTIAL_COMPARATORS.put(Text.class.getName(), TextPartiallyRawComparator.class.getName());
}
@@ -595,11 +597,16 @@ public class HadoopV2TaskContext extends HadoopTaskContext {
if (clsName == null) {
Class keyCls = conf.getMapOutputKeyClass();
- if (keyCls != null) {
+ while (keyCls != null) {
clsName = PARTIAL_COMPARATORS.get(keyCls.getName());
- if (clsName != null)
+ if (clsName != null) {
conf.set(HadoopJobProperty.JOB_PARTIALLY_RAW_COMPARATOR.propertyName(), clsName);
+
+ break;
+ }
+
+ keyCls = keyCls.getSuperclass();
}
}
}
[10/15] ignite git commit: IGNITE-4562 .NET: Add mapping for
BinaryObjectException
Posted by yz...@apache.org.
IGNITE-4562 .NET: Add mapping for BinaryObjectException
This closes #1461
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/885dc32b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/885dc32b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/885dc32b
Branch: refs/heads/ignite-comm-balance-master
Commit: 885dc32ba21d08b0f4bd6b067ad80c738173a2c4
Parents: eed9d66
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Jan 25 14:36:53 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Jan 25 14:36:53 2017 +0300
----------------------------------------------------------------------
.../ignite/platform/PlatformExceptionTask.java | 78 ++++++++++++++++++++
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 38 ++++++++++
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 6 +-
3 files changed, 120 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/885dc32b/modules/core/src/test/java/org/apache/ignite/platform/PlatformExceptionTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformExceptionTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformExceptionTask.java
new file mode 100644
index 0000000..c1ab991
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformExceptionTask.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.platform;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.cache.CacheAtomicUpdateTimeoutException;
+import org.apache.ignite.cluster.ClusterGroupEmptyException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.compute.*;
+import org.apache.ignite.lang.IgniteFutureCancelledException;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.Nullable;
+
+import javax.cache.CacheException;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import javax.cache.processor.EntryProcessorException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task to test exception mappings.
+ */
+public class PlatformExceptionTask extends ComputeTaskAdapter<String, String> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
+ @Nullable String arg) {
+ switch (arg) {
+ case "IllegalArgumentException": throw new IllegalArgumentException(arg);
+ case "IllegalStateException": throw new IllegalStateException(arg);
+ case "UnsupportedOperationException": throw new UnsupportedOperationException(arg);
+ case "IgniteException": throw new IgniteException(arg);
+ case "BinaryObjectException": throw new BinaryObjectException(arg);
+ case "ClusterGroupEmptyException": throw new ClusterGroupEmptyException(arg);
+ case "ClusterTopologyException": throw new ClusterTopologyException(arg);
+ case "ComputeExecutionRejectedException": throw new ComputeExecutionRejectedException(arg);
+ case "ComputeJobFailoverException": throw new ComputeJobFailoverException(arg);
+ case "ComputeTaskCancelledException": throw new ComputeTaskCancelledException(arg);
+ case "ComputeTaskTimeoutException": throw new ComputeTaskTimeoutException(arg);
+ case "ComputeUserUndeclaredException": throw new ComputeUserUndeclaredException(arg);
+ case "CacheException": throw new CacheException(arg);
+ case "CacheLoaderException": throw new CacheLoaderException(arg);
+ case "CacheWriterException": throw new CacheWriterException(arg);
+ case "EntryProcessorException": throw new EntryProcessorException(arg);
+ case "CacheAtomicUpdateTimeoutException": throw new CacheAtomicUpdateTimeoutException(arg);
+ case "TransactionOptimisticException": throw new TransactionOptimisticException(arg);
+ case "TransactionTimeoutException": throw new TransactionTimeoutException(arg);
+ case "TransactionRollbackException": throw new TransactionRollbackException(arg);
+ case "TransactionHeuristicException": throw new TransactionHeuristicException(arg);
+ case "TransactionDeadlockException": throw new TransactionDeadlockException(arg);
+ case "IgniteFutureCancelledException": throw new IgniteFutureCancelledException(arg);
+ }
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String reduce(List<ComputeJobResult> results) {
+ return results.get(0).getData();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/885dc32b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index 052ff6f..8c23ab7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -28,6 +28,8 @@ namespace Apache.Ignite.Core.Tests
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Transactions;
using NUnit.Framework;
/// <summary>
@@ -35,6 +37,9 @@ namespace Apache.Ignite.Core.Tests
/// </summary>
public class ExceptionsTest
{
+ /** */
+ private const string ExceptionTask = "org.apache.ignite.platform.PlatformExceptionTask";
+
/// <summary>
/// Before test.
/// </summary>
@@ -70,12 +75,45 @@ namespace Apache.Ignite.Core.Tests
Assert.IsTrue(e.InnerException.Message.StartsWith(
"class org.apache.ignite.cluster.ClusterGroupEmptyException: Cluster group is empty."));
+ // Check all exceptions mapping.
+ var comp = grid.GetCompute();
+
+ CheckException<BinaryObjectException>(comp, "BinaryObjectException");
+ CheckException<IgniteException>(comp, "IgniteException");
+ CheckException<BinaryObjectException>(comp, "BinaryObjectException");
+ CheckException<ClusterTopologyException>(comp, "ClusterTopologyException");
+ CheckException<ComputeExecutionRejectedException>(comp, "ComputeExecutionRejectedException");
+ CheckException<ComputeJobFailoverException>(comp, "ComputeJobFailoverException");
+ CheckException<ComputeTaskCancelledException>(comp, "ComputeTaskCancelledException");
+ CheckException<ComputeTaskTimeoutException>(comp, "ComputeTaskTimeoutException");
+ CheckException<ComputeUserUndeclaredException>(comp, "ComputeUserUndeclaredException");
+ CheckException<TransactionOptimisticException>(comp, "TransactionOptimisticException");
+ CheckException<TransactionTimeoutException>(comp, "TransactionTimeoutException");
+ CheckException<TransactionRollbackException>(comp, "TransactionRollbackException");
+ CheckException<TransactionHeuristicException>(comp, "TransactionHeuristicException");
+ CheckException<TransactionDeadlockException>(comp, "TransactionDeadlockException");
+ CheckException<IgniteFutureCancelledException>(comp, "IgniteFutureCancelledException");
+
+ // Check stopped grid.
grid.Dispose();
Assert.Throws<InvalidOperationException>(() => grid.GetCache<object, object>("cache1"));
}
/// <summary>
+ /// Checks the exception.
+ /// </summary>
+ private static void CheckException<T>(ICompute comp, string name) where T : Exception
+ {
+ var ex = Assert.Throws<T>(() => comp.ExecuteJavaTask<string>(ExceptionTask, name));
+
+ var javaEx = ex.InnerException as JavaException;
+
+ Assert.IsNotNull(javaEx);
+ Assert.IsTrue(javaEx.Message.Contains("at " + ExceptionTask));
+ }
+
+ /// <summary>
/// Tests CachePartialUpdateException keys propagation.
/// </summary>
[Test]
http://git-wip-us.apache.org/repos/asf/ignite/blob/885dc32b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
index ddbdd86..64f3ccc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Impl
using System.Security;
using System.Text.RegularExpressions;
using System.Threading;
+ using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Store;
using Apache.Ignite.Core.Cluster;
@@ -62,10 +63,10 @@ namespace Apache.Ignite.Core.Impl
Justification = "Readability")]
static ExceptionUtils()
{
- // Common Java exceptions mapped to common .Net exceptions.
+ // Common Java exceptions mapped to common .NET exceptions.
Exs["java.lang.IllegalArgumentException"] = (i, m, e) => new ArgumentException(m, e);
Exs["java.lang.IllegalStateException"] = (i, m, e) => new InvalidOperationException(m, e);
- Exs["java.lang.UnsupportedOperationException"] = (i, m, e) => new NotImplementedException(m, e);
+ Exs["java.lang.UnsupportedOperationException"] = (i, m, e) => new NotSupportedException(m, e);
Exs["java.lang.InterruptedException"] = (i, m, e) => new ThreadInterruptedException(m, e);
// Generic Ignite exceptions.
@@ -73,6 +74,7 @@ namespace Apache.Ignite.Core.Impl
Exs["org.apache.ignite.IgniteCheckedException"] = (i, m, e) => new IgniteException(m, e);
Exs["org.apache.ignite.IgniteClientDisconnectedException"] = (i, m, e) => new ClientDisconnectedException(m, e, i.GetCluster().ClientReconnectTask);
Exs["org.apache.ignite.internal.IgniteClientDisconnectedCheckedException"] = (i, m, e) => new ClientDisconnectedException(m, e, i.GetCluster().ClientReconnectTask);
+ Exs["org.apache.ignite.binary.BinaryObjectException"] = (i, m, e) => new BinaryObjectException(m, e);
// Cluster exceptions.
Exs["org.apache.ignite.cluster.ClusterGroupEmptyException"] = (i, m, e) => new ClusterGroupEmptyException(m, e);
[02/15] ignite git commit: IGNITE-1943 Visor CMD: Fixed wrong
behavior of "mclear" command". - Fixes #1179.
Posted by yz...@apache.org.
IGNITE-1943 Visor CMD: Fixed wrong behavior of "mclear" command". - Fixes #1179.
Signed-off-by: Andrey Novikov <an...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/24e14b66
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/24e14b66
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/24e14b66
Branch: refs/heads/ignite-comm-balance-master
Commit: 24e14b6618564873ca9509ce3272cd315df93728
Parents: d5b2748
Author: samaitra <sa...@gmail.com>
Authored: Tue Jan 24 14:31:24 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jan 24 14:31:24 2017 +0700
----------------------------------------------------------------------
.../scala/org/apache/ignite/visor/visor.scala | 104 ++++++++++++-------
.../commands/mem/VisorMemoryCommandSpec.scala | 14 +++
.../commands/node/VisorNodeCommandSpec.scala | 10 ++
3 files changed, 89 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/24e14b66/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 8673b9c..0aa8549 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -330,43 +330,6 @@ object visor extends VisorTag {
)
addHelp(
- name = "mclear",
- shortInfo = "Clears Visor console memory variables.",
- spec = Seq(
- "mclear",
- "mclear <name>|-ev|-al|-ca|-no|-tn|-ex"
- ),
- args = Seq(
- "<name>" -> Seq(
- "Variable name to clear.",
- "Note that name doesn't include '@' symbol used to reference variable."
- ),
- "-ev" ->
- "Clears all 'event' variables.",
- "-al" ->
- "Clears all 'alert' variables.",
- "-ca" ->
- "Clears all 'cache' variables.",
- "-no" ->
- "Clears all 'node' variables.",
- "-tn" ->
- "Clears all 'task name' variables.",
- "-ex" ->
- "Clears all 'task execution' variables."
- ),
- examples = Seq(
- "mclear" ->
- "Clears all Visor console variables.",
- "mclear -ca" ->
- "Clears all Visor console cache variables.",
- "mclear n2" ->
- "Clears 'n2' Visor console variable."
- ),
- emptyArgs = mclear,
- withArgs = mclear
- )
-
- addHelp(
name = "mget",
shortInfo = "Gets Visor console memory variable.",
longInfo = Seq(
@@ -388,6 +351,23 @@ object visor extends VisorTag {
)
addHelp(
+ name = "mcompact",
+ shortInfo = "Fills gap in Visor console memory variable.",
+ longInfo = Seq(
+ "Finds and fills gap in Visor console memory variable."
+ ),
+ spec = Seq(
+ "mcompact"
+ ),
+ examples = Seq(
+ "mcompact" ->
+ "Fills gap in Visor console memory variable."
+ ),
+ emptyArgs = mcompact,
+ withArgs = _ => wrongArgs("mcompact")
+ )
+
+ addHelp(
name = "help",
shortInfo = "Prints Visor console help.",
aliases = Seq("?"),
@@ -616,6 +596,28 @@ object visor extends VisorTag {
}
/**
+ * ==Command==
+ * Fills gap in Visor console memory variable.
+ *
+ * ==Examples==
+ * <ex>mcompact</ex>
+ * Fills gap in Visor console memory variable.
+ */
+ def mcompact() {
+ var elements = Array("e", "a", "c", "n", "t", "s")
+ for (element <- elements){
+ val r = mem.filter { case (k, _) => (element.contains(k.charAt(0)) && k != "nl" && k != "nr") }
+
+ if (r.isEmpty)
+ NA
+ else {
+ clearNamespace(element)
+ r.toSeq.sortBy(_._1).foreach { case (k, v) => setVar(v, element) }
+ }
+ }
+ }
+
+ /**
* Clears given Visor console variable or the whole namespace.
*
* @param arg Variable host or namespace mnemonic.
@@ -1677,15 +1679,39 @@ object visor extends VisorTag {
val n = ignite.cluster.node(id)
val id8 = nid8(id)
- val v = mfindHead(id8)
+ var v = mfindHead(id8)
+
+ if(!v.isDefined){
+ v = assignNodeValue(n)
+ }
id8 +
- (if (v.isDefined) "(@" + v.get._1 + ")" else "") +
+ (if (v.isDefined) "(@" + v.get._1 + ")" else "" )+
", " +
(if (n == null) NA else sortAddresses(n.addresses).headOption.getOrElse(NA))
}
}
+ def assignNodeValue(node: ClusterNode): Option[(String, String)] = {
+ assert(node != null)
+
+ val id8 = nid8(node.id())
+
+ setVarIfAbsent(id8, "n")
+
+ val alias = if (U.sameMacs(ignite.localNode(), node)) "nl" else "nr"
+
+ if (mgetOpt(alias).isEmpty)
+ msetOpt(alias, nid8(node.id()))
+
+ val ip = sortAddresses(node.addresses).headOption
+
+ if (ip.isDefined)
+ setVarIfAbsent(ip.get, "h")
+
+ mfindHead(id8)
+ }
+
/**
* Returns string with node id8 and its memory variable, if available.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/24e14b66/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
index 27eaa94..a360ea3 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/mem/VisorMemoryCommandSpec.scala
@@ -79,4 +79,18 @@ class VisorMemoryCommandSpec extends FunSpec with Matchers {
visor.mlist()
}
}
+
+ describe("A 'mcompact' visor command") {
+ it("should compact variable") {
+
+ visor.mset("key1", "value1")
+ visor.mset("key2", "value2")
+ visor.mset("key3", "value3")
+
+ visor mclear "key2"
+
+ visor.mcompact()
+ visor.mlist()
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/24e14b66/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
index c0983c0..0ef4814 100644
--- a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/node/VisorNodeCommandSpec.scala
@@ -38,5 +38,15 @@ class VisorNodeCommandSpec extends VisorRuntimeBaseSpec(1) {
visor.node("") // Arguments are ignored.
}
+
+ visor.mclear()
+
+ it("should properly execute with valid node ID value post mclear") {
+ visor.node("-id8=@n1")
+ }
+
+ it("should list all variables") {
+ visor.mlist()
+ }
}
}
[14/15] ignite git commit: Merge branches
'ignite-comm-balance-master' and 'master' of
https://git-wip-us.apache.org/repos/asf/ignite into
ignite-comm-balance-master-apache
Posted by yz...@apache.org.
Merge branches 'ignite-comm-balance-master' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-comm-balance-master-apache
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9bfdd7bb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9bfdd7bb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9bfdd7bb
Branch: refs/heads/ignite-comm-balance-master
Commit: 9bfdd7bb0feea50e5140b1167fa0a3b02d9648f1
Parents: 1b88631 9d64a28
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Thu Jan 26 17:50:18 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Thu Jan 26 17:50:18 2017 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 3 +
assembly/dependencies-fabric-lgpl.xml | 1 +
assembly/dependencies-fabric.xml | 1 +
.../processors/cache/GridCacheAdapter.java | 30 +-
.../GridDistributedCacheAdapter.java | 6 +-
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../distributed/dht/GridDhtLockFuture.java | 28 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 7 +
.../distributed/dht/GridDhtTxLocalAdapter.java | 8 +-
.../dht/GridPartitionedGetFuture.java | 1 +
.../dht/GridPartitionedSingleGetFuture.java | 2 +
.../dht/atomic/GridDhtAtomicCache.java | 1 +
.../dht/colocated/GridDhtColocatedCache.java | 10 +
.../colocated/GridDhtColocatedLockFuture.java | 10 +-
.../distributed/near/GridNearAtomicCache.java | 1 +
.../distributed/near/GridNearGetFuture.java | 1 +
.../distributed/near/GridNearGetRequest.java | 77 +++--
.../distributed/near/GridNearLockFuture.java | 7 +
.../distributed/near/GridNearLockRequest.java | 81 ++++--
.../near/GridNearSingleGetRequest.java | 57 +++-
.../near/GridNearTransactionalCache.java | 2 +
.../cache/distributed/near/GridNearTxLocal.java | 17 +-
.../processors/cache/local/GridLocalCache.java | 1 +
.../local/atomic/GridLocalAtomicCache.java | 1 +
.../transactions/IgniteTxLocalAdapter.java | 36 ++-
.../cache/transactions/IgniteTxLocalEx.java | 3 +
...eCacheExpiryPolicyWithStoreAbstractTest.java | 100 +++++--
.../IgniteCacheTxExpiryPolicyWithStoreTest.java | 21 ++
.../processors/igfs/IgfsTaskSelfTest.java | 87 ++----
.../ignite/platform/PlatformExceptionTask.java | 78 +++++
.../io/BytesWritablePartiallyRawComparator.java | 51 ++++
.../hadoop/io/TextPartiallyRawComparator.java | 68 +----
.../processors/hadoop/impl/HadoopUtils.java | 66 +++++
.../hadoop/impl/v2/HadoopV2TaskContext.java | 13 +-
modules/platforms/cpp/binary/Makefile.am | 2 +
.../platforms/cpp/binary/include/Makefile.am | 3 +
.../cpp/binary/include/ignite/binary/binary.h | 15 +-
.../include/ignite/binary/binary_object.h | 77 +++++
.../ignite/impl/binary/binary_object_header.h | 250 ++++++++++++++++
.../ignite/impl/binary/binary_object_impl.h | 102 +++++++
.../include/ignite/impl/binary/binary_schema.h | 2 +-
.../include/ignite/impl/binary/binary_utils.h | 61 ++++
.../cpp/binary/project/vs/binary.vcxproj | 5 +
.../binary/project/vs/binary.vcxproj.filters | 15 +
.../src/impl/binary/binary_object_header.cpp | 51 ++++
.../src/impl/binary/binary_object_impl.cpp | 52 ++++
.../cpp/binary/src/impl/binary/binary_utils.cpp | 83 ++++++
.../src/impl/binary/binary_writer_impl.cpp | 2 +-
modules/platforms/cpp/core-test/Makefile.am | 1 +
.../core-test/include/ignite/binary_test_defs.h | 25 ++
.../cpp/core-test/include/ignite/complex_type.h | 135 +++++++++
.../cpp/core-test/include/ignite/test_type.h | 186 ++++++++++++
.../cpp/core-test/project/vs/core-test.vcxproj | 3 +
.../project/vs/core-test.vcxproj.filters | 16 +-
.../cpp/core-test/src/binary_object_test.cpp | 282 +++++++++++++++++++
.../Binary/BinaryStructureTest.cs | 122 ++++++++
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 38 +++
.../Impl/Binary/BinaryReader.cs | 137 ++++-----
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 6 +-
.../scala/org/apache/ignite/visor/visor.scala | 115 ++++----
.../commands/mem/VisorMemoryCommandSpec.scala | 33 +++
modules/web-console/backend/app/agent.js | 12 +-
.../web-agent/bin/ignite-web-agent.bat | 4 +-
.../web-agent/bin/ignite-web-agent.sh | 2 +
.../ignite/console/agent/AgentLauncher.java | 90 +++++-
modules/yardstick/DEVNOTES.txt | 16 ++
modules/yardstick/README.txt | 10 +-
modules/yardstick/pom-standalone.xml | 209 ++++++++++++++
modules/yardstick/pom.xml | 10 +-
pom.xml | 95 ++++++-
70 files changed, 2739 insertions(+), 410 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9bfdd7bb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9bfdd7bb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9bfdd7bb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearSingleGetRequest.java
----------------------------------------------------------------------
[12/15] ignite git commit: IGNITE-3922 : Simplified IgfsTaskSelfTest.
This closes #1079.
Posted by yz...@apache.org.
IGNITE-3922 : Simplified IgfsTaskSelfTest. This closes #1079.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/58b49b6c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/58b49b6c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/58b49b6c
Branch: refs/heads/ignite-comm-balance-master
Commit: 58b49b6c2e9a834386ee4d8d06e8578a8229953c
Parents: e8067a6
Author: devozerov <vo...@gridgain.com>
Authored: Thu Jan 26 12:24:27 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Jan 26 12:24:27 2017 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsTaskSelfTest.java | 87 +++++---------------
1 file changed, 20 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58b49b6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
index e5abfea..7b972c3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
@@ -17,12 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -42,9 +36,7 @@ import org.apache.ignite.igfs.mapreduce.IgfsTaskArgs;
import org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.JobContextResource;
import org.apache.ignite.resources.TaskSessionResource;
@@ -52,6 +44,13 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -76,13 +75,10 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
private static final int BLOCK_SIZE = 64 * 1024;
/** Total words in file. */
- private static final int TOTAL_WORDS = 2 * 1024 * 1024;
+ private static final int TOTAL_WORDS = 1024 * 1024;
/** Node count */
- private static final int NODE_CNT = 4;
-
- /** Repeat count. */
- private static final int REPEAT_CNT = 10;
+ private static final int NODE_CNT = 3;
/** IGFS. */
private static IgniteFileSystem igfs;
@@ -159,63 +155,18 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
*
* @throws Exception If failed.
*/
+ @SuppressWarnings("ConstantConditions")
public void testTask() throws Exception {
- U.sleep(3000); // TODO: Sleep in order to wait for fragmentizing to finish.
-
- for (int i = 0; i < REPEAT_CNT; i++) {
- String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
-
- generateFile(TOTAL_WORDS);
- Long genLen = igfs.info(FILE).length();
-
- IgniteBiTuple<Long, Integer> taskRes = igfs.execute(new Task(),
- new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg);
-
- assert F.eq(genLen, taskRes.getKey());
- assert F.eq(TOTAL_WORDS, taskRes.getValue());
- }
- }
-
- /**
- * Test task.
- *
- * @throws Exception If failed.
- */
- public void testTaskAsync() throws Exception {
- U.sleep(3000);
-
- assertFalse(igfs.isAsync());
-
- IgniteFileSystem igfsAsync = igfs.withAsync();
-
- assertTrue(igfsAsync.isAsync());
-
- for (int i = 0; i < REPEAT_CNT; i++) {
- String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
-
- generateFile(TOTAL_WORDS);
- Long genLen = igfs.info(FILE).length();
-
- assertNull(igfsAsync.execute(
- new Task(), new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg));
-
- IgniteFuture<IgniteBiTuple<Long, Integer>> fut = igfsAsync.future();
-
- assertNotNull(fut);
-
- IgniteBiTuple<Long, Integer> taskRes = fut.get();
-
- assert F.eq(genLen, taskRes.getKey());
- assert F.eq(TOTAL_WORDS, taskRes.getValue());
- }
-
- igfsAsync.format();
+ String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
- IgniteFuture<?> fut = igfsAsync.future();
+ generateFile(TOTAL_WORDS);
+ Long genLen = igfs.info(FILE).length();
- assertNotNull(fut);
+ IgniteBiTuple<Long, Integer> taskRes = igfs.execute(new Task(),
+ new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg);
- fut.get();
+ assert F.eq(genLen, taskRes.getKey());
+ assert F.eq(TOTAL_WORDS, taskRes.getValue());
}
/**
@@ -252,12 +203,13 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
}
/** {@inheritDoc} */
+ @SuppressWarnings("ConstantConditions")
@Override public IgniteBiTuple<Long, Integer> reduce(List<ComputeJobResult> ress) {
long totalLen = 0;
int argCnt = 0;
for (ComputeJobResult res : ress) {
- IgniteBiTuple<Long, Integer> res0 = (IgniteBiTuple<Long, Integer>)res.getData();
+ IgniteBiTuple<Long, Integer> res0 = res.getData();
if (res0 != null) {
totalLen += res0.getKey();
@@ -272,6 +224,7 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
/**
* Job.
*/
+ @SuppressWarnings("unused")
private static class Job implements IgfsJob, Serializable {
@IgniteInstanceResource
private Ignite ignite;
[13/15] ignite git commit: IGNITE-1466: CPP: Added initial
BinaryObject implementation. This closes #1448.
Posted by yz...@apache.org.
IGNITE-1466: CPP: Added initial BinaryObject implementation. This closes #1448.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9d64a281
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9d64a281
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9d64a281
Branch: refs/heads/ignite-comm-balance-master
Commit: 9d64a281b89d447c92fc8181190d0554ea3f5755
Parents: 58b49b6
Author: isapego <ig...@gmail.com>
Authored: Thu Jan 26 15:02:03 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Jan 26 15:02:03 2017 +0300
----------------------------------------------------------------------
modules/platforms/cpp/binary/Makefile.am | 2 +
.../platforms/cpp/binary/include/Makefile.am | 3 +
.../cpp/binary/include/ignite/binary/binary.h | 15 +-
.../include/ignite/binary/binary_object.h | 77 +++++
.../ignite/impl/binary/binary_object_header.h | 250 ++++++++++++++++
.../ignite/impl/binary/binary_object_impl.h | 102 +++++++
.../include/ignite/impl/binary/binary_schema.h | 2 +-
.../include/ignite/impl/binary/binary_utils.h | 61 ++++
.../cpp/binary/project/vs/binary.vcxproj | 5 +
.../binary/project/vs/binary.vcxproj.filters | 15 +
.../src/impl/binary/binary_object_header.cpp | 51 ++++
.../src/impl/binary/binary_object_impl.cpp | 52 ++++
.../cpp/binary/src/impl/binary/binary_utils.cpp | 83 ++++++
.../src/impl/binary/binary_writer_impl.cpp | 2 +-
modules/platforms/cpp/core-test/Makefile.am | 1 +
.../core-test/include/ignite/binary_test_defs.h | 25 ++
.../cpp/core-test/include/ignite/complex_type.h | 135 +++++++++
.../cpp/core-test/include/ignite/test_type.h | 186 ++++++++++++
.../cpp/core-test/project/vs/core-test.vcxproj | 3 +
.../project/vs/core-test.vcxproj.filters | 16 +-
.../cpp/core-test/src/binary_object_test.cpp | 282 +++++++++++++++++++
21 files changed, 1357 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/Makefile.am b/modules/platforms/cpp/binary/Makefile.am
index 5ffc4fd..cee87cd 100644
--- a/modules/platforms/cpp/binary/Makefile.am
+++ b/modules/platforms/cpp/binary/Makefile.am
@@ -60,6 +60,8 @@ libignite_binary_la_SOURCES = \
src/impl/binary/binary_type_updater.cpp \
src/impl/binary/binary_schema.cpp \
src/impl/binary/binary_type_snapshot.cpp \
+ src/impl/binary/binary_object_header.cpp \
+ src/impl/binary/binary_object_impl.cpp \
src/impl/interop/interop_memory.cpp \
src/impl/interop/interop_output_stream.cpp \
src/impl/interop/interop_input_stream.cpp
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/Makefile.am b/modules/platforms/cpp/binary/include/Makefile.am
index d3211a3..2795cbc 100644
--- a/modules/platforms/cpp/binary/include/Makefile.am
+++ b/modules/platforms/cpp/binary/include/Makefile.am
@@ -26,6 +26,7 @@ nobase_include_HEADERS = \
ignite/binary/binary.h \
ignite/binary/binary_consts.h \
ignite/binary/binary_type.h \
+ ignite/binary/binary_object.h \
ignite/impl/binary/binary_type_handler.h \
ignite/impl/binary/binary_id_resolver.h \
ignite/impl/binary/binary_type_manager.h \
@@ -36,6 +37,8 @@ nobase_include_HEADERS = \
ignite/impl/binary/binary_reader_impl.h \
ignite/impl/binary/binary_schema.h \
ignite/impl/binary/binary_utils.h \
+ ignite/impl/binary/binary_object_header.h \
+ ignite/impl/binary/binary_object_impl.h \
ignite/impl/interop/interop_memory.h \
ignite/impl/interop/interop.h \
ignite/impl/interop/interop_stream_position_guard.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/ignite/binary/binary.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary.h b/modules/platforms/cpp/binary/include/ignite/binary/binary.h
index bfe23f4..d8c5404 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary.h
@@ -23,12 +23,13 @@
#ifndef _IGNITE_BINARY_BINARY
#define _IGNITE_BINARY_BINARY
-#include "ignite/binary/binary_consts.h"
-#include "ignite/binary/binary_containers.h"
-#include "ignite/binary/binary_type.h"
-#include "ignite/binary/binary_raw_reader.h"
-#include "ignite/binary/binary_raw_writer.h"
-#include "ignite/binary/binary_reader.h"
-#include "ignite/binary/binary_writer.h"
+#include <ignite/binary/binary_consts.h>
+#include <ignite/binary/binary_containers.h>
+#include <ignite/binary/binary_type.h>
+#include <ignite/binary/binary_object.h>
+#include <ignite/binary/binary_raw_reader.h>
+#include <ignite/binary/binary_raw_writer.h>
+#include <ignite/binary/binary_reader.h>
+#include <ignite/binary/binary_writer.h>
#endif //_IGNITE_BINARY_BINARY
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
new file mode 100644
index 0000000..41907d0
--- /dev/null
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file
+ * Declares ignite::binary::BinaryObject class.
+ */
+
+#ifndef _IGNITE_BINARY_BINARY_OBJECT
+#define _IGNITE_BINARY_BINARY_OBJECT
+
+#include <stdint.h>
+
+#include <ignite/impl/interop/interop.h>
+#include <ignite/impl/binary/binary_reader_impl.h>
+#include <ignite/impl/binary/binary_object_impl.h>
+
+namespace ignite
+{
+ namespace binary
+ {
+ /**
+ * Binary object.
+ *
+ * This is a thin wrapper over the memory area that contains serialized
+ * binary object. Provides method that allows deserialize object.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryObject : private impl::binary::BinaryObjectImpl
+ {
+ public:
+ /// @cond INTERNAL
+ /**
+ * Constructor.
+ *
+ * @param mem Binary object memory.
+ * @param start Object starting position in memory.
+ */
+ BinaryObject(impl::interop::InteropMemory& mem, int32_t start) :
+ BinaryObjectImpl(mem, start)
+ {
+ // No-op.
+ };
+ /// @endcond
+
+ /**
+ * Deserialize object.
+ * @throw IgniteError if the object can not be deserialized to specified type.
+ *
+ * @return Deserialized value.
+ */
+ template<typename T>
+ T Deserialize() const
+ {
+ return impl::binary::BinaryObjectImpl::Deserialize<T>();
+ }
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryObject)
+ };
+ }
+}
+
+#endif //_IGNITE_BINARY_BINARY_OBJECT
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_header.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_header.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_header.h
new file mode 100644
index 0000000..5ba1960
--- /dev/null
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_header.h
@@ -0,0 +1,250 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file
+ * Declares ignite::impl::binary::BinaryObjectHeader class.
+ */
+
+#ifndef _IGNITE_IMPL_BINARY_BINARY_OBJECT_HEADER
+#define _IGNITE_IMPL_BINARY_BINARY_OBJECT_HEADER
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+#include <ignite/impl/binary/binary_common.h>
+#include <ignite/impl/interop/interop_memory.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+
+ // This is a packed structure - we do not want padding for our fields here.
+#pragma pack(push, 1)
+
+ /**
+ * Binary object header layout.
+ */
+ struct IGNITE_IMPORT_EXPORT BinaryObjectHeaderLayout
+ {
+ int8_t headerType;
+ int8_t version;
+ int16_t flags;
+ int32_t typeId;
+ int32_t hashCode;
+ int32_t length;
+ int32_t schemaId;
+ int32_t schemaOffset;
+ };
+
+#pragma pack(pop)
+
+ /**
+ * Binary object header class.
+ *
+ * @note Most methods are defined in header to encourage inlining.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryObjectHeader
+ {
+ public:
+ // Header size in bytes.
+ enum { SIZE = sizeof(BinaryObjectHeaderLayout) };
+
+ /**
+ * Create from InteropMemory instance.
+ * @throw IgniteError if the memory at the specified offset
+ * is not a valid BinaryObject.
+ *
+ * @param mem Memory.
+ * @param offset Offset in memory.
+ * @return New BinaryObjectHeader instance.
+ */
+ static BinaryObjectHeader FromMemory(interop::InteropMemory& mem, int32_t offset);
+
+ /**
+ * Constructor.
+ *
+ * @param mem Pointer to header memory.
+ */
+ BinaryObjectHeader(void* mem) :
+ header(reinterpret_cast<BinaryObjectHeaderLayout*>(mem))
+ {
+ // No-op.
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param other Instance to copy.
+ */
+ BinaryObjectHeader(const BinaryObjectHeader& other) :
+ header(other.header)
+ {
+ // No-op.
+ }
+
+ /**
+ * Assingment operator.
+ *
+ * @param other Other instance.
+ * @return Reference to this.
+ */
+ BinaryObjectHeader& operator=(const BinaryObjectHeader& other)
+ {
+ header = other.header;
+
+ return *this;
+ }
+
+ /**
+ * Get header type.
+ *
+ * @return Header type.
+ */
+ int8_t GetType() const
+ {
+ return header->headerType;
+ }
+
+ /**
+ * Get version.
+ *
+ * @return Binary object layout version.
+ */
+ int8_t GetVersion() const
+ {
+ return header->version;
+ }
+
+ /**
+ * Get flags.
+ *
+ * @return Flags.
+ */
+ int16_t GetFlags() const
+ {
+ return header->flags;
+ }
+
+ /**
+ * Get type ID.
+ *
+ * @return Type ID.
+ */
+ int32_t GetTypeId() const
+ {
+ return header->typeId;
+ }
+
+ /**
+ * Get hash code.
+ *
+ * @return Hash code.
+ */
+ int32_t GetHashCode() const
+ {
+ return header->hashCode;
+ }
+
+ /**
+ * Get object length.
+ *
+ * @return Object length.
+ */
+ int32_t GetLength() const
+ {
+ return header->length;
+ }
+
+ /**
+ * Get schema ID.
+ *
+ * @return Schema ID.
+ */
+ int32_t GetSchemaId() const
+ {
+ return header->schemaId;
+ }
+
+ /**
+ * Get schema offset.
+ *
+ * @return Schema offset.
+ */
+ int32_t GetSchemaOffset() const
+ {
+ return header->schemaOffset;
+ }
+
+ /**
+ * Check if the binary object has schema.
+ *
+ * @return True if the binary object has schema.
+ */
+ bool HasSchema() const
+ {
+ return (header->flags & IGNITE_BINARY_FLAG_HAS_SCHEMA) != 0;
+ }
+
+ /**
+ * Check if the binary object is of user-defined type.
+ *
+ * @return True if the binary object is of user-defined type.
+ */
+ bool IsUserType() const
+ {
+ return (header->flags & IGNITE_BINARY_FLAG_USER_TYPE) != 0;
+ }
+
+ /**
+ * Get footer offset.
+ *
+ * @return Footer offset.
+ */
+ int32_t GetFooterOffset() const
+ {
+ // No schema: all we have is data. There is no offset in last 4 bytes.
+ if (!HasSchema())
+ return GetLength();
+
+ // There is schema. Regardless of raw data presence, footer starts with schema.
+ return GetSchemaOffset();
+ }
+
+ /**
+ * Get size of data without header and footer.
+ *
+ * @return Data length.
+ */
+ int32_t GetDataLength() const
+ {
+ return GetFooterOffset() - SIZE;
+ }
+
+ private:
+ /** Header layout */
+ BinaryObjectHeaderLayout* header;
+ };
+ }
+ }
+}
+
+#endif //_IGNITE_IMPL_BINARY_BINARY_OBJECT_HEADER
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
new file mode 100644
index 0000000..288ba26
--- /dev/null
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file
+ * Declares ignite::binary::BinaryObject class.
+ */
+
+#ifndef _IGNITE_IMPL_BINARY_BINARY_OBJECT_IMPL
+#define _IGNITE_IMPL_BINARY_BINARY_OBJECT_IMPL
+
+#include <stdint.h>
+
+#include <ignite/impl/interop/interop.h>
+#include <ignite/impl/binary/binary_reader_impl.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ /**
+ * Binary object implementation.
+ *
+ * This is a thin wrapper over the memory area that contains serialized
+ * binary object. Provides some methods that allow to access object's
+ * data without deserialization. Also provides method that allows
+ * deserialize object.
+ */
+ class IGNITE_IMPORT_EXPORT BinaryObjectImpl
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param mem Binary object memory.
+ * @param start Object starting position in memory.
+ */
+ BinaryObjectImpl(interop::InteropMemory& mem, int32_t start);
+
+ /**
+ * Deserialize object.
+ * @throw IgniteError if the object can not be deserialized to specified type.
+ *
+ * @return Deserialized value.
+ */
+ template<typename T>
+ T Deserialize() const
+ {
+ interop::InteropInputStream stream(&mem);
+
+ stream.Position(start);
+ BinaryReaderImpl reader(&stream);
+
+ return reader.ReadObject<T>();
+ }
+
+ /**
+ * Get object data.
+ * @throw IgniteError if the object is not in a valid state.
+ *
+ * @return Pointer to object data.
+ */
+ const int8_t* GetData() const;
+
+ /**
+ * Get object length.
+ * @throw IgniteError if the object is not in a valid state.
+ *
+ * @return Object length.
+ */
+ int32_t GetLength() const;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(BinaryObjectImpl)
+
+ /** Underlying object memory. */
+ interop::InteropMemory& mem;
+
+ /** Object starting position in memory. */
+ int32_t start;
+ };
+ }
+ }
+}
+
+#endif //_IGNITE_IMPL_BINARY_BINARY_OBJECT_IMPL
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_schema.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_schema.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_schema.h
index 756a3f7..cf97f8d 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_schema.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_schema.h
@@ -67,7 +67,7 @@ namespace ignite
/**
* Add another field to schema.
*
- * @param id Field id.
+ * @param fieldId Field id.
* @param offset Field offset.
*/
void AddField(int32_t fieldId, int32_t offset);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
index 3abd651..9599fce 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
@@ -36,6 +36,7 @@ namespace ignite
{
class InteropInputStream;
class InteropOutputStream;
+ class InteropMemory;
}
namespace binary
@@ -55,6 +56,26 @@ namespace ignite
static int8_t ReadInt8(interop::InteropInputStream* stream);
/**
+ * Utility method to read signed 8-bit integer from memory.
+ * @throw IgniteError if there is not enough memory.
+ *
+ * @param mem Memory.
+ * @param pos Position in memory.
+ * @return Value.
+ */
+ static int8_t ReadInt8(interop::InteropMemory& mem, int32_t pos);
+
+ /**
+ * Utility method to read signed 8-bit integer from memory.
+ * @warning Does not check if there is enough data in memory to read.
+ *
+ * @param mem Memory.
+ * @param pos Position in memory.
+ * @return Value.
+ */
+ static int8_t UnsafeReadInt8(interop::InteropMemory& mem, int32_t pos);
+
+ /**
* Utility method to write signed 8-bit integer to stream.
*
* @param stream Stream.
@@ -123,6 +144,26 @@ namespace ignite
static int16_t ReadInt16(interop::InteropInputStream* stream);
/**
+ * Utility method to read signed 16-bit integer from memory.
+ * @throw IgniteError if there is not enough memory.
+ *
+ * @param mem Memory.
+ * @param pos Position in memory.
+ * @return Value.
+ */
+ static int16_t ReadInt16(interop::InteropMemory& mem, int32_t pos);
+
+ /**
+ * Utility method to read signed 16-bit integer from memory.
+ * @warning Does not check if there is enough data in memory to read.
+ *
+ * @param mem Memory.
+ * @param pos Position in memory.
+ * @return Value.
+ */
+ static int16_t UnsafeReadInt16(interop::InteropMemory& mem, int32_t pos);
+
+ /**
* Utility method to write signed 16-bit integer to stream.
*
* @param stream Stream.
@@ -191,6 +232,26 @@ namespace ignite
static int32_t ReadInt32(interop::InteropInputStream* stream);
/**
+ * Utility method to read signed 32-bit integer from memory.
+ * @throw IgniteError if there is not enough memory.
+ *
+ * @param mem Memory.
+ * @param pos Position in memory.
+ * @return Value.
+ */
+ static int32_t ReadInt32(interop::InteropMemory& mem, int32_t pos);
+
+ /**
+ * Utility method to read signed 32-bit integer from memory.
+ * @warning Does not check if there is enough data in memory to read.
+ *
+ * @param mem Memory.
+ * @param pos Position in memory.
+ * @return Value.
+ */
+ static int32_t UnsafeReadInt32(interop::InteropMemory& mem, int32_t pos);
+
+ /**
* Utility method to write signed 32-bit integer to stream.
*
* @param stream Stream.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/project/vs/binary.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/project/vs/binary.vcxproj b/modules/platforms/cpp/binary/project/vs/binary.vcxproj
index a29b361..887eb96 100644
--- a/modules/platforms/cpp/binary/project/vs/binary.vcxproj
+++ b/modules/platforms/cpp/binary/project/vs/binary.vcxproj
@@ -180,6 +180,7 @@
<ClInclude Include="..\..\include\ignite\binary\binary.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_consts.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_containers.h" />
+ <ClInclude Include="..\..\include\ignite\binary\binary_object.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_raw_reader.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_raw_writer.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_reader.h" />
@@ -187,6 +188,8 @@
<ClInclude Include="..\..\include\ignite\binary\binary_writer.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_common.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_id_resolver.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_object_header.h" />
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_object_impl.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_reader_impl.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_schema.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_type_handler.h" />
@@ -208,6 +211,8 @@
<ClCompile Include="..\..\src\binary\binary_reader.cpp" />
<ClCompile Include="..\..\src\binary\binary_type.cpp" />
<ClCompile Include="..\..\src\binary\binary_writer.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_object_header.cpp" />
+ <ClCompile Include="..\..\src\impl\binary\binary_object_impl.cpp" />
<ClCompile Include="..\..\src\impl\binary\binary_reader_impl.cpp" />
<ClCompile Include="..\..\src\impl\binary\binary_schema.cpp" />
<ClCompile Include="..\..\src\impl\binary\binary_type_handler.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters b/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
index 09aca58..a1a83ef 100644
--- a/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
+++ b/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
@@ -88,6 +88,15 @@
<ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h">
<Filter>Code\impl\interop</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary\binary_object.h">
+ <Filter>Code\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_object_header.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\impl\binary\binary_object_impl.h">
+ <Filter>Code\impl\binary</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\binary\binary_containers.cpp">
@@ -141,5 +150,11 @@
<ClCompile Include="..\..\src\impl\interop\interop_output_stream.cpp">
<Filter>Code\impl\interop</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\impl\binary\binary_object_header.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\impl\binary\binary_object_impl.cpp">
+ <Filter>Code\impl\binary</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/src/impl/binary/binary_object_header.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_object_header.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_object_header.cpp
new file mode 100644
index 0000000..aef095f
--- /dev/null
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_object_header.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#include <ignite/ignite_error.h>
+
+#include <ignite/impl/binary/binary_object_header.h>
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryObjectHeader BinaryObjectHeader::FromMemory(interop::InteropMemory& mem, int32_t offset)
+ {
+ if ((mem.Length() - offset) < SIZE)
+ {
+ IGNITE_ERROR_FORMATTED_3(ignite::IgniteError::IGNITE_ERR_MEMORY,
+ "Not enough data in the binary object", "memPtr", mem.PointerLong(),
+ "len", mem.Length(), "headerLen", SIZE);
+ }
+
+ BinaryObjectHeader hdr(mem.Data() + offset);
+
+ int8_t type = hdr.GetType();
+ if (type != impl::binary::IGNITE_TYPE_OBJECT)
+ {
+ IGNITE_ERROR_FORMATTED_3(ignite::IgniteError::IGNITE_ERR_MEMORY,
+ "Not enough data in the binary object", "memPtr", mem.PointerLong(),
+ "type", type, "expected", impl::binary::IGNITE_TYPE_OBJECT);
+ }
+
+ return hdr;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp
new file mode 100644
index 0000000..652d54d
--- /dev/null
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_object_impl.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#include <ignite/impl/binary/binary_object_header.h>
+#include <ignite/impl/binary/binary_object_impl.h>
+
+using namespace ignite::impl::binary;
+
+namespace ignite
+{
+ namespace impl
+ {
+ namespace binary
+ {
+ BinaryObjectImpl::BinaryObjectImpl(impl::interop::InteropMemory& mem, int32_t start) :
+ mem(mem),
+ start(start)
+ {
+ // No-op.
+ }
+
+ const int8_t* BinaryObjectImpl::GetData() const
+ {
+ // Creating header here to validate object header layout.
+ BinaryObjectHeader header = BinaryObjectHeader::FromMemory(mem, start);
+
+ return mem.Data() + start + BinaryObjectHeader::SIZE;
+ }
+
+ int32_t BinaryObjectImpl::GetLength() const
+ {
+ BinaryObjectHeader header = BinaryObjectHeader::FromMemory(mem, start);
+
+ return header.GetDataLength();
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
index 22738ef..bffd038 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
@@ -17,12 +17,65 @@
#include <time.h>
+#include "ignite/ignite_error.h"
+
#include "ignite/impl/interop/interop.h"
#include "ignite/impl/binary/binary_utils.h"
using namespace ignite::impl::interop;
using namespace ignite::impl::binary;
+namespace
+{
+ /**
+ * Check if there is enough data in memory.
+ * @throw IgniteError if there is not enough memory.
+ *
+ * @param mem Memory.
+ * @param pos Position.
+ * @param len Data to read.
+ */
+ inline void CheckEnoughData(InteropMemory& mem, int32_t pos, int32_t len)
+ {
+ if (mem.Length() < (pos + len))
+ {
+ IGNITE_ERROR_FORMATTED_4(ignite::IgniteError::IGNITE_ERR_MEMORY, "Not enough data in "
+ "the binary object", "memPtr", mem.PointerLong(), "len", mem.Length(), "pos", pos,
+ "requested", len);
+ }
+ }
+
+ /**
+ * Read primitive int type from the specific place in memory.
+ * @throw IgniteError if there is not enough memory.
+ *
+ * @param mem Memory.
+ * @param pos Position.
+ * @return Primitive.
+ */
+ template<typename T>
+ inline T ReadPrimitive(InteropMemory& mem, int32_t pos)
+ {
+ CheckEnoughData(mem, pos, sizeof(T));
+
+ return *reinterpret_cast<T*>(mem.Data() + pos);
+ }
+
+ /**
+ * Read primitive int type from the specific place in memory.
+ * @warning Does not check if there is enough data in memory to read.
+ *
+ * @param mem Memory.
+ * @param pos Position.
+ * @return Primitive.
+ */
+ template<typename T>
+ inline T UnsafeReadPrimitive(InteropMemory& mem, int32_t pos)
+ {
+ return *reinterpret_cast<T*>(mem.Data() + pos);
+ }
+}
+
namespace ignite
{
namespace impl
@@ -34,6 +87,16 @@ namespace ignite
return stream->ReadInt8();
}
+ int8_t BinaryUtils::ReadInt8(InteropMemory& mem, int32_t pos)
+ {
+ return ReadPrimitive<int8_t>(mem, pos);
+ }
+
+ int8_t BinaryUtils::UnsafeReadInt8(interop::InteropMemory& mem, int32_t pos)
+ {
+ return UnsafeReadPrimitive<int8_t>(mem, pos);
+ }
+
void BinaryUtils::WriteInt8(InteropOutputStream* stream, int8_t val)
{
stream->WriteInt8(val);
@@ -74,6 +137,16 @@ namespace ignite
return stream->ReadInt16();
}
+ int16_t BinaryUtils::ReadInt16(interop::InteropMemory& mem, int32_t pos)
+ {
+ return ReadPrimitive<int16_t>(mem, pos);
+ }
+
+ int16_t BinaryUtils::UnsafeReadInt16(interop::InteropMemory& mem, int32_t pos)
+ {
+ return UnsafeReadPrimitive<int16_t>(mem, pos);
+ }
+
void BinaryUtils::WriteInt16(InteropOutputStream* stream, int16_t val)
{
stream->WriteInt16(val);
@@ -114,6 +187,16 @@ namespace ignite
return stream->ReadInt32();
}
+ int32_t BinaryUtils::ReadInt32(interop::InteropMemory& mem, int32_t pos)
+ {
+ return ReadPrimitive<int32_t>(mem, pos);
+ }
+
+ int32_t BinaryUtils::UnsafeReadInt32(interop::InteropMemory& mem, int32_t pos)
+ {
+ return UnsafeReadPrimitive<int32_t>(mem, pos);
+ }
+
void BinaryUtils::WriteInt32(InteropOutputStream* stream, int32_t val)
{
stream->WriteInt32(val);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
index 5df0c2a..20fb74d 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
@@ -736,7 +736,7 @@ namespace ignite
int32_t length = stream->Position() - start;
flags |= IGNITE_BINARY_FLAG_HAS_SCHEMA;
-
+
if (schemaType == OFFSET_TYPE_ONE_BYTE)
flags |= IGNITE_BINARY_FLAG_OFFSET_ONE_BYTE;
else if (schemaType == OFFSET_TYPE_TWO_BYTES)
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/Makefile.am b/modules/platforms/cpp/core-test/Makefile.am
index a5a60ed..4af2850 100644
--- a/modules/platforms/cpp/core-test/Makefile.am
+++ b/modules/platforms/cpp/core-test/Makefile.am
@@ -64,6 +64,7 @@ ignite_tests_SOURCES = \
src/handle_registry_test.cpp \
src/ignite_error_test.cpp \
src/binary_test_defs.cpp \
+ src/binary_object_test.cpp \
src/binary_reader_writer_raw_test.cpp \
src/binary_reader_writer_test.cpp \
src/binary_session_test.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
index 00b17e2..42f4539 100644
--- a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
@@ -76,6 +76,31 @@ namespace ignite_test
{
// No-op.
}
+
+ friend bool operator==(const BinaryFields& one, const BinaryFields& two)
+ {
+ return one.val1 == two.val1 && one.val2 == two.val2 &&
+ one.rawVal1 == two.rawVal1 &&one.rawVal2 == two.rawVal2;
+ }
+ };
+
+ class DummyIdResolver : public ignite::impl::binary::BinaryIdResolver
+ {
+ public:
+ virtual ~DummyIdResolver()
+ {
+ // No-op.
+ }
+
+ virtual int32_t GetTypeId()
+ {
+ return 0;
+ }
+
+ virtual int32_t GetFieldId(const int32_t, const char*)
+ {
+ return 0;
+ }
};
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/include/ignite/complex_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/complex_type.h b/modules/platforms/cpp/core-test/include/ignite/complex_type.h
new file mode 100644
index 0000000..cb4a8a1
--- /dev/null
+++ b/modules/platforms/cpp/core-test/include/ignite/complex_type.h
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_TEST_COMPLEX_TYPE
+#define _IGNITE_ODBC_TEST_COMPLEX_TYPE
+
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+namespace ignite
+{
+ struct InnerObject
+ {
+ InnerObject() :
+ f1(412),
+ f2("Lorem ipsum")
+ {
+ // No-op.
+ }
+
+ friend bool operator==(const InnerObject& one, const InnerObject& two)
+ {
+ return one.f1 == two.f1 &&
+ one.f2 == two.f2;
+ }
+
+ int32_t f1;
+ std::string f2;
+ };
+
+ struct ComplexType
+ {
+ ComplexType() :
+ i32Field(0)
+ {
+ // No-op.
+ }
+
+ friend bool operator==(const ComplexType& one, const ComplexType& two)
+ {
+ return one.i32Field == two.i32Field &&
+ one.objField == two.objField &&
+ one.strField == two.strField;
+ }
+
+ int32_t i32Field;
+ InnerObject objField;
+ std::string strField;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+
+ IGNITE_BINARY_TYPE_START(ignite::InnerObject)
+
+ typedef ignite::InnerObject InnerObject;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(InnerObject)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(InnerObject)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(InnerObject)
+ IGNITE_BINARY_IS_NULL_FALSE(InnerObject)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(InnerObject)
+
+ void Write(BinaryWriter& writer, InnerObject obj)
+ {
+ writer.WriteInt32("f1", obj.f1);
+ writer.WriteString("f2", obj.f2);
+ }
+
+ InnerObject Read(BinaryReader& reader)
+ {
+ InnerObject obj;
+
+ obj.f1 = reader.ReadInt32("f1");
+ obj.f2 = reader.ReadString("f2");
+
+ return obj;
+ }
+
+ IGNITE_BINARY_TYPE_END
+
+ IGNITE_BINARY_TYPE_START(ignite::ComplexType)
+
+ typedef ignite::ComplexType ComplexType;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ComplexType)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ComplexType)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(ComplexType)
+ IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)
+
+ void Write(BinaryWriter& writer, ComplexType obj)
+ {
+ writer.WriteInt32("i32Field", obj.i32Field);
+ writer.WriteObject("objField", obj.objField);
+ writer.WriteString("strField", obj.strField);
+ }
+
+ ComplexType Read(BinaryReader& reader)
+ {
+ ComplexType obj;
+
+ obj.i32Field = reader.ReadInt32("i32Field");
+ obj.objField = reader.ReadObject<InnerObject>("objField");
+ obj.strField = reader.ReadString("strField");
+
+ return obj;
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
+
+#endif // _IGNITE_ODBC_TEST_COMPLEX_TYPE
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/include/ignite/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/test_type.h b/modules/platforms/cpp/core-test/include/ignite/test_type.h
new file mode 100644
index 0000000..b399afe
--- /dev/null
+++ b/modules/platforms/cpp/core-test/include/ignite/test_type.h
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_TEST_TEST_TYPE
+#define _IGNITE_ODBC_TEST_TEST_TYPE
+
+#include <string>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+namespace ignite
+{
+ struct TestType
+ {
+ TestType() :
+ allNulls(false),
+ i8Field(0),
+ i16Field(0),
+ i32Field(0),
+ i64Field(0),
+ floatField(0.0f),
+ doubleField(0.0),
+ boolField(false),
+ dateField(),
+ timestampField()
+ {
+ // No-op.
+ }
+
+ TestType(int8_t i8Field, int16_t i16Field, int32_t i32Field,
+ int64_t i64Field, const std::string& strField, float floatField,
+ double doubleField, bool boolField, const Guid& guidField,
+ const Date& dateField, const Timestamp& timestampField) :
+ allNulls(false),
+ i8Field(i8Field),
+ i16Field(i16Field),
+ i32Field(i32Field),
+ i64Field(i64Field),
+ strField(strField),
+ floatField(floatField),
+ doubleField(doubleField),
+ boolField(boolField),
+ guidField(guidField),
+ dateField(dateField),
+ timestampField(timestampField)
+ {
+ // No-op.
+ }
+
+ friend bool operator==(const TestType& one, const TestType& two)
+ {
+ return
+ one.allNulls == two.allNulls &&
+ one.i8Field == two.i8Field &&
+ one.i16Field == two.i16Field &&
+ one.i32Field == two.i32Field &&
+ one.i64Field == two.i64Field &&
+ one.strField == two.strField &&
+ one.floatField == two.floatField &&
+ one.doubleField == two.doubleField &&
+ one.boolField == two.boolField &&
+ one.guidField == two.guidField &&
+ one.dateField == two.dateField &&
+ one.timestampField == two.timestampField &&
+ one.i8ArrayField == two.i8ArrayField;
+ }
+
+ bool allNulls;
+ int8_t i8Field;
+ int16_t i16Field;
+ int32_t i32Field;
+ int64_t i64Field;
+ std::string strField;
+ float floatField;
+ double doubleField;
+ bool boolField;
+ Guid guidField;
+ Date dateField;
+ Timestamp timestampField;
+ std::vector<int8_t> i8ArrayField;
+ };
+}
+
+namespace ignite
+{
+ namespace binary
+ {
+ IGNITE_BINARY_TYPE_START(ignite::TestType)
+
+ typedef ignite::TestType TestType;
+
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestType)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestType)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(TestType)
+ IGNITE_BINARY_IS_NULL_FALSE(TestType)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType)
+
+ void Write(BinaryWriter& writer, TestType obj)
+ {
+ if (!obj.allNulls)
+ {
+ writer.WriteInt8("i8Field", obj.i8Field);
+ writer.WriteInt16("i16Field", obj.i16Field);
+ writer.WriteInt32("i32Field", obj.i32Field);
+ writer.WriteInt64("i64Field", obj.i64Field);
+ writer.WriteString("strField", obj.strField);
+ writer.WriteFloat("floatField", obj.floatField);
+ writer.WriteDouble("doubleField", obj.doubleField);
+ writer.WriteBool("boolField", obj.boolField);
+ writer.WriteGuid("guidField", obj.guidField);
+ writer.WriteDate("dateField", obj.dateField);
+ writer.WriteTimestamp("timestampField", obj.timestampField);
+ if (obj.i8ArrayField.empty())
+ {
+ writer.WriteNull("i8ArrayField");
+ }
+ else
+ {
+ writer.WriteInt8Array("i8ArrayField", &obj.i8ArrayField[0], static_cast<int32_t>(obj.i8ArrayField.size()));
+ }
+ }
+ else
+ {
+ writer.WriteNull("i8Field");
+ writer.WriteNull("i16Field");
+ writer.WriteNull("i32Field");
+ writer.WriteNull("i64Field");
+ writer.WriteNull("strField");
+ writer.WriteNull("floatField");
+ writer.WriteNull("doubleField");
+ writer.WriteNull("boolField");
+ writer.WriteNull("guidField");
+ writer.WriteNull("dateField");
+ writer.WriteNull("timestampField");
+ writer.WriteNull("i8ArrayField");
+ }
+ }
+
+ TestType Read(BinaryReader& reader)
+ {
+ int8_t i8Field = reader.ReadInt8("i8Field");
+ int16_t i16Field = reader.ReadInt16("i16Field");
+ int32_t i32Field = reader.ReadInt32("i32Field");
+ int64_t i64Field = reader.ReadInt64("i64Field");
+ std::string strField = reader.ReadString("strField");
+ float floatField = reader.ReadFloat("floatField");
+ double doubleField = reader.ReadDouble("doubleField");
+ bool boolField = reader.ReadBool("boolField");
+ Guid guidField = reader.ReadGuid("guidField");
+ Date dateField = reader.ReadDate("dateField");
+ Timestamp timestampField = reader.ReadTimestamp("timestampField");
+
+ TestType result(i8Field, i16Field, i32Field, i64Field, strField,
+ floatField, doubleField, boolField, guidField, dateField,
+ timestampField);
+
+ int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0);
+ if (len > 0)
+ {
+ result.i8ArrayField.resize(len);
+ reader.ReadInt8Array("i8ArrayField", &result.i8ArrayField[0], len);
+ }
+ return result;
+ }
+
+ IGNITE_BINARY_TYPE_END
+ }
+};
+
+#endif // _IGNITE_ODBC_TEST_TEST_TYPE
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index a41d8f8..634ede2 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -38,6 +38,7 @@
<None Include="..\..\config\invalid.xml" />
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\..\src\binary_object_test.cpp" />
<ClCompile Include="..\..\src\cache_test.cpp" />
<ClCompile Include="..\..\src\concurrent_test.cpp" />
<ClCompile Include="..\..\src\decimal_test.cpp" />
@@ -63,6 +64,8 @@
<ItemGroup>
<ClInclude Include="..\..\include\ignite\binary_test_defs.h" />
<ClInclude Include="..\..\include\ignite\binary_test_utils.h" />
+ <ClInclude Include="..\..\include\ignite\complex_type.h" />
+ <ClInclude Include="..\..\include\ignite\test_type.h" />
<ClInclude Include="..\..\include\teamcity_messages.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index a95e3a4..906a9d4 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -64,15 +64,24 @@
<ClCompile Include="..\..\src\reference_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\binary_object_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\teamcity_messages.h">
<Filter>TeamCity</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\binary_test_defs.h">
+ <ClInclude Include="..\..\include\ignite\binary_test_utils.h">
<Filter>Code</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\binary_test_utils.h">
+ <ClInclude Include="..\..\include\ignite\complex_type.h">
+ <Filter>Code\Types</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\test_type.h">
+ <Filter>Code\Types</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\binary_test_defs.h">
<Filter>Code</Filter>
</ClInclude>
</ItemGroup>
@@ -86,6 +95,9 @@
<Filter Include="TeamCity">
<UniqueIdentifier>{76bceab0-e251-445f-88c3-3f6f8739423b}</UniqueIdentifier>
</Filter>
+ <Filter Include="Code\Types">
+ <UniqueIdentifier>{fb43524e-3694-44ee-b153-770cd9cf6c7a}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<None Include="..\..\config\cache-test.xml">
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d64a281/modules/platforms/cpp/core-test/src/binary_object_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_object_test.cpp b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
new file mode 100644
index 0000000..0ae7136
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
@@ -0,0 +1,282 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ignite/common/fixed_size_array.h>
+#include <ignite/binary/binary_object.h>
+#include <ignite/binary/binary_writer.h>
+
+#include "ignite/binary_test_defs.h"
+#include "ignite/test_type.h"
+#include "ignite/complex_type.h"
+
+using namespace ignite;
+using namespace ignite::binary;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+using namespace ignite_test::core::binary;
+
+template<typename T>
+void FillMem(InteropMemory& mem, const T& value)
+{
+ InteropOutputStream stream(&mem);
+ BinaryWriterImpl writer(&stream, 0);
+
+ writer.WriteObject<T>(value);
+
+ stream.Synchronize();
+}
+
+template<typename T>
+void CheckSimple(const T& value)
+{
+ InteropUnpooledMemory mem(1024);
+
+ FillMem<T>(mem, value);
+
+ BinaryObject obj(mem, 0);
+
+ T actual = obj.Deserialize<T>();
+
+ BOOST_REQUIRE_EQUAL(value, actual);
+}
+
+template<typename T>
+void CheckSimpleNP(const T& value)
+{
+ InteropUnpooledMemory mem(1024);
+
+ FillMem<T>(mem, value);
+
+ BinaryObject obj(mem, 0);
+
+ T actual = obj.Deserialize<T>();
+
+ BOOST_REQUIRE(value == actual);
+}
+
+template<typename T>
+void GetObjectData(const T& obj, common::FixedSizeArray<int8_t>& data)
+{
+ DummyIdResolver idResolver;
+
+ InteropUnpooledMemory mem(1024);
+ InteropOutputStream stream(&mem);
+ BinaryWriterImpl writerImpl(&stream, &idResolver, 0, 0, 0);
+ BinaryWriter writer(&writerImpl);
+
+ BinaryType<T> bt;
+
+ bt.Write(writer, obj);
+
+ data.Assign(mem.Data(), stream.Position());
+}
+
+template<typename T>
+void CheckData(const T& obj)
+{
+ common::FixedSizeArray<int8_t> objData;
+ GetObjectData<T>(obj, objData);
+
+ InteropUnpooledMemory mem(1024);
+ FillMem<T>(mem, obj);
+
+ BinaryObjectImpl binObj(mem, 0);
+
+ BOOST_REQUIRE_EQUAL(binObj.GetLength(), objData.GetSize());
+
+ common::FixedSizeArray<int8_t> binObjData(binObj.GetData(), binObj.GetLength());
+
+ for (int32_t i = 0; i < objData.GetSize(); ++i)
+ BOOST_CHECK_EQUAL(objData[i], binObjData[i]);
+}
+
+BOOST_AUTO_TEST_SUITE(BinaryObjectTestSuite)
+
+#ifdef CHECK_BINARY_OBJECT_WITH_PRIMITIVES
+
+BOOST_AUTO_TEST_CASE(PrimitiveInt8)
+{
+ CheckSimple<int8_t>(0);
+ CheckSimple<int8_t>(INT8_MAX);
+ CheckSimple<int8_t>(INT8_MIN);
+ CheckSimple<int8_t>(42);
+ CheckSimple<int8_t>(-12);
+ CheckSimple<int8_t>(0x7D);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveInt16)
+{
+ CheckSimple<int32_t>(0);
+ CheckSimple<int32_t>(INT16_MAX);
+ CheckSimple<int32_t>(INT16_MIN);
+ CheckSimple<int32_t>(42);
+ CheckSimple<int32_t>(12321);
+ CheckSimple<int32_t>(0x7AB0);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveInt32)
+{
+ CheckSimple<int32_t>(0);
+ CheckSimple<int32_t>(INT32_MAX);
+ CheckSimple<int32_t>(INT32_MIN);
+ CheckSimple<int32_t>(42);
+ CheckSimple<int32_t>(1337);
+ CheckSimple<int32_t>(0xA2496BC9);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveInt64)
+{
+ CheckSimple<int64_t>(0);
+ CheckSimple<int64_t>(INT64_MAX);
+ CheckSimple<int64_t>(INT64_MIN);
+ CheckSimple<int64_t>(42);
+ CheckSimple<int64_t>(13371337133713371337LL);
+ CheckSimple<int64_t>(0xA928673F501CC09E);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveBool)
+{
+ CheckSimple<bool>(true);
+ CheckSimple<bool>(false);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveFloat)
+{
+ CheckSimple<float>(0.0);
+ CheckSimple<float>(1E38f);
+ CheckSimple<float>(-1E38f);
+ CheckSimple<float>(1E-38f);
+ CheckSimple<float>(-1E-38f);
+ CheckSimple<float>(42.0f);
+ CheckSimple<float>(42.42f);
+ CheckSimple<float>(1337.1337f);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveDouble)
+{
+ CheckSimple<double>(0);
+ CheckSimple<double>(1E127);
+ CheckSimple<double>(-1E127);
+ CheckSimple<double>(1E-127);
+ CheckSimple<double>(-1E-127);
+ CheckSimple<double>(42);
+ CheckSimple<double>(42.42);
+ CheckSimple<double>(1337.1337 * 1337.1337);
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveString)
+{
+ CheckSimple<std::string>("");
+ CheckSimple<std::string>("Lorem ipsum");
+ CheckSimple<std::string>("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
+ "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
+ "quis nostrud exercitation");
+
+ CheckSimple<std::string>(std::string(1000, '.'));
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveGuid)
+{
+ CheckSimple<Guid>(Guid(0, 0));
+ CheckSimple<Guid>(Guid(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF));
+ CheckSimple<Guid>(Guid(0x4F9039DEF0FB8000, 0x905AE8A2D6FD49C1));
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveDate)
+{
+ CheckSimpleNP<Date>(Date(0));
+ CheckSimpleNP<Date>(BinaryUtils::MakeDateGmt(1998, 12, 3, 18, 32, 01));
+ CheckSimpleNP<Date>(BinaryUtils::MakeDateGmt(2017, 1, 18, 20, 50, 41));
+ CheckSimpleNP<Date>(BinaryUtils::MakeDateLocal(1998, 12, 3, 18, 32, 01));
+}
+
+BOOST_AUTO_TEST_CASE(PrimitiveTimestamp)
+{
+ CheckSimpleNP<Timestamp>(Timestamp(0));
+ CheckSimpleNP<Timestamp>(BinaryUtils::MakeTimestampGmt(1998, 12, 3, 18, 32, 01, 593846589));
+ CheckSimpleNP<Timestamp>(BinaryUtils::MakeTimestampGmt(2017, 1, 18, 20, 50, 41, 920700532));
+ CheckSimpleNP<Timestamp>(BinaryUtils::MakeTimestampLocal(1998, 12, 3, 18, 32, 01, 2385));
+}
+
+#endif //CHECK_BINARY_OBJECT_WITH_PRIMITIVES
+
+BOOST_AUTO_TEST_CASE(UserTestType)
+{
+ CheckSimpleNP(TestType());
+ CheckSimpleNP(TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9),
+ BinaryUtils::MakeDateGmt(1987, 6, 5),
+ BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456)));
+}
+
+BOOST_AUTO_TEST_CASE(UserComplexType)
+{
+ CheckSimpleNP(ComplexType());
+
+ ComplexType nonDefault;
+
+ nonDefault.i32Field = 589630659;
+ nonDefault.strField = "Some string value";
+ nonDefault.objField.f1 = 403685016;
+ nonDefault.objField.f2 = "Whatever";
+
+ CheckSimpleNP(nonDefault);
+}
+
+BOOST_AUTO_TEST_CASE(UserBinaryFields)
+{
+ CheckSimpleNP(BinaryFields());
+
+ BinaryFields nonDefault(423425, 961851, 18946, 180269165);
+
+ CheckSimpleNP(nonDefault);
+}
+
+BOOST_AUTO_TEST_CASE(UserComplexTypeGetData)
+{
+ CheckData(ComplexType());
+
+ ComplexType nonDefault;
+
+ nonDefault.i32Field = 589630659;
+ nonDefault.strField = "Some string value";
+ nonDefault.objField.f1 = 403685016;
+ nonDefault.objField.f2 = "Whatever";
+
+ CheckData(nonDefault);
+}
+
+BOOST_AUTO_TEST_CASE(UserTestTypeGetData)
+{
+ CheckData(TestType());
+ CheckData(TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9),
+ BinaryUtils::MakeDateGmt(1987, 6, 5),
+ BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456)));
+}
+
+BOOST_AUTO_TEST_CASE(UserBinaryFieldsGetData)
+{
+ CheckData(BinaryFields());
+ CheckData(BinaryFields(423425, 961851, 18946, 180269165));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
[07/15] ignite git commit: IGNITE-4520 Added credential request for
authentication on proxy.
Posted by yz...@apache.org.
IGNITE-4520 Added credential request for authentication on proxy.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ef04f35f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ef04f35f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ef04f35f
Branch: refs/heads/ignite-comm-balance-master
Commit: ef04f35fad5a8e74ee3e5f7fb6085a8e101d19ef
Parents: d4d5976
Author: Andrey Novikov <an...@gridgain.com>
Authored: Wed Jan 25 13:58:57 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Wed Jan 25 13:58:57 2017 +0700
----------------------------------------------------------------------
.../web-agent/bin/ignite-web-agent.bat | 4 +-
.../web-agent/bin/ignite-web-agent.sh | 2 +
.../ignite/console/agent/AgentLauncher.java | 90 ++++++++++++++++++--
3 files changed, 88 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ef04f35f/modules/web-console/web-agent/bin/ignite-web-agent.bat
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/bin/ignite-web-agent.bat b/modules/web-console/web-agent/bin/ignite-web-agent.bat
index 8291b55..1f1b52d 100644
--- a/modules/web-console/web-agent/bin/ignite-web-agent.bat
+++ b/modules/web-console/web-agent/bin/ignite-web-agent.bat
@@ -60,7 +60,9 @@ if %ERRORLEVEL% equ 0 (
if "%JVM_OPTS%" == "" set JVM_OPTS=-Xms1g -Xmx1g -server -XX:+AggressiveOpts -XX:MaxMetaspaceSize=256m
)
-"%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "*" org.apache.ignite.console.agent.AgentLauncher %*
+set JVM_OPTS=%JVM_OPTS% -Djava.net.useSystemProxies=true
+
+"%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "*" org.apache.ignite.console.agent.AgentLauncher %*
set JAVA_ERRORLEVEL=%ERRORLEVEL%
http://git-wip-us.apache.org/repos/asf/ignite/blob/ef04f35f/modules/web-console/web-agent/bin/ignite-web-agent.sh
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/bin/ignite-web-agent.sh b/modules/web-console/web-agent/bin/ignite-web-agent.sh
index 2e9f041..c2958fc 100644
--- a/modules/web-console/web-agent/bin/ignite-web-agent.sh
+++ b/modules/web-console/web-agent/bin/ignite-web-agent.sh
@@ -88,4 +88,6 @@ if [ -z "$JVM_OPTS" ] ; then
fi
fi
+JVM_OPTS="${JVM_OPTS} -Djava.net.useSystemProxies=true"
+
"$JAVA" ${JVM_OPTS} -cp "*" org.apache.ignite.console.agent.AgentLauncher "$@"
http://git-wip-us.apache.org/repos/asf/ignite/blob/ef04f35f/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
index 0c03d77..049791f 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
@@ -25,11 +25,15 @@ import io.socket.client.Socket;
import io.socket.emitter.Emitter;
import java.io.File;
import java.io.IOException;
+import java.net.Authenticator;
import java.net.ConnectException;
+import java.net.PasswordAuthentication;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.UnknownHostException;
import java.util.Arrays;
+import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -76,9 +80,6 @@ public class AgentLauncher {
/** */
private static final String EVENT_AGENT_CLOSE = "agent:close";
- /** */
- private static final int RECONNECT_INTERVAL = 3000;
-
/**
* Create a trust manager that trusts all certificates It is not using a particular keyStore
*/
@@ -121,6 +122,15 @@ public class AgentLauncher {
System.exit(1);
}
+ ignore = X.cause(e, UnknownHostException.class);
+
+ if (ignore != null) {
+ log.error("Failed to establish connection to server, due to errors with DNS or missing proxy settings.");
+ log.error("Documentation for proxy configuration can be found here: http://apacheignite.readme.io/docs/web-agent#section-proxy-configuration");
+
+ System.exit(1);
+ }
+
ignore = X.cause(e, IOException.class);
if (ignore != null && "404".equals(ignore.getMessage())) {
@@ -129,6 +139,29 @@ public class AgentLauncher {
return;
}
+ if (ignore != null && "407".equals(ignore.getMessage())) {
+ log.error("Failed to establish connection to server, due to proxy requires authentication.");
+
+ String userName = System.getProperty("https.proxyUsername", System.getProperty("http.proxyUsername"));
+
+ if (userName == null || userName.trim().isEmpty())
+ userName = readLine("Enter proxy user name: ");
+ else
+ System.out.println("Read username from system properties: " + userName);
+
+ char[] pwd = readPassword("Enter proxy password: ");
+
+ final PasswordAuthentication pwdAuth = new PasswordAuthentication(userName, pwd);
+
+ Authenticator.setDefault(new Authenticator() {
+ @Override protected PasswordAuthentication getPasswordAuthentication() {
+ return pwdAuth;
+ }
+ });
+
+ return;
+ }
+
log.error("Connection error.", e);
}
}
@@ -144,6 +177,32 @@ public class AgentLauncher {
};
/**
+ * @param fmt Format string.
+ * @param args Arguments.
+ */
+ private static String readLine(String fmt, Object ... args) {
+ if (System.console() != null)
+ return System.console().readLine(fmt, args);
+
+ System.out.print(String.format(fmt, args));
+
+ return new Scanner(System.in).nextLine();
+ }
+
+ /**
+ * @param fmt Format string.
+ * @param args Arguments.
+ */
+ private static char[] readPassword(String fmt, Object ... args) {
+ if (System.console() != null)
+ return System.console().readPassword(fmt, args);
+
+ System.out.print(String.format(fmt, args));
+
+ return new Scanner(System.in).nextLine().toCharArray();
+ }
+
+ /**
* @param args Args.
*/
@SuppressWarnings("BusyWait")
@@ -214,9 +273,9 @@ public class AgentLauncher {
System.out.println("Security token is required to establish connection to the web console.");
System.out.println(String.format("It is available on the Profile page: https://%s/profile", webHost));
- System.out.print("Enter security tokens separated by comma: ");
+ String tokens = String.valueOf(readPassword("Enter security tokens separated by comma: "));
- cfg.tokens(Arrays.asList(System.console().readLine().trim().split(",")));
+ cfg.tokens(Arrays.asList(tokens.trim().split(",")));
}
final RestHandler restHnd = new RestHandler(cfg);
@@ -226,12 +285,29 @@ public class AgentLauncher {
URI uri = URI.create(cfg.serverUri());
+ // Create proxy authenticator using passed properties.
+ switch (uri.getScheme()) {
+ case "http":
+ case "https":
+ final String username = System.getProperty(uri.getScheme() + ".proxyUsername");
+ final char[] pwd = System.getProperty(uri.getScheme() + ".proxyPassword", "").toCharArray();
+
+ Authenticator.setDefault(new Authenticator() {
+ @Override protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, pwd);
+ }
+ });
+
+ break;
+
+ default:
+ // No-op.
+ }
+
IO.Options opts = new IO.Options();
opts.path = "/agents";
- opts.reconnectionDelay = RECONNECT_INTERVAL;
-
// Workaround for use self-signed certificate
if (Boolean.getBoolean("trust.all")) {
SSLContext ctx = SSLContext.getInstance("TLS");