${project.groupId}
ignite-codegen
@@ -360,6 +372,8 @@
${project.groupId}:ignite-binary-impl
${project.groupId}:ignite-grid-unsafe
${project.groupId}:ignite-thin-client-api
+ ${project.groupId}:ignite-thin-client-impl
+ ${project.groupId}:ignite-nio
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 b1c36a9015827..430f5bfbf734f 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -41,7 +41,6 @@
import org.apache.ignite.internal.processors.query.schema.SchemaIndexCachePartitionWorker;
import org.apache.ignite.internal.processors.rest.GridRestCommand;
import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.lang.IgniteExperimental;
import org.apache.ignite.mxbean.MetricsMxBean;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry;
@@ -134,8 +133,6 @@
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;
@@ -744,12 +741,6 @@ public final class IgniteSystemProperties extends IgniteCommonsSystemProperties
defaults = "" + DFLT_DISCOVERY_HISTORY_SIZE)
public static final String IGNITE_DISCOVERY_HISTORY_SIZE = "IGNITE_DISCOVERY_HISTORY_SIZE";
- /** Human-readable ID of a data center where the node is running. */
- @IgniteExperimental
- @SystemProperty(value = "Data Center ID where local node is running. Not required for a single Data Center deployments",
- type = String.class)
- public static final String IGNITE_DATA_CENTER_ID = "IGNITE_DATA_CENTER_ID";
-
/** Maximum number of discovery message history used to support client reconnect. */
@SystemProperty(value = "Maximum number of discovery message history used to support client reconnect",
type = Integer.class, defaults = "" + DFLT_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE)
@@ -814,44 +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";
- /** Defines path to the file that contains list of classes allowed to safe deserialization.*/
- @SystemProperty(value = "Path to the file that contains list of classes allowed to safe deserialization",
- type = String.class)
- public static final String IGNITE_MARSHALLER_WHITELIST = "IGNITE_MARSHALLER_WHITELIST";
-
- /** Defines path to the file that contains list of classes disallowed to safe deserialization.*/
- @SystemProperty(value = "Path to the file that contains list of classes disallowed to safe deserialization",
- type = String.class)
- public static final String IGNITE_MARSHALLER_BLACKLIST = "IGNITE_MARSHALLER_BLACKLIST";
-
- /**
- * If this parameter is set to true, Ignite will automatically configure an ObjectInputFilter instance for the
- * current JVM it is running in.
- * Default value is {@code true}.
- */
- @SystemProperty(
- value = "If this parameter is set to true, Ignite will automatically configure an ObjectInputFilter" +
- " instance for the current JVM it is running in. Filtering is based on class lists defined by the" +
- " `IGNITE_MARSHALLER_WHITELIST` and `IGNITE_MARSHALLER_BLACKLIST` system properties or their default values." +
- " Disabling it is not recommended because the Ignite host may be vulnerable to RCE attacks based on Java" +
- " serialization mechanisms",
- defaults = "true"
- )
- public static final String IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION = "IGNITE_ENABLE_OBJECT_INPUT_FILTER_AUTOCONFIGURATION";
-
- /**
- * 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.
- *
- * 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.
*
@@ -926,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.
@@ -1351,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/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 3c14f5d2615f0..78a776e50c5ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -37,12 +37,12 @@
import org.apache.ignite.failure.FailureType;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.processors.cache.GridCacheUtils;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
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.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.resources.IgniteInstanceResource;
@@ -117,7 +117,7 @@ public class RendezvousAffinityFunction implements AffinityFunction, Serializabl
* @return Mask to use in calculation when partitions count is power of 2.
*/
public static int calculateMask(int parts) {
- return (parts & (parts - 1)) == 0 ? parts - 1 : -1;
+ return CommonUtils.calculateMask(parts);
}
/**
@@ -129,13 +129,7 @@ public static int calculateMask(int parts) {
* @return Partition number for a given key.
*/
public static int calculatePartition(Object key, int mask, int parts) {
- if (mask >= 0) {
- int h;
-
- return ((h = key.hashCode()) ^ (h >>> 16)) & mask;
- }
-
- return U.safeAbs(key.hashCode() % parts);
+ return CommonUtils.calculatePartition(key, mask, parts);
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 4a8d52e81e770..ce1bc69c9b77d 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -52,10 +52,10 @@
import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.query.QueryUtils;
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.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteExperimental;
@@ -1984,7 +1984,7 @@ public CacheConfiguration setIndexedTypes(Class>... indexedTypes) {
qryEntities.add(newEntity);
// Set key configuration if needed.
- String affFieldName = CU.affinityFieldName(keyCls);
+ String affFieldName = BinaryUtils.affinityFieldName(keyCls);
if (affFieldName != null) {
CacheKeyConfiguration newKeyCfg = new CacheKeyConfiguration(newEntity.getKeyType(), affFieldName);
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java
index 8a993bcc5304d..9f5b62b25e729 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/ClientConnectorConfiguration.java
@@ -19,6 +19,7 @@
import javax.cache.configuration.Factory;
import javax.net.ssl.SSLContext;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.ssl.SslContextFactory;
@@ -29,10 +30,10 @@
*/
public class ClientConnectorConfiguration {
/** Default port. */
- public static final int DFLT_PORT = 10800;
+ public static final int DFLT_PORT = CommonUtils.DFLT_PORT;
/** Default port range. */
- public static final int DFLT_PORT_RANGE = 100;
+ public static final int DFLT_PORT_RANGE = CommonUtils.DFLT_PORT_RANGE;
/** Default socket send and receive buffer size. */
public static final int DFLT_SOCK_BUF_SIZE = 0;
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 00c5413dd374e..238f6ce8c48b2 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 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/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index fda923e3596db..2521be22a8e93 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -19,10 +19,12 @@
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -34,6 +36,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.function.BiPredicate;
+import java.util.function.Consumer;
import java.util.function.Function;
import javax.management.MBeanServer;
import org.apache.ignite.IgniteCheckedException;
@@ -125,7 +128,7 @@ public MarshallerContextImpl(@Nullable Collection plugins, Ignit
try {
ClassLoader ldr = U.gridClassLoader();
- MarshallerUtils.processSystemClasses(ldr, plugins, clsName -> {
+ processSystemClasses(ldr, plugins, clsName -> {
int typeId = clsName.hashCode();
MappedName oldClsName;
@@ -709,6 +712,29 @@ public void setMarshallerMappingFileStoreDir(@Nullable final File marshallerMapp
this.marshallerMappingFileStoreDir = marshallerMappingFileStoreDir;
}
+ /**
+ * Finds all system class names (JDK, Ignite and plugin classes) and processes them with the given consumer.
+ *
+ * @param ldr Class loader.
+ * @param plugins Plugins (may be {@code null}).
+ * @param proc Class processor (class name consumer).
+ * @throws IOException In case of error.
+ */
+ private static void processSystemClasses(ClassLoader ldr, @Nullable Collection plugins,
+ Consumer proc) throws IOException {
+ MarshallerUtils.processSystemClasses(ldr, proc);
+
+ if (plugins != null && !plugins.isEmpty()) {
+ for (PluginProvider plugin : plugins) {
+ Enumeration pluginUrls = ldr.getResources("META-INF/" + plugin.name().toLowerCase()
+ + ".classnames.properties");
+
+ while (pluginUrls.hasMoreElements())
+ MarshallerUtils.processResource(pluginUrls.nextElement(), proc);
+ }
+ }
+ }
+
/**
*
*/
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 bd194b7acba35..2b7fcab1d26fa 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
@@ -18,13 +18,14 @@
package org.apache.ignite.internal.cluster;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.ExpectedFailure;
import org.apache.ignite.internal.IgniteInternalFuture;
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 ExpectedFailure {
/** */
private static final long serialVersionUID = 0L;
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
index 619057cd6ce9d..64e1fb2f45c03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
@@ -2427,7 +2427,7 @@ private class JdbcMarshallerContext extends BlockingJdbcChannel implements Marsh
*/
public JdbcMarshallerContext() {
try {
- processSystemClasses(U.gridClassLoader(), null, sysTypes::add);
+ processSystemClasses(U.gridClassLoader(), sysTypes::add);
}
catch (IOException e) {
throw new IgniteException("Unable to initialize marshaller context", e);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/management/tx/FetchNearXidVersionTask.java b/modules/core/src/main/java/org/apache/ignite/internal/management/tx/FetchNearXidVersionTask.java
index 519dd55a7564d..7845fbf89982f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/management/tx/FetchNearXidVersionTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/management/tx/FetchNearXidVersionTask.java
@@ -23,6 +23,7 @@
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -78,7 +79,7 @@ public FetchNearXidVersionJob(TxInfoCommandArg arg, boolean debug) {
for (IgniteInternalTx tx : transactions) {
if (tx.xid().equals(arg.uuid()) ||
- tx.nearXidVersion().asIgniteUuid().equals(arg.uuid()) ||
+ BinaryUtils.asIgniteUuid(tx.nearXidVersion()).equals(arg.uuid()) ||
tx.xidVersion().equals(arg.gridCacheVersion()) ||
tx.nearXidVersion().equals(arg.gridCacheVersion()))
return tx.nearXidVersion();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/management/tx/TxTask.java b/modules/core/src/main/java/org/apache/ignite/internal/management/tx/TxTask.java
index ffd7a6a31ab98..4e07c6525f02c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/management/tx/TxTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/management/tx/TxTask.java
@@ -38,6 +38,7 @@
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.management.tx.TxCommand.AbstractTxCommandArg;
import org.apache.ignite.internal.managers.discovery.DiscoCache;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -351,7 +352,7 @@ else if (locTx instanceof GridDhtTxRemote) {
infos.add(new TxInfo(locTx.xid(), locTx.startTime(), duration, locTx.isolation(),
locTx.concurrency(), locTx.timeout(), lb, mappings, locTx.state(), size,
- locTx.nearXidVersion().asIgniteUuid(), locTx.masterNodeIds(), locTx.topologyVersionSnapshot(),
+ BinaryUtils.asIgniteUuid(locTx.nearXidVersion()), locTx.masterNodeIds(), locTx.topologyVersionSnapshot(),
verboseInfo));
if (arg.kill())
@@ -367,9 +368,9 @@ else if (locTx instanceof GridDhtTxRemote) {
if (completed != null) {
if (Boolean.TRUE.equals(completed))
- infos.add(new TxInfo(infoArg.gridCacheVersion().asIgniteUuid(), COMMITTED));
+ infos.add(new TxInfo(BinaryUtils.asIgniteUuid(infoArg.gridCacheVersion()), COMMITTED));
else if (Boolean.FALSE.equals(completed))
- infos.add(new TxInfo(infoArg.gridCacheVersion().asIgniteUuid(), ROLLED_BACK));
+ infos.add(new TxInfo(BinaryUtils.asIgniteUuid(infoArg.gridCacheVersion()), ROLLED_BACK));
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
index cb09122415def..846b3c721ea1f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
@@ -27,12 +27,13 @@
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageContainer;
import org.jetbrains.annotations.Nullable;
/**
* Wrapper for all grid messages.
*/
-public class GridIoMessage implements Message, SpanTransport {
+public class GridIoMessage implements Message, SpanTransport, MessageContainer {
/** */
public static final Integer STRIPE_DISABLED_PART = Integer.MIN_VALUE;
@@ -125,10 +126,8 @@ int topicOrdinal() {
return GridTopicMessage.ordinal(topicMsg);
}
- /**
- * @return Message.
- */
- public Message message() {
+ /** {@inheritDoc} */
+ @Override public Message message() {
return msg;
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/tracing/GridTracingManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/tracing/GridTracingManager.java
index 4e5e66e692452..4e0871024881c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/tracing/GridTracingManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/tracing/GridTracingManager.java
@@ -34,8 +34,10 @@
import org.apache.ignite.internal.processors.tracing.Tracing;
import org.apache.ignite.internal.processors.tracing.configuration.GridTracingConfigurationManager;
import org.apache.ignite.internal.processors.tracing.messages.TraceableMessagesHandler;
+import org.apache.ignite.internal.processors.tracing.messages.TraceableMessagesTable;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.logger.NullLogger;
+import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.tracing.NoopTracingSpi;
import org.apache.ignite.spi.tracing.Scope;
@@ -507,6 +509,11 @@ private Span enrichWithLocalNodeParameters(@Nullable Span span) {
}
}
+ /** {@inheritDoc} */
+ @Override public String traceName(Message msg) {
+ return TraceableMessagesTable.traceName(msg);
+ }
+
/** {@inheritDoc} */
@Override public TraceableMessagesHandler messages() {
// Optimization for noop spi.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
index 7c78a10a5cf48..b18f4ddef15b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheReturn.java
@@ -259,7 +259,8 @@ else if (err instanceof UnregisteredBinaryTypeException)
throw (UnregisteredBinaryTypeException)err;
}
- CacheInvokeResult res0 = err == null ? CacheInvokeResult.fromResult(res) : CacheInvokeResult.fromError(err);
+ CacheInvokeResult res0 = err == null ? CacheInvokeResult.fromResult(res)
+ : CacheInvokeResult.fromError(CU.prepareEntryProcessorError(err));
Object resKey = key0 != null ? key0 :
((keepBinary && key instanceof BinaryObject) ? key : CU.value(key, cctx, true));
@@ -367,7 +368,7 @@ public void finishUnmarshal(GridCacheContext ctx, ClassLoader ldr) throws Ignite
for (CacheInvokeDirectResult res : invokeResCol) {
CacheInvokeResult> res0 = res.error() == null ?
CacheInvokeResult.fromResult(ctx.cacheObjectContext().unwrapBinaryIfNeeded(res.result(), true, false, null)) :
- CacheInvokeResult.fromError(res.error());
+ CacheInvokeResult.fromError(CU.prepareEntryProcessorError(res.error()));
map0.put(ctx.cacheObjectContext().unwrapBinaryIfNeeded(res.key(), true, false, null), res0);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 9437762372485..ca13b67f54110 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.processors.cache;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -42,6 +41,7 @@
import javax.cache.integration.CacheLoader;
import javax.cache.integration.CacheWriter;
import javax.cache.integration.CacheWriterException;
+import javax.cache.processor.EntryProcessorException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
@@ -53,7 +53,6 @@
import org.apache.ignite.cache.CacheServerNotFoundException;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.affinity.AffinityFunction;
-import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cluster.ClusterNode;
@@ -67,6 +66,8 @@
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteNodeAttributes;
+import org.apache.ignite.internal.UnregisteredBinaryTypeException;
+import org.apache.ignite.internal.UnregisteredClassException;
import org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
@@ -2206,18 +2207,23 @@ public static Map affinityFields(@Nullable IgniteConfiguration c
}
/**
- * @param cls Class to get affinity field for.
- * @return Affinity field name or {@code null} if field name was not found.
+ * Prepares an entry processor error so it can be stored in a {@link CacheInvokeResult} and rethrown
+ * as-is by {@link CacheInvokeResult#get()}: an {@link UnregisteredClassException} or
+ * {@link UnregisteredBinaryTypeException} (which must propagate unwrapped) and an existing
+ * {@link EntryProcessorException} are returned unchanged; any other error is wrapped in an
+ * {@link EntryProcessorException}.
+ *
+ * @param err Error thrown by the entry processor.
+ * @return Prepared error to store in the cache invoke result.
*/
- public static String affinityFieldName(Class cls) {
- for (; cls != Object.class && cls != null; cls = cls.getSuperclass()) {
- for (Field f : cls.getDeclaredFields()) {
- if (f.getAnnotation(AffinityKeyMapped.class) != null)
- return f.getName();
- }
- }
+ public static Throwable prepareEntryProcessorError(Throwable err) {
+ if (err instanceof UnregisteredClassException || err instanceof UnregisteredBinaryTypeException)
+ return err;
- return null;
+ if (err instanceof EntryProcessorException)
+ return err;
+
+ return new EntryProcessorException(err);
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 2913263ed9d80..2e44c95fe2533 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -115,9 +115,9 @@
import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAIT_SCHEMA_UPDATE;
import static org.apache.ignite.IgniteSystemProperties.getBoolean;
import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.BINARY_PROC;
+import static org.apache.ignite.internal.binary.BinaryUtils.affinityFieldName;
import static org.apache.ignite.internal.binary.BinaryUtils.mergeMetadata;
import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName;
-import static org.apache.ignite.internal.util.typedef.internal.CU.affinityFieldName;
/**
* Binary processor implementation.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index fef43785bef3a..91d018e4c530f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -34,6 +34,7 @@
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheLockCandidates;
@@ -1219,7 +1220,7 @@ private String dumpPendingLocks() {
sb.append("Transaction tx=").append(tx.getClass().getSimpleName());
sb.append(" [xid=").append(tx.xid());
sb.append(", xidVer=").append(tx.xidVersion());
- sb.append(", nearXid=").append(tx.nearXidVersion().asIgniteUuid());
+ sb.append(", nearXid=").append(BinaryUtils.asIgniteUuid(tx.nearXidVersion()));
sb.append(", nearXidVer=").append(tx.nearXidVersion());
sb.append(", nearNodeId=").append(tx.nearNodeId());
sb.append(", label=").append(tx.label());
@@ -1245,7 +1246,7 @@ private String dumpPendingLocks() {
sb.append("key=").append(key).append(", owner=");
sb.append("[xid=").append(itx.xid()).append(", ");
sb.append("xidVer=").append(itx.xidVersion()).append(", ");
- sb.append("nearXid=").append(itx.nearXidVersion().asIgniteUuid()).append(", ");
+ sb.append("nearXid=").append(BinaryUtils.asIgniteUuid(itx.nearXidVersion())).append(", ");
sb.append("nearXidVer=").append(itx.nearXidVersion()).append(", ");
sb.append("label=").append(itx.label()).append(", ");
sb.append("nearNodeId=").append(candidate.otherNodeId()).append("]");
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index a214cba09be4e..44b463f923bec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -2236,7 +2236,7 @@ private void updateWithBatch(
throw e;
}
catch (Exception e) {
- curInvokeRes = CacheInvokeResult.fromError(e);
+ curInvokeRes = CacheInvokeResult.fromError(CU.prepareEntryProcessorError(e));
updated = old;
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 95c1a1ea4e1f8..9ba6ed7a6622b 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
@@ -19,12 +19,13 @@
import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.ExpectedFailure;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
/**
* Consistency violation exception.
*/
-public abstract class IgniteConsistencyViolationException extends IgniteCheckedException {
+public abstract class IgniteConsistencyViolationException extends IgniteCheckedException implements ExpectedFailure {
/**
* Inconsistent entries keys.
*/
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 193eb2a4e8ae0..c9a8890dbae62 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -41,6 +41,7 @@
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.TransactionStateChangedEvent;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.managers.discovery.ConsistentIdMapper;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -693,7 +694,7 @@ public boolean remote() {
/** {@inheritDoc} */
@Override public IgniteUuid xid() {
- return xidVer.asIgniteUuid();
+ return BinaryUtils.asIgniteUuid(xidVer);
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 5f81792151696..3496874f46003 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -137,13 +137,13 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
public static final String VOLATILE_GRP_NAME = DEFAULT_VOLATILE_DS_GROUP_NAME + "@" + VOLATILE_DATA_REGION_NAME;
/** */
- public static final String DEFAULT_DS_GROUP_NAME = "default-ds-group";
+ public static final String DEFAULT_DS_GROUP_NAME = DataStructuresConstants.DEFAULT_DS_GROUP_NAME;
/** */
private static final String DS_CACHE_NAME_PREFIX = "datastructures_";
/** Atomics system cache name. */
- public static final String ATOMICS_CACHE_NAME = "ignite-sys-atomic-cache";
+ public static final String ATOMICS_CACHE_NAME = DataStructuresConstants.ATOMICS_CACHE_NAME;
/** */
public static final String QUEUES_VIEW = metricName("ds", "queues");
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java
index 3d6f6ab75c3be..de9833824e0a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerNioListener.java
@@ -63,7 +63,7 @@ public class ClientListenerNioListener extends GridNioServerListenerAdapterbuilder()
+ GridNioServer.Builder builder = GridNioServer.builder()
.address(hostAddr)
.port(port)
.listener(new ClientListenerNioListener(ctx, busyLock, cliConnCfg, metrics, newConnEnabled))
@@ -210,9 +210,11 @@ public ClientListenerProcessor(GridKernalContext ctx) {
.filters(filters)
.directMode(true)
.idleTimeout(idleTimeout > 0 ? idleTimeout : Long.MAX_VALUE)
- .metricRegistry(mreg)
- .messageQueueSizeListener(msgQueueSizeLsnr)
- .build();
+ .messageQueueSizeListener(msgQueueSizeLsnr);
+
+ srv = U.setNioServerMetrics(builder, mreg).build();
+
+ U.registerNioServerMetrics(srv, filters, mreg);
ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
@@ -492,7 +494,7 @@ else if (connCtx.managementClient()) {
throw new IgniteCheckedException("Failed to create client listener " +
"(SSL is enabled but factory is null). Check the ClientConnectorConfiguration");
- GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtxFactory.create(),
+ GridNioSslFilter sslFilter = U.sslFilter(sslCtxFactory.create(),
true, ByteOrder.nativeOrder(), log, ctx.metric().registry(CLIENT_CONNECTOR_METRICS));
sslFilter.directMode(true);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java
index d7006f70a617f..a31679a1d6ee0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientListenerRequest.java
@@ -22,7 +22,7 @@
*/
public interface ClientListenerRequest {
/** Handshake request. */
- public static final int HANDSHAKE = 1;
+ public static final int HANDSHAKE = ClientListenerProtocol.HANDSHAKE;
/**
* @return Request ID.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientMessage.java
index ec592ad63f1c7..4e8a3a9187da3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/ClientMessage.java
@@ -24,10 +24,10 @@
import java.nio.ByteBuffer;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.SelfSerializingMessage;
/** */
-public class ClientMessage implements Message, Externalizable {
+public class ClientMessage implements SelfSerializingMessage, Externalizable {
/** */
private static final long serialVersionUID = -4609408156037304495L;
@@ -81,13 +81,8 @@ public ClientMessage(BinaryOutputStream stream) {
isFirstMessage = false;
}
- /**
- * Writes this message to provided byte buffer.
- *
- * @param buf Byte buffer.
- * @return Whether message was fully written.
- */
- public boolean writeTo(ByteBuffer buf) {
+ /** {@inheritDoc} */
+ @Override public boolean writeTo(ByteBuffer buf) {
assert stream != null || data != null;
byte[] data = stream != null ? stream.array() : this.data;
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
index bd15a26ff0a6a..837cab1666ca7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientRequestHandler.java
@@ -115,7 +115,7 @@ public class ClientRequestHandler implements ClientListenerRequestHandler {
return handle0(req);
}
catch (SecurityException ex) {
- throw IgniteClientException.wrapAuthorizationExeption(ex);
+ throw wrapAuthorizationExeption(ex);
}
}
@@ -229,4 +229,18 @@ private int getStatus(Throwable e) {
return ClientStatus.FAILED;
}
+
+ /**
+ * Wraps a security exception into a client authorization exception.
+ *
+ * @param e Security exception.
+ * @return Client exception.
+ */
+ public static IgniteClientException wrapAuthorizationExeption(SecurityException e) {
+ return new IgniteClientException(
+ ClientStatus.SECURITY_VIOLATION,
+ "Client is not authorized to perform this operation [errMsg=" + e.getMessage() + ']',
+ e
+ );
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheSqlFieldsQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheSqlFieldsQueryRequest.java
index 972184f9791bd..abc7ed4da0c8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheSqlFieldsQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheSqlFieldsQueryRequest.java
@@ -29,8 +29,8 @@
import org.apache.ignite.internal.processors.platform.client.ClientBitmaskFeature;
import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
import org.apache.ignite.internal.processors.platform.client.ClientProtocolContext;
+import org.apache.ignite.internal.processors.platform.client.ClientRequestHandler;
import org.apache.ignite.internal.processors.platform.client.ClientResponse;
-import org.apache.ignite.internal.processors.platform.client.IgniteClientException;
import org.apache.ignite.internal.processors.platform.client.tx.ClientTxAwareRequest;
import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.util.typedef.X;
@@ -174,7 +174,7 @@ public ClientCacheSqlFieldsQueryRequest(BinaryReaderEx reader,
SecurityException securityEx = X.cause(e, SecurityException.class);
if (securityEx != null)
- throw IgniteClientException.wrapAuthorizationExeption(securityEx);
+ throw ClientRequestHandler.wrapAuthorizationExeption(securityEx);
throw e;
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 332a7d1ab2780..21a16ba4d6151 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -1138,30 +1138,7 @@ public static boolean isSqlType(Class> cls) {
* @return Type name.
*/
public static String typeName(String clsName) {
- int genericStart = clsName.indexOf('`'); // .NET generic, not valid for Java class name.
-
- if (genericStart >= 0)
- clsName = clsName.substring(0, genericStart);
-
- int pkgEnd = clsName.lastIndexOf('.');
-
- if (pkgEnd >= 0 && pkgEnd < clsName.length() - 1)
- clsName = clsName.substring(pkgEnd + 1);
-
- if (clsName.endsWith("[]"))
- clsName = clsName.substring(0, clsName.length() - 2) + "_array";
-
- int parentEnd = clsName.lastIndexOf('$');
-
- if (parentEnd >= 0)
- clsName = clsName.substring(parentEnd + 1);
-
- parentEnd = clsName.lastIndexOf('+'); // .NET parent
-
- if (parentEnd >= 0)
- clsName = clsName.substring(parentEnd + 1);
-
- return clsName;
+ return CommonUtils.typeName(clsName);
}
/**
@@ -1171,22 +1148,7 @@ public static String typeName(String clsName) {
* @return Type name.
*/
public static String typeName(Class> cls) {
- String typeName = cls.getSimpleName();
-
- // To protect from failure on anonymous classes.
- if (F.isEmpty(typeName)) {
- String pkg = cls.getPackage().getName();
-
- typeName = cls.getName().substring(pkg.length() + (pkg.isEmpty() ? 0 : 1));
- }
-
- if (cls.isArray()) {
- assert typeName.endsWith("[]");
-
- typeName = typeName.substring(0, typeName.length() - 2) + "_array";
- }
-
- return typeName;
+ return CommonUtils.typeName(cls);
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
index a1aaa0910dd55..38c0ef625e44e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
@@ -36,6 +36,7 @@
import org.apache.ignite.internal.client.marshaller.jdk.GridClientJdkMarshaller;
import org.apache.ignite.internal.client.marshaller.optimized.GridClientOptimizedMarshaller;
import org.apache.ignite.internal.client.marshaller.optimized.GridClientZipOptimizedMarshaller;
+import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
import org.apache.ignite.internal.processors.rest.client.message.GridClientMessage;
import org.apache.ignite.internal.processors.rest.protocols.GridRestProtocolAdapter;
@@ -209,7 +210,7 @@ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerList
GridNioFilter[] filters;
if (sslCtx != null) {
- GridNioSslFilter sslFilter = new GridNioSslFilter(
+ GridNioSslFilter sslFilter = U.sslFilter(
sslCtx,
cfg.isDirectBuffer(),
ByteOrder.nativeOrder(),
@@ -232,7 +233,9 @@ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerList
else
filters = new GridNioFilter[] { codec };
- srv = GridNioServer.builder()
+ MetricRegistryImpl mreg = ctx.metric().registry(REST_CONNECTOR_METRIC_REGISTRY_NAME);
+
+ GridNioServer.Builder builder = GridNioServer.builder()
.address(hostAddr)
.port(port)
.listener(lsnr)
@@ -247,9 +250,11 @@ private boolean startTcpServer(InetAddress hostAddr, int port, GridNioServerList
.socketReceiveBufferSize(cfg.getReceiveBufferSize())
.sendQueueLimit(cfg.getSendQueueLimit())
.filters(filters)
- .directMode(false)
- .metricRegistry(ctx.metric().registry(REST_CONNECTOR_METRIC_REGISTRY_NAME))
- .build();
+ .directMode(false);
+
+ srv = U.setNioServerMetrics(builder, mreg).build();
+
+ U.registerNioServerMetrics(srv, filters, mreg);
srv.idleTimeout(cfg.getIdleTimeout());
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/NoopTracing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/NoopTracing.java
index 77563757c5742..c7cd10f562629 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/NoopTracing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/tracing/NoopTracing.java
@@ -22,15 +22,11 @@
import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.spi.tracing.TracingConfigurationManager;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
/**
* Noop implementation of {@link Tracing}.
*/
-public class NoopTracing implements Tracing {
- /** Noop serialized span. */
- public static final byte[] NOOP_SERIALIZED_SPAN = new byte[0];
-
+public class NoopTracing extends NoopSpanManager implements Tracing {
/** Traceable messages handler. */
private final TraceableMessagesHandler msgHnd;
@@ -46,29 +42,6 @@ public NoopTracing() {
return msgHnd;
}
- /** {@inheritDoc} */
- @Override public Span create(@NotNull SpanType spanType, @Nullable Span parentSpan) {
- return NoopSpan.INSTANCE;
- }
-
- /** {@inheritDoc} */
- @Override public Span create(@NotNull SpanType spanType, @Nullable byte[] serializedParentSpan) {
- return NoopSpan.INSTANCE;
- }
-
- /** {@inheritDoc} */
- @Override public @NotNull Span create(
- @NotNull SpanType spanType,
- @Nullable Span parentSpan,
- @Nullable String label) {
- return NoopSpan.INSTANCE;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] serialize(@NotNull Span span) {
- return NOOP_SERIALIZED_SPAN;
- }
-
/** {@inheritDoc} */
@Override public @NotNull TracingConfigurationManager configuration() {
return NoopTracingConfigurationManager.INSTANCE;
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 9430dd7c20046..a9b99a841aeee 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.ExpectedFailure;
+
/**
* Exception thrown whenever grid transactions fail optimistically.
*/
-public class IgniteTxOptimisticCheckedException extends TransactionCheckedException {
+public class IgniteTxOptimisticCheckedException extends TransactionCheckedException implements ExpectedFailure {
/** */
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 1513346138589..1f722faffc8de 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.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;
@@ -114,7 +113,7 @@
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.function.LongConsumer;
import java.util.jar.JarFile;
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
@@ -135,6 +134,7 @@
import javax.management.ObjectName;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
@@ -144,13 +144,7 @@
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.binary.BinaryField;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinarySerializer;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.cluster.ClusterGroupEmptyException;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
@@ -171,7 +165,6 @@
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryMetadata;
import org.apache.ignite.internal.binary.BinaryMetadataHandler;
import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderEx;
@@ -194,15 +187,18 @@
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.IgnitePeerToPeerClassLoadingException;
+import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.future.IgniteFutureImpl;
-import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.GridPeerDeployAware;
import org.apache.ignite.internal.util.lang.IgniteThrowableFunction;
+import org.apache.ignite.internal.util.nio.GridNioFilter;
+import org.apache.ignite.internal.util.nio.GridNioServer;
+import org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -231,7 +227,6 @@
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;
@@ -300,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];
@@ -350,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;
@@ -413,10 +402,6 @@ public abstract class IgniteUtils extends CommonUtils {
public static boolean IGNITE_TEST_FEATURES_ENABLED =
IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_TEST_FEATURES_ENABLED);
- /** For tests. */
- @SuppressWarnings("PublicField")
- public static boolean useTestBinaryCtx;
-
/** */
private static final boolean assertionsEnabled;
@@ -2130,28 +2115,6 @@ private static long fromBytes(byte[] bytes, int off, int limit) {
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.
@@ -2796,47 +2759,6 @@ public static void closeWithSuppressingException(@Nullable AutoCloseable rsrc, @
}
}
- /**
- * Quietly closes given resource ignoring possible checked exception.
- *
- * @param rsrc Resource to close. If it's {@code null} - it's no-op.
- */
- public static void closeQuiet(@Nullable AutoCloseable rsrc) {
- if (rsrc != null)
- try {
- rsrc.close();
- }
- catch (Exception ignored) {
- // No-op.
- }
- }
-
- /**
- * Quietly closes given {@link Socket} ignoring possible checked exception.
- *
- * @param sock Socket to close. If it's {@code null} - it's no-op.
- */
- public static void closeQuiet(@Nullable Socket sock) {
- if (sock == null)
- return;
-
- try {
- // Avoid tls 1.3 incompatibility https://bugs.openjdk.java.net/browse/JDK-8208526
- sock.shutdownOutput();
- sock.shutdownInput();
- }
- catch (Exception ignored) {
- // No-op.
- }
-
- try {
- sock.close();
- }
- catch (Exception ignored) {
- // No-op.
- }
- }
-
/**
* Quietly releases file lock ignoring all possible exceptions.
*
@@ -3288,69 +3210,6 @@ public static boolean joinThreads(Iterable extends Thread> workers, @Nullable
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.
*
@@ -4880,49 +4739,6 @@ public static JMException jmException(Throwable e) {
return new JMException(e.getMessage());
}
- /**
- * Unwraps closure exceptions.
- *
- * @param t Exception.
- * @return Unwrapped exception.
- */
- public static Exception unwrap(Throwable t) {
- assert t != null;
-
- while (true) {
- if (t instanceof Error)
- throw (Error)t;
-
- if (t instanceof GridClosureException) {
- t = ((GridClosureException)t).unwrap();
-
- continue;
- }
-
- return (Exception)t;
- }
- }
-
- /**
- * Casts the passed {@code Throwable t} to {@link IgniteCheckedException}.
- * If {@code t} is a {@link GridClosureException}, it is unwrapped and then cast to {@link IgniteCheckedException}.
- * If {@code t} is an {@link IgniteCheckedException}, it is returned.
- * If {@code t} is not a {@link IgniteCheckedException}, a new {@link IgniteCheckedException} caused by {@code t}
- * is returned.
- *
- * @param t Throwable to cast.
- * @return {@code t} cast to {@link IgniteCheckedException}.
- */
- public static IgniteCheckedException cast(Throwable t) {
- assert t != null;
-
- t = unwrap(t);
-
- return t instanceof IgniteCheckedException
- ? (IgniteCheckedException)t
- : new IgniteCheckedException(t);
- }
-
/**
* Checks if class loader is an internal P2P class loader.
*
@@ -5153,23 +4969,6 @@ public static void awaitQuiet(CyclicBarrier barrier) {
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.
*
@@ -5648,30 +5447,6 @@ public static void removeJavaNoOpLogger(Collection rmvHnds) {
}
}
- /**
- * Gets absolute value for integer. If integer is {@link Integer#MIN_VALUE}, then {@code 0} is returned.
- *
- * @param i Integer.
- * @return Absolute value.
- */
- public static int safeAbs(int i) {
- i = Math.abs(i);
-
- return i < 0 ? 0 : i;
- }
-
- /**
- * Gets absolute value for long. If argument is {@link Long#MIN_VALUE}, then {@code 0} is returned.
- *
- * @param i Argument.
- * @return Absolute value.
- */
- public static long safeAbs(long i) {
- i = Math.abs(i);
-
- return i < 0 ? 0 : i;
- }
-
/**
* When {@code long} value given is positive returns that value, otherwise returns provided default value.
*
@@ -7289,31 +7064,6 @@ private static Collection doInParallel(
return results;
}
- /**
- * Utility method to add the given throwable error to the given throwable root error. If the given
- * suppressed throwable is an {@code Error}, but the root error is not, will change the root to the {@code Error}.
- *
- * @param root Root error to add suppressed error to.
- * @param err Error to add.
- * @return New root error.
- */
- public static T addSuppressed(T root, T err) {
- assert err != null;
-
- if (root == null)
- return err;
-
- if (err instanceof Error && !(root instanceof Error)) {
- err.addSuppressed(root);
-
- root = err;
- }
- else
- root.addSuppressed(err);
-
- return root;
- }
-
/**
* @return {@code true} if local node is coordinator.
*/
@@ -7450,30 +7200,6 @@ public static Runnable wrapIgniteFuture(Runnable r, GridFutureAdapter> fut) {
};
}
- /**
- * 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.
*/
@@ -7896,35 +7622,16 @@ public static BinaryContext binaryContext(
) {
BinaryConfiguration bcfg = cfg.getBinaryConfiguration() == null ? new BinaryConfiguration() : cfg.getBinaryConfiguration();
- return useTestBinaryCtx
- ? new TestBinaryContext(
- metaHnd,
- marsh,
- cfg.getIgniteInstanceName(),
- cfg.getClassLoader(),
- bcfg.getSerializer(),
- bcfg.getIdMapper(),
- bcfg.getNameMapper(),
- bcfg.getTypeConfigurations(),
- CU.affinityFields(cfg),
- bcfg.isCompactFooter(),
- CU::affinityFieldName,
- log
- )
- : new BinaryContext(
- metaHnd,
- marsh,
- cfg.getIgniteInstanceName(),
- cfg.getClassLoader(),
- bcfg.getSerializer(),
- bcfg.getIdMapper(),
- bcfg.getNameMapper(),
- bcfg.getTypeConfigurations(),
- CU.affinityFields(cfg),
- bcfg.isCompactFooter(),
- CU::affinityFieldName,
- log
- );
+ return BinaryUtils.binaryContext(
+ metaHnd,
+ marsh,
+ cfg.getIgniteInstanceName(),
+ cfg.getClassLoader(),
+ bcfg,
+ CU.affinityFields(cfg),
+ BinaryUtils::affinityFieldName,
+ log
+ );
}
/**
@@ -8000,106 +7707,6 @@ public static void prepareAffinityField(BinaryObjectBuilder builder, CacheObject
}
}
- /**
- * 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);
- }
-
- /** */
- @SuppressWarnings("PublicInnerClass")
- public static class TestBinaryContext extends BinaryContext {
- /** */
- private List listeners;
-
- /** */
- public TestBinaryContext(
- BinaryMetadataHandler metaHnd,
- @Nullable BinaryMarshaller marsh,
- @Nullable String igniteInstanceName,
- @Nullable ClassLoader clsLdr,
- @Nullable BinarySerializer dfltSerializer,
- @Nullable BinaryIdMapper idMapper,
- @Nullable BinaryNameMapper nameMapper,
- @Nullable Collection typeCfgs,
- Map affFlds,
- boolean compactFooter,
- Function, String> affFldNameProvider,
- IgniteLogger log
- ) {
- super(
- metaHnd,
- marsh,
- igniteInstanceName,
- clsLdr,
- dfltSerializer,
- idMapper,
- nameMapper,
- typeCfgs,
- affFlds,
- compactFooter,
- affFldNameProvider,
- log
- );
- }
-
-
- /** {@inheritDoc} */
- @Nullable @Override public BinaryType metadata(int typeId) throws BinaryObjectException {
- BinaryType metadata = super.metadata(typeId);
-
- if (listeners != null) {
- for (TestBinaryContextListener listener : listeners)
- listener.onAfterMetadataRequest(typeId, metadata);
- }
-
- return metadata;
- }
-
- /** {@inheritDoc} */
- @Override public void updateMetadata(int typeId, BinaryMetadata meta, boolean failIfUnregistered) throws BinaryObjectException {
- if (listeners != null) {
- for (TestBinaryContextListener listener : listeners)
- listener.onBeforeMetadataUpdate(typeId, meta);
- }
-
- super.updateMetadata(typeId, meta, failIfUnregistered);
- }
-
- /** */
- public interface TestBinaryContextListener {
- /**
- * @param typeId Type id.
- * @param type Type.
- */
- void onAfterMetadataRequest(int typeId, BinaryType type);
-
- /**
- * @param typeId Type id.
- * @param metadata Metadata.
- */
- void onBeforeMetadataUpdate(int typeId, BinaryMetadata metadata);
- }
-
- /** @param lsnr Listener. */
- public void addListener(TestBinaryContextListener lsnr) {
- if (listeners == null)
- listeners = new ArrayList<>();
-
- if (!listeners.contains(lsnr))
- listeners.add(lsnr);
- }
-
- /** */
- public void clearAllListener() {
- if (listeners != null)
- listeners.clear();
- }
- }
-
/** */
public static final IgniteDataTransferObjectSerializer> EMPTY_DTO_SERIALIZER = new IgniteDataTransferObjectSerializer() {
/** {@inheritDoc} */
@@ -8136,4 +7743,68 @@ public static DiscoveryCustomMessage unwrapCustomMessage(DiscoverySpiCustomMessa
return msg instanceof SecurityAwareCustomMessageWrapper ?
((SecurityAwareCustomMessageWrapper)msg).delegate() : (DiscoveryCustomMessage)msg;
}
+
+ /**
+ * Sets the received/sent bytes and per-session queue-size metric consumers on the given NIO server builder,
+ * creating the underlying metrics in the provided registry.
+ *
+ * @param builder NIO server builder.
+ * @param mreg Metric registry.
+ * @return The given builder for chaining.
+ */
+ public static GridNioServer.Builder setNioServerMetrics(GridNioServer.Builder builder, MetricRegistryImpl mreg) {
+ return builder
+ .receivedBytesMetric(mreg.longAdderMetric(
+ GridNioServer.RECEIVED_BYTES_METRIC_NAME, GridNioServer.RECEIVED_BYTES_METRIC_DESC)::add)
+ .sentBytesMetric(mreg.longAdderMetric(
+ GridNioServer.SENT_BYTES_METRIC_NAME, GridNioServer.SENT_BYTES_METRIC_DESC)::add)
+ .outboundMessagesQueueSizeMetric(mreg.longAdderMetric(
+ GridNioServer.OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME,
+ GridNioServer.OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_DESC)::add)
+ .maxMessagesQueueSizeMetric(mreg.maxValueMetric(
+ GridNioServer.MAX_MESSAGES_QUEUE_SIZE_METRIC_NAME,
+ GridNioServer.MAX_MESSAGES_QUEUE_SIZE_METRIC_DESC, 60_000, 5)::update);
+ }
+
+ /**
+ * Registers the active TCP sessions count metric in the given registry, backed by the NIO server.
+ *
+ * @param srv NIO server.
+ * @param mreg Metric registry.
+ */
+ public static void registerNioServerMetrics(GridNioServer> srv, GridNioFilter[] filters, MetricRegistryImpl mreg) {
+ boolean sslEnabled = Arrays.stream(filters).anyMatch(filter -> filter instanceof GridNioSslFilter);
+
+ mreg.register(GridNioServer.SSL_ENABLED_METRIC_NAME, () -> sslEnabled, "Whether SSL is enabled");
+ mreg.register(GridNioServer.SESSIONS_CNT_METRIC_NAME, srv::activeTcpSessionsCount, "Active TCP sessions count.");
+ }
+
+ /**
+ * Creates an SSL NIO filter, wiring its metrics from the given registry.
+ *
+ * @param sslCtx SSL context.
+ * @param directBuf Direct buffer flag.
+ * @param order Byte order.
+ * @param log Logger to use.
+ * @param mreg Optional metric registry; if {@code null}, the filter is created without metrics.
+ * @return SSL NIO filter.
+ */
+ public static GridNioSslFilter sslFilter(
+ SSLContext sslCtx,
+ boolean directBuf,
+ ByteOrder order,
+ IgniteLogger log,
+ @Nullable MetricRegistryImpl mreg
+ ) {
+ LongConsumer handshakeDuration = mreg == null ? null : mreg.histogram(
+ GridNioSslFilter.SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME,
+ new long[] {250, 500, 1000},
+ "SSL handshake duration in milliseconds.")::value;
+
+ Runnable rejectedSesCnt = mreg == null ? null : mreg.intMetric(
+ GridNioSslFilter.SSL_REJECTED_SESSIONS_CNT_METRIC_NAME,
+ "TCP sessions count that were rejected due to SSL errors.")::increment;
+
+ return new GridNioSslFilter(sslCtx, directBuf, order, log, handshakeDuration, rejectedSesCnt);
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationMetricsListener.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationMetricsListener.java
index 2fb542ceb8be2..4bf17f1a969fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationMetricsListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationMetricsListener.java
@@ -44,6 +44,8 @@
import static java.util.stream.Collectors.toMap;
import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.SEPARATOR;
import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName;
+import static org.apache.ignite.internal.util.nio.GridNioServer.OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_DESC;
+import static org.apache.ignite.internal.util.nio.GridNioServer.OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME;
import static org.apache.ignite.internal.util.nio.GridNioServer.RECEIVED_BYTES_METRIC_DESC;
import static org.apache.ignite.internal.util.nio.GridNioServer.RECEIVED_BYTES_METRIC_NAME;
import static org.apache.ignite.internal.util.nio.GridNioServer.SENT_BYTES_METRIC_DESC;
@@ -105,6 +107,9 @@ public class TcpCommunicationMetricsListener {
/** Received messages count metric. */
private final LongAdderMetric rcvdMsgsMetric;
+ /** Outbound messages queue size metric. */
+ private final LongAdderMetric outboundMessagesQueueSizeMetric;
+
/** Counters of sent and received messages by direct type. */
private final IntMap> msgCntrsByType;
@@ -146,6 +151,11 @@ public TcpCommunicationMetricsListener(Ignite ignite, IgniteSpiContext spiCtx) {
sentMsgsMetric = mreg.longAdderMetric(SENT_MESSAGES_METRIC_NAME, SENT_MESSAGES_METRIC_DESC);
rcvdMsgsMetric = mreg.longAdderMetric(RECEIVED_MESSAGES_METRIC_NAME, RECEIVED_MESSAGES_METRIC_DESC);
+ outboundMessagesQueueSizeMetric = mreg.longAdderMetric(
+ OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME,
+ OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_DESC
+ );
+
spiCtx.addMetricRegistryCreationListener(mreg -> {
// Metrics for the specific nodes or other communication metrics.
if (!TcpCommunicationSpi.isCommunicationMetrics(mreg.name()))
@@ -276,6 +286,15 @@ public long receivedBytesCount() {
return rcvdBytesMetric.value();
}
+ /**
+ * Gets outbound messages queue size.
+ *
+ * @return Outbound messages queue size.
+ */
+ public int outboundMessagesQueueSize() {
+ return (int)outboundMessagesQueueSizeMetric.value();
+ }
+
/**
* Gets received messages counts (grouped by type).
*
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 f9ab18727eada..4bcae5a26a29b 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
@@ -411,9 +411,10 @@ public static boolean isCommunicationMetrics(String metricName) {
/** {@inheritDoc} */
@Override public int getOutboundMessagesQueueSize() {
- GridNioServer srv = nioSrvWrapper.nio();
+ if (metricsLsnr == null)
+ return 0;
- return srv != null ? srv.outboundMessagesQueueSize() : 0;
+ return metricsLsnr.outboundMessagesQueueSize();
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
index df7935c6c2f41..eb90f002a240f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/internal/GridNioServerWrapper.java
@@ -56,6 +56,7 @@
import org.apache.ignite.internal.managers.GridManager;
import org.apache.ignite.internal.managers.tracing.GridTracingManager;
import org.apache.ignite.internal.processors.metric.GridMetricManager;
+import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
import org.apache.ignite.internal.processors.tracing.Tracing;
import org.apache.ignite.internal.util.GridConcurrentFactory;
import org.apache.ignite.internal.util.IgniteExceptionRegistry;
@@ -909,7 +910,7 @@ private MessageFactory get() {
filters.add(new GridConnectionBytesVerifyFilter(log));
if (stateProvider.isSslEnabled()) {
- GridNioSslFilter sslFilter = new GridNioSslFilter(
+ GridNioSslFilter sslFilter = U.sslFilter(
igniteCfg.getSslContextFactory().create(),
true,
ByteOrder.LITTLE_ENDIAN,
@@ -924,6 +925,11 @@ private MessageFactory get() {
filters.add(sslFilter);
}
+ GridNioFilter[] filtersArr = filters.toArray(new GridNioFilter[filters.size()]);
+
+ MetricRegistryImpl mreg = metricMgr != null ?
+ metricMgr.registry(COMMUNICATION_METRICS_GROUP_NAME) : null;
+
GridNioServer.Builder builder = GridNioServer.builder()
.address(cfg.localHost())
.port(port)
@@ -941,7 +947,7 @@ private MessageFactory get() {
.directMode(true)
.writeTimeout(cfg.socketWriteTimeout())
.selectorSpins(cfg.selectorSpins())
- .filters(filters.toArray(new GridNioFilter[filters.size()]))
+ .filters(filtersArr)
.writerFactory(writerFactory)
.skipRecoveryPredicate(skipRecoveryPred)
.messageQueueSizeListener(queueSizeMonitor)
@@ -949,13 +955,17 @@ private MessageFactory get() {
.readWriteSelectorsAssign(cfg.usePairedConnections())
.messageFactory(msgFactory);
- if (metricMgr != null) {
- builder.workerListener(workersRegistry)
- .metricRegistry(metricMgr.registry(COMMUNICATION_METRICS_GROUP_NAME));
+ if (mreg != null) {
+ builder.workerListener(workersRegistry);
+
+ U.setNioServerMetrics(builder, mreg);
}
GridNioServer srvr = builder.build();
+ if (mreg != null)
+ U.registerNioServerMetrics(srvr, filtersArr, mreg);
+
cfg.boundTcpPort(port);
// Ack Port the TCP server was bound to.
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java
index fd42dc16fbf41..d40a168677626 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotJoiningClientTest.java
@@ -29,6 +29,7 @@
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.pagemem.wal.WALIterator;
import org.apache.ignite.internal.pagemem.wal.record.IncrementalSnapshotFinishRecord;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
@@ -183,7 +184,7 @@ private boolean transactionExcluded(int nodeIdx, IgniteUuid txId) throws Excepti
if (rec.type() == WALRecord.RecordType.INCREMENTAL_SNAPSHOT_FINISH_RECORD) {
IncrementalSnapshotFinishRecord finRec = (IncrementalSnapshotFinishRecord)rec;
- assertTrue(finRec.excluded().stream().anyMatch(id -> id.asIgniteUuid().equals(txId)));
+ assertTrue(finRec.excluded().stream().anyMatch(id -> BinaryUtils.asIgniteUuid(id).equals(txId)));
return true;
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotRestoreTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotRestoreTest.java
index 5cad5b48d5cd3..d6553f9fa3d39 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotRestoreTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/incremental/IncrementalSnapshotRestoreTest.java
@@ -53,6 +53,7 @@
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.management.consistency.ConsistencyRepairCommandArg;
import org.apache.ignite.internal.management.consistency.ConsistencyRepairTask;
import org.apache.ignite.internal.management.consistency.ConsistencyTaskResult;
@@ -675,7 +676,7 @@ public void testNoGapsInCountersAfterRestore() throws Exception {
for (int n = 1; n < nodes(); n++) {
TestRecordingCommunicationSpi.spi(grid(n)).blockMessages((node, msg) ->
msg instanceof GridNearTxPrepareResponse
- && ((GridNearTxPrepareResponse)msg).version().asIgniteUuid().equals(exclTxId.get()));
+ && BinaryUtils.asIgniteUuid(((GridNearTxPrepareResponse)msg).version()).equals(exclTxId.get()));
}
msgBlkSet.countDown();
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateAbstractTest.java
index 65ef7afee2c40..232cef9e2a346 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateAbstractTest.java
@@ -45,6 +45,7 @@
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.cache.PartitionUpdateCounter;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheTxRecoveryRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest;
@@ -313,7 +314,7 @@ protected Map>> runOnPartition(
futMap.put(req.futureId(), req.version());
- return cb.beforePrimaryPrepare(to, req.version().asIgniteUuid(), createSendFuture(clientWrappedSpi, msg));
+ return cb.beforePrimaryPrepare(to, BinaryUtils.asIgniteUuid(req.version()), createSendFuture(clientWrappedSpi, msg));
}
else if (msg instanceof GridNearTxFinishRequest) {
IgniteEx to = IgnitionEx.gridxx(node.id());
@@ -440,7 +441,8 @@ else if (msg instanceof GridDhtTxFinishRequest) {
IgniteInternalTx primTx = findTx(from, nearVer, true);
IgniteInternalTx backupTx = findTx(to, nearVer, false);
- return cb.beforeBackupFinish(from, to, primTx, backupTx, nearVer.asIgniteUuid(), createSendFuture(wrappedPrimSpi, msg));
+ return cb.beforeBackupFinish(from, to, primTx, backupTx, BinaryUtils.asIgniteUuid(nearVer),
+ createSendFuture(wrappedPrimSpi, msg));
}
else if (msg instanceof GridNearTxPrepareResponse) {
GridNearTxPrepareResponse resp = (GridNearTxPrepareResponse)msg;
@@ -451,7 +453,7 @@ else if (msg instanceof GridNearTxPrepareResponse) {
IgniteInternalTx primTx = findTx(from, ver, true);
- return cb.afterPrimaryPrepare(from, primTx, ver.asIgniteUuid(), createSendFuture(wrappedPrimSpi, msg));
+ return cb.afterPrimaryPrepare(from, primTx, BinaryUtils.asIgniteUuid(ver), createSendFuture(wrappedPrimSpi, msg));
}
else if (msg instanceof GridNearTxFinishResponse) {
IgniteEx to = IgnitionEx.gridxx(node.id());
@@ -460,7 +462,7 @@ else if (msg instanceof GridNearTxFinishResponse) {
IgniteEx from = fromNode(wrappedPrimSpi);
- IgniteUuid nearVer = futMap.get(req.futureId()).asIgniteUuid();
+ IgniteUuid nearVer = BinaryUtils.asIgniteUuid(futMap.get(req.futureId()));
return cb.afterPrimaryFinish(from, nearVer, createSendFuture(wrappedPrimSpi, msg));
}
@@ -490,7 +492,7 @@ private IgniteBiPredicate createBackupMessagePredicate(Tes
IgniteInternalTx backupTx = findTx(from, ver, false);
- return cb.afterBackupPrepare(to, from, backupTx, ver.asIgniteUuid(), createSendFuture(wrappedBackupSpi, msg));
+ return cb.afterBackupPrepare(to, from, backupTx, BinaryUtils.asIgniteUuid(ver), createSendFuture(wrappedBackupSpi, msg));
}
else if (msg instanceof GridDhtTxFinishResponse) {
IgniteEx from = fromNode(wrappedBackupSpi);
@@ -504,7 +506,7 @@ else if (msg instanceof GridDhtTxFinishResponse) {
return false; // Message from parallel partition.
// Version is null if message is a response to checkCommittedRequest.
- return cb.afterBackupFinish(to, from, ver.asIgniteUuid(), createSendFuture(wrappedBackupSpi, msg));
+ return cb.afterBackupFinish(to, from, BinaryUtils.asIgniteUuid(ver), createSendFuture(wrappedBackupSpi, msg));
}
return false;
@@ -973,7 +975,7 @@ private long countForNode(IgniteEx node, TxState state) {
return false;
runAsync(() -> {
- futures.put(new T3<>(primary, TxState.COMMIT, tx.nearXidVersion().asIgniteUuid()), proceedFut);
+ futures.put(new T3<>(primary, TxState.COMMIT, BinaryUtils.asIgniteUuid(tx.nearXidVersion())), proceedFut);
if (countForNode(primary, TxState.COMMIT) == txCnt)
futures.remove(new T3<>(primary, TxState.COMMIT, version(commits.get(primary).poll()))).onDone();
@@ -993,11 +995,11 @@ private long countForNode(IgniteEx node, TxState state) {
runAsync(() -> {
if (assigns.get(primary) != null) {
- int v0 = assignCntr.compute(new T2<>(primary, primaryTx.nearXidVersion().asIgniteUuid()),
+ int v0 = assignCntr.compute(new T2<>(primary, BinaryUtils.asIgniteUuid(primaryTx.nearXidVersion())),
(key, val) -> (val == null ? 0 : val) + 1);
if (v0 == 2) {
- onCounterAssigned(primary, primaryTx, order(primaryTx.nearXidVersion().asIgniteUuid()));
+ onCounterAssigned(primary, primaryTx, order(BinaryUtils.asIgniteUuid(primaryTx.nearXidVersion())));
if (!assigns.get(primary).isEmpty())
futures.remove(new T3<>(primary, TxState.ASSIGN,
@@ -1006,7 +1008,7 @@ private long countForNode(IgniteEx node, TxState state) {
}
if (prepares.get(backup) != null) {
- futures.put(new T3<>(backup, TxState.PREPARE, primaryTx.nearXidVersion().asIgniteUuid()), proceedFut);
+ futures.put(new T3<>(backup, TxState.PREPARE, BinaryUtils.asIgniteUuid(primaryTx.nearXidVersion())), proceedFut);
// Wait until all prep requests queued and force prepare order.
if (countForNode(backup, TxState.PREPARE) == txCnt) {
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateOnePrimaryOneBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateOnePrimaryOneBackupTest.java
index cab77867215c0..219f188ded00c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateOnePrimaryOneBackupTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPartitionCounterStateOnePrimaryOneBackupTest.java
@@ -29,6 +29,7 @@
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.cache.PartitionUpdateCounter;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -348,7 +349,7 @@ protected void onAllBackupCommitted(IgniteEx backup) {
@Override public boolean beforeBackupPrepare(IgniteEx primary, IgniteEx backup, IgniteInternalTx primaryTx,
GridFutureAdapter> proceedFut) {
runAsync(() -> {
- IgniteUuid nearXidVer = primaryTx.nearXidVersion().asIgniteUuid();
+ IgniteUuid nearXidVer = BinaryUtils.asIgniteUuid(primaryTx.nearXidVersion());
onPrimaryPrepared(primary, primaryTx, order(nearXidVer));
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java
index 79bc9f0ef82e7..9b2199f213e94 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/nio/GridNioSslSelfTest.java
@@ -71,7 +71,7 @@ public class GridNioSslSelfTest extends GridNioSelfTest {
.sendQueueLimit(0)
.filters(
new GridNioCodecFilter(parser, log, false),
- new GridNioSslFilter(sslCtx, true, ByteOrder.nativeOrder(), log, null));
+ new GridNioSslFilter(sslCtx, true, ByteOrder.nativeOrder(), log, null, null));
}
/** {@inheritDoc} */
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index 152b209a533a7..a37e758c414ee 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -480,7 +480,7 @@ public IgniteMock(String name, String locHost, UUID nodeId, Marshaller marshalle
bcfg.getTypeConfigurations(),
CU.affinityFields(configuration()),
bcfg.isCompactFooter(),
- CU::affinityFieldName,
+ BinaryUtils::affinityFieldName,
NullLogger.INSTANCE
) {
@Override public int typeId(String typeName) {
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java
index 1a4403a307acd..8e9bbd48ca383 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/BinaryMetadataConcurrentUpdateWithIndexesTest.java
@@ -44,10 +44,11 @@
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryMetadata;
+import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.BinaryUtils.TestBinaryContext;
+import org.apache.ignite.internal.binary.BinaryUtils.TestBinaryContext.TestBinaryContextListener;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.binary.MetadataUpdateProposedMessage;
-import org.apache.ignite.internal.util.IgniteUtils.TestBinaryContext;
-import org.apache.ignite.internal.util.IgniteUtils.TestBinaryContext.TestBinaryContextListener;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.discovery.tcp.BlockTcpDiscoverySpi;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -343,14 +344,14 @@ protected BinaryObject build(Ignite ignite, String prefix, int... fields) {
@Override protected void beforeTest() throws Exception {
super.beforeTest();
- U.useTestBinaryCtx = true;
+ BinaryUtils.useTestBinaryCtx = true;
}
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
super.afterTest();
- U.useTestBinaryCtx = false;
+ BinaryUtils.useTestBinaryCtx = false;
stopAllGrids();
}
diff --git a/modules/nio/pom.xml b/modules/nio/pom.xml
new file mode 100644
index 0000000000000..c6247439fee3d
--- /dev/null
+++ b/modules/nio/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+ 4.0.0
+
+
+ org.apache.ignite
+ ignite-parent-internal
+ ${revision}
+ ../../parent-internal/pom.xml
+
+
+ ignite-nio
+
+ http://ignite.apache.org
+
+
+
+ ${project.groupId}
+ ignite-commons
+ provided
+
+
+
+ ${project.groupId}
+ ignite-binary-api
+ provided
+
+
+
+ ${project.groupId}
+ ignite-grid-unsafe
+ provided
+
+
+
+ org.jetbrains
+ annotations
+ ${jetbrains.annotations.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ ${maven.deploy.plugin.version}
+
+ false
+
+
+
+
+
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
similarity index 91%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
index 79de224b7772a..267d43156f0c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridAbstractCommunicationClient.java
+++ b/modules/nio/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 @@ protected GridAbstractCommunicationClient(int connIdx) {
/** {@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/GridBufferedParser.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridCommunicationClient.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
similarity index 87%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
index 3829aaa6aa0e5..49eca090eaa33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java
@@ -22,15 +22,15 @@
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}.
*
- * 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 GridConnectionBytesVerifyFilter(IgniteLogger log) {
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/GridDelimitedParser.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
similarity index 87%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
index faf416dfdbee7..76b0d60ad7463 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridDirectParser.java
@@ -22,15 +22,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.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
import org.jetbrains.annotations.Nullable;
-import static org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi.makeMessageType;
-
/**
* Parser for direct messages.
*/
@@ -67,10 +65,10 @@ public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMess
/** {@inheritDoc} */
@Nullable @Override public Object decode(GridNioSession ses, ByteBuffer buf)
throws IOException, IgniteCheckedException {
- DirectMessageReader reader = ses.meta(READER_META_KEY);
+ MessageReader reader = ses.meta(READER_META_KEY);
if (reader == null)
- ses.addMeta(READER_META_KEY, reader = (DirectMessageReader)readerFactory.reader(ses, msgFactory));
+ ses.addMeta(READER_META_KEY, reader = readerFactory.reader(ses, msgFactory));
Message msg = ses.removeMeta(MSG_META_KEY);
@@ -79,7 +77,7 @@ public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMess
byte b0 = buf.get();
byte b1 = buf.get();
- msg = msgFactory.create(makeMessageType(b0, b1));
+ msg = msgFactory.create((short)((b1 & 0xFF) << 8 | b0 & 0xFF));
}
boolean finished = false;
@@ -105,7 +103,7 @@ public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMess
}
}
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/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
similarity index 96%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
index 3fb1ec5dd4a8c..4a5889f17dfb3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioAsyncNotifyFilter.java
@@ -22,7 +22,7 @@
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 @@ protected void handleException(GridNioSession ses, IgniteCheckedException ex) {
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/GridNioBackPressureControl.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioBackPressureControl.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioBackPressureControl.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioBackPressureControl.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioCodecFilter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioCodecFilter.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioCodecFilter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioCodecFilter.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioException.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioException.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioException.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioException.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilter.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilter.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterAdapter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterAdapter.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterAdapter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterAdapter.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterChain.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterChain.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterChain.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioFilterChain.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioKeyAttachment.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioKeyAttachment.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioKeyAttachment.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioKeyAttachment.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReaderFactory.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReaderFactory.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReaderFactory.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageReaderFactory.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageTracker.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageTracker.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageTracker.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageTracker.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriterFactory.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriterFactory.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriterFactory.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioMessageWriterFactory.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioParser.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioParser.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioParser.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioParser.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
similarity index 96%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
index 1cedb7d800ee4..4223821a42eb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
@@ -20,9 +20,9 @@
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.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/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
similarity index 93%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index 797290677db52..d6a4ee038f0c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -47,25 +47,22 @@
import java.util.concurrent.ConcurrentLinkedQueue;
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;
-import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
-import org.apache.ignite.internal.processors.metric.impl.LongAdderMetric;
-import org.apache.ignite.internal.processors.odbc.ClientMessage;
import org.apache.ignite.internal.processors.tracing.MTC;
import org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings;
import org.apache.ignite.internal.processors.tracing.NoopSpan;
-import org.apache.ignite.internal.processors.tracing.NoopTracing;
+import org.apache.ignite.internal.processors.tracing.NoopSpanManager;
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.processors.tracing.Tracing;
+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;
@@ -77,7 +74,6 @@
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;
@@ -86,10 +82,12 @@
import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lang.IgniteRunnable;
import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageContainer;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageSerializer;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.apache.ignite.plugin.extensions.communication.SelfSerializingMessage;
import org.apache.ignite.thread.IgniteThread;
import org.jetbrains.annotations.Nullable;
@@ -97,7 +95,6 @@
import static org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION;
import static org.apache.ignite.internal.processors.tracing.SpanTags.SOCKET_WRITE_BYTES;
import static org.apache.ignite.internal.processors.tracing.SpanType.COMMUNICATION_SOCKET_WRITE;
-import static org.apache.ignite.internal.processors.tracing.messages.TraceableMessagesTable.traceName;
import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.MSG_WRITER;
import static org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.NIO_OPERATION;
@@ -119,6 +116,9 @@ public class GridNioServer {
/** 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;
@@ -145,10 +145,7 @@ public class GridNioServer {
/** */
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";
@@ -231,7 +228,7 @@ public class GridNioServer {
private volatile long writeTimeout = DFLT_SES_WRITE_TIMEOUT;
/** Idle timeout. */
- private volatile long idleTimeout = ConnectorConfiguration.DFLT_IDLE_TIMEOUT;
+ private volatile long idleTimeout = DFLT_IDLE_TIMEOUT;
/** For test purposes only. */
private boolean skipWrite;
@@ -251,17 +248,17 @@ public class GridNioServer {
/** Whether direct mode is used. */
private final boolean directMode;
- /** */
- @Nullable private final MetricRegistryImpl mreg;
-
/** Received bytes count metric. */
- @Nullable private final LongAdderMetric rcvdBytesCntMetric;
+ @Nullable private final LongConsumer rcvdBytesCntMetric;
/** Sent bytes count metric. */
- @Nullable private final LongAdderMetric sentBytesCntMetric;
+ @Nullable private final LongConsumer sentBytesCntMetric;
+
+ /** Per-session outbound messages queue size metric. */
+ @Nullable private final LongConsumer outboundMessagesQueueSizeMetric;
- /** Outbound messages queue size. */
- @Nullable private final LongAdderMetric outboundMessagesQueueSizeMetric;
+ /** Per-session maximum outbound messages queue size metric. */
+ @Nullable private final LongConsumer maxMessagesQueueSizeMetric;
/** Sessions. */
private final GridConcurrentHashSet sessions = new GridConcurrentHashSet<>();
@@ -295,8 +292,8 @@ public class GridNioServer {
*/
private final boolean readWriteSelectorsAssign;
- /** Tracing processor. */
- private Tracing tracing;
+ /** Span manager. */
+ private SpanManager tracing;
/** Message factory. */
private final MessageFactory msgFactory;
@@ -325,7 +322,10 @@ public class GridNioServer {
* @param msgQueueLsnr Message queue size listener.
* @param readWriteSelectorsAssign If {@code true} then in/out connections are assigned to even/odd workers.
* @param workerLsnr Worker lifecycle listener.
- * @param mreg Metrics registry.
+ * @param rcvdBytesCntMetric Received bytes count metric, or {@code null} if metrics disabled.
+ * @param sentBytesCntMetric Sent bytes count metric, or {@code null} if metrics disabled.
+ * @param outboundMessagesQueueSizeMetric Per-session outbound messages queue size metric, or {@code null} if metrics disabled.
+ * @param maxMessagesQueueSizeMetric Per-session maximum outbound messages queue size metric, or {@code null} if metrics disabled.
* @param filters Filters for this server.
* @throws IgniteCheckedException If failed.
*/
@@ -351,8 +351,11 @@ private GridNioServer(
IgniteBiInClosure msgQueueLsnr,
boolean readWriteSelectorsAssign,
@Nullable GridWorkerListener workerLsnr,
- @Nullable MetricRegistryImpl mreg,
- Tracing tracing,
+ @Nullable LongConsumer rcvdBytesCntMetric,
+ @Nullable LongConsumer sentBytesCntMetric,
+ @Nullable LongConsumer outboundMessagesQueueSizeMetric,
+ @Nullable LongConsumer maxMessagesQueueSizeMetric,
+ SpanManager tracing,
MessageFactory msgFactory,
GridNioFilter... filters
) throws IgniteCheckedException {
@@ -380,7 +383,11 @@ private GridNioServer(
this.selectorSpins = selectorSpins;
this.readWriteSelectorsAssign = readWriteSelectorsAssign;
this.lsnr = lsnr;
- this.tracing = tracing == null ? new NoopTracing() : tracing;
+ this.rcvdBytesCntMetric = rcvdBytesCntMetric;
+ this.sentBytesCntMetric = sentBytesCntMetric;
+ this.outboundMessagesQueueSizeMetric = outboundMessagesQueueSizeMetric;
+ this.maxMessagesQueueSizeMetric = maxMessagesQueueSizeMetric;
+ this.tracing = tracing == null ? new NoopSpanManager() : tracing;
this.msgFactory = msgFactory;
filterChain = new GridNioFilterChain<>(log, lsnr, new HeadFilter(), filters);
@@ -433,7 +440,7 @@ private GridNioServer(
clientWorkers.add(worker);
- clientThreads[i] = U.newThread(worker);
+ clientThreads[i] = CommonUtils.newThread(worker);
clientThreads[i].setDaemon(daemon);
}
@@ -443,13 +450,14 @@ private GridNioServer(
this.skipRecoveryPred = skipRecoveryPred != null ? skipRecoveryPred : F.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();
@@ -461,27 +469,13 @@ private GridNioServer(
}
this.balancer = balancer0;
+ }
- this.mreg = mreg;
-
- rcvdBytesCntMetric = mreg == null ?
- null : mreg.longAdderMetric(RECEIVED_BYTES_METRIC_NAME, RECEIVED_BYTES_METRIC_DESC);
-
- sentBytesCntMetric = mreg == null ?
- null : mreg.longAdderMetric(SENT_BYTES_METRIC_NAME, SENT_BYTES_METRIC_DESC);
-
- outboundMessagesQueueSizeMetric = mreg == null ? null : mreg.longAdderMetric(
- OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME,
- OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_DESC
- );
-
- if (mreg != null) {
- mreg.register(SESSIONS_CNT_METRIC_NAME, sessions::size, "Active TCP sessions count.");
-
- boolean sslEnabled = Arrays.stream(filters).anyMatch(filter -> filter instanceof GridNioSslFilter);
-
- mreg.register(SSL_ENABLED_METRIC_NAME, () -> sslEnabled, "Whether SSL is enabled");
- }
+ /**
+ * @return Number of active TCP sessions.
+ */
+ public int activeTcpSessionsCount() {
+ return sessions.size();
}
/**
@@ -521,7 +515,7 @@ public void start() {
filterChain.start();
if (acceptWorker != null)
- U.newThread(acceptWorker).start();
+ CommonUtils.newThread(acceptWorker).start();
for (IgniteThread thread : clientThreads)
thread.start();
@@ -535,11 +529,11 @@ public void stop() {
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();
@@ -781,7 +775,8 @@ public void resend(GridNioSession ses) {
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);
}
}
}
@@ -868,7 +863,7 @@ public IgniteInternalFuture dumpStats(final String msg, IgnitePredicate<
if (!F.isEmpty(msg)) {
synchronized (sb) {
if (sb.length() > 0)
- sb.append(U.nl());
+ sb.append(CommonUtils.nl());
sb.append(msg);
}
@@ -918,7 +913,7 @@ public IgniteInternalFuture dumpNodeStats(final String msg, IgnitePredic
if (!F.isEmpty(msg)) {
synchronized (sb) {
if (sb.length() > 0)
- sb.append(U.nl());
+ sb.append(CommonUtils.nl());
sb.append(msg);
}
@@ -1043,7 +1038,7 @@ public void writeTimeout(long writeTimeout) {
/**
* 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.
*/
@@ -1097,8 +1092,8 @@ private Selector createSelector(@Nullable SocketAddress addr) throws IgniteCheck
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;
@@ -1215,10 +1210,10 @@ protected ByteBufferNioClientWorker(
@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;
@@ -1249,7 +1244,7 @@ else if (cnt == 0)
log.trace("Bytes received [sockCh=" + sockCh + ", cnt=" + cnt + ']');
if (rcvdBytesCntMetric != null)
- rcvdBytesCntMetric.add(cnt);
+ rcvdBytesCntMetric.accept(cnt);
ses.bytesReceived(cnt);
@@ -1316,7 +1311,7 @@ else if (cnt == 0)
span.addTag(SOCKET_WRITE_BYTES, () -> Integer.toString(cnt));
if (sentBytesCntMetric != null)
- sentBytesCntMetric.add(cnt);
+ sentBytesCntMetric.accept(cnt);
ses.bytesSent(cnt);
}
@@ -1324,7 +1319,7 @@ else if (cnt == 0)
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);
@@ -1384,10 +1379,10 @@ protected DirectNioClientWorker(
@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;
@@ -1418,7 +1413,7 @@ protected DirectNioClientWorker(
return;
if (rcvdBytesCntMetric != null)
- rcvdBytesCntMetric.add(cnt);
+ rcvdBytesCntMetric.accept(cnt);
ses.bytesReceived(cnt);
onRead(cnt);
@@ -1491,7 +1486,7 @@ private void processWriteSsl(SelectionKey key) throws IOException {
int cnt = sockCh.write(sslNetBuf);
if (sentBytesCntMetric != null)
- sentBytesCntMetric.add(cnt);
+ sentBytesCntMetric.accept(cnt);
ses.bytesSent(cnt);
@@ -1578,14 +1573,14 @@ private void processWriteSsl(SelectionKey key) throws IOException {
log.trace("Bytes sent [sockCh=" + sockCh + ", cnt=" + cnt + ']');
if (sentBytesCntMetric != null)
- sentBytesCntMetric.add(cnt);
+ sentBytesCntMetric.accept(cnt);
ses.bytesSent(cnt);
}
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);
@@ -1636,16 +1631,16 @@ private boolean writeToBuffer(
Span span = tracing.create(SpanType.COMMUNICATION_SOCKET_WRITE, req.span());
try (TraceSurroundings ignore = span.equals(NoopSpan.INSTANCE) ? null : MTC.support(span)) {
- span.addTag(SpanTags.MESSAGE, () -> traceName(msg));
+ span.addTag(SpanTags.MESSAGE, () -> tracing.traceName(msg));
assert msg != null;
int startPos = buf.position();
if (messageFactory() == null) {
- assert msg instanceof ClientMessage; // TODO: Will refactor in IGNITE-26554.
+ assert msg instanceof SelfSerializingMessage; // TODO: Will refactor in IGNITE-26554.
- finished = ((ClientMessage)msg).writeTo(buf);
+ finished = ((SelfSerializingMessage)msg).writeTo(buf);
}
else {
MessageSerializer msgSer = messageFactory().serializer(msg.directType());
@@ -1687,7 +1682,7 @@ private boolean writeSslSystem(GridSelectorNioSessionImpl ses, WritableByteChann
int cnt = sockCh.write(buf);
if (sentBytesCntMetric != null)
- sentBytesCntMetric.add(cnt);
+ sentBytesCntMetric.accept(cnt);
ses.bytesSent(cnt);
@@ -1778,7 +1773,7 @@ private void processWrite0(SelectionKey key) throws IOException {
log.trace("Bytes sent [sockCh=" + sockCh + ", cnt=" + cnt + ']');
if (sentBytesCntMetric != null)
- sentBytesCntMetric.add(cnt);
+ sentBytesCntMetric.accept(cnt);
ses.bytesSent(cnt);
onWrite(cnt);
@@ -1786,7 +1781,7 @@ private void processWrite0(SelectionKey key) throws IOException {
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);
@@ -1839,14 +1834,14 @@ private boolean writeToBuffer(GridSelectorNioSessionImpl ses, ByteBuffer buf, Se
Span span = tracing.create(SpanType.COMMUNICATION_SOCKET_WRITE, req.span());
try (TraceSurroundings ignore = span.equals(NoopSpan.INSTANCE) ? null : MTC.support(span)) {
- span.addTag(SpanTags.MESSAGE, () -> traceName(msg));
+ span.addTag(SpanTags.MESSAGE, () -> tracing.traceName(msg));
int startPos = buf.position();
if (msgFactory == null) {
- assert msg instanceof ClientMessage; // TODO: Will refactor in IGNITE-26554.
+ assert msg instanceof SelfSerializingMessage; // TODO: Will refactor in IGNITE-26554.
- finished = ((ClientMessage)msg).writeTo(buf);
+ finished = ((SelfSerializingMessage)msg).writeTo(buf);
}
else {
MessageSerializer msgSer = msgFactory.serializer(msg.directType());
@@ -1981,10 +1976,10 @@ private abstract class AbstractNioClientWorker extends GridWorker implements Gri
}
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;
}
@@ -1992,7 +1987,7 @@ private abstract class AbstractNioClientWorker extends GridWorker implements Gri
}
}
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;
@@ -2032,7 +2027,7 @@ private void createSelector() throws IgniteCheckedException {
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()))
@@ -2114,7 +2109,7 @@ private void createSelector() throws IgniteCheckedException {
*/
private void bodyInternal() throws IgniteCheckedException, InterruptedException {
try {
- long lastIdleCheck = U.currentTimeMillis();
+ long lastIdleCheck = CommonUtils.currentTimeMillis();
while (selector.isOpen() && !(isCancelled() && changeReqs.isEmpty())) {
SessionChangeRequest req;
@@ -2148,7 +2143,7 @@ private void bodyInternal() throws IgniteCheckedException, InterruptedException
break;
// Just in case we do busy selects.
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (now - lastIdleCheck > 2000) {
lastIdleCheck = now;
@@ -2197,7 +2192,7 @@ private void bodyInternal() throws IgniteCheckedException, InterruptedException
select = false;
}
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (now - lastIdleCheck > 2000) {
lastIdleCheck = now;
@@ -2233,7 +2228,7 @@ private void bodyInternal() throws IgniteCheckedException, InterruptedException
if (log.isDebugEnabled())
log.debug("Closing NIO selector.");
- U.close(selector, log);
+ CommonUtils.close(selector, log);
}
}
}
@@ -2266,7 +2261,7 @@ private void processSessionChangedRequest(SessionChangeRequest req0) throws Igni
if (key != null)
key.cancel();
- U.closeQuiet(ch);
+ CommonUtils.closeQuiet(ch);
req.onDone();
@@ -2448,7 +2443,7 @@ private void dumpSelectorInfo(StringBuilder sb, Set keys) {
.append(", bytesRcvd0=").append(bytesRcvd0)
.append(", bytesSent=").append(bytesSent)
.append(", bytesSent0=").append(bytesSent0)
- .append("]").append(U.nl());
+ .append("]").append(CommonUtils.nl());
}
/**
@@ -2506,8 +2501,8 @@ private void dumpStats(StringBuilder sb,
Object msg = req.message();
- if (shortInfo && msg instanceof GridIoMessage)
- msg = ((GridIoMessage)msg).message().getClass().getSimpleName();
+ if (shortInfo && msg instanceof MessageContainer)
+ msg = ((MessageContainer)msg).message().getClass().getSimpleName();
sb.append(msg);
@@ -2550,8 +2545,8 @@ private void dumpStats(StringBuilder sb,
for (SessionWriteRequest req : ses.writeQueue()) {
Object msg = req.message();
- if (shortInfo && msg instanceof GridIoMessage)
- msg = ((GridIoMessage)msg).message().getClass().getSimpleName();
+ if (shortInfo && msg instanceof MessageContainer)
+ msg = ((MessageContainer)msg).message().getClass().getSimpleName();
if (cnt == 0)
sb.append(",\n opQueue=[").append(msg);
@@ -2614,7 +2609,7 @@ private void processSelectedKeysOptimized(SelectionKey[] keys) throws ClosedByIn
}
catch (Exception | Error e) { // TODO IGNITE-2659.
try {
- U.sleep(1000);
+ CommonUtils.sleep(1000);
}
catch (IgniteInterruptedCheckedException ignore) {
// No-op.
@@ -2623,7 +2618,7 @@ private void processSelectedKeysOptimized(SelectionKey[] keys) throws ClosedByIn
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 + ']');
@@ -2681,7 +2676,7 @@ private void processSelectedKeys(Set keys) throws ClosedByInterrup
}
catch (Exception | Error e) { // TODO IGNITE-2659.
try {
- U.sleep(1000);
+ CommonUtils.sleep(1000);
}
catch (IgniteInterruptedCheckedException ignore) {
// No-op.
@@ -2690,7 +2685,7 @@ private void processSelectedKeys(Set keys) throws ClosedByInterrup
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 + ']');
}
@@ -2703,7 +2698,7 @@ else if (log.isDebugEnabled())
* @param keys Keys registered to selector.
*/
private void checkIdle(Iterable keys) {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
for (SelectionKey key : keys) {
GridNioKeyAttachment attach = (GridNioKeyAttachment)key.attachment();
@@ -2782,7 +2777,9 @@ private void register(NioOperationFuture fut) {
(InetSocketAddress)sockCh.getRemoteAddress(),
fut.accepted(),
sndQueueLimit,
- mreg,
+ outboundMessagesQueueSizeMetric,
+ maxMessagesQueueSizeMetric,
+ tracing,
writeBuf,
readBuf);
@@ -2847,11 +2844,11 @@ private void register(NioOperationFuture fut) {
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);
}
}
@@ -2878,8 +2875,8 @@ private void closeKey(SelectionKey key) {
}
}
finally {
- U.close(key, log);
- U.close(sock, log);
+ CommonUtils.close(key, log);
+ CommonUtils.close(sock, log);
}
}
@@ -2908,11 +2905,11 @@ protected boolean close(
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);
@@ -3000,7 +2997,7 @@ private void processConnect(SelectionKey key) throws IOException {
register(sesFut);
}
catch (IOException e) {
- U.closeQuiet(ch);
+ CommonUtils.closeQuiet(ch);
sesFut.onDone(new GridNioException("Failed to connect to node", e));
@@ -3057,18 +3054,6 @@ final void reset0() {
}
}
- /**
- * Gets outbound messages queue size.
- *
- * @return Write queue size.
- */
- public int outboundMessagesQueueSize() {
- if (outboundMessagesQueueSizeMetric == null)
- return -1;
-
- return (int)outboundMessagesQueueSizeMetric.value();
- }
-
/**
* A separate thread that will accept incoming connections and schedule read to some worker.
*/
@@ -3121,10 +3106,10 @@ protected GridNioAcceptWorker(
}
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;
}
@@ -3213,12 +3198,12 @@ private void closeSelector() {
// 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);
}
}
@@ -3277,9 +3262,9 @@ private void addRegistrationRequest(SocketChannel sockCh) {
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);
}
}
}
@@ -3946,11 +3931,20 @@ public static class Builder {
/** Worker lifecycle listener to be used by server's worker threads. */
private GridWorkerListener workerLsnr;
- /** Metrics registry. */
- private MetricRegistryImpl mreg;
+ /** Received bytes count metric. */
+ private LongConsumer rcvdBytesCntMetric;
+
+ /** Sent bytes count metric. */
+ private LongConsumer sentBytesCntMetric;
+
+ /** Per-session outbound messages queue size metric. */
+ private LongConsumer outboundMessagesQueueSizeMetric;
- /** Tracing processor */
- private Tracing tracing;
+ /** Per-session maximum outbound messages queue size metric. */
+ private LongConsumer maxMessagesQueueSizeMetric;
+
+ /** Span manager */
+ private SpanManager tracing;
/** Message factory. */
private MessageFactory msgFactory;
@@ -3984,7 +3978,10 @@ public GridNioServer build() throws IgniteCheckedException {
msgQueueLsnr,
readWriteSelectorsAssign,
workerLsnr,
- mreg,
+ rcvdBytesCntMetric,
+ sentBytesCntMetric,
+ outboundMessagesQueueSizeMetric,
+ maxMessagesQueueSizeMetric,
tracing,
msgFactory,
filters != null ? Arrays.copyOf(filters, filters.length) : EMPTY_FILTERS
@@ -4010,10 +4007,10 @@ public Builder readWriteSelectorsAssign(boolean readWriteSelectorsAssign) {
}
/**
- * @param tracing Tracing processor.
+ * @param tracing Span manager.
* @return This for chaining.
*/
- public Builder tracing(Tracing tracing) {
+ public Builder tracing(SpanManager tracing) {
this.tracing = tracing;
return this;
@@ -4253,11 +4250,41 @@ public Builder workerListener(GridWorkerListener workerLsnr) {
}
/**
- * @param mreg Metrics registry.
+ * @param rcvdBytesCntMetric Received bytes count metric.
+ * @return This for chaining.
+ */
+ public Builder receivedBytesMetric(LongConsumer rcvdBytesCntMetric) {
+ this.rcvdBytesCntMetric = rcvdBytesCntMetric;
+
+ return this;
+ }
+
+ /**
+ * @param sentBytesCntMetric Sent bytes count metric.
+ * @return This for chaining.
+ */
+ public Builder sentBytesMetric(LongConsumer sentBytesCntMetric) {
+ this.sentBytesCntMetric = sentBytesCntMetric;
+
+ return this;
+ }
+
+ /**
+ * @param outboundMessagesQueueSizeMetric Per-session outbound messages queue size metric.
+ * @return This for chaining.
+ */
+ public Builder outboundMessagesQueueSizeMetric(LongConsumer outboundMessagesQueueSizeMetric) {
+ this.outboundMessagesQueueSizeMetric = outboundMessagesQueueSizeMetric;
+
+ return this;
+ }
+
+ /**
+ * @param maxMessagesQueueSizeMetric Per-session maximum outbound messages queue size metric.
* @return This for chaining.
*/
- public Builder metricRegistry(MetricRegistryImpl mreg) {
- this.mreg = mreg;
+ public Builder maxMessagesQueueSizeMetric(LongConsumer maxMessagesQueueSizeMetric) {
+ this.maxMessagesQueueSizeMetric = maxMessagesQueueSizeMetric;
return this;
}
@@ -4295,7 +4322,7 @@ private class ReadWriteSizeBasedBalancer implements IgniteRunnable {
/** {@inheritDoc} */
@Override public void run() {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (lastBalance + balancePeriod < now) {
lastBalance = now;
@@ -4358,9 +4385,9 @@ private class ReadWriteSizeBasedBalancer implements IgniteRunnable {
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);
}
}
@@ -4391,9 +4418,9 @@ private class ReadWriteSizeBasedBalancer implements IgniteRunnable {
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);
}
}
@@ -4441,7 +4468,7 @@ private class SizeBasedBalancer implements IgniteRunnable {
/** {@inheritDoc} */
@Override public void run() {
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
if (lastBalance + balancePeriod < now) {
lastBalance = now;
@@ -4485,9 +4512,9 @@ private class SizeBasedBalancer implements IgniteRunnable {
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/GridNioServerBuffer.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerBuffer.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerBuffer.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerBuffer.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListener.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListener.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListener.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListener.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListenerAdapter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListenerAdapter.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListenerAdapter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioServerListenerAdapter.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSession.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
similarity index 96%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
index 0211eb85dcae1..56638bcefe97a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionImpl.java
@@ -24,10 +24,10 @@
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 GridNioSessionImpl(
this.rmtAddr = rmtAddr;
this.accepted = accepted;
- long now = U.currentTimeMillis();
+ long now = CommonUtils.currentTimeMillis();
sndSchedTime = now;
createTime = now;
@@ -317,7 +317,7 @@ public void bytesSent(int cnt) {
bytesSent += cnt;
bytesSent0 += cnt;
- lastSndTime = U.currentTimeMillis();
+ lastSndTime = CommonUtils.currentTimeMillis();
}
/**
@@ -331,14 +331,14 @@ public void bytesReceived(int cnt) {
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 void resetSendScheduleTime() {
* {@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/GridNioSessionMetaKey.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
similarity index 93%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
index 650aeb2cc7ce3..47644636def68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioTracerFilter.java
@@ -23,9 +23,9 @@
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.tracing.MTC;
import org.apache.ignite.internal.processors.tracing.NoopSpan;
-import org.apache.ignite.internal.processors.tracing.NoopTracing;
+import org.apache.ignite.internal.processors.tracing.NoopSpanManager;
import org.apache.ignite.internal.processors.tracing.Span;
-import org.apache.ignite.internal.processors.tracing.Tracing;
+import org.apache.ignite.internal.processors.tracing.SpanManager;
import org.apache.ignite.internal.processors.tracing.messages.SpanTransport;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -42,7 +42,7 @@ public class GridNioTracerFilter extends GridNioFilterAdapter {
private IgniteLogger log;
/** Tracing processor. */
- private final Tracing tracer;
+ private final SpanManager tracer;
/**
* Creates a tracer filter.
@@ -50,11 +50,11 @@ public class GridNioTracerFilter extends GridNioFilterAdapter {
* @param log Log instance to use.
* @param tracer Tracing processor.
*/
- public GridNioTracerFilter(IgniteLogger log, Tracing tracer) {
+ public GridNioTracerFilter(IgniteLogger log, SpanManager tracer) {
super("GridNioTracerFilter");
this.log = log;
- this.tracer = tracer == null ? new NoopTracing() : tracer;
+ this.tracer = tracer == null ? new NoopSpanManager() : tracer;
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioWorker.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioWorker.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioWorker.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridNioWorker.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
similarity index 88%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
index 561941903b6b7..aa03d919cfca3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
@@ -26,25 +26,19 @@
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.LongConsumer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
-import org.apache.ignite.internal.processors.metric.impl.LongAdderMetric;
-import org.apache.ignite.internal.processors.metric.impl.MaxValueMetric;
import org.apache.ignite.internal.processors.tracing.MTC;
+import org.apache.ignite.internal.processors.tracing.SpanManager;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.util.deque.FastSizeDeque;
import org.jetbrains.annotations.Nullable;
-import static org.apache.ignite.internal.processors.tracing.messages.TraceableMessagesTable.traceName;
-import static org.apache.ignite.internal.util.nio.GridNioServer.MAX_MESSAGES_QUEUE_SIZE_METRIC_DESC;
-import static org.apache.ignite.internal.util.nio.GridNioServer.MAX_MESSAGES_QUEUE_SIZE_METRIC_NAME;
-import static org.apache.ignite.internal.util.nio.GridNioServer.OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_DESC;
-import static org.apache.ignite.internal.util.nio.GridNioServer.OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME;
-
/**
* Session implementation bound to selector API and socket API.
* Note that this implementation requires non-null values for local and remote
@@ -93,10 +87,13 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
private volatile boolean closeSocket = true;
/** Outbound messages queue size metric. */
- @Nullable private final LongAdderMetric outboundMessagesQueueSizeMetric;
+ @Nullable private final LongConsumer outboundMessagesQueueSizeMetric;
/** Maximum outbound messages queue size metric. */
- @Nullable private final MaxValueMetric maxMessagesQueueSizeMetric;
+ @Nullable private final LongConsumer maxMessagesQueueSizeMetric;
+
+ /** Span manager used to resolve trace names for logging. */
+ private final SpanManager tracer;
/**
* Creates session instance.
@@ -108,6 +105,9 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
* @param rmtAddr Remote address.
* @param accepted Accepted flag.
* @param sndQueueLimit Send queue limit.
+ * @param outboundMessagesQueueSizeMetric Outbound messages queue size metric, or {@code null} if metrics disabled.
+ * @param maxMessagesQueueSizeMetric Maximum outbound messages queue size metric, or {@code null} if metrics disabled.
+ * @param tracer Span manager used to resolve trace names for logging.
* @param writeBuf Write buffer.
* @param readBuf Read buffer.
*/
@@ -119,7 +119,9 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
InetSocketAddress rmtAddr,
boolean accepted,
int sndQueueLimit,
- @Nullable MetricRegistryImpl mreg,
+ @Nullable LongConsumer outboundMessagesQueueSizeMetric,
+ @Nullable LongConsumer maxMessagesQueueSizeMetric,
+ SpanManager tracer,
@Nullable ByteBuffer writeBuf,
@Nullable ByteBuffer readBuf
) {
@@ -151,17 +153,11 @@ public class GridSelectorNioSessionImpl extends GridNioSessionImpl implements Gr
this.readBuf = readBuf;
}
- outboundMessagesQueueSizeMetric = mreg == null ? null : mreg.longAdderMetric(
- OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_NAME,
- OUTBOUND_MESSAGES_QUEUE_SIZE_METRIC_DESC
- );
+ this.outboundMessagesQueueSizeMetric = outboundMessagesQueueSizeMetric;
+
+ this.maxMessagesQueueSizeMetric = maxMessagesQueueSizeMetric;
- maxMessagesQueueSizeMetric = mreg == null ? null : mreg.maxValueMetric(
- MAX_MESSAGES_QUEUE_SIZE_METRIC_NAME,
- MAX_MESSAGES_QUEUE_SIZE_METRIC_DESC,
- 60_000,
- 5
- );
+ this.tracer = tracer;
}
/** {@inheritDoc} */
@@ -323,17 +319,17 @@ int offerSystemFuture(SessionWriteRequest writeFut) {
boolean res = queue.offerFirst(writeFut);
- MTC.span().addLog(() -> "Added to system queue - " + traceName(writeFut.message()));
+ MTC.span().addLog(() -> "Added to system queue - " + tracer.traceName((Message)writeFut.message()));
assert res : "Future was not added to queue";
if (outboundMessagesQueueSizeMetric != null)
- outboundMessagesQueueSizeMetric.increment();
+ outboundMessagesQueueSizeMetric.accept(1);
if (maxMessagesQueueSizeMetric != null) {
int queueSize = queue.sizex();
- maxMessagesQueueSizeMetric.update(queueSize);
+ maxMessagesQueueSizeMetric.accept(queueSize);
return queueSize;
}
@@ -361,17 +357,17 @@ int offerFuture(SessionWriteRequest writeFut) {
boolean res = queue.offer(writeFut);
- MTC.span().addLog(() -> "Added to queue - " + traceName(writeFut.message()));
+ MTC.span().addLog(() -> "Added to queue - " + tracer.traceName((Message)writeFut.message()));
assert res : "Future was not added to queue";
if (outboundMessagesQueueSizeMetric != null)
- outboundMessagesQueueSizeMetric.increment();
+ outboundMessagesQueueSizeMetric.accept(1);
if (maxMessagesQueueSizeMetric != null) {
int queueSize = queue.sizex();
- maxMessagesQueueSizeMetric.update(queueSize);
+ maxMessagesQueueSizeMetric.accept(queueSize);
return queueSize;
}
@@ -390,10 +386,10 @@ void resend(Collection futs) {
assert add;
if (outboundMessagesQueueSizeMetric != null)
- outboundMessagesQueueSizeMetric.add(futs.size());
+ outboundMessagesQueueSizeMetric.accept(futs.size());
if (maxMessagesQueueSizeMetric != null)
- maxMessagesQueueSizeMetric.update(futs.size());
+ maxMessagesQueueSizeMetric.accept(futs.size());
}
/**
@@ -404,7 +400,7 @@ void resend(Collection futs) {
if (last != null) {
if (outboundMessagesQueueSizeMetric != null)
- outboundMessagesQueueSizeMetric.decrement();
+ outboundMessagesQueueSizeMetric.accept(-1);
if (sem != null && !last.messageThread())
sem.release();
@@ -439,7 +435,7 @@ boolean removeFuture(SessionWriteRequest fut) {
boolean rmv = queue.removeLastOccurrence(fut);
if (rmv && outboundMessagesQueueSizeMetric != null)
- outboundMessagesQueueSizeMetric.decrement();
+ outboundMessagesQueueSizeMetric.accept(-1);
return rmv;
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
similarity index 97%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
index 4ff126fa4cf91..f553f8d97e583 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/GridTcpNioCommunicationClient.java
@@ -25,9 +25,9 @@
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 GridNioSession session() {
/** {@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/SelectedSelectionKeySet.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/SessionWriteRequest.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/package-info.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/package-info.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/package-info.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/package-info.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
similarity index 98%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index 1da7c8ab62ae3..bcf85808db758 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -28,8 +28,8 @@
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 boolean handshake() throws IgniteCheckedException, SSLException {
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 ByteBuffer decode(ByteBuffer buf) throws IgniteCheckedException, SSLExcep
// 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 @@ private void readFromNet() throws IgniteCheckedException {
*/
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/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
similarity index 91%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
index ab9f29946999b..b2994a874a6c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.function.LongConsumer;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
@@ -27,16 +28,13 @@
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
-import org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl;
-import org.apache.ignite.internal.processors.metric.impl.IntMetricImpl;
+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;
@@ -86,10 +84,10 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
@Nullable private Exception onSessionOpenedException;
/** Metric that indicates sessions count that were rejected due to SSL errors. */
- @Nullable private final IntMetricImpl rejectedSesCnt;
+ @Nullable private final Runnable rejectedSesCnt;
- /** Histogram that provides distribution of SSL handshake duration. */
- @Nullable private final HistogramMetricImpl handshakeDuration;
+ /** Records the SSL handshake duration (in milliseconds). */
+ @Nullable private final LongConsumer handshakeDuration;
/**
* Creates SSL filter.
@@ -98,14 +96,16 @@ public class GridNioSslFilter extends GridNioFilterAdapter {
* @param directBuf Direct buffer flag.
* @param order Byte order.
* @param log Logger to use.
- * @param mreg Optional metric registry.
+ * @param handshakeDuration Records SSL handshake duration (ms), or {@code null} if metrics disabled.
+ * @param rejectedSesCnt Increments the rejected-sessions counter, or {@code null} if metrics disabled.
*/
public GridNioSslFilter(
SSLContext sslCtx,
boolean directBuf,
ByteOrder order,
IgniteLogger log,
- @Nullable MetricRegistryImpl mreg
+ @Nullable LongConsumer handshakeDuration,
+ @Nullable Runnable rejectedSesCnt
) {
super("SSL filter");
@@ -113,17 +113,8 @@ public GridNioSslFilter(
this.sslCtx = sslCtx;
this.directBuf = directBuf;
this.order = order;
-
- handshakeDuration = mreg == null ? null : mreg.histogram(
- SSL_HANDSHAKE_DURATION_HISTOGRAM_METRIC_NAME,
- new long[] {250, 500, 1000},
- "SSL handshake duration in milliseconds."
- );
-
- rejectedSesCnt = mreg == null ? null : mreg.intMetric(
- SSL_REJECTED_SESSIONS_CNT_METRIC_NAME,
- "TCP sessions count that were rejected due to SSL errors."
- );
+ this.handshakeDuration = handshakeDuration;
+ this.rejectedSesCnt = rejectedSesCnt;
}
/**
@@ -253,7 +244,7 @@ public void enabledProtocols(String... enabledProtos) {
long startTime = System.nanoTime();
- fut.listen(() -> handshakeDuration.value(U.nanosToMillis(System.nanoTime() - startTime)));
+ fut.listen(() -> handshakeDuration.accept(CommonUtils.nanosToMillis(System.nanoTime() - startTime)));
}
hnd.handshake();
@@ -262,7 +253,7 @@ public void enabledProtocols(String... enabledProtos) {
}
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();
}
@@ -275,7 +266,7 @@ public void enabledProtocols(String... enabledProtos) {
if (fut != null) {
if (rejectedSesCnt != null)
- rejectedSesCnt.increment();
+ rejectedSesCnt.run();
fut.onDone(new IgniteCheckedException("SSL handshake failed (connection closed).", onSessionOpenedException));
}
@@ -455,7 +446,7 @@ private IgniteInternalFuture shutdownSession(GridNioSession ses, GridNi
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/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
similarity index 98%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
index 13cf4ab96bed6..0b225256c29fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
+++ b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
@@ -30,10 +30,10 @@
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 @@ void handshake() throws IgniteCheckedException, SSLException {
if (log.isDebugEnabled())
log.debug("Entered handshake(): [handshakeStatus=" + handshakeStatus + ", ses=" + ses + ']');
- long startTs = U.currentTimeMillis();
+ long startTs = CommonUtils.currentTimeMillis();
lock();
@@ -258,7 +258,7 @@ void handshake() throws IgniteCheckedException, SSLException {
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 @@ void handshake() throws IgniteCheckedException, SSLException {
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 @@ void messageReceived(ByteBuffer buf) throws IgniteCheckedException, SSLException
// 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/internal/util/nio/ssl/GridSslMeta.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/package-info.java b/modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/package-info.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/package-info.java
rename to modules/nio/src/main/java/org/apache/ignite/internal/util/nio/ssl/package-info.java
diff --git a/modules/thin-client/impl/README.txt b/modules/thin-client/impl/README.txt
new file mode 100644
index 0000000000000..e0d6f4297d37e
--- /dev/null
+++ b/modules/thin-client/impl/README.txt
@@ -0,0 +1,9 @@
+Apache Ignite Thin Client Implementation Module
+------------------------
+
+ignite-thin-client-impl module is internal module to separate thin-client API and implementation.
+It contains the implementation of the thin client API declared in ignite-thin-client-api
+(TcpIgniteClient and supporting classes).
+
+Note, class files of this module are copied in ignite-core.jar during project assembly
+to ensure compatibility with previous Ignite releases.
diff --git a/modules/thin-client/impl/pom.xml b/modules/thin-client/impl/pom.xml
new file mode 100644
index 0000000000000..d19ba53ec78a8
--- /dev/null
+++ b/modules/thin-client/impl/pom.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+ 4.0.0
+
+
+ org.apache.ignite
+ ignite-parent-internal
+ ${revision}
+ ../../../parent-internal/pom.xml
+
+
+ ignite-thin-client-impl
+
+ http://ignite.apache.org
+
+
+
+ ${project.groupId}
+ ignite-commons
+ provided
+
+
+
+ ${project.groupId}
+ ignite-binary-api
+ provided
+
+
+
+ ${project.groupId}
+ ignite-thin-client-api
+ provided
+
+
+
+ ${project.groupId}
+ ignite-nio
+ provided
+
+
+
+ org.jetbrains
+ annotations
+ ${jetbrains.annotations.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+ ${maven.deploy.plugin.version}
+
+ false
+
+
+
+
+
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/monitoring/EventListenerDemultiplexer.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/monitoring/EventListenerDemultiplexer.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/monitoring/EventListenerDemultiplexer.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/monitoring/EventListenerDemultiplexer.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/BinaryNameMapperMode.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/BinaryNameMapperMode.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/BinaryNameMapperMode.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/BinaryNameMapperMode.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientAtomicLongImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientAtomicLongImpl.java
similarity index 97%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientAtomicLongImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientAtomicLongImpl.java
index f7f6f521b2659..d3d606b4655d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientAtomicLongImpl.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientAtomicLongImpl.java
@@ -21,7 +21,7 @@
import org.apache.ignite.client.ClientAtomicLong;
import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.binary.BinaryWriterEx;
-import org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor;
+import org.apache.ignite.internal.processors.datastructures.DataStructuresConstants;
import org.jetbrains.annotations.Nullable;
/**
@@ -53,8 +53,8 @@ public ClientAtomicLongImpl(String name, @Nullable String groupName, ReliableCha
this.groupName = groupName;
this.ch = ch;
- String grpNameInternal = groupName == null ? DataStructuresProcessor.DEFAULT_DS_GROUP_NAME : groupName;
- cacheId = ClientUtils.cacheId(DataStructuresProcessor.ATOMICS_CACHE_NAME + "@" + grpNameInternal);
+ String grpNameInternal = groupName == null ? DataStructuresConstants.DEFAULT_DS_GROUP_NAME : groupName;
+ cacheId = ClientUtils.cacheId(DataStructuresConstants.ATOMICS_CACHE_NAME + "@" + grpNameInternal);
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinary.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientBinary.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinary.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientBinary.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
similarity index 92%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
index a496265c5b18e..671e1a2c869b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientBinaryMarshaller.java
@@ -17,14 +17,14 @@
package org.apache.ignite.internal.client.thin;
+import java.util.Collections;
import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryMetadataHandler;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.MarshallerContext;
@@ -108,10 +108,14 @@ private GridBinaryMarshaller createImpl(BinaryConfiguration binCfg) {
marsh.setContext(marshCtx);
- BinaryContext ctx = U.binaryContext(
+ BinaryContext ctx = BinaryUtils.binaryContext(
metaHnd,
marsh,
- new IgniteConfiguration().setBinaryConfiguration(binCfg),
+ null,
+ null,
+ binCfg,
+ Collections.emptyMap(),
+ BinaryUtils::affinityFieldName,
NullLogger.INSTANCE
);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityContext.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityContext.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityContext.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityContext.java
index 9ac655460ef71..fb3877dbdee6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityContext.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityContext.java
@@ -38,8 +38,8 @@
import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.binary.BinaryWriterEx;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE;
@@ -365,7 +365,7 @@ public void registerCache(String cacheName) {
ClientPartitionAwarenessMapperHolder hld = cacheKeyMapperFactoryMap.computeIfAbsent(ClientUtils.cacheId(cacheName),
id -> new ClientPartitionAwarenessMapperHolder(cacheName));
- hld.ts = U.currentTimeMillis();
+ hld.ts = CommonUtils.currentTimeMillis();
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityMapping.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityMapping.java
similarity index 96%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityMapping.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityMapping.java
index 4a944e0c6915e..1ee7b28fb7eef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityMapping.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheAffinityMapping.java
@@ -26,7 +26,6 @@
import java.util.UUID;
import java.util.function.Function;
import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.client.ClientFeatureNotSupportedByServerException;
import org.apache.ignite.client.ClientPartitionAwarenessMapper;
import org.apache.ignite.internal.binary.BinaryReaderEx;
@@ -34,8 +33,8 @@
import org.apache.ignite.internal.binary.BinaryWriterEx;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
import static org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.ALL_AFFINITY_MAPPINGS;
import static org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.DC_AWARE;
@@ -211,7 +210,7 @@ public static ClientCacheAffinityMapping readResponse(
int cachesCnt = in.readInt();
if (applicable) { // Partition awareness is applicable for these caches.
- Map> cacheKeyCfg = U.newHashMap(cachesCnt);
+ Map> cacheKeyCfg = CommonUtils.newHashMap(cachesCnt);
for (int j = 0; j < cachesCnt; j++)
cacheKeyCfg.put(in.readInt(), readCacheKeyConfiguration(in));
@@ -264,7 +263,7 @@ public static ClientCacheAffinityMapping readResponse(
private static Map readCacheKeyConfiguration(BinaryReaderEx in) {
int keyCfgCnt = in.readInt();
- Map keyCfg = U.newHashMap(keyCfgCnt);
+ Map keyCfg = CommonUtils.newHashMap(keyCfgCnt);
for (int i = 0; i < keyCfgCnt; i++)
keyCfg.put(in.readInt(), in.readInt());
@@ -298,7 +297,7 @@ private static UUID[] readNodePartitions(BinaryReaderEx in) {
// Expand partToNode if needed.
if (part >= partToNode.length)
- partToNode = Arrays.copyOf(partToNode, U.ceilPow2(part + 1));
+ partToNode = Arrays.copyOf(partToNode, CommonUtils.ceilPow2(part + 1));
}
partToNode[part] = nodeId;
@@ -384,12 +383,12 @@ private static class RendezvousAffinityKeyMapper implements ClientPartitionAware
*/
private RendezvousAffinityKeyMapper(int parts) {
this.parts = parts;
- affinityMask = RendezvousAffinityFunction.calculateMask(parts);
+ affinityMask = CommonUtils.calculateMask(parts);
}
/** {@inheritDoc} */
@Override public int partition(Object key) {
- return RendezvousAffinityFunction.calculatePartition(key, affinityMask, parts);
+ return CommonUtils.calculatePartition(key, affinityMask, parts);
}
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntry.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntry.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntry.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntry.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenerHandler.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenerHandler.java
similarity index 98%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenerHandler.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenerHandler.java
index 72142323a2546..5ca39dc97d98d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenerHandler.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenerHandler.java
@@ -36,8 +36,8 @@
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
import org.apache.ignite.internal.binary.streams.BinaryStreams;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.U;
import static org.apache.ignite.internal.client.thin.ClientNotificationType.CONTINUOUS_QUERY_EVENT;
import static org.apache.ignite.internal.client.thin.TcpClientCache.JAVA_PLATFORM;
@@ -176,7 +176,7 @@ public synchronized void startListen(
if (lsnr != null)
lsnr.onDisconnected(reason);
- U.closeQuiet(this);
+ CommonUtils.closeQuiet(this);
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenersRegistry.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenersRegistry.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenersRegistry.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientCacheEntryListenersRegistry.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannel.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientChannel.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannel.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientChannel.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientChannelConfiguration.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterGroupImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterGroupImpl.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterGroupImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterGroupImpl.java
index 838aecc92a33a..fbca7b15caa04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterGroupImpl.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterGroupImpl.java
@@ -42,10 +42,10 @@
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.binary.BinaryReaderEx;
import org.apache.ignite.internal.binary.BinaryWriterEx;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.lang.ClusterNodeFunc;
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.U;
import org.apache.ignite.lang.IgniteProductVersion;
import org.jetbrains.annotations.Nullable;
@@ -121,7 +121,7 @@ private ClientClusterGroupImpl(ReliableChannelEx ch, ClientUtils utils,
@Override public ClientClusterGroup forOthers(ClusterNode node, ClusterNode... nodes) {
A.notNull(node, "node");
- Collection nodes0 = collection(U::newHashSet, node, nodes);
+ Collection nodes0 = collection(CommonUtils::newHashSet, node, nodes);
return forPredicate(n -> !nodes0.contains(n));
}
@@ -221,7 +221,7 @@ private ClientClusterGroupImpl(ReliableChannelEx ch, ClientUtils utils,
@Override public ClientClusterGroup forHost(String host, String... hosts) {
A.notNull(host, "host");
- Collection hosts0 = collection(U::newHashSet, host, hosts);
+ Collection hosts0 = collection(CommonUtils::newHashSet, host, hosts);
return forPredicate(n -> {
for (String hostName : n.hostNames()) {
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterImpl.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterImpl.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterNodeImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterNodeImpl.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterNodeImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientClusterNodeImpl.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java
index 7234473597c2e..d3fbf8744ffae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientComputeImpl.java
@@ -37,9 +37,9 @@
import org.apache.ignite.internal.binary.BinaryWriterEx;
import org.apache.ignite.internal.binary.streams.BinaryStreams;
import org.apache.ignite.internal.processors.platform.client.ClientStatus;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.client.thin.ClientNotificationType.COMPUTE_TASK_FINISHED;
@@ -266,7 +266,7 @@ private static boolean cancelGridFuture(GridFutureAdapter> fut, Boolean mayInt
return mayInterruptIfRunning ? fut.cancel() : fut.onCancelled();
}
catch (IgniteCheckedException e) {
- throw U.convertException(e);
+ throw CommonUtils.convertException(e);
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientContinuousQueryCursor.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientContinuousQueryCursor.java
similarity index 93%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientContinuousQueryCursor.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientContinuousQueryCursor.java
index 0ff1f41782e61..7a5e1447b5e25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientContinuousQueryCursor.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientContinuousQueryCursor.java
@@ -21,7 +21,7 @@
import java.util.Iterator;
import java.util.List;
import org.apache.ignite.cache.query.QueryCursor;
-import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.util.CommonUtils;
import org.jetbrains.annotations.NotNull;
/**
@@ -50,8 +50,8 @@ class ClientContinuousQueryCursor implements QueryCursor {
/** {@inheritDoc} */
@Override public void close() {
- U.closeQuiet(initQryCursor);
- U.closeQuiet(lsnrHnd);
+ CommonUtils.closeQuiet(initQryCursor);
+ CommonUtils.closeQuiet(lsnrHnd);
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientDiscoveryContext.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientDiscoveryContext.java
similarity index 97%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientDiscoveryContext.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientDiscoveryContext.java
index 928c00349c860..b09a119d731ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientDiscoveryContext.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientDiscoveryContext.java
@@ -37,8 +37,8 @@
import org.apache.ignite.client.ClientAddressFinder;
import org.apache.ignite.client.ClientException;
import org.apache.ignite.configuration.ClientConfiguration;
-import org.apache.ignite.configuration.ClientConnectorConfiguration;
import org.apache.ignite.internal.binary.BinaryReaderEx;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.HostAndPortRange;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.logger.NullLogger;
@@ -231,8 +231,8 @@ private static Set> parsedAddresses(String[] addrs) thro
try {
ranges.add(HostAndPortRange.parse(
a,
- ClientConnectorConfiguration.DFLT_PORT,
- ClientConnectorConfiguration.DFLT_PORT + ClientConnectorConfiguration.DFLT_PORT_RANGE,
+ CommonUtils.DFLT_PORT,
+ CommonUtils.DFLT_PORT + CommonUtils.DFLT_PORT_RANGE,
"Failed to parse Ignite server address"
));
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryCursor.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryCursor.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryCursor.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryCursor.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryPager.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryPager.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryPager.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientFieldsQueryPager.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientIgniteSetImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientIgniteSetImpl.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientIgniteSetImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientIgniteSetImpl.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientInternalBinaryConfiguration.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheAdapter.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheAdapter.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheAdapter.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheAdapter.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheEntryListenerAdapter.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheEntryListenerAdapter.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheEntryListenerAdapter.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientJCacheEntryListenerAdapter.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientNotificationType.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientNotificationType.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientNotificationType.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientNotificationType.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientOperation.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientOperation.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientOperation.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientOperation.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientProtocolError.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientProtocolError.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientProtocolError.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientProtocolError.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryCursor.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryCursor.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryCursor.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryCursor.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryPager.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryPager.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryPager.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientQueryPager.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientRetryPolicyContextImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientRetryPolicyContextImpl.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientRetryPolicyContextImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientRetryPolicyContextImpl.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServiceDescriptorImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientServiceDescriptorImpl.java
similarity index 98%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServiceDescriptorImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientServiceDescriptorImpl.java
index 51a1eea708b93..580c7963676d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServiceDescriptorImpl.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientServiceDescriptorImpl.java
@@ -20,7 +20,6 @@
import java.util.UUID;
import org.apache.ignite.client.ClientServiceDescriptor;
import org.apache.ignite.platform.PlatformType;
-import org.apache.ignite.services.Service;
import org.jetbrains.annotations.Nullable;
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
similarity index 98%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
index 6cda195ddf72a..342ce8f630c5f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
@@ -40,9 +40,9 @@
import org.apache.ignite.internal.binary.BinaryWriterEx;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.service.ServiceCallContextImpl;
+import org.apache.ignite.internal.util.CommonUtils;
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.U;
import org.apache.ignite.platform.PlatformServiceMethod;
import org.apache.ignite.platform.PlatformType;
import org.apache.ignite.services.ServiceCallContext;
@@ -218,7 +218,7 @@ private ServiceTopology(String name) {
*/
private boolean isUpdateRequired(AffinityTopologyVersion curAffTop) {
return lastAffTop == null || curAffTop.topologyVersion() > lastAffTop.topologyVersion()
- || U.nanosToMillis(System.nanoTime() - lastUpdateRequestTime) >= SRV_TOP_UPDATE_PERIOD;
+ || CommonUtils.nanosToMillis(System.nanoTime() - lastUpdateRequestTime) >= SRV_TOP_UPDATE_PERIOD;
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientSslUtils.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientSslUtils.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientSslUtils.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientSslUtils.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientUtils.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientUtils.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientUtils.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ClientUtils.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/FieldsQueryPager.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/FieldsQueryPager.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/FieldsQueryPager.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/FieldsQueryPager.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/GenericQueryPager.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/GenericQueryPager.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/GenericQueryPager.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/GenericQueryPager.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/IgniteClientFutureImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/IgniteClientFutureImpl.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/IgniteClientFutureImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/IgniteClientFutureImpl.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/NotificationListener.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/NotificationListener.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/NotificationListener.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/NotificationListener.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/PayloadInputChannel.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/PayloadInputChannel.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/PayloadInputChannel.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/PayloadInputChannel.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/PayloadOutputChannel.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/PayloadOutputChannel.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/PayloadOutputChannel.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/PayloadOutputChannel.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolContext.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ProtocolContext.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolContext.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ProtocolContext.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersion.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersion.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersion.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersion.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersionFeature.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersionFeature.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersionFeature.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ProtocolVersionFeature.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/QueryPager.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/QueryPager.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/QueryPager.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/QueryPager.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelEx.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelEx.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelEx.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelEx.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelImpl.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelImpl.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelImpl.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelImpl.java
index ec6e96cb0f979..b29bb69629fe3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelImpl.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannelImpl.java
@@ -39,8 +39,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCommonsSystemProperties;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.client.ClientAuthenticationException;
import org.apache.ignite.client.ClientConnectionException;
import org.apache.ignite.client.ClientException;
@@ -52,8 +52,8 @@
import org.apache.ignite.configuration.ClientConfiguration;
import org.apache.ignite.internal.client.thin.io.ClientConnectionMultiplexer;
import org.apache.ignite.internal.client.thin.io.gridnioserver.GridNioClientConnectionMultiplexer;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.logger.NullLogger;
import org.jetbrains.annotations.Nullable;
@@ -141,10 +141,10 @@ final class ReliableChannelImpl implements ReliableChannelEx {
partitionAwarenessEnabled = clientCfg.isPartitionAwarenessEnabled();
- String dcId = IgniteSystemProperties.getString(IgniteSystemProperties.IGNITE_DATA_CENTER_ID);
+ String dcId = IgniteCommonsSystemProperties.getString(IgniteCommonsSystemProperties.IGNITE_DATA_CENTER_ID);
if (dcId == null && !F.isEmpty(clientCfg.getUserAttributes()))
- dcId = clientCfg.getUserAttributes().get(IgniteSystemProperties.IGNITE_DATA_CENTER_ID);
+ dcId = clientCfg.getUserAttributes().get(IgniteCommonsSystemProperties.IGNITE_DATA_CENTER_ID);
affinityCtx = new ClientCacheAffinityContext(
binary,
@@ -1133,7 +1133,7 @@ private ClientChannel getOrCreateChannel(boolean ignoreThrottling)
*/
private synchronized void closeChannel() {
if (ch != null) {
- U.closeQuiet(ch);
+ CommonUtils.closeQuiet(ch);
ch = null;
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java
index 0099f096b4fbf..ab574b9cf3eb4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java
@@ -72,11 +72,11 @@
import org.apache.ignite.internal.processors.cache.CacheInvokeResult;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.platform.client.ClientStatus;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T3;
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.U;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
@@ -1146,7 +1146,7 @@ else if (qry instanceof IndexQuery)
return new ClientContinuousQueryCursor<>(cur, hnd);
}
catch (Exception e) {
- U.closeQuiet(hnd);
+ CommonUtils.closeQuiet(hnd);
throw e;
}
@@ -1202,7 +1202,7 @@ else if (qry instanceof IndexQuery)
@Override public void deregisterCacheEntryListener(CacheEntryListenerConfiguration cfg) {
ClientCacheEntryListenerHandler, ?> hnd = lsnrsRegistry.deregisterCacheEntryListener(name, cfg);
- U.closeQuiet(hnd);
+ CommonUtils.closeQuiet(hnd);
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
similarity index 98%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
index 00a6c56c59e88..25e2401c010e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientChannel.java
@@ -64,16 +64,15 @@
import org.apache.ignite.internal.client.thin.io.ClientMessageHandler;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.odbc.ClientConnectionNodeRecoveryException;
-import org.apache.ignite.internal.processors.odbc.ClientListenerNioListener;
-import org.apache.ignite.internal.processors.odbc.ClientListenerRequest;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProtocol;
import org.apache.ignite.internal.processors.platform.client.ClientFlag;
import org.apache.ignite.internal.processors.platform.client.ClientStatus;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
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.apache.ignite.logger.NullLogger;
import org.jetbrains.annotations.Nullable;
@@ -217,7 +216,7 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
catch (ClientConnectionException e) {
log.info("Can't establish connection with " + addr);
- connectionEx = U.addSuppressed(connectionEx, e);
+ connectionEx = CommonUtils.addSuppressed(connectionEx, e);
continue;
}
@@ -231,9 +230,9 @@ class TcpClientChannel implements ClientChannel, ClientMessageHandler, ClientCon
log.info("Can't establish connection with " + addr + ". Node in recovery mode.");
- connectionEx = U.addSuppressed(connectionEx, e);
+ connectionEx = CommonUtils.addSuppressed(connectionEx, e);
- U.closeQuiet(sock);
+ CommonUtils.closeQuiet(sock);
sock = null;
continue;
@@ -290,7 +289,7 @@ private void close(Exception cause) {
if (heartbeatTimer != null)
heartbeatTimer.cancel();
- U.closeQuiet(sock);
+ CommonUtils.closeQuiet(sock);
pendingReqsLock.writeLock().lock();
@@ -842,17 +841,17 @@ else if (!supportedVers.contains(srvVer) ||
/** Send handshake request. */
private void handshakeReq(ProtocolVersion proposedVer, String user, String pwd,
Map userAttrs) throws ClientConnectionException {
- try (BinaryWriterEx writer = BinaryUtils.writer(U.binaryContext(null), BinaryStreams.outputStream(32), null)) {
+ try (BinaryWriterEx writer = BinaryUtils.writer(BinaryUtils.binaryContext(null), BinaryStreams.outputStream(32), null)) {
ProtocolContext protocolCtx = protocolContextFromVersion(proposedVer);
writer.writeInt(0); // reserve an integer for the request size
- writer.writeByte((byte)ClientListenerRequest.HANDSHAKE);
+ writer.writeByte((byte)ClientListenerProtocol.HANDSHAKE);
writer.writeShort(proposedVer.major());
writer.writeShort(proposedVer.minor());
writer.writeShort(proposedVer.patch());
- writer.writeByte(ClientListenerNioListener.THIN_CLIENT);
+ writer.writeByte(ClientListenerProtocol.THIN_CLIENT);
if (protocolCtx.isFeatureSupported(BITMAP_FEATURES)) {
byte[] features = ProtocolBitmaskFeature.featuresAsBytes(protocolCtx.features());
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientTransactions.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientTransactions.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientTransactions.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpClientTransactions.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
index b21eca8578160..3aca5f9fde6b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/TcpIgniteClient.java
@@ -71,9 +71,9 @@
import org.apache.ignite.internal.client.thin.io.ClientConnectionMultiplexer;
import org.apache.ignite.internal.processors.platform.client.ClientStatus;
import org.apache.ignite.internal.processors.platform.client.IgniteClientException;
+import org.apache.ignite.internal.util.CommonUtils;
import org.apache.ignite.internal.util.GridArgumentCheck;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.MarshallerContext;
@@ -792,7 +792,7 @@ private class ClientMarshallerContext implements MarshallerContext {
*/
public ClientMarshallerContext() {
try {
- MarshallerUtils.processSystemClasses(U.gridClassLoader(), null, sysTypes::add);
+ MarshallerUtils.processSystemClasses(CommonUtils.gridClassLoader(), sysTypes::add);
}
catch (IOException e) {
throw new IllegalStateException("Failed to initialize marshaller context.", e);
@@ -858,7 +858,8 @@ public ClientMarshallerContext() {
@Override public Class getClass(int typeId, ClassLoader ldr)
throws ClassNotFoundException, IgniteCheckedException {
- return U.forName(getClassName(MarshallerPlatformIds.JAVA_ID, typeId), ldr, null);
+ return CommonUtils.forName(getClassName(MarshallerPlatformIds.JAVA_ID, typeId), ldr, null,
+ Marshallers.USE_CACHE.get());
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnection.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnection.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnection.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnection.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionMultiplexer.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionMultiplexer.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionMultiplexer.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionMultiplexer.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionStateHandler.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionStateHandler.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionStateHandler.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientConnectionStateHandler.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageDecoder.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageDecoder.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageDecoder.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageDecoder.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageHandler.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageHandler.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageHandler.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/ClientMessageHandler.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnection.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnection.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnection.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnection.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java
similarity index 99%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java
index a26a6f2dac7e7..5d157fe725178 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java
+++ b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java
@@ -82,7 +82,7 @@ public GridNioClientConnectionMultiplexer(ClientConfiguration cfg) {
sslCtx = ClientSslUtils.getSslContext(cfg);
if (sslCtx != null) {
- GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtx, true, ByteOrder.nativeOrder(), gridLog, null);
+ GridNioSslFilter sslFilter = new GridNioSslFilter(sslCtx, true, ByteOrder.nativeOrder(), gridLog, null, null);
sslFilter.directMode(false);
filters = new GridNioFilter[] {codecFilter, sslFilter};
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientListener.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientListener.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientListener.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientListener.java
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientParser.java b/modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientParser.java
similarity index 100%
rename from modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientParser.java
rename to modules/thin-client/impl/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientParser.java
diff --git a/pom.xml b/pom.xml
index 5b4ef9e6f5516..13b4ca6e55e23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,7 +43,9 @@
modules/binary/api
modules/binary/impl
modules/thin-client/api
+ modules/thin-client/impl
modules/unsafe
+ modules/nio
modules/core
modules/compress
modules/dev-utils