This is an automated email from the ASF dual-hosted git repository.
nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 83a7115da1c IGNITE-28819 [4/N] Thin client implementation extraction
(#13341)
83a7115da1c is described below
commit 83a7115da1c2f7ff9d91ce7b6def54a389a0c0ee
Author: Nikolay <[email protected]>
AuthorDate: Thu Jul 9 13:15:17 2026 +0300
IGNITE-28819 [4/N] Thin client implementation extraction (#13341)
---
.../ignite/IgniteCommonsSystemProperties.java | 30 ++++
.../compute/ComputeExecutionRejectedException.java | 0
.../org/apache/ignite/failure/FailureType.java | 0
.../IgniteFutureCancelledCheckedException.java | 3 +-
.../ignite/internal/NodeStoppingException.java | 0
.../apache/ignite/internal/util/CommonUtils.java | 153 +++++++++++++++++++++
.../apache/ignite/internal/util/GridLongList.java | 2 +-
.../internal/util/future/GridCompoundFuture.java | 28 ++--
.../internal/util/lang/IgniteInClosure2X.java | 0
.../apache/ignite/internal/util/typedef/CIX2.java | 0
.../ignite/internal/util/worker/GridWorker.java | 11 +-
.../internal/util/worker/GridWorkerListener.java | 0
.../internal/util/worker/GridWorkerPool.java | 6 +-
.../util/worker/WorkProgressDispatcher.java | 0
.../apache/ignite/util/deque/FastSizeDeque.java | 0
.../org/apache/ignite/IgniteSystemProperties.java | 27 ----
.../configuration/ConnectorConfiguration.java | 3 +-
.../cluster/ClusterTopologyCheckedException.java | 3 +-
.../IgniteConsistencyViolationException.java | 3 +-
.../IgniteTxOptimisticCheckedException.java | 4 +-
.../apache/ignite/internal/util/IgniteUtils.java | 143 -------------------
.../util/nio/GridAbstractCommunicationClient.java | 8 +-
.../util/nio/GridConnectionBytesVerifyFilter.java | 16 +--
.../ignite/internal/util/nio/GridDirectParser.java | 6 +-
.../util/nio/GridNioAsyncNotifyFilter.java | 4 +-
.../util/nio/GridNioRecoveryDescriptor.java | 10 +-
.../ignite/internal/util/nio/GridNioServer.java | 129 ++++++++---------
.../internal/util/nio/GridNioSessionImpl.java | 12 +-
.../util/nio/GridTcpNioCommunicationClient.java | 4 +-
.../internal/util/nio/ssl/BlockingSslHandler.java | 8 +-
.../internal/util/nio/ssl/GridNioSslFilter.java | 8 +-
.../internal/util/nio/ssl/GridNioSslHandler.java | 10 +-
.../spi/communication/tcp/TcpCommunicationSpi.java | 11 --
.../tcp/internal/TcpHandshakeExecutor.java | 2 +-
.../spi/discovery/tcp/TcpDiscoveryIoSession.java | 5 +-
.../QueryEntityMessageSerializationTest.java | 2 +-
...municationSpiSkipWaitHandshakeOnClientTest.java | 2 +-
.../zk/internal/DiscoveryMessageParser.java | 5 +-
38 files changed, 331 insertions(+), 327 deletions(-)
diff --git
a/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
b/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
index d424f23cfe7..ec443398ce3 100644
---
a/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
+++
b/modules/commons/src/main/java/org/apache/ignite/IgniteCommonsSystemProperties.java
@@ -185,6 +185,36 @@ public class IgniteCommonsSystemProperties {
)
public static final String
IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION =
"IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION";
+ /**
+ * Enables default selected keys set to be used inside {@code
GridNioServer}.
+ * <p>
+ * Default value is {@code false}. Should be switched to {@code true} if
there are
+ * any problems in communication layer.
+ */
+ @SystemProperty("Enables default selected keys set to be used inside
GridNioServer " +
+ "which lead to some extra garbage generation when processing selected
keys. " +
+ "Should be switched to true if there are any problems in communication
layer")
+ public static final String IGNITE_NO_SELECTOR_OPTS =
"IGNITE_NO_SELECTOR_OPTS";
+
+ /** Default IO balance period. */
+ public static final int DFLT_IO_BALANCE_PERIOD = 5000;
+
+ /** */
+ @SystemProperty(value = "IO balance period in milliseconds", type =
Long.class,
+ defaults = "" + DFLT_IO_BALANCE_PERIOD)
+ public static final String IGNITE_IO_BALANCE_PERIOD =
"IGNITE_IO_BALANCE_PERIOD";
+
+ /** Default timeout for TCP client recovery descriptor reservation. */
+ public static final int DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT =
5_000;
+
+ /**
+ * Sets timeout for TCP client recovery descriptor reservation.
+ */
+ @SystemProperty(value = "Timeout for TCP client recovery descriptor
reservation in milliseconds",
+ type = Long.class, defaults = "" +
DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT)
+ public static final String
IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT =
+ "IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT";
+
/**
* @param enumCls Enum type.
* @param name Name of the system property or environment variable.
diff --git
a/modules/core/src/main/java/org/apache/ignite/compute/ComputeExecutionRejectedException.java
b/modules/commons/src/main/java/org/apache/ignite/compute/ComputeExecutionRejectedException.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/compute/ComputeExecutionRejectedException.java
rename to
modules/commons/src/main/java/org/apache/ignite/compute/ComputeExecutionRejectedException.java
diff --git
a/modules/core/src/main/java/org/apache/ignite/failure/FailureType.java
b/modules/commons/src/main/java/org/apache/ignite/failure/FailureType.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/failure/FailureType.java
rename to
modules/commons/src/main/java/org/apache/ignite/failure/FailureType.java
diff --git
a/modules/commons/src/main/java/org/apache/ignite/internal/IgniteFutureCancelledCheckedException.java
b/modules/commons/src/main/java/org/apache/ignite/internal/IgniteFutureCancelledCheckedException.java
index 1cec418142d..1ef01e562d2 100644
---
a/modules/commons/src/main/java/org/apache/ignite/internal/IgniteFutureCancelledCheckedException.java
+++
b/modules/commons/src/main/java/org/apache/ignite/internal/IgniteFutureCancelledCheckedException.java
@@ -18,12 +18,13 @@
package org.apache.ignite.internal;
import org.apache.ignite.IgniteCheckedException;
+import
org.apache.ignite.internal.util.future.GridCompoundFuture.SkipLoggingException;
import org.jetbrains.annotations.Nullable;
/**
* Future computation cannot be retrieved because it was cancelled.
*/
-public class IgniteFutureCancelledCheckedException extends
IgniteCheckedException {
+public class IgniteFutureCancelledCheckedException extends
IgniteCheckedException implements SkipLoggingException {
/** */
private static final long serialVersionUID = 0L;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/NodeStoppingException.java
b/modules/commons/src/main/java/org/apache/ignite/internal/NodeStoppingException.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/internal/NodeStoppingException.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/NodeStoppingException.java
diff --git
a/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
index 3cda23f41ea..8954c0cafd1 100644
---
a/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
+++
b/modules/commons/src/main/java/org/apache/ignite/internal/util/CommonUtils.java
@@ -37,9 +37,11 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.AccessController;
@@ -87,6 +89,7 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.worker.GridWorker;
import org.apache.ignite.lang.IgniteFutureCancelledException;
import org.apache.ignite.lang.IgniteFutureTimeoutException;
import org.apache.ignite.lang.IgnitePredicate;
@@ -101,6 +104,12 @@ import static
org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_HOME;
* Collection of utility methods used in 'ignite-commons' and throughout the
system.
*/
public abstract class CommonUtils {
+ /** Empty longs array. */
+ public static final long[] EMPTY_LONGS = new long[0];
+
+ /** Network packet header (corresponds to {@code 0x0149474E}). */
+ public static final byte[] IGNITE_HEADER = new byte[] {0x01, 0x49, 0x47,
0x4E};
+
/** */
public static final long KB = 1024L;
@@ -2592,4 +2601,148 @@ public abstract class CommonUtils {
return typeName;
}
+
+ /**
+ * Cancels given runnable.
+ *
+ * @param w Worker to cancel - it's no-op if runnable is {@code null}.
+ */
+ public static void cancel(@Nullable GridWorker w) {
+ if (w != null)
+ w.cancel();
+ }
+
+ /**
+ * Cancels collection of runnables.
+ *
+ * @param ws Collection of workers - it's no-op if collection is {@code
null}.
+ */
+ public static void cancel(Iterable<? extends GridWorker> ws) {
+ if (ws != null)
+ for (GridWorker w : ws)
+ w.cancel();
+ }
+
+ /**
+ * Joins runnable.
+ *
+ * @param w Worker to join.
+ * @param log The logger to possible exception.
+ * @return {@code true} if worker has not been interrupted, {@code false}
if it was interrupted.
+ */
+ public static boolean join(@Nullable GridWorker w, @Nullable IgniteLogger
log) {
+ if (w != null)
+ try {
+ w.join();
+ }
+ catch (InterruptedException ignore) {
+ warn(log, "Got interrupted while waiting for completion of
runnable: " + w);
+
+ Thread.currentThread().interrupt();
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Joins given collection of runnables.
+ *
+ * @param ws Collection of workers to join.
+ * @param log The logger to possible exceptions.
+ * @return {@code true} if none of the worker have been interrupted,
+ * {@code false} if at least one was interrupted.
+ */
+ public static boolean join(Iterable<? extends GridWorker> ws, IgniteLogger
log) {
+ boolean retval = true;
+
+ if (ws != null)
+ for (GridWorker w : ws)
+ if (!join(w, log))
+ retval = false;
+
+ return retval;
+ }
+
+ /**
+ * Creates thread with given worker.
+ *
+ * @param worker Runnable to create thread with.
+ */
+ public static IgniteThread newThread(GridWorker worker) {
+ return new IgniteThread(worker.igniteInstanceName(), worker.name(),
worker);
+ }
+
+ /**
+ * Sleeps for given number of milliseconds.
+ *
+ * @param ms Time to sleep.
+ * @throws IgniteInterruptedCheckedException Wrapped {@link
InterruptedException}.
+ */
+ public static void sleep(long ms) throws IgniteInterruptedCheckedException
{
+ try {
+ Thread.sleep(ms);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+
+ throw new IgniteInterruptedCheckedException(e);
+ }
+ }
+
+ /**
+ * Safely write buffer fully to blocking socket channel.
+ * Will throw assert if non blocking channel passed.
+ *
+ * @param sockCh WritableByteChannel.
+ * @param buf Buffer.
+ * @throws IOException IOException.
+ */
+ public static void writeFully(SocketChannel sockCh, ByteBuffer buf) throws
IOException {
+ int totalWritten = 0;
+
+ assert sockCh.isBlocking() : "SocketChannel should be in blocking mode
" + sockCh;
+
+ while (buf.hasRemaining()) {
+ int written = sockCh.write(buf);
+
+ if (written < 0)
+ throw new IOException("Error writing buffer to channel " +
+ "[written = " + written + ", buf " + buf + ", totalWritten
= " + totalWritten + "]");
+
+ totalWritten += written;
+ }
+ }
+
+ /**
+ * @param a First byte array.
+ * @param aOff First byte array offset.
+ * @param b Second byte array.
+ * @param bOff Second byte array offset.
+ * @param len Number of bytes to compare.
+ * @return {@code True} if the specified sub-arrays are equal.
+ */
+ public static boolean bytesEqual(byte[] a, int aOff, byte[] b, int bOff,
int len) {
+ if (aOff + len > a.length || bOff + len > b.length)
+ return false;
+ else {
+ for (int i = 0; i < len; i++)
+ if (a[aOff + i] != b[bOff + i])
+ return false;
+
+ return true;
+ }
+ }
+
+ /**
+ * Concatenates the two parameter bytes to form a message type value.
+ *
+ * @param b0 The first byte.
+ * @param b1 The second byte.
+ * @return Message type.
+ */
+ public static short makeMessageType(byte b0, byte b1) {
+ return (short)((b1 & 0xFF) << 8 | b0 & 0xFF);
+ }
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridLongList.java
similarity index 99%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/GridLongList.java
index 27f5dfc13b5..ba69dcaba6d 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLongList.java
+++
b/modules/commons/src/main/java/org/apache/ignite/internal/util/GridLongList.java
@@ -26,7 +26,7 @@ import java.util.NoSuchElementException;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.SB;
-import static org.apache.ignite.internal.util.IgniteUtils.EMPTY_LONGS;
+import static org.apache.ignite.internal.util.CommonUtils.EMPTY_LONGS;
/**
* Minimal list API to work with primitive longs. This list exists
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
similarity index 92%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index 28e25449210..2b3abd84230 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++
b/modules/commons/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@ -26,16 +26,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Supplier;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.IgniteFutureCancelledCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
-import
org.apache.ignite.internal.processors.cache.distributed.near.consistency.IgniteConsistencyViolationException;
-import
org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteReducer;
import org.jetbrains.annotations.Nullable;
@@ -117,17 +113,14 @@ public class GridCompoundFuture<T, R> extends
GridFutureAdapter<R> implements Ig
throw e;
}
}
- catch (IgniteTxOptimisticCheckedException |
IgniteFutureCancelledCheckedException |
- ClusterTopologyCheckedException |
IgniteConsistencyViolationException e) {
- if (!processFailure(e, fut))
- onDone(e);
- }
catch (IgniteCheckedException e) {
if (!processFailure(e, fut)) {
- if (e instanceof NodeStoppingException)
- logDebug(logger(), "Failed to execute compound future
reducer, node stopped.");
- else
- logError(null, "Failed to execute compound future reducer:
" + this, e);
+ if (!(e instanceof SkipLoggingException)) {
+ if (e instanceof NodeStoppingException)
+ logDebug(logger(), "Failed to execute compound future
reducer, node stopped.");
+ else
+ logError(null, "Failed to execute compound future
reducer: " + this, e);
+ }
onDone(e);
}
@@ -370,7 +363,7 @@ public class GridCompoundFuture<T, R> extends
GridFutureAdapter<R> implements Ig
* @param e Exception.
*/
protected void logError(IgniteLogger log, String msg, Throwable e) {
- U.error(log, msg, e);
+ CommonUtils.error(log, msg, e);
}
/**
@@ -425,4 +418,9 @@ public class GridCompoundFuture<T, R> extends
GridFutureAdapter<R> implements Ig
F.viewReadOnly(futures(), (IgniteInternalFuture<T> f) ->
Boolean.toString(f.isDone()))
);
}
+
+ /** */
+ public interface SkipLoggingException {
+ // No-op marker interface.
+ }
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteInClosure2X.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/lang/IgniteInClosure2X.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/lang/IgniteInClosure2X.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/lang/IgniteInClosure2X.java
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/typedef/CIX2.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/CIX2.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/typedef/CIX2.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/typedef/CIX2.java
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
similarity index 96%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
index e19e2170aa1..414b8dac3c7 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
+++
b/modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
@@ -24,9 +24,9 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import org.apache.ignite.IgniteInterruptedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
/**
@@ -140,9 +140,10 @@ public abstract class GridWorker implements Runnable,
WorkProgressDispatcher {
if (!X.hasCause(e, InterruptedException.class) &&
!X.hasCause(e, IgniteInterruptedCheckedException.class) &&
!X.hasCause(e, IgniteInterruptedException.class))
- U.error(log, "Runtime error caught during grid runnable
execution: " + this, e);
+ CommonUtils.error(log, "Runtime error caught during grid
runnable execution: " + this, e);
else
- U.warn(log, "Runtime exception occurred during grid runnable
execution caused by thread interruption: " + e.getMessage());
+ CommonUtils.warn(log,
+ "Runtime exception occurred during grid runnable execution
caused by thread interruption: " + e.getMessage());
if (e instanceof Error)
throw e;
@@ -271,7 +272,7 @@ public abstract class GridWorker implements Runnable,
WorkProgressDispatcher {
/** {@inheritDoc} */
@Override public void updateHeartbeat() {
- long curTs = U.currentTimeMillis();
+ long curTs = CommonUtils.currentTimeMillis();
long hbTs = heartbeatTs;
// Avoid heartbeat update while in the blocking section.
@@ -290,7 +291,7 @@ public abstract class GridWorker implements Runnable,
WorkProgressDispatcher {
/** {@inheritDoc} */
@Override public void blockingSectionEnd() {
- heartbeatTs = U.currentTimeMillis();
+ heartbeatTs = CommonUtils.currentTimeMillis();
}
/** Can be called from {@link #runner()} thread to perform idleness
handling. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerListener.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerListener.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerListener.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerListener.java
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerPool.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerPool.java
similarity index 95%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerPool.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerPool.java
index 83f8fd8a308..51b6a97bd32 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerPool.java
+++
b/modules/commons/src/main/java/org/apache/ignite/internal/util/worker/GridWorkerPool.java
@@ -23,8 +23,8 @@ import java.util.concurrent.RejectedExecutionException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.compute.ComputeExecutionRejectedException;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
-import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Pool of runnable workers. This class automatically takes care of
@@ -102,9 +102,9 @@ public class GridWorkerPool {
for (GridWorker worker : workers) {
try {
if (cancel)
- U.cancel(worker);
+ CommonUtils.cancel(worker);
- U.join(worker, log);
+ CommonUtils.join(worker, log);
}
catch (Exception e) {
if (log != null)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/WorkProgressDispatcher.java
b/modules/commons/src/main/java/org/apache/ignite/internal/util/worker/WorkProgressDispatcher.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/internal/util/worker/WorkProgressDispatcher.java
rename to
modules/commons/src/main/java/org/apache/ignite/internal/util/worker/WorkProgressDispatcher.java
diff --git
a/modules/core/src/main/java/org/apache/ignite/util/deque/FastSizeDeque.java
b/modules/commons/src/main/java/org/apache/ignite/util/deque/FastSizeDeque.java
similarity index 100%
rename from
modules/core/src/main/java/org/apache/ignite/util/deque/FastSizeDeque.java
rename to
modules/commons/src/main/java/org/apache/ignite/util/deque/FastSizeDeque.java
diff --git
a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 18b3e0f86fb..430f5bfbf73 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -133,8 +133,6 @@ import static
org.apache.ignite.internal.thread.pool.IgniteStripedExecutor.DFLT_
import static
org.apache.ignite.internal.util.GridReflectionCache.DFLT_REFLECTION_CACHE_SIZE;
import static
org.apache.ignite.internal.util.IgniteExceptionRegistry.DEFAULT_QUEUE_SIZE;
import static
org.apache.ignite.internal.util.IgniteUtils.DFLT_MBEAN_APPEND_CLASS_LOADER_ID;
-import static
org.apache.ignite.internal.util.nio.GridNioRecoveryDescriptor.DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT;
-import static
org.apache.ignite.internal.util.nio.GridNioServer.DFLT_IO_BALANCE_PERIOD;
import static
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE;
import static
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_DISCOVERY_METRICS_QNT_WARN;
import static
org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.DFLT_DISCO_FAILED_CLIENT_RECONNECT_DELAY;
@@ -807,19 +805,6 @@ public final class IgniteSystemProperties extends
IgniteCommonsSystemProperties
@SystemProperty("Enables local store keeps primary only. Backward
compatibility flag")
public static final String IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY =
"IGNITE_LOCAL_STORE_KEEPS_PRIMARY_ONLY";
- /**
- * If set to {@code true}, then default selected keys set is used inside
- * {@code GridNioServer} which lead to some extra garbage generation when
- * processing selected keys.
- * <p>
- * Default value is {@code false}. Should be switched to {@code true} if
there are
- * any problems in communication layer.
- */
- @SystemProperty("Enables default selected keys set to be used inside
GridNioServer " +
- "which lead to some extra garbage generation when processing selected
keys. " +
- "Should be switched to true if there are any problems in communication
layer")
- public static final String IGNITE_NO_SELECTOR_OPTS =
"IGNITE_NO_SELECTOR_OPTS";
-
/**
* System property to specify period in milliseconds between calls of the
SQL statements cache cleanup task.
* <p>
@@ -894,11 +879,6 @@ public final class IgniteSystemProperties extends
IgniteCommonsSystemProperties
+ "when resolving local node's addresses", defaults = "true")
public static final String IGNITE_IGNORE_LOCAL_HOST_NAME =
"IGNITE_IGNORE_LOCAL_HOST_NAME";
- /** */
- @SystemProperty(value = "IO balance period in milliseconds", type =
Long.class,
- defaults = "" + DFLT_IO_BALANCE_PERIOD)
- public static final String IGNITE_IO_BALANCE_PERIOD =
"IGNITE_IO_BALANCE_PERIOD";
-
/**
* When set to {@code true} BinaryObject will be unwrapped before passing
to IndexingSpi to preserve
* old behavior query processor with IndexingSpi.
@@ -1319,13 +1299,6 @@ public final class IgniteSystemProperties extends
IgniteCommonsSystemProperties
public static final String
IGNITE_DISABLE_REBALANCING_CANCELLATION_OPTIMIZATION =
"IGNITE_DISABLE_REBALANCING_CANCELLATION_OPTIMIZATION";
- /**
- * Sets timeout for TCP client recovery descriptor reservation.
- */
- @SystemProperty(value = "Timeout for TCP client recovery descriptor
reservation in milliseconds",
- type = Long.class, defaults = "" +
DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT)
- public static final String
IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT =
- "IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT";
/**
* When set to {@code true}, Ignite will skip partitions sizes check on
partition validation after rebalance has finished.
diff --git
a/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
index 00c5413dd37..238f6ce8c48 100644
---
a/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
+++
b/modules/core/src/main/java/org/apache/ignite/configuration/ConnectorConfiguration.java
@@ -21,6 +21,7 @@ import java.net.Socket;
import javax.cache.configuration.Factory;
import javax.net.ssl.SSLContext;
import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.internal.util.nio.GridNioServer;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.ssl.SslContextFactory;
@@ -40,7 +41,7 @@ public class ConnectorConfiguration {
public static final boolean DFLT_TCP_DIRECT_BUF = false;
/** Default REST idle timeout. */
- public static final int DFLT_IDLE_TIMEOUT = 7000;
+ public static final int DFLT_IDLE_TIMEOUT =
GridNioServer.DFLT_IDLE_TIMEOUT;
/** Default rest port range. */
public static final int DFLT_PORT_RANGE = 100;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyCheckedException.java
b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyCheckedException.java
index bd194b7acba..8da622fbea3 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyCheckedException.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterTopologyCheckedException.java
@@ -19,12 +19,13 @@ package org.apache.ignite.internal.cluster;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
+import
org.apache.ignite.internal.util.future.GridCompoundFuture.SkipLoggingException;
import org.jetbrains.annotations.Nullable;
/**
* This exception is used to indicate error with grid topology (e.g., crashed
node, etc.).
*/
-public class ClusterTopologyCheckedException extends IgniteCheckedException {
+public class ClusterTopologyCheckedException extends IgniteCheckedException
implements SkipLoggingException {
/** */
private static final long serialVersionUID = 0L;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java
index 95c1a1ea4e1..de79781e076 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/consistency/IgniteConsistencyViolationException.java
@@ -20,11 +20,12 @@ package
org.apache.ignite.internal.processors.cache.distributed.near.consistency
import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import
org.apache.ignite.internal.util.future.GridCompoundFuture.SkipLoggingException;
/**
* Consistency violation exception.
*/
-public abstract class IgniteConsistencyViolationException extends
IgniteCheckedException {
+public abstract class IgniteConsistencyViolationException extends
IgniteCheckedException implements SkipLoggingException {
/**
* Inconsistent entries keys.
*/
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxOptimisticCheckedException.java
b/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxOptimisticCheckedException.java
index 9430dd7c200..0cc0ffd3665 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxOptimisticCheckedException.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/transactions/IgniteTxOptimisticCheckedException.java
@@ -17,10 +17,12 @@
package org.apache.ignite.internal.transactions;
+import
org.apache.ignite.internal.util.future.GridCompoundFuture.SkipLoggingException;
+
/**
* Exception thrown whenever grid transactions fail optimistically.
*/
-public class IgniteTxOptimisticCheckedException extends
TransactionCheckedException {
+public class IgniteTxOptimisticCheckedException extends
TransactionCheckedException implements SkipLoggingException {
/** */
private static final long serialVersionUID = 0L;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 2223082eca0..1f722faffc8 100755
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -65,7 +65,6 @@ import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileLock;
-import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
@@ -228,7 +227,6 @@ import org.apache.ignite.spi.discovery.DiscoverySpi;
import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
import org.apache.ignite.spi.discovery.DiscoverySpiOrderSupport;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.thread.IgniteThread;
import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.transactions.TransactionHeuristicException;
import org.apache.ignite.transactions.TransactionOptimisticException;
@@ -297,9 +295,6 @@ public abstract class IgniteUtils extends CommonUtils {
/** Empty integers array. */
public static final int[] EMPTY_INTS = new int[0];
- /** Empty longs array. */
- public static final long[] EMPTY_LONGS = new long[0];
-
/** Empty strings array. */
public static final String[] EMPTY_STRS = new String[0];
@@ -347,9 +342,6 @@ public abstract class IgniteUtils extends CommonUtils {
public static final String JMX_DOMAIN =
IgniteUtils.class.getName().substring(0, IgniteUtils.class.getName().
indexOf('.', IgniteUtils.class.getName().indexOf('.') + 1));
- /** Network packet header. */
- public static final byte[] IGNITE_HEADER = intToBytes(0x0149474E);
-
/** Default buffer size = 4K. */
private static final int BUF_SIZE = 4096;
@@ -2123,28 +2115,6 @@ public abstract class IgniteUtils extends CommonUtils {
return res;
}
- /**
- * Compares fragments of byte arrays.
- *
- * @param a First array.
- * @param aOff First array offset.
- * @param b Second array.
- * @param bOff Second array offset.
- * @param len Length of fragments.
- * @return {@code true} if fragments are equal, {@code false} otherwise.
- */
- public static boolean bytesEqual(byte[] a, int aOff, byte[] b, int bOff,
int len) {
- if (aOff + len > a.length || bOff + len > b.length)
- return false;
- else {
- for (int i = 0; i < len; i++)
- if (a[aOff + i] != b[bOff + i])
- return false;
-
- return true;
- }
- }
-
/**
* @param bytes Number of bytes to display.
* @param si If {@code true}, then unit base is 1000, otherwise unit base
is 1024.
@@ -3240,69 +3210,6 @@ public abstract class IgniteUtils extends CommonUtils {
return retval;
}
- /**
- * Cancels given runnable.
- *
- * @param w Worker to cancel - it's no-op if runnable is {@code null}.
- */
- public static void cancel(@Nullable GridWorker w) {
- if (w != null)
- w.cancel();
- }
-
- /**
- * Cancels collection of runnables.
- *
- * @param ws Collection of workers - it's no-op if collection is {@code
null}.
- */
- public static void cancel(Iterable<? extends GridWorker> ws) {
- if (ws != null)
- for (GridWorker w : ws)
- w.cancel();
- }
-
- /**
- * Joins runnable.
- *
- * @param w Worker to join.
- * @param log The logger to possible exception.
- * @return {@code true} if worker has not been interrupted, {@code false}
if it was interrupted.
- */
- public static boolean join(@Nullable GridWorker w, @Nullable IgniteLogger
log) {
- if (w != null)
- try {
- w.join();
- }
- catch (InterruptedException ignore) {
- warn(log, "Got interrupted while waiting for completion of
runnable: " + w);
-
- Thread.currentThread().interrupt();
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Joins given collection of runnables.
- *
- * @param ws Collection of workers to join.
- * @param log The logger to possible exceptions.
- * @return {@code true} if none of the worker have been interrupted,
- * {@code false} if at least one was interrupted.
- */
- public static boolean join(Iterable<? extends GridWorker> ws, IgniteLogger
log) {
- boolean retval = true;
-
- if (ws != null)
- for (GridWorker w : ws)
- if (!join(w, log))
- retval = false;
-
- return retval;
- }
-
/**
* Shutdowns given {@code ExecutorService} and wait for executor service
to stop.
*
@@ -5062,23 +4969,6 @@ public abstract class IgniteUtils extends CommonUtils {
Thread.currentThread().interrupt();
}
- /**
- * Sleeps for given number of milliseconds.
- *
- * @param ms Time to sleep.
- * @throws IgniteInterruptedCheckedException Wrapped {@link
InterruptedException}.
- */
- public static void sleep(long ms) throws IgniteInterruptedCheckedException
{
- try {
- Thread.sleep(ms);
- }
- catch (InterruptedException e) {
- Thread.currentThread().interrupt();
-
- throw new IgniteInterruptedCheckedException(e);
- }
- }
-
/**
* Joins worker.
*
@@ -7310,30 +7200,6 @@ public abstract class IgniteUtils extends CommonUtils {
};
}
- /**
- * Safely write buffer fully to blocking socket channel.
- * Will throw assert if non blocking channel passed.
- *
- * @param sockCh WritableByteChannel.
- * @param buf Buffer.
- * @throws IOException IOException.
- */
- public static void writeFully(SocketChannel sockCh, ByteBuffer buf) throws
IOException {
- int totalWritten = 0;
-
- assert sockCh.isBlocking() : "SocketChannel should be in blocking mode
" + sockCh;
-
- while (buf.hasRemaining()) {
- int written = sockCh.write(buf);
-
- if (written < 0)
- throw new IOException("Error writing buffer to channel " +
- "[written = " + written + ", buf " + buf + ", totalWritten
= " + totalWritten + "]");
-
- totalWritten += written;
- }
- }
-
/**
* @return New identity hash set.
*/
@@ -7841,15 +7707,6 @@ public abstract class IgniteUtils extends CommonUtils {
}
}
- /**
- * Creates thread with given worker.
- *
- * @param worker Runnable to create thread with.
- */
- public static IgniteThread newThread(GridWorker worker) {
- return new IgniteThread(worker.igniteInstanceName(), worker.name(),
worker);
- }
-
/** */
public static final IgniteDataTransferObjectSerializer<?>
EMPTY_DTO_SERIALIZER = new IgniteDataTransferObjectSerializer() {
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
index 79de224b777..267d43156f0 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
@@ -18,15 +18,15 @@
package org.apache.ignite.internal.util.nio;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Implements basic lifecycle for communication clients.
*/
public abstract class GridAbstractCommunicationClient implements
GridCommunicationClient {
/** Time when this client was last used. */
- private volatile long lastUsed = U.currentTimeMillis();
+ private volatile long lastUsed = CommonUtils.currentTimeMillis();
/** Reservations. */
private final AtomicBoolean closed = new AtomicBoolean();
@@ -73,14 +73,14 @@ public abstract class GridAbstractCommunicationClient
implements GridCommunicati
/** {@inheritDoc} */
@Override public long getIdleTime() {
- return U.currentTimeMillis() - lastUsed;
+ return CommonUtils.currentTimeMillis() - lastUsed;
}
/**
* Updates used time.
*/
protected void markUsed() {
- lastUsed = U.currentTimeMillis();
+ lastUsed = CommonUtils.currentTimeMillis();
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
index 3829aaa6aa0..49eca090eaa 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
@@ -22,15 +22,15 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.internal.LT;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
/**
* Verifies that first bytes received in accepted (incoming)
* NIO session are equal to {@link U#IGNITE_HEADER}.
* <p>
- * First {@code U.IGNITE_HEADER.length} bytes are consumed by this filter
+ * First {@code CommonUtils.IGNITE_HEADER.length} bytes are consumed by this
filter
* and all other bytes are forwarded through chain without any modification.
*/
public class GridConnectionBytesVerifyFilter extends GridNioFilterAdapter {
@@ -99,27 +99,27 @@ public class GridConnectionBytesVerifyFilter extends
GridNioFilterAdapter {
Integer magic = ses.meta(MAGIC_META_KEY);
- if (magic == null || magic < U.IGNITE_HEADER.length) {
+ if (magic == null || magic < CommonUtils.IGNITE_HEADER.length) {
byte[] magicBuf = ses.meta(MAGIC_BUF_KEY);
if (magicBuf == null)
- magicBuf = new byte[U.IGNITE_HEADER.length];
+ magicBuf = new byte[CommonUtils.IGNITE_HEADER.length];
int magicRead = magic == null ? 0 : magic;
int cnt = buf.remaining();
- buf.get(magicBuf, magicRead, Math.min(U.IGNITE_HEADER.length -
magicRead, cnt));
+ buf.get(magicBuf, magicRead,
Math.min(CommonUtils.IGNITE_HEADER.length - magicRead, cnt));
- if (cnt + magicRead < U.IGNITE_HEADER.length) {
+ if (cnt + magicRead < CommonUtils.IGNITE_HEADER.length) {
// Magic bytes are not fully read.
ses.addMeta(MAGIC_META_KEY, cnt + magicRead);
ses.addMeta(MAGIC_BUF_KEY, magicBuf);
}
- else if (U.bytesEqual(magicBuf, 0, U.IGNITE_HEADER, 0,
U.IGNITE_HEADER.length)) {
+ else if (CommonUtils.bytesEqual(magicBuf, 0,
CommonUtils.IGNITE_HEADER, 0, CommonUtils.IGNITE_HEADER.length)) {
// Magic bytes read and equal to IGNITE_HEADER.
ses.removeMeta(MAGIC_BUF_KEY);
- ses.addMeta(MAGIC_META_KEY, U.IGNITE_HEADER.length);
+ ses.addMeta(MAGIC_META_KEY, CommonUtils.IGNITE_HEADER.length);
proceedMessageReceived(ses, buf);
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
index faf416dfdbe..22601094b6d 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
@@ -23,13 +23,13 @@ import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.direct.DirectMessageReader;
-import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
import org.jetbrains.annotations.Nullable;
-import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
+import static org.apache.ignite.internal.util.CommonUtils.makeMessageType;
/**
* Parser for direct messages.
@@ -105,7 +105,7 @@ public class GridDirectParser implements GridNioParser {
}
}
catch (Throwable e) {
- U.error(log, "Failed to read message [msg=" + msg +
+ CommonUtils.error(log, "Failed to read message [msg=" + msg +
", buf=" + buf +
", reader=" + reader +
", ses=" + ses + "]",
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
index 3fb1ec5dd4a..4a5889f17df 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
@@ -22,7 +22,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.worker.GridWorker;
import org.apache.ignite.internal.util.worker.GridWorkerPool;
import org.apache.ignite.lang.IgniteInClosure;
@@ -144,7 +144,7 @@ public class GridNioAsyncNotifyFilter extends
GridNioFilterAdapter {
proceedExceptionCaught(ses, ex);
}
catch (IgniteCheckedException e) {
- U.warn(log, "Failed to forward exception to the underlying filter
(will ignore) [ses=" + ses + ", " +
+ CommonUtils.warn(log, "Failed to forward exception to the
underlying filter (will ignore) [ses=" + ses + ", " +
"originalEx=" + ex + ", ex=" + e + ']');
}
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
index 1cedb7d800e..4223821a42e 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
@@ -20,9 +20,9 @@ package org.apache.ignite.internal.util.nio;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
+import org.apache.ignite.IgniteCommonsSystemProperties;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -30,18 +30,16 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteInClosure;
import org.jetbrains.annotations.Nullable;
-import static
org.apache.ignite.IgniteSystemProperties.IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT;
+import static
org.apache.ignite.IgniteCommonsSystemProperties.DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT;
+import static
org.apache.ignite.IgniteCommonsSystemProperties.IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT;
/**
* Recovery information for single node.
*/
public class GridNioRecoveryDescriptor {
- /** @see
IgniteSystemProperties#IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT */
- public static final int DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT =
5_000;
-
/** Timeout for outgoing recovery descriptor reservation. */
private static final long DESC_RESERVATION_TIMEOUT = Math.max(1_000,
-
IgniteSystemProperties.getLong(IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT,
+
IgniteCommonsSystemProperties.getLong(IGNITE_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT,
DFLT_NIO_RECOVERY_DESCRIPTOR_RESERVATION_TIMEOUT));
/** Number of acknowledged messages. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index 2668427f424..290d115939c 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -49,9 +49,9 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.LongConsumer;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteCommonsSystemProperties;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.tracing.Span;
import org.apache.ignite.internal.processors.tracing.SpanManager;
import org.apache.ignite.internal.processors.tracing.SpanTags;
import org.apache.ignite.internal.processors.tracing.SpanType;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
@@ -76,7 +77,6 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.LT;
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.internal.util.worker.GridWorkerListener;
import org.apache.ignite.lang.IgniteBiInClosure;
@@ -117,6 +117,9 @@ public class GridNioServer<T> {
/** Default session write timeout. */
public static final int DFLT_SES_WRITE_TIMEOUT = 5000;
+ /** Default value for {@code idleTimeout} (in milliseconds). */
+ public static final int DFLT_IDLE_TIMEOUT = 7000;
+
/** Default send queue limit. */
public static final int DFLT_SEND_QUEUE_LIMIT = 0;
@@ -143,10 +146,7 @@ public class GridNioServer<T> {
/** */
private static final boolean DISABLE_KEYSET_OPTIMIZATION =
-
IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_NO_SELECTOR_OPTS);
-
- /** @see IgniteSystemProperties#IGNITE_IO_BALANCE_PERIOD */
- public static final int DFLT_IO_BALANCE_PERIOD = 5000;
+
IgniteCommonsSystemProperties.getBoolean(IgniteCommonsSystemProperties.IGNITE_NO_SELECTOR_OPTS);
/** */
public static final String OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME =
"outboundMessagesQueueSize";
@@ -441,7 +441,7 @@ public class GridNioServer<T> {
clientWorkers.add(worker);
- clientThreads[i] = U.newThread(worker);
+ clientThreads[i] = CommonUtils.newThread(worker);
clientThreads[i].setDaemon(daemon);
}
@@ -451,13 +451,13 @@ public class GridNioServer<T> {
this.skipRecoveryPred = skipRecoveryPred != null ? skipRecoveryPred :
F.<Message>alwaysFalse();
- long balancePeriod = IgniteSystemProperties.getLong(
- IgniteSystemProperties.IGNITE_IO_BALANCE_PERIOD,
DFLT_IO_BALANCE_PERIOD);
+ long balancePeriod = IgniteCommonsSystemProperties.getLong(
+ IgniteCommonsSystemProperties.IGNITE_IO_BALANCE_PERIOD,
IgniteCommonsSystemProperties.DFLT_IO_BALANCE_PERIOD);
IgniteRunnable balancer0 = null;
if (balancePeriod > 0) {
- boolean rndBalance =
IgniteSystemProperties.getBoolean(IGNITE_IO_BALANCE_RANDOM_BALANCE, false);
+ boolean rndBalance =
IgniteCommonsSystemProperties.getBoolean(IGNITE_IO_BALANCE_RANDOM_BALANCE,
false);
if (rndBalance)
balancer0 = new RandomBalancer();
@@ -515,7 +515,7 @@ public class GridNioServer<T> {
filterChain.start();
if (acceptWorker != null)
- U.newThread(acceptWorker).start();
+ CommonUtils.newThread(acceptWorker).start();
for (IgniteThread thread : clientThreads)
thread.start();
@@ -529,11 +529,11 @@ public class GridNioServer<T> {
closed = true;
// Make sure to entirely stop acceptor if any.
- U.cancel(acceptWorker);
- U.join(acceptWorker, log);
+ CommonUtils.cancel(acceptWorker);
+ CommonUtils.join(acceptWorker, log);
- U.cancel(clientWorkers);
- U.join(clientWorkers, log);
+ CommonUtils.cancel(clientWorkers);
+ CommonUtils.join(clientWorkers, log);
filterChain.stop();
@@ -775,7 +775,8 @@ public class GridNioServer<T> {
ses0.offerStateChange((GridNioServer.SessionChangeRequest)fut0);
}
catch (IgniteCheckedException e) {
- U.error(log, "Failed to notify NIO Server while resending
messages [rmtNode=" + recoveryDesc.node().id() + ']', e);
+ CommonUtils.error(log,
+ "Failed to notify NIO Server while resending messages
[rmtNode=" + recoveryDesc.node().id() + ']', e);
}
}
}
@@ -862,7 +863,7 @@ public class GridNioServer<T> {
if (!F.isEmpty(msg)) {
synchronized (sb) {
if (sb.length() > 0)
- sb.append(U.nl());
+ sb.append(CommonUtils.nl());
sb.append(msg);
}
@@ -912,7 +913,7 @@ public class GridNioServer<T> {
if (!F.isEmpty(msg)) {
synchronized (sb) {
if (sb.length() > 0)
- sb.append(U.nl());
+ sb.append(CommonUtils.nl());
sb.append(msg);
}
@@ -1037,7 +1038,7 @@ public class GridNioServer<T> {
/**
* Gets configurable idle timeout for this session. If not set, default
value is
- * {@link ConnectorConfiguration#DFLT_IDLE_TIMEOUT}.
+ * {@link #DFLT_IDLE_TIMEOUT}.
*
* @return Idle timeout in milliseconds.
*/
@@ -1091,8 +1092,8 @@ public class GridNioServer<T> {
return selector;
}
catch (Throwable e) {
- U.close(srvrCh, log);
- U.close(selector, log);
+ CommonUtils.close(srvrCh, log);
+ CommonUtils.close(selector, log);
if (e instanceof Error)
throw (Error)e;
@@ -1209,10 +1210,10 @@ public class GridNioServer<T> {
@Override protected void processRead(SelectionKey key) throws
IOException {
if (skipRead) {
try {
- U.sleep(50);
+ CommonUtils.sleep(50);
}
catch (IgniteInterruptedCheckedException ignored) {
- U.warn(log, "Sleep has been interrupted.");
+ CommonUtils.warn(log, "Sleep has been interrupted.");
}
return;
@@ -1318,7 +1319,7 @@ public class GridNioServer<T> {
else {
// For test purposes only (skipWrite is set to true in
tests only).
try {
- U.sleep(50);
+ CommonUtils.sleep(50);
}
catch (IgniteInterruptedCheckedException e) {
throw new IOException("Thread has been interrupted.",
e);
@@ -1378,10 +1379,10 @@ public class GridNioServer<T> {
@Override protected void processRead(SelectionKey key) throws
IOException {
if (skipRead) {
try {
- U.sleep(50);
+ CommonUtils.sleep(50);
}
catch (IgniteInterruptedCheckedException ignored) {
- U.warn(log, "Sleep has been interrupted.");
+ CommonUtils.warn(log, "Sleep has been interrupted.");
}
return;
@@ -1579,7 +1580,7 @@ public class GridNioServer<T> {
else {
// For test purposes only (skipWrite is set to true in
tests only).
try {
- U.sleep(50);
+ CommonUtils.sleep(50);
}
catch (IgniteInterruptedCheckedException e) {
throw new IOException("Thread has been
interrupted.", e);
@@ -1780,7 +1781,7 @@ public class GridNioServer<T> {
else {
// For test purposes only (skipWrite is set to true in tests
only).
try {
- U.sleep(50);
+ CommonUtils.sleep(50);
}
catch (IgniteInterruptedCheckedException e) {
throw new IOException("Thread has been interrupted.", e);
@@ -1975,10 +1976,10 @@ public class GridNioServer<T> {
}
catch (IgniteCheckedException e) {
if (!Thread.currentThread().isInterrupted()) {
- U.error(log, "Failed to read data from remote
connection (will wait for " +
+ CommonUtils.error(log, "Failed to read data from
remote connection (will wait for " +
ERR_WAIT_TIME + "ms).", e);
- U.sleep(ERR_WAIT_TIME);
+ CommonUtils.sleep(ERR_WAIT_TIME);
reset = true;
}
@@ -1986,7 +1987,7 @@ public class GridNioServer<T> {
}
}
catch (Throwable e) {
- U.error(log, "Caught unhandled exception in NIO worker thread
(restart the node).", e);
+ CommonUtils.error(log, "Caught unhandled exception in NIO
worker thread (restart the node).", e);
err = e;
@@ -2026,7 +2027,7 @@ public class GridNioServer<T> {
SelectedSelectionKeySet selectedKeySet = new
SelectedSelectionKeySet();
Class<?> selectorImplCls =
- Class.forName("sun.nio.ch.SelectorImpl", false,
U.gridClassLoader());
+ Class.forName("sun.nio.ch.SelectorImpl", false,
CommonUtils.gridClassLoader());
// Ensure the current selector implementation is what we can
instrument.
if (!selectorImplCls.isAssignableFrom(selector.getClass()))
@@ -2108,7 +2109,7 @@ public class GridNioServer<T> {
*/
private void bodyInternal() throws IgniteCheckedException,
InterruptedException {
try {
- long lastIdleCheck = U.currentTimeMillis();
+ long lastIdleCheck = CommonUtils.currentTimeMillis();
while (selector.isOpen() && !(isCancelled() &&
changeReqs.isEmpty())) {
SessionChangeRequest req;
@@ -2142,7 +2143,7 @@ public class GridNioServer<T> {
break;
// Just in case we do busy selects.
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (now - lastIdleCheck > 2000) {
lastIdleCheck = now;
@@ -2191,7 +2192,7 @@ public class GridNioServer<T> {
select = false;
}
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (now - lastIdleCheck > 2000) {
lastIdleCheck = now;
@@ -2227,7 +2228,7 @@ public class GridNioServer<T> {
if (log.isDebugEnabled())
log.debug("Closing NIO selector.");
- U.close(selector, log);
+ CommonUtils.close(selector, log);
}
}
}
@@ -2260,7 +2261,7 @@ public class GridNioServer<T> {
if (key != null)
key.cancel();
- U.closeQuiet(ch);
+ CommonUtils.closeQuiet(ch);
req.onDone();
@@ -2442,7 +2443,7 @@ public class GridNioServer<T> {
.append(", bytesRcvd0=").append(bytesRcvd0)
.append(", bytesSent=").append(bytesSent)
.append(", bytesSent0=").append(bytesSent0)
- .append("]").append(U.nl());
+ .append("]").append(CommonUtils.nl());
}
/**
@@ -2608,7 +2609,7 @@ public class GridNioServer<T> {
}
catch (Exception | Error e) { // TODO IGNITE-2659.
try {
- U.sleep(1000);
+ CommonUtils.sleep(1000);
}
catch (IgniteInterruptedCheckedException ignore) {
// No-op.
@@ -2617,7 +2618,7 @@ public class GridNioServer<T> {
GridSelectorNioSessionImpl ses = attach.session();
if (!closed)
- U.error(log, "Failed to process selector key [ses=" +
ses + ']', e);
+ CommonUtils.error(log, "Failed to process selector key
[ses=" + ses + ']', e);
else if (log.isDebugEnabled())
log.debug("Failed to process selector key [ses=" + ses
+ ", err=" + e + ']');
@@ -2675,7 +2676,7 @@ public class GridNioServer<T> {
}
catch (Exception | Error e) { // TODO IGNITE-2659.
try {
- U.sleep(1000);
+ CommonUtils.sleep(1000);
}
catch (IgniteInterruptedCheckedException ignore) {
// No-op.
@@ -2684,7 +2685,7 @@ public class GridNioServer<T> {
GridSelectorNioSessionImpl ses = attach.session();
if (!closed)
- U.error(log, "Failed to process selector key [ses=" +
ses + ']', e);
+ CommonUtils.error(log, "Failed to process selector key
[ses=" + ses + ']', e);
else if (log.isDebugEnabled())
log.debug("Failed to process selector key [ses=" + ses
+ ", err=" + e + ']');
}
@@ -2697,7 +2698,7 @@ public class GridNioServer<T> {
* @param keys Keys registered to selector.
*/
private void checkIdle(Iterable<SelectionKey> keys) {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
for (SelectionKey key : keys) {
GridNioKeyAttachment attach =
(GridNioKeyAttachment)key.attachment();
@@ -2843,11 +2844,11 @@ public class GridNioServer<T> {
ses.onServerStopped();
}
catch (ClosedChannelException e) {
- U.warn(log, "Failed to register accepted socket channel to
selector (channel was closed): "
+ CommonUtils.warn(log, "Failed to register accepted socket
channel to selector (channel was closed): "
+ sock.getRemoteSocketAddress(), e);
}
catch (IOException e) {
- U.error(log, "Failed to get socket addresses.", e);
+ CommonUtils.error(log, "Failed to get socket addresses.", e);
}
}
@@ -2874,8 +2875,8 @@ public class GridNioServer<T> {
}
}
finally {
- U.close(key, log);
- U.close(sock, log);
+ CommonUtils.close(key, log);
+ CommonUtils.close(sock, log);
}
}
@@ -2904,11 +2905,11 @@ public class GridNioServer<T> {
if (e != null) {
// Print stack trace only if has runtime exception in it's
cause.
if (e.hasCause(IOException.class))
- U.warn(log, "Client disconnected abruptly due to network
connection loss or because " +
+ CommonUtils.warn(log, "Client disconnected abruptly due to
network connection loss or because " +
"the connection was left open on application shutdown.
[cls=" + e.getClass() +
", msg=" + e.getMessage() + ']');
else
- U.error(log, "Closing NIO session because of unhandled
exception.", e);
+ CommonUtils.error(log, "Closing NIO session because of
unhandled exception.", e);
}
sessions.remove(ses);
@@ -2996,7 +2997,7 @@ public class GridNioServer<T> {
register(sesFut);
}
catch (IOException e) {
- U.closeQuiet(ch);
+ CommonUtils.closeQuiet(ch);
sesFut.onDone(new GridNioException("Failed to connect to
node", e));
@@ -3105,10 +3106,10 @@ public class GridNioServer<T> {
}
catch (IgniteCheckedException e) {
if (!Thread.currentThread().isInterrupted()) {
- U.error(log, "Failed to accept remote connection
(will wait for " + ERR_WAIT_TIME + "ms).",
+ CommonUtils.error(log, "Failed to accept remote
connection (will wait for " + ERR_WAIT_TIME + "ms).",
e);
- U.sleep(ERR_WAIT_TIME);
+ CommonUtils.sleep(ERR_WAIT_TIME);
reset = true;
}
@@ -3197,12 +3198,12 @@ public class GridNioServer<T> {
// Close all channels registered with selector.
for (SelectionKey key : selector.keys())
- U.close(key.channel(), log);
+ CommonUtils.close(key.channel(), log);
if (log.isDebugEnabled())
log.debug("Closing NIO selector.");
- U.close(selector, log);
+ CommonUtils.close(selector, log);
}
}
@@ -3261,9 +3262,9 @@ public class GridNioServer<T> {
offerBalanced(new NioOperationFuture<>(sockCh, true, null),
null);
}
catch (IgniteCheckedException e) {
- U.warn(log, "Incoming connection was rejected [addr=" +
sockCh.socket().getRemoteSocketAddress() + ']', e);
+ CommonUtils.warn(log, "Incoming connection was rejected
[addr=" + sockCh.socket().getRemoteSocketAddress() + ']', e);
- U.close(sockCh, log);
+ CommonUtils.close(sockCh, log);
}
}
}
@@ -4321,7 +4322,7 @@ public class GridNioServer<T> {
/** {@inheritDoc} */
@Override public void run() {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (lastBalance + balancePeriod < now) {
lastBalance = now;
@@ -4384,9 +4385,9 @@ public class GridNioServer<T> {
long bytesSent0 = ses0.bytesSent0();
if (bytesSent0 < threshold &&
- (ses == null || delta > U.safeAbs(bytesSent0 -
sentDiff / 2))) {
+ (ses == null || delta >
CommonUtils.safeAbs(bytesSent0 - sentDiff / 2))) {
ses = ses0;
- delta = U.safeAbs(bytesSent0 - sentDiff / 2);
+ delta = CommonUtils.safeAbs(bytesSent0 - sentDiff
/ 2);
}
}
@@ -4417,9 +4418,9 @@ public class GridNioServer<T> {
long bytesRcvd0 = ses0.bytesReceived0();
if (bytesRcvd0 < threshold &&
- (ses == null || delta > U.safeAbs(bytesRcvd0 -
rcvdDiff / 2))) {
+ (ses == null || delta >
CommonUtils.safeAbs(bytesRcvd0 - rcvdDiff / 2))) {
ses = ses0;
- delta = U.safeAbs(bytesRcvd0 - rcvdDiff / 2);
+ delta = CommonUtils.safeAbs(bytesRcvd0 - rcvdDiff
/ 2);
}
}
@@ -4467,7 +4468,7 @@ public class GridNioServer<T> {
/** {@inheritDoc} */
@Override public void run() {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (lastBalance + balancePeriod < now) {
lastBalance = now;
@@ -4511,9 +4512,9 @@ public class GridNioServer<T> {
long bytesSent0 = ses0.bytesSent0();
if (bytesSent0 < threshold &&
- (ses == null || delta > U.safeAbs(bytesSent0 -
bytesDiff / 2))) {
+ (ses == null || delta >
CommonUtils.safeAbs(bytesSent0 - bytesDiff / 2))) {
ses = ses0;
- delta = U.safeAbs(bytesSent0 - bytesDiff / 2);
+ delta = CommonUtils.safeAbs(bytesSent0 - bytesDiff
/ 2);
}
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
index 0211eb85dca..56638bcefe9 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
@@ -24,10 +24,10 @@ import javax.net.ssl.SSLPeerUnverifiedException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.nio.ssl.GridSslMeta;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.jetbrains.annotations.Nullable;
@@ -103,7 +103,7 @@ public class GridNioSessionImpl implements GridNioSession {
this.rmtAddr = rmtAddr;
this.accepted = accepted;
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
sndSchedTime = now;
createTime = now;
@@ -317,7 +317,7 @@ public class GridNioSessionImpl implements GridNioSession {
bytesSent += cnt;
bytesSent0 += cnt;
- lastSndTime = U.currentTimeMillis();
+ lastSndTime = CommonUtils.currentTimeMillis();
}
/**
@@ -331,14 +331,14 @@ public class GridNioSessionImpl implements GridNioSession
{
bytesRcvd += cnt;
bytesRcvd0 += cnt;
- lastRcvTime = U.currentTimeMillis();
+ lastRcvTime = CommonUtils.currentTimeMillis();
}
/**
* Resets send schedule time to avoid multiple idle notifications.
*/
public void resetSendScheduleTime() {
- sndSchedTime = U.currentTimeMillis();
+ sndSchedTime = CommonUtils.currentTimeMillis();
}
/**
@@ -348,7 +348,7 @@ public class GridNioSessionImpl implements GridNioSession {
* {@code false} if session was already closed.
*/
public boolean setClosed() {
- return closeTime.compareAndSet(0, U.currentTimeMillis());
+ return closeTime.compareAndSet(0, CommonUtils.currentTimeMillis());
}
/**
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
index 4ff126fa4cf..f553f8d97e5 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
@@ -25,9 +25,9 @@ import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.lang.IgniteInClosure2X;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.jetbrains.annotations.Nullable;
@@ -135,7 +135,7 @@ public class GridTcpNioCommunicationClient extends
GridAbstractCommunicationClie
/** {@inheritDoc} */
@Override public long getIdleTime() {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
// Session can be used for receiving and sending.
return Math.min(Math.min(now - ses.lastReceiveTime(), now -
ses.lastSendScheduleTime()),
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index 1da7c8ab62a..bcf85808db7 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -28,8 +28,8 @@ import javax.net.ssl.SSLEngineResult.Status;
import javax.net.ssl.SSLException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.nio.GridNioException;
-import org.apache.ignite.internal.util.typedef.internal.U;
import static javax.net.ssl.SSLEngineResult.HandshakeStatus.FINISHED;
import static javax.net.ssl.SSLEngineResult.HandshakeStatus.NEED_TASK;
@@ -171,7 +171,7 @@ public class BlockingSslHandler {
case NEED_WRAP: {
// If the output buffer has remaining data, clear it.
if (outNetBuf.hasRemaining())
- U.warn(log, "Output net buffer has unsent bytes during
handshake (will clear). ");
+ CommonUtils.warn(log, "Output net buffer has unsent
bytes during handshake (will clear). ");
outNetBuf.clear();
@@ -301,7 +301,7 @@ public class BlockingSslHandler {
// If we received close_notify but not all bytes has been read
by SSL engine, print a warning.
if (buf.hasRemaining())
- U.warn(log, "Got unread bytes after receiving close_notify
message (will ignore).");
+ CommonUtils.warn(log, "Got unread bytes after receiving
close_notify message (will ignore).");
}
inNetBuf.clear();
@@ -539,7 +539,7 @@ public class BlockingSslHandler {
*/
private void writeNetBuffer() throws IgniteCheckedException {
try {
- U.writeFully(ch, outNetBuf);
+ CommonUtils.writeFully(ch, outNetBuf);
}
catch (IOException e) {
throw new IgniteCheckedException("Failed to write byte to
socket.", e);
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
index c6b5981471d..9abcae2ad56 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
@@ -28,13 +28,13 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.nio.GridNioException;
import org.apache.ignite.internal.util.nio.GridNioFilterAdapter;
import org.apache.ignite.internal.util.nio.GridNioSession;
import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.jetbrains.annotations.Nullable;
@@ -244,7 +244,7 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
long startTime = System.nanoTime();
- fut.listen(() ->
handshakeDuration.accept(U.nanosToMillis(System.nanoTime() - startTime)));
+ fut.listen(() ->
handshakeDuration.accept(CommonUtils.nanosToMillis(System.nanoTime() -
startTime)));
}
hnd.handshake();
@@ -253,7 +253,7 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
}
catch (SSLException e) {
onSessionOpenedException = e;
- U.error(log, "Failed to start SSL handshake (will close inbound
connection): " + ses, e);
+ CommonUtils.error(log, "Failed to start SSL handshake (will close
inbound connection): " + ses, e);
ses.close();
}
@@ -446,7 +446,7 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
hnd.writeNetBuffer(null);
}
catch (SSLException e) {
- U.warn(log, "Failed to shutdown SSL session gracefully (will force
close) [ex=" + e + ", ses=" + ses + ']');
+ CommonUtils.warn(log, "Failed to shutdown SSL session gracefully
(will force close) [ex=" + e + ", ses=" + ses + ']');
}
return proceedSessionClose(ses);
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
index 13cf4ab96be..0b225256c29 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
@@ -30,10 +30,10 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.nio.GridNioException;
import org.apache.ignite.internal.util.nio.GridNioSession;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.jetbrains.annotations.Nullable;
@@ -197,7 +197,7 @@ class GridNioSslHandler extends ReentrantLock {
if (log.isDebugEnabled())
log.debug("Entered handshake(): [handshakeStatus=" +
handshakeStatus + ", ses=" + ses + ']');
- long startTs = U.currentTimeMillis();
+ long startTs = CommonUtils.currentTimeMillis();
lock();
@@ -258,7 +258,7 @@ class GridNioSslHandler extends ReentrantLock {
case NEED_WRAP: {
// If the output buffer has remaining data, clear it.
if (outNetBuf.hasRemaining())
- U.warn(log, "Output net buffer has unsent bytes
during handshake (will clear): " + ses);
+ CommonUtils.warn(log, "Output net buffer has
unsent bytes during handshake (will clear): " + ses);
outNetBuf.clear();
@@ -287,7 +287,7 @@ class GridNioSslHandler extends ReentrantLock {
finally {
unlock();
- long elapsed = U.currentTimeMillis() - startTs;
+ long elapsed = CommonUtils.currentTimeMillis() - startTs;
if (elapsed > LONG_HANDSHAKE_THRESHOLD_MS && log.isInfoEnabled()) {
log.info("Handshake took too long: [millis=" + elapsed + ",
handshakeStatus=" + handshakeStatus +
@@ -334,7 +334,7 @@ class GridNioSslHandler extends ReentrantLock {
// If we received close_notify but not all bytes has been read
by SSL engine, print a warning.
if (buf.hasRemaining())
- U.warn(log, "Got unread bytes after receiving close_notify
message (will ignore): " + ses);
+ CommonUtils.warn(log, "Got unread bytes after receiving
close_notify message (will ignore): " + ses);
}
inNetBuf.clear();
diff --git
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 4bcae5a26a2..216219cb5a6 100755
---
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -1161,17 +1161,6 @@ public class TcpCommunicationSpi extends
TcpCommunicationConfigInitializer {
"]";
}
- /**
- * Concatenates the two parameter bytes to form a message type value.
- *
- * @param b0 The first byte.
- * @param b1 The second byte.
- * @return Message type.
- */
- public static short makeMessageType(byte b0, byte b1) {
- return (short)((b1 & 0xFF) << 8 | b0 & 0xFF);
- }
-
/**
* @param ignite Ignite.
*/
diff --git
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
index 7a609d2f7eb..612ef1418f2 100644
---
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
+++
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/TcpHandshakeExecutor.java
@@ -39,8 +39,8 @@ import
org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMess
import
org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMessageSerializer;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.internal.util.CommonUtils.makeMessageType;
import static
org.apache.ignite.plugin.extensions.communication.Message.DIRECT_TYPE_SIZE;
-import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
import static
org.apache.ignite.spi.communication.tcp.messages.RecoveryLastReceivedMessage.NEED_WAIT;
/**
diff --git
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java
index b8fc4714930..d054080e4c6 100644
---
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java
+++
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryIoSession.java
@@ -35,6 +35,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.direct.DirectMessageReader;
import org.apache.ignite.internal.direct.DirectMessageWriter;
import
org.apache.ignite.internal.managers.communication.UnknownMessageException;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
@@ -44,8 +45,6 @@ import
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
-
/**
* Handles I/O operations between discovery nodes in the cluster. This class
encapsulates the socket connection used
* by the {@link TcpDiscoverySpi} to exchange discovery protocol messages
between nodes.
@@ -150,7 +149,7 @@ public class TcpDiscoveryIoSession {
byte b0 = (byte)in.read();
byte b1 = (byte)in.read();
- short msgType = makeMessageType(b0, b1);
+ short msgType = CommonUtils.makeMessageType(b0, b1);
Message msg;
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityMessageSerializationTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityMessageSerializationTest.java
index 6ed6171d81a..4de9416c1ff 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityMessageSerializationTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/query/schema/message/QueryEntityMessageSerializationTest.java
@@ -44,8 +44,8 @@ import
org.apache.ignite.plugin.extensions.communication.MessageSerializer;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.internal.util.CommonUtils.makeMessageType;
import static org.apache.ignite.marshaller.Marshallers.jdk;
-import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
/** Test for serialization round-trip of {@link QueryEntityMessage} and {@link
QueryEntityExMessage}. */
public class QueryEntityMessageSerializationTest extends
GridCommonAbstractTest {
diff --git
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest.java
index d5add388704..25aa63f8188 100644
---
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest.java
@@ -30,7 +30,7 @@ import
org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Assert;
import org.junit.Test;
-import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
+import static org.apache.ignite.internal.util.CommonUtils.makeMessageType;
/**
* This test check that client sends only Node ID message type on connect.
diff --git
a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
index d29a73f7039..b33684d6abd 100644
---
a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
+++
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/DiscoveryMessageParser.java
@@ -27,13 +27,12 @@ import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
import org.apache.ignite.internal.direct.DirectMessageReader;
import org.apache.ignite.internal.direct.DirectMessageWriter;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
import org.apache.ignite.spi.IgniteSpiException;
-import static
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
-
/**
* Class is responsible for serializing discovery messages using RU-ready
{@link MessageSerializer} mechanism.
*/
@@ -104,7 +103,7 @@ public class DiscoveryMessageParser {
msgReader.setBuffer(msgBuf);
- Message msg = msgFactory.create(makeMessageType((byte)in.read(),
(byte)in.read()));
+ Message msg =
msgFactory.create(CommonUtils.makeMessageType((byte)in.read(),
(byte)in.read()));
MessageSerializer msgSer = msgFactory.serializer(msg.directType());
boolean finished;