You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/11/29 10:28:42 UTC
[01/12] ignite git commit: IGNITE-7020 Web Console: fixed resize of
pinned columns.
Repository: ignite
Updated Branches:
refs/heads/ignite-7016 2fafa2180 -> 60e3680f7
IGNITE-7020 Web Console: fixed resize of pinned columns.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3ccf57a3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3ccf57a3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3ccf57a3
Branch: refs/heads/ignite-7016
Commit: 3ccf57a3a399efab7967f7baaac0f2556231d7a1
Parents: 2b1e087
Author: Dmitriy Shabalin <ds...@gridgain.com>
Authored: Tue Nov 28 10:43:33 2017 +0700
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:32 2017 +0300
----------------------------------------------------------------------
modules/web-console/frontend/app/primitives/ui-grid/index.scss | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ccf57a3/modules/web-console/frontend/app/primitives/ui-grid/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/ui-grid/index.scss b/modules/web-console/frontend/app/primitives/ui-grid/index.scss
index e86eec7..5caa57c 100644
--- a/modules/web-console/frontend/app/primitives/ui-grid/index.scss
+++ b/modules/web-console/frontend/app/primitives/ui-grid/index.scss
@@ -401,6 +401,7 @@
.ui-grid-column-resizer {
right: -1px;
opacity: 0;
+ z-index: 1000;
}
}
}
[05/12] ignite git commit: IGNITE-6406: SQL: parallel index creation.
This closes #3014.
Posted by ag...@apache.org.
IGNITE-6406: SQL: parallel index creation. This closes #3014.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9a52bb28
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9a52bb28
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9a52bb28
Branch: refs/heads/ignite-7016
Commit: 9a52bb28ed3a23a189a255207e85c8f6825fc683
Parents: 60cef7c
Author: rkondakov <rk...@gridgain.com>
Authored: Tue Nov 28 16:08:00 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:33 2017 +0300
----------------------------------------------------------------------
.../processors/query/GridQueryProcessor.java | 7 +-
.../schema/SchemaIndexCacheVisitorImpl.java | 153 +++++++++++++++--
.../operation/SchemaIndexCreateOperation.java | 16 +-
.../apache/ignite/internal/sql/SqlKeyword.java | 3 +
.../ignite/internal/sql/SqlParserUtils.java | 8 +-
.../sql/command/SqlCreateIndexCommand.java | 95 ++++++++---
.../sql/SqlParserCreateIndexSelfTest.java | 152 +++++++++++------
.../query/h2/ddl/DdlStatementsProcessor.java | 6 +-
.../cache/index/AbstractSchemaSelfTest.java | 7 +-
.../DynamicIndexAbstractBasicSelfTest.java | 168 ++++++++++++++++---
.../DynamicIndexAbstractConcurrentSelfTest.java | 36 ++--
.../cache/index/SchemaExchangeSelfTest.java | 2 +-
12 files changed, 525 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 471888a..e52a1dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1330,7 +1330,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
SchemaIndexCacheFilter filter = new TableCacheFilter(cctx, op0.tableName());
- SchemaIndexCacheVisitor visitor = new SchemaIndexCacheVisitorImpl(cctx, filter, cancelTok);
+ SchemaIndexCacheVisitor visitor = new SchemaIndexCacheVisitorImpl(cctx, filter, cancelTok, op0.parallel());
idx.dynamicIndexCreate(op0.schemaName(), op0.tableName(), idxDesc, op0.ifNotExists(), visitor);
}
@@ -2174,12 +2174,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param tblName Table name.
* @param idx Index.
* @param ifNotExists When set to {@code true} operation will fail if index already exists.
+ * @param parallel Index creation parallelism level.
* @return Future completed when index is created.
*/
public IgniteInternalFuture<?> dynamicIndexCreate(String cacheName, String schemaName, String tblName,
- QueryIndex idx, boolean ifNotExists) {
+ QueryIndex idx, boolean ifNotExists, int parallel) {
SchemaAbstractOperation op = new SchemaIndexCreateOperation(UUID.randomUUID(), cacheName, schemaName, tblName,
- idx, ifNotExists);
+ idx, ifNotExists, parallel);
return startIndexOperationDistributed(op);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
index c11c614..7b8de06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/SchemaIndexCacheVisitorImpl.java
@@ -17,8 +17,8 @@
package org.apache.ignite.internal.processors.query.schema;
-import java.util.List;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -29,8 +29,15 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalP
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter;
+import org.apache.ignite.internal.util.future.GridCompoundFuture;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridCursor;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.util.worker.GridWorker;
+import org.apache.ignite.thread.IgniteThread;
+
+import java.util.List;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
@@ -41,6 +48,9 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDh
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
+ /** Default degree of parallelism. */
+ private static final int DFLT_PARALLELISM = Math.max(1, Runtime.getRuntime().availableProcessors() / 4);
+
/** Count of rows, being processed within a single checkpoint lock. */
private static final int BATCH_SIZE = 1000;
@@ -53,24 +63,38 @@ public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
/** Cancellation token. */
private final SchemaIndexOperationCancellationToken cancel;
+ /** Parallelism. */
+ private final int parallelism;
+
+ /** Whether to stop the process. */
+ private volatile boolean stop;
+
/**
* Constructor.
* @param cctx Cache context.
*/
public SchemaIndexCacheVisitorImpl(GridCacheContext cctx) {
- this(cctx, null, null);
+ this(cctx, null, null, 0);
}
/**
* Constructor.
- * @param cctx Cache context.
+ *
+ * @param cctx Cache context.
+ * @param rowFilter Row filter.
* @param cancel Cancellation token.
+ * @param parallelism Degree of parallelism.
*/
public SchemaIndexCacheVisitorImpl(GridCacheContext cctx, SchemaIndexCacheFilter rowFilter,
- SchemaIndexOperationCancellationToken cancel) {
+ SchemaIndexOperationCancellationToken cancel, int parallelism) {
this.rowFilter = rowFilter;
this.cancel = cancel;
+ if (parallelism > 0)
+ this.parallelism = Math.min(Runtime.getRuntime().availableProcessors(), parallelism);
+ else
+ this.parallelism = DFLT_PARALLELISM;
+
if (cctx.isNear())
cctx = ((GridNearCacheAdapter)cctx.cache()).dht().context();
@@ -83,8 +107,63 @@ public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
List<GridDhtLocalPartition> parts = cctx.topology().localPartitions();
- for (int i = 0, size = parts.size(); i < size; i++)
- processPartition(parts.get(i), clo);
+ if (parts.isEmpty())
+ return;
+
+ GridCompoundFuture<Void, Void> fut = null;
+
+ if (parallelism > 1) {
+ fut = new GridCompoundFuture<>();
+
+ for (int i = 1; i < parallelism; i++)
+ fut.add(processPartitionsAsync(parts, clo, i));
+
+ fut.markInitialized();
+ }
+
+ processPartitions(parts, clo, 0);
+
+ if (fut != null)
+ fut.get();
+ }
+
+ /**
+ * Process partitions asynchronously.
+ *
+ * @param parts Partitions.
+ * @param clo Closure.
+ * @param remainder Remainder.
+ * @return Future.
+ */
+ private GridFutureAdapter<Void> processPartitionsAsync(List<GridDhtLocalPartition> parts,
+ SchemaIndexCacheVisitorClosure clo, int remainder) {
+ GridFutureAdapter<Void> fut = new GridFutureAdapter<>();
+
+ AsyncWorker worker = new AsyncWorker(parts, clo, remainder, fut);
+
+ new IgniteThread(worker).start();
+
+ return fut;
+ }
+
+ /**
+ * Process partitions.
+ *
+ * @param parts Partitions.
+ * @param clo Closure.
+ * @param remainder Remainder.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void processPartitions(List<GridDhtLocalPartition> parts, SchemaIndexCacheVisitorClosure clo,
+ int remainder)
+ throws IgniteCheckedException {
+ for (int i = 0, size = parts.size(); i < size; i++) {
+ if (stop)
+ break;
+
+ if ((i % parallelism) == remainder)
+ processPartition(parts.get(i), clo);
+ }
}
/**
@@ -107,9 +186,7 @@ public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
return;
try {
- GridCursor<? extends CacheDataRow> cursor = part.dataStore().cursor(cctx.cacheId(),
- null,
- null,
+ GridCursor<? extends CacheDataRow> cursor = part.dataStore().cursor(cctx.cacheId(), null, null,
CacheDataRowAdapter.RowData.KEY_ONLY);
boolean locked = false;
@@ -117,7 +194,7 @@ public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
try {
int cntr = 0;
- while (cursor.next()) {
+ while (cursor.next() && !stop) {
KeyCacheObject key = cursor.get().key();
if (!locked) {
@@ -194,4 +271,60 @@ public class SchemaIndexCacheVisitorImpl implements SchemaIndexCacheVisitor {
@Override public String toString() {
return S.toString(SchemaIndexCacheVisitorImpl.class, this);
}
+
+ /**
+ * Async worker.
+ */
+ private class AsyncWorker extends GridWorker {
+ /** Partitions. */
+ private final List<GridDhtLocalPartition> parts;
+
+ /** Closure. */
+ private final SchemaIndexCacheVisitorClosure clo;
+
+ /** Remained.. */
+ private final int remainder;
+
+ /** Future. */
+ private final GridFutureAdapter<Void> fut;
+
+ /**
+ * Constructor.
+ *
+ * @param parts Partitions.
+ * @param clo Closure.
+ * @param remainder Remainder.
+ * @param fut Future.
+ */
+ @SuppressWarnings("unchecked")
+ public AsyncWorker(List<GridDhtLocalPartition> parts, SchemaIndexCacheVisitorClosure clo, int remainder,
+ GridFutureAdapter<Void> fut) {
+ super(cctx.igniteInstanceName(), "parallel-idx-worker-" + cctx.cache() + "-" + remainder,
+ cctx.logger(AsyncWorker.class));
+
+ this.parts = parts;
+ this.clo = clo;
+ this.remainder = remainder;
+ this.fut = fut;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
+ Throwable err = null;
+
+ try {
+ processPartitions(parts, clo, remainder);
+ }
+ catch (Throwable e) {
+ err = e;
+
+ U.error(log, "Error during parallel index create/rebuild.", e);
+
+ stop = true;
+ }
+ finally {
+ fut.onDone(err);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaIndexCreateOperation.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaIndexCreateOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaIndexCreateOperation.java
index 7b4543f..c2e891c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaIndexCreateOperation.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/schema/operation/SchemaIndexCreateOperation.java
@@ -41,6 +41,9 @@ public class SchemaIndexCreateOperation extends SchemaIndexAbstractOperation {
/** Ignore operation if index exists. */
private final boolean ifNotExists;
+ /** Index creation parallelism level */
+ private final int parallel;
+
/**
* Constructor.
*
@@ -50,14 +53,16 @@ public class SchemaIndexCreateOperation extends SchemaIndexAbstractOperation {
* @param tblName Table name.
* @param idx Index params.
* @param ifNotExists Ignore operation if index exists.
+ * @param parallel Index creation parallelism level.
*/
public SchemaIndexCreateOperation(UUID opId, String cacheName, String schemaName, String tblName, QueryIndex idx,
- boolean ifNotExists) {
+ boolean ifNotExists, int parallel) {
super(opId, cacheName, schemaName);
this.tblName = tblName;
this.idx = idx;
this.ifNotExists = ifNotExists;
+ this.parallel = parallel;
}
/** {@inheritDoc} */
@@ -86,6 +91,15 @@ public class SchemaIndexCreateOperation extends SchemaIndexAbstractOperation {
return ifNotExists;
}
+ /**
+ * Gets index creation parallelism level.
+ *
+ * @return Index creation parallelism level.
+ */
+ public int parallel() {
+ return parallel;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(SchemaIndexCreateOperation.class, this, "parent", super.toString());
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlKeyword.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlKeyword.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlKeyword.java
index 08fa94b..021dfb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlKeyword.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlKeyword.java
@@ -201,6 +201,9 @@ public class SqlKeyword {
/** Keyword: YEAR. */
public static final String YEAR = "YEAR";
+ /** Keyword: PARALLEL. */
+ public static final String PARALLEL = "PARALLEL";
+
/** All keywords. */
private static final HashSet<String> KEYWORDS;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParserUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParserUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParserUtils.java
index d812b3d..829c48c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParserUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/SqlParserUtils.java
@@ -71,7 +71,7 @@ public class SqlParserUtils {
}
/**
- * Skip commr or right parenthesis.
+ * Skip comma or right parenthesis.
*
* @param lex Lexer.
* @return {@code True} if right parenthesis is found.
@@ -130,7 +130,7 @@ public class SqlParserUtils {
* @return Name.
*/
public static String parseIdentifier(SqlLexer lex, String... additionalExpTokens) {
- if (lex.shift() && isVaildIdentifier(lex))
+ if (lex.shift() && isValidIdentifier(lex))
return lex.token();
throw errorUnexpectedToken(lex, "[identifier]", additionalExpTokens);
@@ -144,7 +144,7 @@ public class SqlParserUtils {
* @return Qualified name.
*/
public static SqlQualifiedName parseQualifiedIdentifier(SqlLexer lex, String... additionalExpTokens) {
- if (lex.shift() && isVaildIdentifier(lex)) {
+ if (lex.shift() && isValidIdentifier(lex)) {
SqlQualifiedName res = new SqlQualifiedName();
String first = lex.token();
@@ -171,7 +171,7 @@ public class SqlParserUtils {
* @param token Token.
* @return {@code True} if we are standing on possible identifier.
*/
- public static boolean isVaildIdentifier(SqlLexerToken token) {
+ public static boolean isValidIdentifier(SqlLexerToken token) {
switch (token.tokenType()) {
case DEFAULT:
char c = token.tokenFirstChar();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
index 05eeb44..f3f38d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlCreateIndexCommand.java
@@ -38,11 +38,13 @@ import static org.apache.ignite.internal.sql.SqlKeyword.DESC;
import static org.apache.ignite.internal.sql.SqlKeyword.IF;
import static org.apache.ignite.internal.sql.SqlKeyword.INLINE_SIZE;
import static org.apache.ignite.internal.sql.SqlKeyword.ON;
+import static org.apache.ignite.internal.sql.SqlKeyword.PARALLEL;
import static org.apache.ignite.internal.sql.SqlParserUtils.error;
import static org.apache.ignite.internal.sql.SqlParserUtils.errorUnexpectedToken;
import static org.apache.ignite.internal.sql.SqlParserUtils.matchesKeyword;
import static org.apache.ignite.internal.sql.SqlParserUtils.parseIdentifier;
import static org.apache.ignite.internal.sql.SqlParserUtils.parseIfNotExists;
+import static org.apache.ignite.internal.sql.SqlParserUtils.parseInt;
import static org.apache.ignite.internal.sql.SqlParserUtils.parseQualifiedIdentifier;
import static org.apache.ignite.internal.sql.SqlParserUtils.skipCommaOrRightParenthesis;
import static org.apache.ignite.internal.sql.SqlParserUtils.skipIfMatchesKeyword;
@@ -66,6 +68,12 @@ public class SqlCreateIndexCommand implements SqlCommand {
/** Spatial index flag. */
private boolean spatial;
+ /**
+ * Parallelism level. <code>parallel=0</code> means that a default number
+ * of cores will be used during index creation (e.g. 25% of available cores).
+ */
+ private int parallel;
+
/** Columns. */
@GridToStringInclude
private Collection<SqlIndexColumn> cols;
@@ -109,6 +117,13 @@ public class SqlCreateIndexCommand implements SqlCommand {
}
/**
+ * @return Parallelism level.
+ */
+ public int parallel() {
+ return parallel;
+ }
+
+ /**
* @return Spatial index flag.
*/
public boolean spatial() {
@@ -154,7 +169,7 @@ public class SqlCreateIndexCommand implements SqlCommand {
parseColumnList(lex);
- parseInlineSize(lex);
+ parseIndexProperties(lex);
return this;
}
@@ -172,25 +187,6 @@ public class SqlCreateIndexCommand implements SqlCommand {
return parseIdentifier(lex, IF);
}
- /**
- * Parses inline size option if exists.
- *
- * @param lex Lexer.
- */
- private void parseInlineSize(SqlLexer lex) {
- SqlLexerToken nextTok = lex.lookAhead();
-
- if (matchesKeyword(nextTok, INLINE_SIZE)) {
- lex.shift();
-
- int stmtInlineSize = SqlParserUtils.parseInt(lex);
-
- if (stmtInlineSize < 0)
- throw error(lex, "Inline size should be positive: " + stmtInlineSize);
-
- inlineSize = stmtInlineSize;
- }
- }
/**
* @param lex Lexer.
@@ -242,6 +238,65 @@ public class SqlCreateIndexCommand implements SqlCommand {
cols.add(col);
}
+ /**
+ * Parses CREATE INDEX command properties.
+ *
+ * @param lex Lexer.
+ */
+ private void parseIndexProperties(SqlLexer lex) {
+ Set<String> foundProps = new HashSet<>();
+
+ while (true) {
+ SqlLexerToken token = lex.lookAhead();
+
+ if (token.tokenType() == SqlLexerTokenType.EOF)
+ return;
+
+ if (token.tokenType() == SqlLexerTokenType.DEFAULT) {
+ switch (token.token()) {
+ case PARALLEL:
+ parallel = getIntProperty(lex, PARALLEL, foundProps);
+
+ if (parallel < 0)
+ throw error(lex, "Illegal " + PARALLEL + " value. Should be positive: " + parallel);
+
+ break;
+
+ case INLINE_SIZE:
+ inlineSize = getIntProperty(lex, INLINE_SIZE, foundProps);
+
+ if (inlineSize < 0)
+ throw error(lex, "Illegal " + INLINE_SIZE +
+ " value. Should be positive: " + inlineSize);
+
+ break;
+
+ default:
+ return;
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Parses <code>Integer</code> property by its keyword.
+ * @param lex Lexer.
+ * @param keyword Keyword.
+ * @param foundProps Set of properties to check if one has already been found in SQL clause.
+ * @return parsed value;
+ */
+ private Integer getIntProperty(SqlLexer lex, String keyword, Set<String> foundProps) {
+ if (foundProps.contains(keyword))
+ throw error(lex, "Only one " + keyword + " clause may be specified.");
+
+ foundProps.add(keyword);
+
+ lex.shift();
+
+ return parseInt(lex);
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(SqlCreateIndexCommand.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
index 8cfeb2c..80328ab 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/sql/SqlParserCreateIndexSelfTest.java
@@ -17,18 +17,27 @@
package org.apache.ignite.internal.sql;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.ignite.cache.QueryIndex;
import org.apache.ignite.internal.sql.command.SqlCreateIndexCommand;
import org.apache.ignite.internal.sql.command.SqlIndexColumn;
import org.apache.ignite.internal.util.typedef.F;
-import java.util.Collection;
-import java.util.Iterator;
+import static org.apache.ignite.internal.sql.SqlKeyword.INLINE_SIZE;
+import static org.apache.ignite.internal.sql.SqlKeyword.PARALLEL;
/**
* Tests for SQL parser: CREATE INDEX.
*/
@SuppressWarnings({"UnusedReturnValue", "ThrowableNotThrown"})
public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
+ /** Default properties */
+ private static final Map<String, Object> DEFAULT_PROPS = getProps(null, null);
+
/**
* Tests for CREATE INDEX command.
*
@@ -36,44 +45,44 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
*/
public void testCreateIndex() throws Exception {
// Base.
- parseValidate(null, "CREATE INDEX idx ON tbl(a)", null, "TBL", "IDX", "A", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a ASC)", null, "TBL", "IDX", "A", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a DESC)", null, "TBL", "IDX", "A", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a ASC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", true);
// Case (in)sensitivity.
- parseValidate(null, "CREATE INDEX IDX ON TBL(COL)", null, "TBL", "IDX", "COL", false);
- parseValidate(null, "CREATE INDEX iDx ON tBl(cOl)", null, "TBL", "IDX", "COL", false);
+ parseValidate(null, "CREATE INDEX IDX ON TBL(COL)", null, "TBL", "IDX", DEFAULT_PROPS, "COL", false);
+ parseValidate(null, "CREATE INDEX iDx ON tBl(cOl)", null, "TBL", "IDX", DEFAULT_PROPS, "COL", false);
- parseValidate(null, "CREATE INDEX \"idx\" ON tbl(col)", null, "TBL", "idx", "COL", false);
- parseValidate(null, "CREATE INDEX \"iDx\" ON tbl(col)", null, "TBL", "iDx", "COL", false);
+ parseValidate(null, "CREATE INDEX \"idx\" ON tbl(col)", null, "TBL", "idx", DEFAULT_PROPS, "COL", false);
+ parseValidate(null, "CREATE INDEX \"iDx\" ON tbl(col)", null, "TBL", "iDx", DEFAULT_PROPS, "COL", false);
- parseValidate(null, "CREATE INDEX idx ON \"tbl\"(col)", null, "tbl", "IDX", "COL", false);
- parseValidate(null, "CREATE INDEX idx ON \"tBl\"(col)", null, "tBl", "IDX", "COL", false);
+ parseValidate(null, "CREATE INDEX idx ON \"tbl\"(col)", null, "tbl", "IDX", DEFAULT_PROPS, "COL", false);
+ parseValidate(null, "CREATE INDEX idx ON \"tBl\"(col)", null, "tBl", "IDX", DEFAULT_PROPS, "COL", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(\"col\")", null, "TBL", "IDX", "col", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(\"cOl\")", null, "TBL", "IDX", "cOl", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(\"col\")", null, "TBL", "IDX", DEFAULT_PROPS, "col", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(\"cOl\")", null, "TBL", "IDX", DEFAULT_PROPS, "cOl", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(\"cOl\" ASC)", null, "TBL", "IDX", "cOl", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(\"cOl\" DESC)", null, "TBL", "IDX", "cOl", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(\"cOl\" ASC)", null, "TBL", "IDX", DEFAULT_PROPS, "cOl", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(\"cOl\" DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "cOl", true);
// Columns.
- parseValidate(null, "CREATE INDEX idx ON tbl(a, b)", null, "TBL", "IDX", "A", false, "B", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a, b)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a ASC, b)", null, "TBL", "IDX", "A", false, "B", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a, b ASC)", null, "TBL", "IDX", "A", false, "B", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a ASC, b ASC)", null, "TBL", "IDX", "A", false, "B", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a ASC, b)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a, b ASC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a ASC, b ASC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b)", null, "TBL", "IDX", "A", true, "B", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a, b DESC)", null, "TBL", "IDX", "A", false, "B", true);
- parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b DESC)", null, "TBL", "IDX", "A", true, "B", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b)", null, "TBL", "IDX", DEFAULT_PROPS, "A", true, "B", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a, b DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", true, "B", true);
- parseValidate(null, "CREATE INDEX idx ON tbl(a ASC, b DESC)", null, "TBL", "IDX", "A", false, "B", true);
- parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b ASC)", null, "TBL", "IDX", "A", true, "B", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a ASC, b DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b ASC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", true, "B", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a, b, c)", null, "TBL", "IDX", "A", false, "B", false, "C", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b, c)", null, "TBL", "IDX", "A", true, "B", false, "C", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a, b DESC, c)", null, "TBL", "IDX", "A", false, "B", true, "C", false);
- parseValidate(null, "CREATE INDEX idx ON tbl(a, b, c DESC)", null, "TBL", "IDX", "A", false, "B", false, "C", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a, b, c)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", false, "C", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC, b, c)", null, "TBL", "IDX", DEFAULT_PROPS, "A", true, "B", false, "C", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a, b DESC, c)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", true, "C", false);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a, b, c DESC)", null, "TBL", "IDX", DEFAULT_PROPS, "A", false, "B", false, "C", true);
// Negative cases.
assertParseError(null, "CREATE INDEX idx ON tbl()", "Unexpected token");
@@ -82,25 +91,25 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
assertParseError(null, "CREATE INDEX idx ON tbl(b, a, a)", "Column already defined: A");
// Tests with schema.
- parseValidate(null, "CREATE INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", "A", false);
- parseValidate(null, "CREATE INDEX idx ON \"schema\".tbl(a)", "schema", "TBL", "IDX", "A", false);
- parseValidate(null, "CREATE INDEX idx ON \"sChema\".tbl(a)", "sChema", "TBL", "IDX", "A", false);
+ parseValidate(null, "CREATE INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", DEFAULT_PROPS, "A", false);
+ parseValidate(null, "CREATE INDEX idx ON \"schema\".tbl(a)", "schema", "TBL", "IDX", DEFAULT_PROPS, "A", false);
+ parseValidate(null, "CREATE INDEX idx ON \"sChema\".tbl(a)", "sChema", "TBL", "IDX", DEFAULT_PROPS, "A", false);
- parseValidate("SCHEMA", "CREATE INDEX idx ON tbl(a)", "SCHEMA", "TBL", "IDX", "A", false);
- parseValidate("schema", "CREATE INDEX idx ON tbl(a)", "schema", "TBL", "IDX", "A", false);
- parseValidate("sChema", "CREATE INDEX idx ON tbl(a)", "sChema", "TBL", "IDX", "A", false);
+ parseValidate("SCHEMA", "CREATE INDEX idx ON tbl(a)", "SCHEMA", "TBL", "IDX", DEFAULT_PROPS, "A", false);
+ parseValidate("schema", "CREATE INDEX idx ON tbl(a)", "schema", "TBL", "IDX", DEFAULT_PROPS, "A", false);
+ parseValidate("sChema", "CREATE INDEX idx ON tbl(a)", "sChema", "TBL", "IDX", DEFAULT_PROPS, "A", false);
// No index name.
- parseValidate(null, "CREATE INDEX ON tbl(a)", null, "TBL", null, "A", false);
- parseValidate(null, "CREATE INDEX ON schema.tbl(a)", "SCHEMA", "TBL", null, "A", false);
+ parseValidate(null, "CREATE INDEX ON tbl(a)", null, "TBL", null, DEFAULT_PROPS, "A", false);
+ parseValidate(null, "CREATE INDEX ON schema.tbl(a)", "SCHEMA", "TBL", null, DEFAULT_PROPS, "A", false);
// NOT EXISTS
SqlCreateIndexCommand cmd;
- cmd = parseValidate(null, "CREATE INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", "A", false);
+ cmd = parseValidate(null, "CREATE INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", DEFAULT_PROPS, "A", false);
assertFalse(cmd.ifNotExists());
- cmd = parseValidate(null, "CREATE INDEX IF NOT EXISTS idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", "A", false);
+ cmd = parseValidate(null, "CREATE INDEX IF NOT EXISTS idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", DEFAULT_PROPS, "A", false);
assertTrue(cmd.ifNotExists());
assertParseError(null, "CREATE INDEX IF idx ON tbl(a)", "Unexpected token: \"IDX\"");
@@ -109,10 +118,10 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
assertParseError(null, "CREATE INDEX NOT EXISTS idx ON tbl(a)", "Unexpected token: \"NOT\"");
// SPATIAL
- cmd = parseValidate(null, "CREATE INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", "A", false);
+ cmd = parseValidate(null, "CREATE INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", DEFAULT_PROPS, "A", false);
assertFalse(cmd.spatial());
- cmd = parseValidate(null, "CREATE SPATIAL INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", "A", false);
+ cmd = parseValidate(null, "CREATE SPATIAL INDEX idx ON schema.tbl(a)", "SCHEMA", "TBL", "IDX", DEFAULT_PROPS, "A", false);
assertTrue(cmd.spatial());
// UNIQUE
@@ -124,6 +133,15 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
// PRIMARY KEY
assertParseError(null, "CREATE PRIMARY KEY INDEX idx ON tbl(a)", "Unsupported keyword: \"PRIMARY\"");
+ // PARALLEL
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL 1", null, "TBL", "IDX", getProps(1, null), "A", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL 3", null, "TBL", "IDX", getProps(3, null), "A", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL 7", null, "TBL", "IDX", getProps(7, null), "A", true);
+ parseValidate(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL 0", null, "TBL", "IDX", getProps(0, null), "A", true);
+ assertParseError(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL ", "Failed to parse SQL statement \"CREATE INDEX idx ON tbl(a DESC) PARALLEL [*]\"");
+ assertParseError(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL abc", "Unexpected token: \"ABC\"");
+ assertParseError(null, "CREATE INDEX idx ON tbl(a DESC) PARALLEL -2", "Failed to parse SQL statement \"CREATE INDEX idx ON tbl(a DESC) PARALLEL -[*]2\": Illegal PARALLEL value. Should be positive: -2");
+
// INLINE_SIZE option
assertParseError(null, "CREATE INDEX ON tbl(a) INLINE_SIZE",
"Unexpected end of command (expected: \"[integer]\")");
@@ -138,14 +156,24 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
"Unexpected token: \"9223372036854775808\" (expected: \"[integer]\")");
assertParseError(null, "CREATE INDEX ON tbl(a) INLINE_SIZE " + Integer.MIN_VALUE,
- "Inline size should be positive: " + Integer.MIN_VALUE);
+ "Illegal INLINE_SIZE value. Should be positive: " + Integer.MIN_VALUE);
- assertParseError(null, "CREATE INDEX ON tbl(a) INLINE_SIZE -1", "Inline size should be positive: -1");
+ assertParseError(null, "CREATE INDEX ON tbl(a) INLINE_SIZE -1", "Failed to parse SQL statement \"CREATE INDEX ON tbl(a) INLINE_SIZE -[*]1\": Illegal INLINE_SIZE value. Should be positive: -1");
- parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) INLINE_SIZE 0", "SCHEMA", "TBL", "IDX", "A", false);
- parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) INLINE_SIZE 1", "SCHEMA", "TBL", "IDX", "A", false);
+ parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) INLINE_SIZE 0", "SCHEMA", "TBL", "IDX", getProps(null, 0), "A", false);
+ parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) INLINE_SIZE 1", "SCHEMA", "TBL", "IDX", getProps(null, 1), "A", false);
parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) INLINE_SIZE " + Integer.MAX_VALUE,
- "SCHEMA", "TBL", "IDX", "A", false);
+ "SCHEMA", "TBL", "IDX", getProps(null, Integer.MAX_VALUE), "A", false);
+
+ // Both parallel and inline size
+ parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) INLINE_SIZE 5 PARALLEL 7", "SCHEMA", "TBL", "IDX", getProps(7, 5), "A", false);
+ parseValidate(null, "CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE 9 ", "SCHEMA", "TBL", "IDX", getProps(3, 9), "A", false);
+
+ assertParseError(null, "CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE 9 PARALLEL 2", "Failed to parse SQL statement \"CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE [*]9 PARALLEL 2\": Only one PARALLEL clause may be specified.");
+ assertParseError(null, "CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE 9 abc ", "Failed to parse SQL statement \"CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE 9 [*]abc \": Unexpected token: \"ABC\"");
+ assertParseError(null, "CREATE INDEX idx ON schema.tbl(a) PARALLEL INLINE_SIZE 9 abc ", "Failed to parse SQL statement \"CREATE INDEX idx ON schema.tbl(a) PARALLEL [*]INLINE_SIZE 9 abc \": Unexpected token: \"INLINE_SIZE\" (expected: \"[integer]\")");
+ assertParseError(null, "CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE abc ", "Failed to parse SQL statement \"CREATE INDEX idx ON schema.tbl(a) PARALLEL 3 INLINE_SIZE [*]abc \": Unexpected token: \"ABC\" (expected: \"[integer]\")");
+
}
/**
@@ -156,14 +184,15 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
* @param expSchemaName Expected schema name.
* @param expTblName Expected table name.
* @param expIdxName Expected index name.
+ * @param props Expected properties.
* @param expColDefs Expected column definitions.
* @return Command.
*/
private static SqlCreateIndexCommand parseValidate(String schema, String sql, String expSchemaName,
- String expTblName, String expIdxName, Object... expColDefs) {
+ String expTblName, String expIdxName, Map<String, Object> props, Object... expColDefs) {
SqlCreateIndexCommand cmd = (SqlCreateIndexCommand)new SqlParser(schema, sql).nextCommand();
- validate(cmd, expSchemaName, expTblName, expIdxName, expColDefs);
+ validate(cmd, expSchemaName, expTblName, expIdxName, props, expColDefs);
return cmd;
}
@@ -175,14 +204,19 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
* @param expSchemaName Expected schema name.
* @param expTblName Expected table name.
* @param expIdxName Expected index name.
+ * @param props Expected properties.
* @param expColDefs Expected column definitions.
*/
private static void validate(SqlCreateIndexCommand cmd, String expSchemaName, String expTblName, String expIdxName,
- Object... expColDefs) {
+ Map<String, Object> props, Object... expColDefs) {
assertEquals(expSchemaName, cmd.schemaName());
assertEquals(expTblName, cmd.tableName());
assertEquals(expIdxName, cmd.indexName());
+ Map<String, Object> cmpProps = getProps(cmd.parallel(), cmd.inlineSize());
+
+ assertEquals(cmpProps, props);
+
if (F.isEmpty(expColDefs) || expColDefs.length % 2 == 1)
throw new IllegalArgumentException("Column definitions must be even.");
@@ -202,4 +236,26 @@ public class SqlParserCreateIndexSelfTest extends SqlParserAbstractSelfTest {
assertEquals(expDesc, (Boolean)col.descending());
}
}
+
+ /**
+ * Returns map with command properties.
+ *
+ * @param parallel Parallel property value. <code>Null</code> for a default value.
+ * @param inlineSize Inline size property value. <code>Null</code> for a default value.
+ * @return Command properties.
+ */
+ private static Map<String, Object> getProps(Integer parallel, Integer inlineSize) {
+ if (parallel == null)
+ parallel = 0;
+
+ if (inlineSize == null)
+ inlineSize = QueryIndex.DFLT_INLINE_SIZE;
+
+ Map<String, Object> props = new HashMap<>();
+
+ props.put(PARALLEL, parallel);
+ props.put(INLINE_SIZE, inlineSize);
+
+ return Collections.unmodifiableMap(props);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
index ea721f7..68aab49 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
@@ -137,8 +137,8 @@ public class DdlStatementsProcessor {
newIdx.setFields(flds);
newIdx.setInlineSize(cmd0.inlineSize());
- fut = ctx.query().dynamicIndexCreate(tbl.cacheName(), cmd0.schemaName(), typeDesc.tableName(),
- newIdx, cmd0.ifNotExists());
+ fut = ctx.query().dynamicIndexCreate(tbl.cacheName(), cmd.schemaName(), typeDesc.tableName(),
+ newIdx, cmd0.ifNotExists(), cmd0.parallel());
}
else if (cmd instanceof SqlDropIndexCommand) {
SqlDropIndexCommand cmd0 = (SqlDropIndexCommand)cmd;
@@ -231,7 +231,7 @@ public class DdlStatementsProcessor {
newIdx.setFields(flds);
fut = ctx.query().dynamicIndexCreate(tbl.cacheName(), cmd.schemaName(), typeDesc.tableName(),
- newIdx, cmd.ifNotExists());
+ newIdx, cmd.ifNotExists(), 0);
}
else if (stmt0 instanceof GridSqlDropIndex) {
GridSqlDropIndex cmd = (GridSqlDropIndex) stmt0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
index 0074020..01d1f36 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/AbstractSchemaSelfTest.java
@@ -467,9 +467,11 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
* @param tblName Table name.
* @param idx Index.
* @param ifNotExists When set to true operation will fail if index already exists.
+ * @param parallel Parallelism level.
* @throws Exception If failed.
*/
- protected void dynamicIndexCreate(Ignite node, String cacheName, String tblName, QueryIndex idx, boolean ifNotExists)
+ protected void dynamicIndexCreate(Ignite node, String cacheName, String tblName, QueryIndex idx,
+ boolean ifNotExists, int parallel)
throws Exception {
GridStringBuilder sql = new SB("CREATE INDEX ")
.a(ifNotExists ? "IF NOT EXISTS " : "")
@@ -497,6 +499,9 @@ public class AbstractSchemaSelfTest extends GridCommonAbstractTest {
if (idx.getInlineSize() != QueryIndex.DFLT_INLINE_SIZE)
sql.a(" INLINE_SIZE ").a(idx.getInlineSize());
+ if (parallel != 0)
+ sql.a(" PARALLEL ").a(parallel);
+
executeSql(node, cacheName, sql.toString());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
index f7d99b4..bf469f1 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
@@ -197,16 +197,16 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
assertSchemaException(new RunnableX() {
@Override public void run() throws Exception {
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
}
}, IgniteQueryErrorCode.INDEX_ALREADY_EXISTS);
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
@@ -281,7 +281,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED), field(alias(FIELD_NAME_2_ESCAPED)));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE,
field(FIELD_NAME_1_ESCAPED), field(alias(FIELD_NAME_2_ESCAPED)));
@@ -360,7 +360,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
try {
String cacheName = randomString();
- queryProcessor(node()).dynamicIndexCreate(cacheName, cacheName, TBL_NAME, idx, false).get();
+ queryProcessor(node()).dynamicIndexCreate(cacheName, cacheName, TBL_NAME, idx, false, 0).get();
}
catch (SchemaOperationException e) {
assertEquals(SchemaOperationException.CODE_CACHE_NOT_FOUND, e.code());
@@ -445,7 +445,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
assertSchemaException(new RunnableX() {
@Override public void run() throws Exception {
- dynamicIndexCreate(CACHE_NAME, randomString(), idx, false);
+ dynamicIndexCreate(CACHE_NAME, randomString(), idx, false, 0);
}
}, IgniteQueryErrorCode.TABLE_NOT_FOUND);
@@ -521,7 +521,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
assertSchemaException(new RunnableX() {
@Override public void run() throws Exception {
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
}
}, IgniteQueryErrorCode.COLUMN_NOT_FOUND);
@@ -598,7 +598,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
@Override public void run() throws Exception {
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_2_ESCAPED));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
}
}, IgniteQueryErrorCode.COLUMN_NOT_FOUND);
@@ -606,7 +606,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
QueryIndex idx = index(IDX_NAME_1, field(alias(FIELD_NAME_2_ESCAPED)));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(alias(FIELD_NAME_2_ESCAPED)));
assertSimpleIndexOperations(SQL_SIMPLE_FIELD_2);
@@ -713,7 +713,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
idx.setInlineSize(inlineSize);
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, inlineSize, field(FIELD_NAME_1_ESCAPED));
assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
@@ -736,7 +736,137 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
@Override public void run() throws Exception {
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
idx.setInlineSize(inlineSize);
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, 0);
+ }
+ }, igniteQryErrorCode);
+
+ assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
+ }
+
+
+ /**
+ * Tests creating index with parallelism for PARTITIONED ATOMIC cache.
+ *
+ * @throws Exception If failed.
+ */
+ public void testCreateIndexWithParallelismPartitionedAtomic() throws Exception {
+ checkCreateIndexWithParallelism(PARTITIONED, ATOMIC, false);
+ }
+
+ /**
+ * Tests creating index with parallelism for PARTITIONED ATOMIC cache with near cache.
+ *
+ * @throws Exception If failed.
+ */
+ public void testCreateIndexWithParallelismPartitionedAtomicNear() throws Exception {
+ checkCreateIndexWithParallelism(PARTITIONED, ATOMIC, true);
+ }
+
+ /**
+ * Tests creating index with parallelism for PARTITIONED TRANSACTIONAL cache.
+ *
+ * @throws Exception If failed.
+ */
+ public void testCreateIndexWithParallelismPartitionedTransactional() throws Exception {
+ checkCreateIndexWithParallelism(PARTITIONED, TRANSACTIONAL, false);
+ }
+
+ /**
+ * Tests creating index with parallelism for PARTITIONED TRANSACTIONAL cache with near cache.
+ *
+ * @throws Exception If failed.
+ */
+ public void testCreateIndexWithParallelismPartitionedTransactionalNear() throws Exception {
+ checkCreateIndexWithParallelism(PARTITIONED, TRANSACTIONAL, true);
+ }
+
+ /**
+ * Tests creating index with parallelism for REPLICATED ATOMIC cache.
+ *
+ * @throws Exception If failed.
+ */
+ public void testCreateIndexWithParallelismReplicatedAtomic() throws Exception {
+ checkCreateIndexWithParallelism(REPLICATED, ATOMIC, false);
+ }
+
+ /**
+ * Tests creating index with parallelism option for REPLICATED TRANSACTIONAL cache.
+ *
+ * @throws Exception If failed.
+ */
+ public void testCreateIndexWithParallelismReplicatedTransactional() throws Exception {
+ checkCreateIndexWithParallelism(REPLICATED, TRANSACTIONAL, false);
+ }
+
+ /**
+ * Checks that parallelism parameter is correctly handled during index creation.
+ *
+ * @param mode Mode.
+ * @param atomicityMode Atomicity mode.
+ * @param near Near flag.
+ * @throws Exception If failed.
+ */
+ private void checkCreateIndexWithParallelism(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near)
+ throws Exception {
+
+ initialize(mode, atomicityMode, near);
+
+ String prevFallbackPropVal = System.getProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK);
+
+ try {
+ System.setProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, "true");
+
+ checkNoIndexIsCreatedForParallelism(-2, IgniteQueryErrorCode.PARSING);
+ checkNoIndexIsCreatedForParallelism(Integer.MIN_VALUE, IgniteQueryErrorCode.PARSING);
+
+ checkIndexCreatedForParallelism(0);
+ loadInitialData();
+ checkIndexCreatedForParallelism(1);
+ loadInitialData();
+ checkIndexCreatedForParallelism(5);
+ }
+ finally {
+ if (prevFallbackPropVal != null)
+ System.setProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK, prevFallbackPropVal);
+ else
+ System.clearProperty(IgniteSystemProperties.IGNITE_SQL_PARSER_DISABLE_H2_FALLBACK);
+ }
+ }
+
+ /**
+ * Verifies that index was created properly with different parallelism levels.
+ * NOTE! Unfortunately we cannot check the real parallelism level on which this index was created because it should
+ * use internal API. But we can check if this index was created properly on different parallelism levels.
+ *
+ * @param parallel Parallelism level to put into CREATE INDEX
+ * @throws Exception If failed.
+ */
+ private void checkIndexCreatedForParallelism(int parallel) throws Exception {
+ QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
+
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, parallel);
+
+ assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
+ assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
+ assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
+
+ dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
+
+ assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
+ }
+
+ /**
+ * Verifies that no index is created and an exception is thrown.
+ *
+ * @param parallel Parallelism level in the CREATE INDEX statement.
+ * @param igniteQryErrorCode Expected error code in the thrown exception.
+ * @throws Exception If failed for any other reason than the expected exception.
+ */
+ private void checkNoIndexIsCreatedForParallelism(final int parallel, int igniteQryErrorCode) throws Exception {
+ assertSchemaException(new RunnableX() {
+ @Override public void run() throws Exception {
+ QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false, parallel);
}
}, igniteQryErrorCode);
@@ -811,7 +941,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
// Create target index.
QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx1, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx1, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
@@ -821,7 +951,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
// Create another index which must stay intact afterwards.
QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2_ESCAPED)));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx2, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx2, false, 0);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE, field(alias(FIELD_NAME_2_ESCAPED)));
// Load some data.
@@ -1015,7 +1145,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
assertSchemaException(new RunnableX() {
@Override public void run() throws Exception {
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, true, 0);
}
}, IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
@@ -1036,7 +1166,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
public void testNonSqlCache() throws Exception {
final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1));
- dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true);
+ dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true, 0);
assertIndex(STATIC_CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1_ESCAPED));
dynamicIndexDrop(STATIC_CACHE_NAME, IDX_NAME_1, true);
@@ -1087,7 +1217,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
final QueryIndex idx = index(idxNameToCreate, field(FIELD_NAME_1));
- dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true);
+ dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true, 0);
dynamicIndexDrop(STATIC_CACHE_NAME, checkedIdxName, false);
}
@@ -1102,7 +1232,7 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
final QueryIndex idx = index(idxNameToCreate, field(FIELD_NAME_1));
- dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true);
+ dynamicIndexCreate(STATIC_CACHE_NAME, TBL_NAME, idx, true, 0);
GridTestUtils.assertThrows(null, new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -1288,9 +1418,9 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
* @param ifNotExists When set to true operation will fail if index already exists.
* @throws Exception If failed.
*/
- private void dynamicIndexCreate(String cacheName, String tblName, QueryIndex idx, boolean ifNotExists)
+ private void dynamicIndexCreate(String cacheName, String tblName, QueryIndex idx, boolean ifNotExists, int parallel)
throws Exception {
- dynamicIndexCreate(node(), cacheName, tblName, idx, ifNotExists);
+ dynamicIndexCreate(node(), cacheName, tblName, idx, ifNotExists, parallel);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
index 610688a..65ceb24 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractConcurrentSelfTest.java
@@ -159,7 +159,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1));
IgniteInternalFuture<?> idxFut1 = queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME,
- idx1, false);
+ idx1, false, 0);
idxLatch.countDown();
@@ -180,7 +180,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
QueryIndex idx2 = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
IgniteInternalFuture<?> idxFut2 =
- queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx2, false);
+ queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx2, false, 0);
idxLatch.countDown();
@@ -216,10 +216,10 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
QueryIndex idx2 = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
IgniteInternalFuture<?> idxFut1 =
- queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx1, false);
+ queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx1, false, 0);
IgniteInternalFuture<?> idxFut2 =
- queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx2, false);
+ queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx2, false, 0);
// Start even more nodes of different flavors
ignitionStart(serverConfiguration(5));
@@ -263,7 +263,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
IgniteInternalFuture<?> idxFut =
- queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false);
+ queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0);
ignitionStart(serverConfiguration(2));
ignitionStart(serverConfiguration(3, true));
@@ -333,7 +333,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
// Create index.
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
- queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false).get();
+ queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
// Stop updates once index is ready.
stopped.set(true);
@@ -405,7 +405,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
final IgniteInternalFuture<?> idxFut =
- queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false);
+ queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0);
idxLatch1.countDown();
idxLatch2.countDown();
@@ -454,7 +454,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
final IgniteInternalFuture<?> idxFut =
- queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false);
+ queryProcessor(srv1).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0);
idxLatch.countDown();
@@ -509,7 +509,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
exists = false;
}
else {
- fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true);
+ fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0);
exists = true;
}
@@ -537,7 +537,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
idxFut.get();
queryProcessor(cli).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_1, true).get();
- queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true).get();
+ queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0).get();
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1));
@@ -585,7 +585,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
exists = false;
}
else {
- fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true);
+ fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0);
exists = true;
}
@@ -666,7 +666,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
@Override public void run() throws Exception {
final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
- queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false).get();
+ queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
}
});
@@ -688,7 +688,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
// Update existing index.
QueryIndex idx = index(IDX_NAME_2, field(aliasUnescaped(FIELD_NAME_2)));
- queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false).get();
+ queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
assertIndex(cli, true, CACHE_NAME, TBL_NAME, IDX_NAME_2, QueryIndex.DFLT_INLINE_SIZE,
field(aliasUnescaped(FIELD_NAME_2)));
@@ -701,7 +701,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
final QueryIndex idx = index(IDX_NAME_2, field(FIELD_NAME_1), field(aliasUnescaped(FIELD_NAME_2)));
- queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false).get();
+ queryProcessor(srv).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, false, 0).get();
}
});
@@ -830,7 +830,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
exists = false;
}
else {
- fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true);
+ fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0);
exists = true;
}
@@ -862,7 +862,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
createSqlCache(cli);
queryProcessor(cli).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_1, true).get();
- queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true).get();
+ queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0).get();
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1));
@@ -931,7 +931,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
exists = false;
}
else {
- fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true);
+ fut = queryProcessor(node).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0);
exists = true;
}
@@ -963,7 +963,7 @@ public abstract class DynamicIndexAbstractConcurrentSelfTest extends DynamicInde
createSqlCache(cli);
queryProcessor(cli).dynamicIndexDrop(CACHE_NAME, CACHE_NAME, IDX_NAME_1, true).get();
- queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true).get();
+ queryProcessor(cli).dynamicIndexCreate(CACHE_NAME, CACHE_NAME, TBL_NAME, idx, true, 0).get();
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, QueryIndex.DFLT_INLINE_SIZE, field(FIELD_NAME_1));
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a52bb28/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
index 1d0e973..b92c792 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/SchemaExchangeSelfTest.java
@@ -470,7 +470,7 @@ public class SchemaExchangeSelfTest extends AbstractSchemaSelfTest {
final QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1_ESCAPED));
try {
- dynamicIndexCreate(node1, CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(node1, CACHE_NAME, TBL_NAME, idx, false, 0);
}
catch (Exception e) {
throw new IgniteException(e);
[09/12] ignite git commit: Minor: moved custom events processing in
GridContinuousProcessor's methods.
Posted by ag...@apache.org.
Minor: moved custom events processing in GridContinuousProcessor's methods.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fe806701
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fe806701
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fe806701
Branch: refs/heads/ignite-7016
Commit: fe806701ec42c951378d32ff931e98411260f997
Parents: 6afbc09
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 29 11:34:23 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:34 2017 +0300
----------------------------------------------------------------------
.../continuous/GridContinuousProcessor.java | 132 ++++++++++++-------
1 file changed, 85 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe806701/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index fa52be2..571d654 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -176,8 +176,10 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
@Override public void onCustomEvent(AffinityTopologyVersion topVer,
ClusterNode snd,
StartRoutineDiscoveryMessage msg) {
- if (!snd.id().equals(ctx.localNodeId()) && !ctx.isStopping())
- processStartRequest(snd, msg);
+ if (ctx.isStopping())
+ return;
+
+ processStartRequest(snd, msg);
}
});
@@ -186,39 +188,10 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
@Override public void onCustomEvent(AffinityTopologyVersion topVer,
ClusterNode snd,
StartRoutineAckDiscoveryMessage msg) {
- StartFuture fut = startFuts.remove(msg.routineId());
-
- if (fut != null) {
- if (msg.errs().isEmpty()) {
- LocalRoutineInfo routine = locInfos.get(msg.routineId());
-
- // Update partition counters.
- if (routine != null && routine.handler().isQuery()) {
- Map<UUID, Map<Integer, T2<Long, Long>>> cntrsPerNode = msg.updateCountersPerNode();
- Map<Integer, T2<Long, Long>> cntrs = msg.updateCounters();
-
- GridCacheAdapter<Object, Object> interCache =
- ctx.cache().internalCache(routine.handler().cacheName());
-
- GridCacheContext cctx = interCache != null ? interCache.context() : null;
-
- if (cctx != null && cntrsPerNode != null && !cctx.isLocal() && cctx.affinityNode())
- cntrsPerNode.put(ctx.localNodeId(),
- toCountersMap(cctx.topology().localUpdateCounters(false)));
-
- routine.handler().updateCounters(topVer, cntrsPerNode, cntrs);
- }
-
- fut.onRemoteRegistered();
- }
- else {
- IgniteCheckedException firstEx = F.first(msg.errs().values());
-
- fut.onDone(firstEx);
+ if (ctx.isStopping())
+ return;
- stopRoutine(msg.routineId());
- }
- }
+ processStartAckRequest(topVer, msg);
}
});
@@ -227,16 +200,10 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
@Override public void onCustomEvent(AffinityTopologyVersion topVer,
ClusterNode snd,
StopRoutineDiscoveryMessage msg) {
- if (!snd.id().equals(ctx.localNodeId())) {
- UUID routineId = msg.routineId();
-
- unregisterRemote(routineId);
- }
+ if (ctx.isStopping())
+ return;
- for (Map<UUID, LocalRoutineInfo> clientInfo : clientInfos.values()) {
- if (clientInfo.remove(msg.routineId()) != null)
- break;
- }
+ processStopRequest(snd, msg);
}
});
@@ -245,10 +212,10 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
@Override public void onCustomEvent(AffinityTopologyVersion topVer,
ClusterNode snd,
StopRoutineAckDiscoveryMessage msg) {
- StopFuture fut = stopFuts.remove(msg.routineId());
+ if (ctx.isStopping())
+ return;
- if (fut != null)
- fut.onDone();
+ processStopAckRequest(msg);
}
});
@@ -459,7 +426,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override public void onJoiningNodeDataReceived(JoiningNodeDiscoveryData data) {
if (log.isDebugEnabled()) {
- log.info("onJoiningNodeDataReceived [joining=" + data.joiningNodeId() +
+ log.debug("onJoiningNodeDataReceived [joining=" + data.joiningNodeId() +
", loc=" + ctx.localNodeId() +
", data=" + data.joiningNodeData() +
']');
@@ -976,11 +943,82 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
}
/**
+ * @param msg Message.
+ */
+ private void processStopAckRequest(StopRoutineAckDiscoveryMessage msg) {
+ StopFuture fut = stopFuts.remove(msg.routineId());
+
+ if (fut != null)
+ fut.onDone();
+ }
+
+ /**
+ * @param snd Sender node.
+ * @param msg Message/
+ */
+ private void processStopRequest(ClusterNode snd, StopRoutineDiscoveryMessage msg) {
+ if (!snd.id().equals(ctx.localNodeId())) {
+ UUID routineId = msg.routineId();
+
+ unregisterRemote(routineId);
+ }
+
+ for (Map<UUID, LocalRoutineInfo> clientInfo : clientInfos.values()) {
+ if (clientInfo.remove(msg.routineId()) != null)
+ break;
+ }
+ }
+
+ /**
+ * @param topVer Topology version.
+ * @param msg Message.
+ */
+ private void processStartAckRequest(AffinityTopologyVersion topVer,
+ StartRoutineAckDiscoveryMessage msg) {
+ StartFuture fut = startFuts.remove(msg.routineId());
+
+ if (fut != null) {
+ if (msg.errs().isEmpty()) {
+ LocalRoutineInfo routine = locInfos.get(msg.routineId());
+
+ // Update partition counters.
+ if (routine != null && routine.handler().isQuery()) {
+ Map<UUID, Map<Integer, T2<Long, Long>>> cntrsPerNode = msg.updateCountersPerNode();
+ Map<Integer, T2<Long, Long>> cntrs = msg.updateCounters();
+
+ GridCacheAdapter<Object, Object> interCache =
+ ctx.cache().internalCache(routine.handler().cacheName());
+
+ GridCacheContext cctx = interCache != null ? interCache.context() : null;
+
+ if (cctx != null && cntrsPerNode != null && !cctx.isLocal() && cctx.affinityNode())
+ cntrsPerNode.put(ctx.localNodeId(),
+ toCountersMap(cctx.topology().localUpdateCounters(false)));
+
+ routine.handler().updateCounters(topVer, cntrsPerNode, cntrs);
+ }
+
+ fut.onRemoteRegistered();
+ }
+ else {
+ IgniteCheckedException firstEx = F.first(msg.errs().values());
+
+ fut.onDone(firstEx);
+
+ stopRoutine(msg.routineId());
+ }
+ }
+ }
+
+ /**
* @param node Sender.
* @param req Start request.
*/
private void processStartRequest(ClusterNode node, StartRoutineDiscoveryMessage req) {
UUID routineId = req.routineId();
+ if (node.id().equals(ctx.localNodeId()))
+ return;
+
StartRequestData data = req.startRequestData();
GridContinuousHandler hnd = data.handler();
[03/12] ignite git commit: IGNITE-2766 Ensure that cache is available
after client ID changes. This closes #3077.
Posted by ag...@apache.org.
IGNITE-2766 Ensure that cache is available after client ID changes. This closes #3077.
Signed-off-by: nikolay_tikhonov <nt...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2b1e0873
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2b1e0873
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2b1e0873
Branch: refs/heads/ignite-7016
Commit: 2b1e08733ab352fee295acaaba9b8c64405e1e47
Parents: 7566031
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Nov 27 13:08:00 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:32 2017 +0300
----------------------------------------------------------------------
.../internal/IgniteClientReconnectCacheTest.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2b1e0873/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
index 2e1f2f3..1c10bf1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
@@ -85,6 +85,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.junit.Assert.assertNotEquals;
/**
*
@@ -1284,13 +1285,15 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
* @param c Cache operation closure.
* @throws Exception If failed.
*/
- private void checkOperationInProgressFails(IgniteEx client,
+ private void checkOperationInProgressFails(final IgniteEx client,
final CacheConfiguration<Object, Object> ccfg,
Class<?> msgToBlock,
final IgniteInClosure<IgniteCache<Object, Object>> c)
throws Exception {
Ignite srv = clientRouter(client);
+ final UUID id = client.localNode().id();
+
TestTcpDiscoverySpi srvSpi = spi(srv);
final IgniteCache<Object, Object> cache = client.getOrCreateCache(ccfg);
@@ -1306,6 +1309,8 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
IgniteClientDisconnectedException e0 = null;
try {
+ assertEquals(id, client.localNode().id());
+
c.apply(cache);
fail();
@@ -1329,6 +1334,8 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
e0.reconnectFuture().get();
+ assertNotEquals(id, client.localNode().id());
+
c.apply(cache);
return null;
@@ -1351,6 +1358,8 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
((TestCommunicationSpi)grid(i).configuration().getCommunicationSpi()).stopBlock(false);
}
+ assertNotEquals(id, client.localNode().id());
+
cache.put(1, 1);
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@@ -1508,4 +1517,4 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
}
}
}
-}
\ No newline at end of file
+}
[11/12] ignite git commit: IGNITE-7013 .NET: macOS support added
Posted by ag...@apache.org.
IGNITE-7013 .NET: macOS support added
This closes #3091
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bf432ef4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bf432ef4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bf432ef4
Branch: refs/heads/ignite-7016
Commit: bf432ef44d039cb106ccb3c97aa473540899c82d
Parents: f1b47ed
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue Nov 28 18:32:16 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:34 2017 +0300
----------------------------------------------------------------------
.../Common/TestLogger.cs | 74 ++++
.../Common/TestUtils.DotNetCore.cs | 46 ++-
.../Client/ClientConnectionTest.cs | 4 +-
.../Log/CustomLoggerTest.cs | 7 -
.../TestUtils.Common.cs | 3 -
.../Apache.Ignite.Core.csproj | 5 +-
.../Apache.Ignite.Core/IgniteConfiguration.cs | 7 +-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 2 +-
.../Impl/Client/ClientSocket.cs | 12 +-
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 8 +
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 242 -----------
.../dotnet/Apache.Ignite.Core/Impl/Shell.cs | 2 +
.../Impl/Unmanaged/DllLoader.cs | 176 --------
.../Impl/Unmanaged/Jni/DllLoader.cs | 210 ++++++++++
.../Impl/Unmanaged/Jni/Jvm.cs | 80 +---
.../Impl/Unmanaged/Jni/JvmDll.cs | 414 +++++++++++++++++++
.../Impl/Unmanaged/Jni/JvmInitArgs.cs | 33 ++
.../Impl/Unmanaged/Jni/JvmOption.cs | 34 ++
.../Apache.Ignite.Core/Impl/Unmanaged/Os.cs | 6 +
modules/platforms/dotnet/Apache.Ignite.ndproj | 2 +-
20 files changed, 837 insertions(+), 530 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestLogger.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestLogger.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestLogger.cs
new file mode 100644
index 0000000..8253fb8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestLogger.cs
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.DotNetCore.Common
+{
+ using System;
+ using System.Diagnostics;
+ using System.Globalization;
+ using System.IO;
+ using Apache.Ignite.Core.Log;
+
+ /// <summary>
+ /// 'dotnet test' swallows console output. This logger writes to a file to overcome this.
+ /// </summary>
+ internal class TestLogger : ILogger
+ {
+ /** */
+ public static readonly TestLogger Instance = new TestLogger();
+
+ /** */
+ private readonly StreamWriter _file;
+
+ /// <summary>
+ /// Prevents a default instance of the <see cref="TestLogger"/> class from being created.
+ /// </summary>
+ private TestLogger()
+ {
+ var binDir = Path.GetDirectoryName(GetType().Assembly.Location);
+ var file = Path.Combine(binDir, "dotnet-test.log");
+
+ if (File.Exists(file))
+ {
+ File.Delete(file);
+ }
+
+ _file = File.AppendText(file);
+ }
+
+ /** <inheritdoc /> */
+ public void Log(LogLevel level, string message, object[] args, IFormatProvider formatProvider, string category,
+ string nativeErrorInfo, Exception ex)
+ {
+ lock (_file)
+ {
+ var text = args != null
+ ? string.Format(formatProvider ?? CultureInfo.InvariantCulture, message, args)
+ : message;
+
+ _file.WriteLine(text);
+ _file.Flush();
+ }
+ }
+
+ /** <inheritdoc /> */
+ public bool IsEnabled(LogLevel level)
+ {
+ return level > LogLevel.Debug;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
index 0f51593..c0586c3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Common/TestUtils.DotNetCore.cs
@@ -18,40 +18,54 @@
namespace Apache.Ignite.Core.Tests
{
using System;
- using System.Collections.Generic;
+ using System.Diagnostics;
using System.IO;
using System.Linq;
+ using Apache.Ignite.Core.Log;
+ using Apache.Ignite.Core.Tests.DotNetCore.Common;
public static partial class TestUtils
{
- /** */
- private static readonly IList<string> JvmOpts =
- new List<string>
- {
- "-Duser.timezone=UTC"
-
- // Uncomment to debug Java
- //"-Xdebug",
- //"-Xnoagent",
- //"-Djava.compiler=NONE",
- //"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
- };
-
/// <summary>
/// Gets the default code-based test configuration.
/// </summary>
public static IgniteConfiguration GetTestConfiguration(string name = null)
{
+ TestLogger.Instance.Info("GetTestConfiguration: " + GetTestName());
+
return new IgniteConfiguration
{
DiscoverySpi = GetStaticDiscovery(),
Localhost = "127.0.0.1",
- JvmOptions = JvmOpts,
- IgniteInstanceName = name
+ JvmOptions = TestJavaOptions(),
+ IgniteInstanceName = name,
+ Logger = TestLogger.Instance
};
}
/// <summary>
+ /// Gets the name of the test.
+ /// </summary>
+ private static string GetTestName()
+ {
+ var st = new StackTrace();
+
+ for (var i = 0; i < st.FrameCount; i++)
+ {
+ var frame = st.GetFrame(i);
+ var method = frame.GetMethod();
+
+ if (method.DeclaringType != typeof(TestUtils)
+ && method.DeclaringType != typeof(TestBase))
+ {
+ return $"{method.DeclaringType.Name}.{method.Name}";
+ }
+ }
+
+ return st.GetFrames().Skip(2).Select(x => x.ToString()).FirstOrDefault() ?? "unknown";
+ }
+
+ /// <summary>
/// Creates a uniquely named, empty temporary directory on disk and returns the full path of that directory.
/// </summary>
/// <returns>The full path of the temporary directory.</returns>
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
index d965b72..4b9af70 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
@@ -81,7 +81,9 @@ namespace Apache.Ignite.Core.Tests.Client
{
Host = "localhost",
Port = 2000,
- PortRange = 1
+ PortRange = 1,
+ SocketSendBufferSize = 100,
+ SocketReceiveBufferSize = 50
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
index e80bd3f..50d2dbf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs
@@ -78,13 +78,6 @@ namespace Apache.Ignite.Core.Tests.Log
{
Assert.IsTrue(TestLogger.Entries.Any(x => x.Level == level), "No messages with level " + level);
}
-
- // Check IgniteHome and classpath messages.
- Assert.IsTrue(TestLogger.Entries.Any(x => x.Level == LogLevel.Debug &&
- x.Message == "Classpath resolved to: {0}"));
-
- Assert.IsTrue(TestLogger.Entries.Any(x => x.Level == LogLevel.Debug &&
- x.Message == "IGNITE_HOME resolved to: {0}"));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.Common.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.Common.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.Common.cs
index 4f5f3f4..2430300 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.Common.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.Common.cs
@@ -46,7 +46,6 @@ namespace Apache.Ignite.Core.Tests
private const int DfltBusywaitSleepInterval = 200;
/** */
-
private static readonly IList<string> TestJvmOpts = Environment.Is64BitProcess
? new List<string>
{
@@ -230,8 +229,6 @@ namespace Apache.Ignite.Core.Tests
return false;
}
-
-
/// <summary>
/// Waits for condition, polling in busy wait loop.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 6deaa9b..5adb501 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -142,7 +142,7 @@
<Compile Include="Impl\DataRegionMetrics.cs" />
<Compile Include="Impl\PersistentStore\PersistentStoreMetrics.cs" />
<Compile Include="Impl\Shell.cs" />
- <Compile Include="Impl\Unmanaged\DllLoader.cs" />
+ <Compile Include="Impl\Unmanaged\Jni\DllLoader.cs" />
<Compile Include="Impl\Unmanaged\Jni\AppDomains.cs" />
<Compile Include="Impl\Unmanaged\Jni\CallbackDelegates.cs" />
<Compile Include="Impl\Unmanaged\Jni\Callbacks.cs" />
@@ -150,10 +150,13 @@
<Compile Include="Impl\Unmanaged\Jni\EnvDelegates.cs" />
<Compile Include="Impl\Unmanaged\Jni\Env.cs" />
<Compile Include="Impl\Unmanaged\Jni\EnvInterface.cs" />
+ <Compile Include="Impl\Unmanaged\Jni\JvmDll.cs" />
+ <Compile Include="Impl\Unmanaged\Jni\JvmInitArgs.cs" />
<Compile Include="Impl\Unmanaged\Jni\JvmInterface.cs" />
<Compile Include="Impl\PlatformDisposableTargetAdapter.cs" />
<Compile Include="Impl\PlatformJniTarget.cs" />
<Compile Include="Impl\Unmanaged\Jni\GlobalRef.cs" />
+ <Compile Include="Impl\Unmanaged\Jni\JvmOption.cs" />
<Compile Include="Impl\Unmanaged\Jni\MethodId.cs" />
<Compile Include="Impl\Unmanaged\Jni\NativeMethod.cs" />
<Compile Include="Impl\Unmanaged\Jni\JniResult.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index 29b8519..8c39091 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -847,10 +847,9 @@ namespace Apache.Ignite.Core
public string SpringConfigUrl { get; set; }
/// <summary>
- /// Path jvm.dll file. If not set, it's location will be determined
- /// using JAVA_HOME environment variable.
- /// If path is neither set nor determined automatically, an exception
- /// will be thrown.
+ /// Path to jvm.dll (libjvm.so on Linux, libjvm.dylib on Mac) file.
+ /// If not set, it's location will be determined using JAVA_HOME environment variable.
+ /// If path is neither set nor determined automatically, an exception will be thrown.
/// </summary>
public string JvmDllPath { get; set; }
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 41419ac..46b9ec5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -227,7 +227,7 @@ namespace Apache.Ignite.Core
CheckServerGc(cfg, log);
// 2. Create context.
- IgniteUtils.LoadDlls(cfg.JvmDllPath, log);
+ JvmDll.Load(cfg.JvmDllPath, log);
var cbs = IgniteManager.CreateJvmContext(cfg, log);
var env = cbs.Jvm.AttachCurrentThread();
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
index e565f31..078927b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs
@@ -213,11 +213,19 @@ namespace Apache.Ignite.Core.Impl.Client
{
var socket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
{
- SendBufferSize = cfg.SocketSendBufferSize,
- ReceiveBufferSize = cfg.SocketReceiveBufferSize,
NoDelay = cfg.TcpNoDelay
};
+ if (cfg.SocketSendBufferSize != IgniteClientConfiguration.DefaultSocketBufferSize)
+ {
+ socket.SendBufferSize = cfg.SocketSendBufferSize;
+ }
+
+ if (cfg.SocketReceiveBufferSize != IgniteClientConfiguration.DefaultSocketBufferSize)
+ {
+ socket.ReceiveBufferSize = cfg.SocketReceiveBufferSize;
+ }
+
socket.Connect(ipEndPoint);
return socket;
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
index ce84003..47260a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -108,6 +108,14 @@ namespace Apache.Ignite.Core.Impl
/// <returns>JVM.</returns>
private static Jvm CreateJvm(IgniteConfiguration cfg, ILogger log)
{
+ // Do not bother with classpath when JVM exists.
+ var jvm = Jvm.Get(true);
+
+ if (jvm != null)
+ {
+ return jvm;
+ }
+
var cp = Classpath.CreateClasspath(cfg, log: log);
var jvmOpts = GetMergedJvmOptions(cfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 022a5ed..aff028e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -19,9 +19,7 @@ namespace Apache.Ignite.Core.Impl
{
using System;
using System.Collections.Generic;
- using System.Globalization;
using System.IO;
- using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
@@ -31,9 +29,6 @@ namespace Apache.Ignite.Core.Impl
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Cluster;
using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Log;
- using Microsoft.Win32;
using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
/// <summary>
@@ -41,49 +36,9 @@ namespace Apache.Ignite.Core.Impl
/// </summary>
internal static class IgniteUtils
{
- /** Environment variable: JAVA_HOME. */
- private const string EnvJavaHome = "JAVA_HOME";
-
- /** Lookup paths. */
- private static readonly string[] JvmDllLookupPaths = Os.IsWindows
- ? new[]
- {
- // JRE paths
- @"bin\server",
- @"bin\client",
-
- // JDK paths
- @"jre\bin\server",
- @"jre\bin\client",
- @"jre\bin\default"
- }
- : new[]
- {
- // JRE paths
- "lib/amd64/server",
- "lib/amd64/client",
-
- // JDK paths
- "jre/lib/amd64/server",
- "jre/lib/amd64/client"
- };
-
- /** Registry lookup paths. */
- private static readonly string[] JreRegistryKeys =
- {
- @"Software\JavaSoft\Java Runtime Environment",
- @"Software\Wow6432Node\JavaSoft\Java Runtime Environment"
- };
-
- /** Jvm dll file name. */
- internal static readonly string FileJvmDll = Os.IsWindows ? "jvm.dll" : "libjvm.so";
-
/** Prefix for temp directory names. */
private const string DirIgniteTmp = "Ignite_";
- /** Loaded. */
- private static bool _loaded;
-
/** Thread-local random. */
[ThreadStatic]
private static Random _rnd;
@@ -127,25 +82,6 @@ namespace Apache.Ignite.Core.Impl
}
/// <summary>
- /// Load JVM DLL if needed.
- /// </summary>
- /// <param name="configJvmDllPath">JVM DLL path from config.</param>
- /// <param name="log">Log.</param>
- public static void LoadDlls(string configJvmDllPath, ILogger log)
- {
- if (_loaded)
- {
- log.Debug("JNI dll is already loaded.");
- return;
- }
-
- // 1. Load JNI dll.
- LoadJvmDll(configJvmDllPath, log);
-
- _loaded = true;
- }
-
- /// <summary>
/// Create new instance of specified class.
/// </summary>
/// <param name="typeName">Class name</param>
@@ -195,185 +131,7 @@ namespace Apache.Ignite.Core.Impl
}
}
- /// <summary>
- /// Loads the JVM DLL.
- /// </summary>
- private static void LoadJvmDll(string configJvmDllPath, ILogger log)
- {
- var messages = new List<string>();
- foreach (var dllPath in GetJvmDllPaths(configJvmDllPath))
- {
- log.Debug("Trying to load JVM dll from [option={0}, path={1}]...", dllPath.Key, dllPath.Value);
-
- var errInfo = LoadDll(dllPath.Value, FileJvmDll);
- if (errInfo == null)
- {
- log.Debug("jvm.dll successfully loaded from [option={0}, path={1}]", dllPath.Key, dllPath.Value);
- return;
- }
-
- var message = string.Format(CultureInfo.InvariantCulture, "[option={0}, path={1}, error={2}]",
- dllPath.Key, dllPath.Value, errInfo);
- messages.Add(message);
-
- log.Debug("Failed to load jvm.dll: " + message);
-
- if (dllPath.Value == configJvmDllPath)
- break; // if configJvmDllPath is specified and is invalid - do not try other options
- }
-
- if (!messages.Any()) // not loaded and no messages - everything was null
- messages.Add(string.Format(CultureInfo.InvariantCulture,
- "Please specify IgniteConfiguration.JvmDllPath or {0}.", EnvJavaHome));
-
- if (messages.Count == 1)
- throw new IgniteException(string.Format(CultureInfo.InvariantCulture, "Failed to load {0} ({1})",
- FileJvmDll, messages[0]));
-
- var combinedMessage =
- messages.Aggregate((x, y) => string.Format(CultureInfo.InvariantCulture, "{0}\n{1}", x, y));
-
- throw new IgniteException(string.Format(CultureInfo.InvariantCulture, "Failed to load {0}:\n{1}",
- FileJvmDll, combinedMessage));
- }
-
- /// <summary>
- /// Try loading DLLs first using file path, then using it's simple name.
- /// </summary>
- /// <param name="filePath"></param>
- /// <param name="simpleName"></param>
- /// <returns>Null in case of success, error info in case of failure.</returns>
- private static string LoadDll(string filePath, string simpleName)
- {
- string res = null;
-
- if (filePath != null)
- {
- res = DllLoader.Load(filePath);
-
- if (res == null)
- {
- return null; // Success.
- }
- }
-
- // Failed to load using file path, fallback to simple name.
- var res2 = DllLoader.Load(simpleName);
-
- if (res2 == null)
- {
- return null; // Success.
- }
-
- return res;
- }
-
- /// <summary>
- /// Gets the JVM DLL paths in order of lookup priority.
- /// </summary>
- private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPaths(string configJvmDllPath)
- {
- if (!string.IsNullOrEmpty(configJvmDllPath))
- {
- yield return new KeyValuePair<string, string>("IgniteConfiguration.JvmDllPath", configJvmDllPath);
- }
-
- var javaHomeDir = Environment.GetEnvironmentVariable(EnvJavaHome);
-
- if (!string.IsNullOrEmpty(javaHomeDir))
- {
- foreach (var path in JvmDllLookupPaths)
- {
- yield return
- new KeyValuePair<string, string>(EnvJavaHome, Path.Combine(javaHomeDir, path, FileJvmDll));
- }
- }
-
- foreach (var keyValuePair in GetJvmDllPathsFromRegistry().Concat(GetJvmDllPathsFromSymlink()))
- {
- yield return keyValuePair;
- }
- }
-
- /// <summary>
- /// Gets Jvm dll paths from Windows registry.
- /// </summary>
- private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPathsFromRegistry()
- {
- if (!Os.IsWindows)
- {
- yield break;
- }
-
- foreach (var regPath in JreRegistryKeys)
- {
- using (var jSubKey = Registry.LocalMachine.OpenSubKey(regPath))
- {
- if (jSubKey == null)
- continue;
-
- var curVer = jSubKey.GetValue("CurrentVersion") as string;
-
- // Current version comes first
- var versions = new[] {curVer}.Concat(jSubKey.GetSubKeyNames().Where(x => x != curVer));
- foreach (var ver in versions.Where(v => !string.IsNullOrEmpty(v)))
- {
- using (var verKey = jSubKey.OpenSubKey(ver))
- {
- var dllPath = verKey == null ? null : verKey.GetValue("RuntimeLib") as string;
-
- if (dllPath != null)
- yield return new KeyValuePair<string, string>(verKey.Name, dllPath);
- }
- }
- }
- }
- }
-
- /// <summary>
- /// Gets the Jvm dll paths from symlink.
- /// </summary>
- private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPathsFromSymlink()
- {
- if (Os.IsWindows)
- {
- yield break;
- }
-
- const string javaExec = "/usr/bin/java";
- if (!File.Exists(javaExec))
- {
- yield break;
- }
-
- var file = Shell.BashExecute("readlink -f /usr/bin/java");
- // /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
-
- var dir = Path.GetDirectoryName(file);
- // /usr/lib/jvm/java-8-openjdk-amd64/jre/bin
-
- if (dir == null)
- {
- yield break;
- }
-
- var libFolder = Path.GetFullPath(Path.Combine(dir, "../lib/"));
- if (!Directory.Exists(libFolder))
- {
- yield break;
- }
-
- // Predefined path: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so
- yield return new KeyValuePair<string, string>(javaExec,
- Path.Combine(libFolder, "amd64", "server", FileJvmDll));
-
- // Last resort - custom paths:
- foreach (var f in Directory.GetFiles(libFolder, FileJvmDll, SearchOption.AllDirectories))
- {
- yield return new KeyValuePair<string, string>(javaExec, f);
- }
- }
/// <summary>
/// Creates a uniquely named, empty temporary directory on disk and returns the full path of that directory.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Shell.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Shell.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Shell.cs
index e48c8fe..45678f0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Shell.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Shell.cs
@@ -18,10 +18,12 @@
namespace Apache.Ignite.Core.Impl
{
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
/// <summary>
/// Shell utils (cmd/bash).
/// </summary>
+ [ExcludeFromCodeCoverage]
internal static class Shell
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/DllLoader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/DllLoader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/DllLoader.cs
deleted file mode 100644
index 61de8e4..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/DllLoader.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Unmanaged
-{
- using System;
- using System.ComponentModel;
- using System.Diagnostics.CodeAnalysis;
- using System.Runtime.InteropServices;
-
- /// <summary>
- /// Dynamically loads unmanaged DLLs with respect to current platform.
- /// </summary>
- internal static class DllLoader
- {
- /** Lazy symbol binding. */
- private const int RtldLazy = 1;
-
- /** Global symbol access. */
- private const int RtldGlobal = 8;
-
- /// <summary>
- /// ERROR_BAD_EXE_FORMAT constant.
- /// </summary>
- // ReSharper disable once InconsistentNaming
- private const int ERROR_BAD_EXE_FORMAT = 193;
-
- /// <summary>
- /// ERROR_MOD_NOT_FOUND constant.
- /// </summary>
- // ReSharper disable once InconsistentNaming
- private const int ERROR_MOD_NOT_FOUND = 126;
-
- /// <summary>
- /// Loads specified DLL.
- /// </summary>
- /// <returns>Null when successful; error message otherwise.</returns>
- public static string Load(string dllPath)
- {
- if (Os.IsWindows)
- {
- return NativeMethodsWindows.LoadLibrary(dllPath) == IntPtr.Zero
- ? FormatWin32Error(Marshal.GetLastWin32Error()) ?? "Unknown error"
- : null;
- }
-
- if (Os.IsLinux)
- {
- if (Os.IsMono)
- {
- return NativeMethodsMono.dlopen(dllPath, RtldGlobal | RtldLazy) == IntPtr.Zero
- ? GetErrorText(NativeMethodsMono.dlerror())
- : null;
- }
-
- if (Os.IsNetCore)
- {
- return NativeMethodsCore.dlopen(dllPath, RtldGlobal | RtldLazy) == IntPtr.Zero
- ? GetErrorText(NativeMethodsCore.dlerror())
- : null;
- }
-
- return NativeMethodsLinux.dlopen(dllPath, RtldGlobal | RtldLazy) == IntPtr.Zero
- ? GetErrorText(NativeMethodsLinux.dlerror())
- : null;
- }
-
- throw new InvalidOperationException("Unsupported OS: " + Environment.OSVersion);
- }
-
- /// <summary>
- /// Gets the error text.
- /// </summary>
- private static string GetErrorText(IntPtr charPtr)
- {
- return Marshal.PtrToStringAnsi(charPtr) ?? "Unknown error";
- }
-
- /// <summary>
- /// Formats the Win32 error.
- /// </summary>
- [ExcludeFromCodeCoverage]
- private static string FormatWin32Error(int errorCode)
- {
- if (errorCode == ERROR_BAD_EXE_FORMAT)
- {
- var mode = Environment.Is64BitProcess ? "x64" : "x86";
-
- return string.Format("DLL could not be loaded (193: ERROR_BAD_EXE_FORMAT). " +
- "This is often caused by x64/x86 mismatch. " +
- "Current process runs in {0} mode, and DLL is not {0}.", mode);
- }
-
- if (errorCode == ERROR_MOD_NOT_FOUND)
- {
- return "DLL could not be loaded (126: ERROR_MOD_NOT_FOUND). " +
- "This can be caused by missing dependencies. ";
- }
-
- return string.Format("{0}: {1}", errorCode, new Win32Exception(errorCode).Message);
- }
-
- /// <summary>
- /// Windows.
- /// </summary>
- private static class NativeMethodsWindows
- {
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr LoadLibrary(string filename);
- }
-
- /// <summary>
- /// Linux.
- /// </summary>
- private static class NativeMethodsLinux
- {
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("libdl.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr dlopen(string filename, int flags);
-
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("libdl.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr dlerror();
- }
-
- /// <summary>
- /// libdl.so depends on libc6-dev on Linux, use Mono instead.
- /// </summary>
- private static class NativeMethodsMono
- {
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("__Internal", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr dlopen(string filename, int flags);
-
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("__Internal", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr dlerror();
- }
-
- /// <summary>
- /// libdl.so depends on libc6-dev on Linux, use libcoreclr instead.
- /// </summary>
- private static class NativeMethodsCore
- {
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("libcoreclr.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr dlopen(string filename, int flags);
-
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("libcoreclr.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
- ThrowOnUnmappableChar = true)]
- internal static extern IntPtr dlerror();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/DllLoader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/DllLoader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/DllLoader.cs
new file mode 100644
index 0000000..578135d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/DllLoader.cs
@@ -0,0 +1,210 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Runtime.InteropServices;
+
+ /// <summary>
+ /// Dynamically loads unmanaged DLLs with respect to current platform.
+ /// </summary>
+ internal static class DllLoader
+ {
+ /** Lazy symbol binding. */
+ private const int RtldLazy = 1;
+
+ /** Global symbol access. */
+ private const int RtldGlobal = 8;
+
+ /// <summary>
+ /// ERROR_BAD_EXE_FORMAT constant.
+ /// </summary>
+ // ReSharper disable once InconsistentNaming
+ private const int ERROR_BAD_EXE_FORMAT = 193;
+
+ /// <summary>
+ /// ERROR_MOD_NOT_FOUND constant.
+ /// </summary>
+ // ReSharper disable once InconsistentNaming
+ private const int ERROR_MOD_NOT_FOUND = 126;
+
+ /// <summary>
+ /// Loads specified DLL.
+ /// </summary>
+ /// <returns>Library handle and error message.</returns>
+ public static KeyValuePair<IntPtr, string> Load(string dllPath)
+ {
+ if (Os.IsWindows)
+ {
+ var ptr = NativeMethodsWindows.LoadLibrary(dllPath);
+ return new KeyValuePair<IntPtr, string>(ptr, ptr == IntPtr.Zero
+ ? FormatWin32Error(Marshal.GetLastWin32Error()) ?? "Unknown error"
+ : null);
+ }
+
+ if (Os.IsMacOs)
+ {
+ var ptr = NativeMethodsMacOs.dlopen(dllPath, RtldGlobal | RtldLazy);
+ return new KeyValuePair<IntPtr, string>(ptr, ptr == IntPtr.Zero
+ ? GetErrorText(NativeMethodsMacOs.dlerror())
+ : null);
+ }
+
+ if (Os.IsLinux)
+ {
+ if (Os.IsMono)
+ {
+ var ptr = NativeMethodsMono.dlopen(dllPath, RtldGlobal | RtldLazy);
+ return new KeyValuePair<IntPtr, string>(ptr, ptr == IntPtr.Zero
+ ? GetErrorText(NativeMethodsMono.dlerror())
+ : null);
+ }
+
+ if (Os.IsNetCore)
+ {
+ var ptr = NativeMethodsCore.dlopen(dllPath, RtldGlobal | RtldLazy);
+ return new KeyValuePair<IntPtr, string>(ptr, ptr == IntPtr.Zero
+ ? GetErrorText(NativeMethodsCore.dlerror())
+ : null);
+ }
+
+ var lptr = NativeMethodsLinux.dlopen(dllPath, RtldGlobal | RtldLazy);
+ return new KeyValuePair<IntPtr, string>(lptr, lptr == IntPtr.Zero
+ ? GetErrorText(NativeMethodsLinux.dlerror())
+ : null);
+ }
+
+ throw new InvalidOperationException("Unsupported OS: " + Environment.OSVersion);
+ }
+
+ /// <summary>
+ /// Gets the error text.
+ /// </summary>
+ private static string GetErrorText(IntPtr charPtr)
+ {
+ return Marshal.PtrToStringAnsi(charPtr) ?? "Unknown error";
+ }
+
+ /// <summary>
+ /// Formats the Win32 error.
+ /// </summary>
+ [ExcludeFromCodeCoverage]
+ private static string FormatWin32Error(int errorCode)
+ {
+ if (errorCode == ERROR_BAD_EXE_FORMAT)
+ {
+ var mode = Environment.Is64BitProcess ? "x64" : "x86";
+
+ return string.Format("DLL could not be loaded (193: ERROR_BAD_EXE_FORMAT). " +
+ "This is often caused by x64/x86 mismatch. " +
+ "Current process runs in {0} mode, and DLL is not {0}.", mode);
+ }
+
+ if (errorCode == ERROR_MOD_NOT_FOUND)
+ {
+ return "DLL could not be loaded (126: ERROR_MOD_NOT_FOUND). " +
+ "This can be caused by missing dependencies. ";
+ }
+
+ return string.Format("{0}: {1}", errorCode, new Win32Exception(errorCode).Message);
+ }
+
+ /// <summary>
+ /// Windows.
+ /// </summary>
+ private static class NativeMethodsWindows
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr LoadLibrary(string filename);
+ }
+
+ /// <summary>
+ /// Linux.
+ /// </summary>
+ private static class NativeMethodsLinux
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libdl.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlopen(string filename, int flags);
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libdl.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlerror();
+ }
+
+ /// <summary>
+ /// libdl.so depends on libc6-dev on Linux, use Mono instead.
+ /// </summary>
+ private static class NativeMethodsMono
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("__Internal", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlopen(string filename, int flags);
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("__Internal", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlerror();
+ }
+
+ /// <summary>
+ /// libdl.so depends on libc6-dev on Linux, use libcoreclr instead.
+ /// </summary>
+ private static class NativeMethodsCore
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libcoreclr.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlopen(string filename, int flags);
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libcoreclr.so", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlerror();
+ }
+
+ /// <summary>
+ /// macOs uses "libSystem.dylib".
+ /// </summary>
+ internal static class NativeMethodsMacOs
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libSystem.dylib", CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlopen(string filename, int flags);
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libSystem.dylib", CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlerror();
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libSystem.dylib", CharSet = CharSet.Ansi, BestFitMapping = false,
+ ThrowOnUnmappableChar = true)]
+ internal static extern IntPtr dlsym(IntPtr handle, string symbol);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
index ebff15b..3699751 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/Jvm.cs
@@ -126,11 +126,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
/// <summary>
/// Gets the JVM.
/// </summary>
- public static Jvm Get()
+ public static Jvm Get(bool ignoreMissing = false)
{
var res = _instance;
- if (res == null)
+ if (res == null && !ignoreMissing)
{
throw new IgniteException("JVM has not been created.");
}
@@ -205,7 +205,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
int existingJvmCount;
// Use existing JVM if present.
- var res = JniNativeMethods.JNI_GetCreatedJavaVMs(out jvm, 1, out existingJvmCount);
+ var res = JvmDll.Instance.GetCreatedJvms(out jvm, 1, out existingJvmCount);
if (res != JniResult.Success)
{
throw new IgniteException("JNI_GetCreatedJavaVMs failed: " + res);
@@ -238,7 +238,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
}
IntPtr env;
- res = JniNativeMethods.JNI_CreateJavaVM(out jvm, out env, &args);
+ res = JvmDll.Instance.CreateJvm(out jvm, out env, &args);
if (res != JniResult.Success)
{
throw new IgniteException("JNI_CreateJavaVM failed: " + res);
@@ -255,78 +255,6 @@ namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
del = (T) (object) Marshal.GetDelegateForFunctionPointer(ptr, typeof(T));
}
- /// <summary>
- /// JavaVMOption.
- /// </summary>
- [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
- [StructLayout(LayoutKind.Sequential, Pack = 0)]
- private struct JvmOption
- {
- public IntPtr optionString;
- private readonly IntPtr extraInfo;
- }
-
- /// <summary>
- /// JavaVMInitArgs.
- /// </summary>
- [StructLayout(LayoutKind.Sequential, Pack = 0)]
- private struct JvmInitArgs
- {
- public int version;
- public int nOptions;
- public JvmOption* options;
- private readonly byte ignoreUnrecognized;
- }
-
- private static class JniNativeMethods
- {
- internal static JniResult JNI_CreateJavaVM(out IntPtr pvm, out IntPtr penv,
- JvmInitArgs* args)
- {
- return Os.IsWindows
- ? JniNativeMethodsWindows.JNI_CreateJavaVM(out pvm, out penv, args)
- : JniNativeMethodsLinux.JNI_CreateJavaVM(out pvm, out penv, args);
- }
-
- internal static JniResult JNI_GetCreatedJavaVMs(out IntPtr pvm, int size, out int size2)
- {
- return Os.IsWindows
- ? JniNativeMethodsWindows.JNI_GetCreatedJavaVMs(out pvm, size, out size2)
- : JniNativeMethodsLinux.JNI_GetCreatedJavaVMs(out pvm, size, out size2);
- }
- }
-
- /// <summary>
- /// DLL imports.
- /// </summary>
- private static class JniNativeMethodsWindows
- {
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("jvm.dll", CallingConvention = CallingConvention.StdCall)]
- internal static extern JniResult JNI_CreateJavaVM(out IntPtr pvm, out IntPtr penv,
- JvmInitArgs* args);
-
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("jvm.dll", CallingConvention = CallingConvention.StdCall)]
- internal static extern JniResult JNI_GetCreatedJavaVMs(out IntPtr pvm, int size,
- [Out] out int size2);
- }
-
- /// <summary>
- /// DLL imports.
- /// </summary>
- private static class JniNativeMethodsLinux
- {
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("libjvm.so", CallingConvention = CallingConvention.StdCall)]
- internal static extern JniResult JNI_CreateJavaVM(out IntPtr pvm, out IntPtr penv,
- JvmInitArgs* args);
-
- [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
- [DllImport("libjvm.so", CallingConvention = CallingConvention.StdCall)]
- internal static extern JniResult JNI_GetCreatedJavaVMs(out IntPtr pvm, int size,
- [Out] out int size2);
- }
/// <summary>
/// Provides access to <see cref="Callbacks"/> instance in the default AppDomain.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmDll.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmDll.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmDll.cs
new file mode 100644
index 0000000..28c85ef
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmDll.cs
@@ -0,0 +1,414 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
+ using System.IO;
+ using System.Linq;
+ using System.Runtime.InteropServices;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Log;
+ using Microsoft.Win32;
+
+ /// <summary>
+ /// Jvm.dll loader (libjvm.so on Linux, libjvm.dylib on macOs).
+ /// </summary>
+ internal class JvmDll
+ {
+ /** Cached instance. */
+ private static JvmDll _instance;
+
+ /** Environment variable: JAVA_HOME. */
+ private const string EnvJavaHome = "JAVA_HOME";
+
+ /** Lookup paths. */
+ private static readonly string[] JvmDllLookupPaths = Os.IsWindows
+ ? new[]
+ {
+ // JRE paths
+ @"bin\server",
+ @"bin\client",
+
+ // JDK paths
+ @"jre\bin\server",
+ @"jre\bin\client",
+ @"jre\bin\default"
+ }
+ : new[]
+ {
+ // JRE paths
+ "lib/server",
+ "lib/client",
+ "lib/amd64/server",
+ "lib/amd64/client",
+
+ // JDK paths
+ "jre/lib/server",
+ "jre/lib/client",
+ "jre/lib/amd64/server",
+ "jre/lib/amd64/client"
+ };
+
+ /** Registry lookup paths. */
+ private static readonly string[] JreRegistryKeys =
+ {
+ @"Software\JavaSoft\Java Runtime Environment",
+ @"Software\Wow6432Node\JavaSoft\Java Runtime Environment"
+ };
+
+ /** Jvm dll file name. */
+ internal static readonly string FileJvmDll = Os.IsWindows
+ ? "jvm.dll"
+ : Os.IsMacOs
+ ? "libjvm.dylib"
+ : "libjvm.so";
+
+ /** */
+ private unsafe delegate JniResult CreateJvmDel(out IntPtr pvm, out IntPtr penv, JvmInitArgs* args);
+
+ /** */
+ private delegate JniResult GetCreatedJvmsDel(out IntPtr pvm, int size, out int size2);
+
+ /** */
+ private readonly CreateJvmDel _createJvm;
+
+ /** */
+ private readonly GetCreatedJvmsDel _getCreatedJvms;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="JvmDll"/> class.
+ /// </summary>
+ private unsafe JvmDll(IntPtr ptr)
+ {
+ if (Os.IsMacOs)
+ {
+ if (ptr == IntPtr.Zero)
+ {
+ // Retrieve already loaded dll by name.
+ // This happens in default AppDomain when Ignite starts in another domain.
+ var res = DllLoader.Load(FileJvmDll);
+ ptr = res.Key;
+
+ if (res.Key == IntPtr.Zero)
+ {
+ throw new IgniteException(
+ string.Format("{0} has not been loaded: {1}", FileJvmDll, res.Value));
+ }
+ }
+
+ // dlopen + DllImport combo does not work on macOs, so we have to call dlsym manually.
+ var createJvmPtr = DllLoader.NativeMethodsMacOs.dlsym(ptr, "JNI_CreateJavaVM");
+ _createJvm = (CreateJvmDel) Marshal.GetDelegateForFunctionPointer(createJvmPtr, typeof(CreateJvmDel));
+
+ var getJvmsPtr = DllLoader.NativeMethodsMacOs.dlsym(ptr, "JNI_GetCreatedJavaVMs");
+ _getCreatedJvms = (GetCreatedJvmsDel) Marshal.GetDelegateForFunctionPointer(getJvmsPtr,
+ typeof(GetCreatedJvmsDel));
+ }
+ else if (Os.IsWindows)
+ {
+ _createJvm = JniNativeMethodsWindows.JNI_CreateJavaVM;
+ _getCreatedJvms = JniNativeMethodsWindows.JNI_GetCreatedJavaVMs;
+ }
+ else
+ {
+ _createJvm = JniNativeMethodsLinux.JNI_CreateJavaVM;
+ _getCreatedJvms = JniNativeMethodsLinux.JNI_GetCreatedJavaVMs;
+ }
+ }
+
+ /// <summary>
+ /// Gets the instance.
+ /// </summary>
+ public static JvmDll Instance
+ {
+ get { return _instance ?? (_instance = new JvmDll(IntPtr.Zero)); }
+ }
+
+ /// <summary>
+ /// Creates the JVM.
+ /// </summary>
+ public unsafe JniResult CreateJvm(out IntPtr pvm, out IntPtr penv, JvmInitArgs* args)
+ {
+ return _createJvm(out pvm, out penv, args);
+ }
+
+ /// <summary>
+ /// Gets the created JVMS.
+ /// </summary>
+ public JniResult GetCreatedJvms(out IntPtr pvm, int size, out int size2)
+ {
+ return _getCreatedJvms(out pvm, size, out size2);
+ }
+
+ /// <summary>
+ /// Loads the JVM DLL into process memory.
+ /// </summary>
+ public static void Load(string configJvmDllPath, ILogger log)
+ {
+ // Load only once.
+ // Locking is performed by the caller three, omit here.
+ if (_instance != null)
+ {
+ log.Debug("JNI dll is already loaded.");
+ return;
+ }
+
+ var messages = new List<string>();
+ foreach (var dllPath in GetJvmDllPaths(configJvmDllPath))
+ {
+ log.Debug("Trying to load {0} from [option={1}, path={2}]...", FileJvmDll, dllPath.Key, dllPath.Value);
+
+ var res = LoadDll(dllPath.Value, FileJvmDll);
+ if (res.Key != IntPtr.Zero)
+ {
+ log.Debug("{0} successfully loaded from [option={1}, path={2}]",
+ FileJvmDll, dllPath.Key, dllPath.Value);
+
+ _instance = new JvmDll(res.Key);
+
+ return;
+ }
+
+ var message = string.Format(CultureInfo.InvariantCulture, "[option={0}, path={1}, error={2}]",
+ dllPath.Key, dllPath.Value, res.Value);
+ messages.Add(message);
+
+ log.Debug("Failed to load {0}: {1}", FileJvmDll, message);
+
+ if (dllPath.Value == configJvmDllPath)
+ break; // if configJvmDllPath is specified and is invalid - do not try other options
+ }
+
+ if (!messages.Any()) // not loaded and no messages - everything was null
+ {
+ messages.Add(string.Format(CultureInfo.InvariantCulture,
+ "Please specify IgniteConfiguration.JvmDllPath or {0}.", EnvJavaHome));
+ }
+
+ if (messages.Count == 1)
+ {
+ throw new IgniteException(string.Format(CultureInfo.InvariantCulture, "Failed to load {0} ({1})",
+ FileJvmDll, messages[0]));
+ }
+
+ var combinedMessage =
+ messages.Aggregate((x, y) => string.Format(CultureInfo.InvariantCulture, "{0}\n{1}", x, y));
+
+ throw new IgniteException(string.Format(CultureInfo.InvariantCulture, "Failed to load {0}:\n{1}",
+ FileJvmDll, combinedMessage));
+ }
+
+ /// <summary>
+ /// Try loading DLLs first using file path, then using it's simple name.
+ /// </summary>
+ /// <param name="filePath"></param>
+ /// <param name="simpleName"></param>
+ /// <returns>Null in case of success, error info in case of failure.</returns>
+ private static KeyValuePair<IntPtr, string> LoadDll(string filePath, string simpleName)
+ {
+ var res = new KeyValuePair<IntPtr, string>();
+
+ if (filePath != null)
+ {
+ res = DllLoader.Load(filePath);
+
+ if (res.Key != IntPtr.Zero)
+ {
+ return res; // Success.
+ }
+ }
+
+ // Failed to load using file path, fallback to simple name.
+ var res2 = DllLoader.Load(simpleName);
+
+ if (res2.Key != IntPtr.Zero)
+ {
+ return res2; // Success.
+ }
+
+ return res.Value != null ? res : res2;
+ }
+
+ /// <summary>
+ /// Gets the JVM DLL paths in order of lookup priority.
+ /// </summary>
+ private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPaths(string configJvmDllPath)
+ {
+ if (!string.IsNullOrEmpty(configJvmDllPath))
+ {
+ yield return new KeyValuePair<string, string>("IgniteConfiguration.JvmDllPath", configJvmDllPath);
+ }
+
+ var javaHomeDir = Environment.GetEnvironmentVariable(EnvJavaHome);
+
+ if (!string.IsNullOrEmpty(javaHomeDir))
+ {
+ foreach (var path in JvmDllLookupPaths)
+ {
+ yield return
+ new KeyValuePair<string, string>(EnvJavaHome, Path.Combine(javaHomeDir, path, FileJvmDll));
+ }
+ }
+
+ foreach (var keyValuePair in
+ GetJvmDllPathsWindows()
+ .Concat(GetJvmDllPathsLinux())
+ .Concat(GetJvmDllPathsMacOs()))
+ {
+ yield return keyValuePair;
+ }
+ }
+
+ /// <summary>
+ /// Gets Jvm dll paths from Windows registry.
+ /// </summary>
+ private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPathsWindows()
+ {
+ if (!Os.IsWindows)
+ {
+ yield break;
+ }
+
+ foreach (var regPath in JreRegistryKeys)
+ {
+ using (var jSubKey = Registry.LocalMachine.OpenSubKey(regPath))
+ {
+ if (jSubKey == null)
+ continue;
+
+ var curVer = jSubKey.GetValue("CurrentVersion") as string;
+
+ // Current version comes first
+ var versions = new[] {curVer}.Concat(jSubKey.GetSubKeyNames().Where(x => x != curVer));
+
+ foreach (var ver in versions.Where(v => !string.IsNullOrEmpty(v)))
+ {
+ using (var verKey = jSubKey.OpenSubKey(ver))
+ {
+ var dllPath = verKey == null ? null : verKey.GetValue("RuntimeLib") as string;
+
+ if (dllPath != null)
+ yield return new KeyValuePair<string, string>(verKey.Name, dllPath);
+ }
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the Jvm dll paths from /usr/bin/java symlink.
+ /// </summary>
+ private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPathsLinux()
+ {
+ if (Os.IsWindows || Os.IsMacOs)
+ {
+ yield break;
+ }
+
+ const string javaExec = "/usr/bin/java";
+ if (!File.Exists(javaExec))
+ {
+ yield break;
+ }
+
+ var file = Shell.BashExecute("readlink -f /usr/bin/java");
+ // /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
+
+ var dir = Path.GetDirectoryName(file);
+ // /usr/lib/jvm/java-8-openjdk-amd64/jre/bin
+
+ if (dir == null)
+ {
+ yield break;
+ }
+
+ var libFolder = Path.GetFullPath(Path.Combine(dir, "../lib/"));
+ if (!Directory.Exists(libFolder))
+ {
+ yield break;
+ }
+
+ // Predefined path: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so
+ yield return new KeyValuePair<string, string>(javaExec,
+ Path.Combine(libFolder, "amd64", "server", FileJvmDll));
+
+ // Last resort - custom paths:
+ foreach (var f in Directory.GetFiles(libFolder, FileJvmDll, SearchOption.AllDirectories))
+ {
+ yield return new KeyValuePair<string, string>(javaExec, f);
+ }
+ }
+
+ /// <summary>
+ /// Gets the JVM DLL paths on macOs.
+ /// </summary>
+ private static IEnumerable<KeyValuePair<string, string>> GetJvmDllPathsMacOs()
+ {
+ const string jvmDir = "/Library/Java/JavaVirtualMachines";
+
+ if (!Directory.Exists(jvmDir))
+ {
+ yield break;
+ }
+
+ const string subDir = "Contents/Home";
+
+ foreach (var dir in Directory.GetDirectories(jvmDir))
+ {
+ foreach (var path in JvmDllLookupPaths)
+ {
+ yield return
+ new KeyValuePair<string, string>(dir, Path.Combine(dir, subDir, path, FileJvmDll));
+ }
+ }
+ }
+
+ /// <summary>
+ /// DLL imports.
+ /// </summary>
+ private static unsafe class JniNativeMethodsWindows
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("jvm.dll", CallingConvention = CallingConvention.StdCall)]
+ internal static extern JniResult JNI_CreateJavaVM(out IntPtr pvm, out IntPtr penv, JvmInitArgs* args);
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("jvm.dll", CallingConvention = CallingConvention.StdCall)]
+ internal static extern JniResult JNI_GetCreatedJavaVMs(out IntPtr pvm, int size,
+ [Out] out int size2);
+ }
+
+ /// <summary>
+ /// DLL imports.
+ /// </summary>
+ private static unsafe class JniNativeMethodsLinux
+ {
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libjvm.so", CallingConvention = CallingConvention.StdCall)]
+ internal static extern JniResult JNI_CreateJavaVM(out IntPtr pvm, out IntPtr penv, JvmInitArgs* args);
+
+ [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
+ [DllImport("libjvm.so", CallingConvention = CallingConvention.StdCall)]
+ internal static extern JniResult JNI_GetCreatedJavaVMs(out IntPtr pvm, int size,
+ [Out] out int size2);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmInitArgs.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmInitArgs.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmInitArgs.cs
new file mode 100644
index 0000000..0b3c655
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmInitArgs.cs
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
+{
+ using System.Runtime.InteropServices;
+
+ /// <summary>
+ /// JavaVMInitArgs.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential, Pack = 0)]
+ internal unsafe struct JvmInitArgs
+ {
+ public int version;
+ public int nOptions;
+ public JvmOption* options;
+ private readonly byte ignoreUnrecognized;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmOption.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmOption.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmOption.cs
new file mode 100644
index 0000000..3e239d1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Jni/JvmOption.cs
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Impl.Unmanaged.Jni
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Runtime.InteropServices;
+
+ /// <summary>
+ /// JavaVMOption.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1049:TypesThatOwnNativeResourcesShouldBeDisposable")]
+ [StructLayout(LayoutKind.Sequential, Pack = 0)]
+ internal struct JvmOption
+ {
+ public IntPtr optionString;
+ private readonly IntPtr extraInfo;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Os.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Os.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Os.cs
index 22ab447..535aa4c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Os.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/Os.cs
@@ -39,6 +39,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
|| platform == PlatformID.Win32S
|| platform == PlatformID.Win32Windows;
+ IsMacOs = IsLinux && Shell.BashExecute("uname").Contains("Darwin");
IsMono = Type.GetType("Mono.Runtime") != null;
IsNetCore = !IsMono;
}
@@ -62,5 +63,10 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
/// Linux.
/// </summary>
public static bool IsLinux { get; private set; }
+
+ /// <summary>
+ /// MacOs.
+ /// </summary>
+ public static bool IsMacOs { get; private set; }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf432ef4/modules/platforms/dotnet/Apache.Ignite.ndproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.ndproj b/modules/platforms/dotnet/Apache.Ignite.ndproj
index aa30019..5ed9e3c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.ndproj
+++ b/modules/platforms/dotnet/Apache.Ignite.ndproj
@@ -2478,7 +2478,7 @@ select new {
<Query Active="True" DisplayList="True" DisplayStat="False" DisplaySelectionView="False" IsCriticalRule="False"><![CDATA[//<Name>Avoid the Singleton pattern</Name>
warnif count > 0
from t in Application.Types
-where !t.IsStatic && !t.IsAbstract && (t.IsClass || t.IsStructure) && t.Name != "Jvm"
+where !t.IsStatic && !t.IsAbstract && (t.IsClass || t.IsStructure) && t.Name != "Jvm" && t.Name != "JvmDll"
// All ctors of a singleton are private
where t.Constructors.Where(ctor => !ctor.IsPrivate).Count() == 0
[08/12] ignite git commit: IGNITE-7016 Avoid WAL segment fsync on
header write in non-default mode
Posted by ag...@apache.org.
IGNITE-7016 Avoid WAL segment fsync on header write in non-default mode
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/60e3680f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/60e3680f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/60e3680f
Branch: refs/heads/ignite-7016
Commit: 60e3680f7b3f6444242f27089270cbebc36bdcea
Parents: 8e1f842
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Nov 27 12:32:36 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:34 2017 +0300
----------------------------------------------------------------------
.../processors/cache/persistence/wal/FileWriteAheadLogManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/60e3680f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index 517923a..948a8ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -1372,7 +1372,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
return curAbsWalIdx;
}
}
- catch (InterruptedException e) {
+ catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IgniteInterruptedCheckedException(e);
[04/12] ignite git commit: IGNITE-6989 .NET: Thin client: Group
operation codes by purpose
Posted by ag...@apache.org.
IGNITE-6989 .NET: Thin client: Group operation codes by purpose
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/75660313
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/75660313
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/75660313
Branch: refs/heads/ignite-7016
Commit: 756603137ffe463f6c458b695d5d985faaa163c6
Parents: 5735c39
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Nov 27 12:47:44 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:32 2017 +0300
----------------------------------------------------------------------
.../platform/client/ClientMessageParser.java | 97 +++++++++++---------
.../Client/RawSocketTest.cs | 2 +-
.../Apache.Ignite.Core/Impl/Client/ClientOp.cs | 85 +++++++++--------
3 files changed, 100 insertions(+), 84 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/75660313/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
index 626b7ff..057995d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.platform.client;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream;
import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
@@ -69,122 +70,127 @@ import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheSq
* Thin client message parser.
*/
public class ClientMessageParser implements ClientListenerMessageParser {
+ /* General-purpose operations. */
/** */
- private static final short OP_CACHE_GET = 1;
+ private static final short OP_RESOURCE_CLOSE = 0;
+ /* Cache operations */
/** */
- private static final short OP_GET_BINARY_TYPE_NAME = 2;
+ private static final short OP_CACHE_GET = 1000;
/** */
- private static final short OP_GET_BINARY_TYPE = 3;
+ private static final short OP_CACHE_PUT = 1001;
/** */
- private static final short OP_CACHE_PUT = 4;
+ private static final short OP_CACHE_PUT_IF_ABSENT = 1002;
/** */
- private static final short OP_REGISTER_BINARY_TYPE_NAME = 5;
+ private static final short OP_CACHE_GET_ALL = 1003;
/** */
- private static final short OP_PUT_BINARY_TYPE = 6;
+ private static final short OP_CACHE_PUT_ALL = 1004;
/** */
- private static final short OP_QUERY_SCAN = 7;
+ private static final short OP_CACHE_GET_AND_PUT = 1005;
/** */
- private static final short OP_QUERY_SCAN_CURSOR_GET_PAGE = 8;
+ private static final short OP_CACHE_GET_AND_REPLACE = 1006;
/** */
- private static final short OP_RESOURCE_CLOSE = 9;
+ private static final short OP_CACHE_GET_AND_REMOVE = 1007;
/** */
- private static final short OP_CACHE_CONTAINS_KEY = 10;
+ private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 1008;
/** */
- private static final short OP_CACHE_CONTAINS_KEYS = 11;
+ private static final short OP_CACHE_REPLACE = 1009;
/** */
- private static final short OP_CACHE_GET_ALL = 12;
+ private static final short OP_CACHE_REPLACE_IF_EQUALS = 1010;
/** */
- private static final short OP_CACHE_GET_AND_PUT = 13;
+ private static final short OP_CACHE_CONTAINS_KEY = 1011;
/** */
- private static final short OP_CACHE_GET_AND_REPLACE = 14;
+ private static final short OP_CACHE_CONTAINS_KEYS = 1012;
/** */
- private static final short OP_CACHE_GET_AND_REMOVE = 15;
+ private static final short OP_CACHE_CLEAR = 1013;
/** */
- private static final short OP_CACHE_PUT_IF_ABSENT = 16;
+ private static final short OP_CACHE_CLEAR_KEY = 1014;
/** */
- private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 17;
+ private static final short OP_CACHE_CLEAR_KEYS = 1015;
/** */
- private static final short OP_CACHE_REPLACE = 18;
+ private static final short OP_CACHE_REMOVE_KEY = 1016;
/** */
- private static final short OP_CACHE_REPLACE_IF_EQUALS = 19;
+ private static final short OP_CACHE_REMOVE_IF_EQUALS = 1017;
/** */
- private static final short OP_CACHE_PUT_ALL = 20;
+ private static final short OP_CACHE_REMOVE_KEYS = 1018;
/** */
- private static final short OP_CACHE_CLEAR = 21;
+ private static final short OP_CACHE_REMOVE_ALL = 1019;
/** */
- private static final short OP_CACHE_CLEAR_KEY = 22;
+ private static final short OP_CACHE_GET_SIZE = 1020;
+ /* Cache create / destroy, configuration. */
/** */
- private static final short OP_CACHE_CLEAR_KEYS = 23;
+ private static final short OP_CACHE_GET_NAMES = 1050;
/** */
- private static final short OP_CACHE_REMOVE_KEY = 24;
+ private static final short OP_CACHE_CREATE_WITH_NAME = 1051;
/** */
- private static final short OP_CACHE_REMOVE_IF_EQUALS = 25;
+ private static final short OP_CACHE_GET_OR_CREATE_WITH_NAME = 1052;
/** */
- private static final short OP_CACHE_GET_SIZE = 26;
+ private static final short OP_CACHE_CREATE_WITH_CONFIGURATION = 1053;
/** */
- private static final short OP_CACHE_REMOVE_KEYS = 27;
+ private static final short OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 1054;
/** */
- private static final short OP_CACHE_REMOVE_ALL = 28;
+ private static final short OP_CACHE_GET_CONFIGURATION = 1055;
/** */
- private static final short OP_CACHE_CREATE_WITH_NAME = 29;
+ private static final short OP_CACHE_DESTROY = 1056;
+ /* Query operations. */
/** */
- private static final short OP_CACHE_GET_OR_CREATE_WITH_NAME = 30;
+ private static final short OP_QUERY_SCAN = 2000;
/** */
- private static final short OP_CACHE_DESTROY = 31;
+ private static final short OP_QUERY_SCAN_CURSOR_GET_PAGE = 2001;
/** */
- private static final short OP_CACHE_GET_NAMES = 32;
+ private static final short OP_QUERY_SQL = 2002;
/** */
- private static final short OP_CACHE_GET_CONFIGURATION = 33;
+ private static final short OP_QUERY_SQL_CURSOR_GET_PAGE = 2003;
/** */
- private static final short OP_CACHE_CREATE_WITH_CONFIGURATION = 34;
+ private static final short OP_QUERY_SQL_FIELDS = 2004;
/** */
- private static final short OP_CACHE_GET_OR_CREATE_WITH_CONFIGURATION = 35;
+ private static final short OP_QUERY_SQL_FIELDS_CURSOR_GET_PAGE = 2005;
+ /* Binary metadata operations. */
/** */
- private static final short OP_QUERY_SQL = 36;
+ private static final short OP_BINARY_TYPE_NAME_GET = 3000;
/** */
- private static final short OP_QUERY_SQL_CURSOR_GET_PAGE = 37;
+ private static final short OP_BINARY_TYPE_NAME_PUT = 3001;
/** */
- private static final short OP_QUERY_SQL_FIELDS = 38;
+ private static final short OP_BINARY_TYPE_GET = 3002;
/** */
- private static final short OP_QUERY_SQL_FIELDS_CURSOR_GET_PAGE = 39;
+ private static final short OP_BINARY_TYPE_PUT = 3003;
/** Marshaller. */
private final GridBinaryMarshaller marsh;
@@ -206,7 +212,10 @@ public class ClientMessageParser implements ClientListenerMessageParser {
assert msg != null;
BinaryInputStream inStream = new BinaryHeapInputStream(msg);
- BinaryRawReaderEx reader = marsh.reader(inStream);
+
+ // skipHdrCheck must be true (we have 103 op code).
+ BinaryRawReaderEx reader = new BinaryReaderExImpl(marsh.context(), inStream,
+ null, null, true, true);
return decode(reader);
}
@@ -224,19 +233,19 @@ public class ClientMessageParser implements ClientListenerMessageParser {
case OP_CACHE_GET:
return new ClientCacheGetRequest(reader);
- case OP_GET_BINARY_TYPE_NAME:
+ case OP_BINARY_TYPE_NAME_GET:
return new ClientBinaryTypeNameGetRequest(reader);
- case OP_GET_BINARY_TYPE:
+ case OP_BINARY_TYPE_GET:
return new ClientBinaryTypeGetRequest(reader);
case OP_CACHE_PUT:
return new ClientCachePutRequest(reader);
- case OP_REGISTER_BINARY_TYPE_NAME:
+ case OP_BINARY_TYPE_NAME_PUT:
return new ClientBinaryTypeNamePutRequest(reader);
- case OP_PUT_BINARY_TYPE:
+ case OP_BINARY_TYPE_PUT:
return new ClientBinaryTypePutRequest(reader);
case OP_QUERY_SCAN:
http://git-wip-us.apache.org/repos/asf/ignite/blob/75660313/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
index 0f1358a..9aab341 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/RawSocketTest.cs
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Core.Tests.Client
// Cache get.
SendRequest(sock, stream =>
{
- stream.WriteShort(1); // OP_GET
+ stream.WriteShort(1000); // OP_GET
stream.WriteLong(1); // Request id.
var cacheId = BinaryUtils.GetStringHashCodeLowerCase(cache.Name);
stream.WriteInt(cacheId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/75660313/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
index 3af089a..fae3bb9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
@@ -22,44 +22,51 @@ namespace Apache.Ignite.Core.Impl.Client
/// </summary>
internal enum ClientOp : short
{
- CacheGet = 1,
- BinaryTypeNameGet = 2,
- BinaryTypeGet = 3,
- CachePut = 4,
- BinaryTypeNamePut = 5,
- BinaryTypePut = 6,
- QueryScan = 7,
- QueryScanCursorGetPage = 8,
- ResourceClose = 9,
- CacheContainsKey = 10,
- CacheContainsKeys = 11,
- CacheGetAll = 12,
- CacheGetAndPut = 13,
- CacheGetAndReplace = 14,
- CacheGetAndRemove = 15,
- CachePutIfAbsent = 16,
- CacheGetAndPutIfAbsent = 17,
- CacheReplace = 18,
- CacheReplaceIfEquals = 19,
- CachePutAll = 20,
- CacheClear = 21,
- CacheClearKey = 22,
- CacheClearKeys = 23,
- CacheRemoveKey = 24,
- CacheRemoveIfEquals = 25,
- CacheGetSize = 26,
- CacheRemoveKeys = 27,
- CacheRemoveAll = 28,
- CacheCreateWithName = 29,
- CacheGetOrCreateWithName = 30,
- CacheDestroy = 31,
- CacheGetNames = 32,
- CacheGetConfiguration = 33,
- CacheCreateWithConfiguration = 34,
- CacheGetOrCreateWithConfiguration = 35,
- QuerySql = 36,
- QuerySqlCursorGetPage = 37,
- QuerySqlFields = 38,
- QuerySqlFieldsCursorGetPage = 39
+ // General purpose.
+ ResourceClose = 0,
+
+ // Cache.
+ CacheGet = 1000,
+ CachePut = 1001,
+ CachePutIfAbsent = 1002,
+ CacheGetAll = 1003,
+ CachePutAll = 1004,
+ CacheGetAndPut = 1005,
+ CacheGetAndReplace = 1006,
+ CacheGetAndRemove = 1007,
+ CacheGetAndPutIfAbsent = 1008,
+ CacheReplace = 1009,
+ CacheReplaceIfEquals = 1010,
+ CacheContainsKey = 1011,
+ CacheContainsKeys = 1012,
+ CacheClear = 1013,
+ CacheClearKey = 1014,
+ CacheClearKeys = 1015,
+ CacheRemoveKey = 1016,
+ CacheRemoveIfEquals = 1017,
+ CacheRemoveKeys = 1018,
+ CacheRemoveAll = 1019,
+ CacheGetSize = 1020,
+ CacheGetNames = 1050,
+ CacheCreateWithName = 1051,
+ CacheGetOrCreateWithName = 1052,
+ CacheCreateWithConfiguration = 1053,
+ CacheGetOrCreateWithConfiguration = 1054,
+ CacheGetConfiguration = 1055,
+ CacheDestroy = 1056,
+
+ // Queries.
+ QueryScan = 2000,
+ QueryScanCursorGetPage = 2001,
+ QuerySql = 2002,
+ QuerySqlCursorGetPage = 2003,
+ QuerySqlFields = 2004,
+ QuerySqlFieldsCursorGetPage = 2005,
+
+ // Metadata.
+ BinaryTypeNameGet = 3000,
+ BinaryTypeNamePut = 3001,
+ BinaryTypeGet = 3002,
+ BinaryTypePut = 3003
}
}
[07/12] ignite git commit: IGNITE-4454. Web Console: Minor UI changes.
Posted by ag...@apache.org.
IGNITE-4454. Web Console: Minor UI changes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/60cef7c7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/60cef7c7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/60cef7c7
Branch: refs/heads/ignite-7016
Commit: 60cef7c75204dee9e9bba91661d66671f7b82403
Parents: 3ccf57a
Author: alexdel <ve...@yandex.ru>
Authored: Tue Nov 28 17:00:42 2017 +0700
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:33 2017 +0300
----------------------------------------------------------------------
modules/web-console/frontend/views/sql/sql.tpl.pug | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/60cef7c7/modules/web-console/frontend/views/sql/sql.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/sql/sql.tpl.pug b/modules/web-console/frontend/views/sql/sql.tpl.pug
index 7714235..98b4d68 100644
--- a/modules/web-console/frontend/views/sql/sql.tpl.pug
+++ b/modules/web-console/frontend/views/sql/sql.tpl.pug
@@ -32,7 +32,7 @@ mixin result-toolbar
mixin chart-settings
.total.row
- .col-xs-5
+ .col-xs-7
.chart-settings-link(ng-show='paragraph.chart && paragraph.chartColumns.length > 0')
a(title='Click to show chart settings dialog' ng-click='$event.stopPropagation()' bs-popover data-template-url='{{ $ctrl.chartSettingsTemplateUrl }}' data-placement='bottom' data-auto-close='1' data-trigger='click')
i.fa.fa-bars
@@ -143,7 +143,7 @@ mixin query-actions
mixin table-result-heading-query
.total.row
- .col-xs-5
+ .col-xs-7
grid-column-selector(grid-api='paragraph.gridOptions.api')
.fa.fa-bars.icon
label Page: #[b {{paragraph.page}}]
@@ -153,7 +153,7 @@ mixin table-result-heading-query
.col-xs-2
div(ng-if='paragraph.qryType === "query"')
+result-toolbar
- .col-xs-5
+ .col-xs-3
.pull-right
.btn-group.panel-tip-container
button.btn.btn-primary.btn--with-icon(
@@ -188,7 +188,7 @@ mixin table-result-heading-query
mixin table-result-heading-scan
.total.row
- .col-xs-5
+ .col-xs-7
grid-column-selector(grid-api='paragraph.gridOptions.api')
.fa.fa-bars.icon
label Page: #[b {{paragraph.page}}]
@@ -198,7 +198,7 @@ mixin table-result-heading-scan
.col-xs-2
div(ng-if='paragraph.qryType === "query"')
+result-toolbar
- .col-xs-5
+ .col-xs-3
.pull-right
.btn-group.panel-tip-container
// TODO: replace this logic for exporting under one component
[06/12] ignite git commit: IGNITE-6919. Web Console: Minor fix of
page title.
Posted by ag...@apache.org.
IGNITE-6919. Web Console: Minor fix of page title.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f1b47edc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f1b47edc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f1b47edc
Branch: refs/heads/ignite-7016
Commit: f1b47edc98b10f6f8c925950376a16a69115ee00
Parents: 9a52bb2
Author: alexdel <ve...@yandex.ru>
Authored: Tue Nov 28 22:27:43 2017 +0700
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:33 2017 +0300
----------------------------------------------------------------------
.../web-console/frontend/app/modules/branding/branding.service.js | 2 +-
modules/web-console/frontend/views/index.pug | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f1b47edc/modules/web-console/frontend/app/modules/branding/branding.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/branding/branding.service.js b/modules/web-console/frontend/app/modules/branding/branding.service.js
index 46bc358..564aa85 100644
--- a/modules/web-console/frontend/app/modules/branding/branding.service.js
+++ b/modules/web-console/frontend/app/modules/branding/branding.service.js
@@ -19,7 +19,7 @@ export default class {
static $inject = ['IgniteVersion'];
constructor(Version) {
- this.titleSuffix = ' – Apache Ignite Web Console';
+ this.titleSuffix = ' - Apache Ignite Web Console';
this.headerLogo = '/images/ignite-logo.svg';
http://git-wip-us.apache.org/repos/asf/ignite/blob/f1b47edc/modules/web-console/frontend/views/index.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/index.pug b/modules/web-console/frontend/views/index.pug
index 9565949..e91af9b 100644
--- a/modules/web-console/frontend/views/index.pug
+++ b/modules/web-console/frontend/views/index.pug
@@ -19,7 +19,7 @@ html(ng-app='ignite-console' id='app' ng-strict-di)
head
base(href='/')
- meta(http-equiv='content-type' content='text/html; charset=UTF8')
+ meta(http-equiv='content-type' content='text/html; charset=utf-8')
meta(http-equiv='content-language' content='en')
meta(http-equiv='X-UA-Compatible' content='IE=Edge')
[02/12] ignite git commit: Fixed IGNITE-6838. Restore EvictionPolicy
'maxSize' field default value.
Posted by ag...@apache.org.
Fixed IGNITE-6838.
Restore EvictionPolicy 'maxSize' field default value.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5735c39b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5735c39b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5735c39b
Branch: refs/heads/ignite-7016
Commit: 5735c39b69f9f5ba542b2282957df0886eb8f682
Parents: 2fafa21
Author: sboikov <sb...@gridgain.com>
Authored: Mon Jan 9 11:42:39 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:32 2017 +0300
----------------------------------------------------------------------
.../ignite/cache/eviction/AbstractEvictionPolicyFactory.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5735c39b/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicyFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicyFactory.java b/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicyFactory.java
index 012c7ee..aa7dea9 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicyFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/AbstractEvictionPolicyFactory.java
@@ -20,12 +20,14 @@ package org.apache.ignite.cache.eviction;
import javax.cache.configuration.Factory;
import org.apache.ignite.internal.util.typedef.internal.A;
+import static org.apache.ignite.configuration.CacheConfiguration.DFLT_CACHE_SIZE;
+
/**
* Common functionality implementation for eviction policies factories.
*/
public abstract class AbstractEvictionPolicyFactory<T> implements Factory<T> {
/** */
- private int maxSize;
+ private int maxSize = DFLT_CACHE_SIZE;
/** */
private int batchSize = 1;
[12/12] ignite git commit: IGNITE-7043 Fix method name suggested when
page eviction starts - Fixes #3103.
Posted by ag...@apache.org.
IGNITE-7043 Fix method name suggested when page eviction starts - Fixes #3103.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6afbc098
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6afbc098
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6afbc098
Branch: refs/heads/ignite-7016
Commit: 6afbc098d3630f1874662f5630f4757c6d6456ce
Parents: bf432ef
Author: Ilya Kasnacheev <il...@gmail.com>
Authored: Wed Nov 29 09:52:41 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:34 2017 +0300
----------------------------------------------------------------------
.../processors/cache/persistence/pagemem/PageMemoryImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6afbc098/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
index a773b42..3014099 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
@@ -1827,7 +1827,7 @@ public class PageMemoryImpl implements PageMemoryEx {
pageEvictWarned = true;
U.warn(log, "Page evictions started, this will affect storage performance (consider increasing " +
- "DataStorageConfiguration#setPageCacheSize).");
+ "DataRegionConfiguration#setMaxSize).");
}
final ThreadLocalRandom rnd = ThreadLocalRandom.current();
[10/12] ignite git commit: BinaryMetadataTransport: do not cache
local node id, it can change after client reconnect.
Posted by ag...@apache.org.
BinaryMetadataTransport: do not cache local node id, it can change after client reconnect.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8e1f842f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8e1f842f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8e1f842f
Branch: refs/heads/ignite-7016
Commit: 8e1f842fcf5778c202f0285f7c1bf22c8e8414a8
Parents: fe80670
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 29 11:36:49 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 29 13:28:34 2017 +0300
----------------------------------------------------------------------
.../cache/binary/BinaryMetadataTransport.java | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e1f842f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
index 3a77190..def7caa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
@@ -69,9 +69,6 @@ final class BinaryMetadataTransport {
private final IgniteLogger log;
/** */
- private final UUID locNodeId;
-
- /** */
private final boolean clientNode;
/** */
@@ -117,8 +114,6 @@ final class BinaryMetadataTransport {
discoMgr = ctx.discovery();
- locNodeId = ctx.localNodeId();
-
clientNode = ctx.clientNode();
discoMgr.setCustomEventListener(MetadataUpdateProposedMessage.class, new MetadataUpdateProposedListener());
@@ -170,7 +165,7 @@ final class BinaryMetadataTransport {
unlabeledFutures.add(resFut);
if (!stopping)
- discoMgr.sendCustomEvent(new MetadataUpdateProposedMessage(metadata, locNodeId));
+ discoMgr.sendCustomEvent(new MetadataUpdateProposedMessage(metadata, ctx.localNodeId()));
else
resFut.onDone(MetadataUpdateResult.createUpdateDisabledResult());
}
@@ -299,7 +294,7 @@ final class BinaryMetadataTransport {
acceptedVer = msg.acceptedVersion();
}
- if (locNodeId.equals(msg.origNodeId())) {
+ if (ctx.localNodeId().equals(msg.origNodeId())) {
MetadataUpdateResultFuture fut = unlabeledFutures.poll();
if (msg.rejected())
@@ -540,12 +535,16 @@ final class BinaryMetadataTransport {
this.ver = ver;
}
- /** */
+ /**
+ * @return Type ID.
+ */
int typeId() {
return typeId;
}
- /** */
+ /**
+ * @return Version.
+ */
int version() {
return ver;
}
@@ -627,7 +626,6 @@ final class BinaryMetadataTransport {
* Listener is registered on each client node and listens for metadata responses from cluster.
*/
private final class MetadataResponseListener implements GridMessageListener {
-
/** {@inheritDoc} */
@Override public void onMessage(UUID nodeId, Object msg, byte plc) {
assert msg instanceof MetadataResponseMessage : msg;
@@ -674,8 +672,6 @@ final class BinaryMetadataTransport {
fut.onDone(MetadataUpdateResult.createFailureResult(new BinaryObjectException(e)));
}
}
-
-
}
/**