This is an automated email from the ASF dual-hosted git repository.
rpuch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 04ba993a309 IGNITE-27798 Remove duplicate PartitionCommandsMarshaller
(#7568)
04ba993a309 is described below
commit 04ba993a309316259da65ad7676674405141af7e
Author: Roman Puchkovskiy <[email protected]>
AuthorDate: Tue Feb 10 16:30:19 2026 +0400
IGNITE-27798 Remove duplicate PartitionCommandsMarshaller (#7568)
---
.../PartitionCommandsMarshallerImpl.java | 10 ++-
.../ThreadLocalPartitionCommandsMarshaller.java | 63 ---------------
.../raftsnapshot/ItTableRaftSnapshotsTest.java | 2 +-
.../schema/CheckCatalogVersionOnActionRequest.java | 1 +
.../schema/CheckCatalogVersionOnAppendEntries.java | 3 +-
.../schema/PartitionCommandsMarshaller.java | 48 ------------
.../schema/PartitionCommandsMarshallerImpl.java | 90 ----------------------
.../ThreadLocalPartitionCommandsMarshaller.java | 2 +
.../CheckCatalogVersionOnActionRequestTest.java | 1 +
.../PartitionCommandsMarshallerImplTest.java | 2 +
10 files changed, 17 insertions(+), 205 deletions(-)
diff --git
a/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/PartitionCommandsMarshallerImpl.java
b/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/PartitionCommandsMarshallerImpl.java
index 03dc92744bb..7f3007c1a07 100644
---
a/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/PartitionCommandsMarshallerImpl.java
+++
b/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/PartitionCommandsMarshallerImpl.java
@@ -46,8 +46,9 @@ public class PartitionCommandsMarshallerImpl extends
OptimizedMarshaller impleme
stream.setBuffer(buffer);
// We need fixed values here to know the offset for binary patcher.
- // See org.apache.ignite.internal.raft.Marshaller.patch.
+ // See org.apache.ignite.internal.raft.Marshaller.patch()
stream.writeFixedInt(requiredCatalogVersion);
+ // Allocates space for safe timestamp.
stream.writeFixedLong(0);
}
@@ -64,7 +65,6 @@ public class PartitionCommandsMarshallerImpl extends
OptimizedMarshaller impleme
((CatalogVersionAware)
res).requiredCatalogVersion(requiredCatalogVersion);
}
- // Apply patched value.
if (res instanceof SafeTimePropagatingCommand && safeTs != 0) {
((SafeTimePropagatingCommand)
res).safeTime(HybridTimestamp.hybridTimestamp(safeTs));
}
@@ -72,6 +72,12 @@ public class PartitionCommandsMarshallerImpl extends
OptimizedMarshaller impleme
return res;
}
+ /**
+ * Reads required catalog version from the provided buffer.
+ *
+ * @param raw Buffer to read from.
+ * @return Catalog version.
+ */
@Override
public int readRequiredCatalogVersion(ByteBuffer raw) {
return raw.getInt();
diff --git
a/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/ThreadLocalPartitionCommandsMarshaller.java
b/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/ThreadLocalPartitionCommandsMarshaller.java
deleted file mode 100644
index 4e7101ea49f..00000000000
---
a/modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/marshaller/ThreadLocalPartitionCommandsMarshaller.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.partition.replicator.marshaller;
-
-import java.nio.ByteBuffer;
-import
org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
-import org.apache.ignite.internal.raft.util.DefaultByteBuffersPool;
-import
org.apache.ignite.internal.raft.util.OptimizedMarshaller.ByteBuffersPool;
-
-/**
- * Thread-local variant of {@link PartitionCommandsMarshaller}.
- */
-public class ThreadLocalPartitionCommandsMarshaller implements
PartitionCommandsMarshaller {
- /** Thread-local optimized marshaller holder. Not static, because it
depends on serialization registry. */
- private final ThreadLocal<PartitionCommandsMarshaller> marshaller;
-
- /** Shared pool of byte buffers for all thread-local instances. */
- private final ByteBuffersPool pool = new
DefaultByteBuffersPool(Runtime.getRuntime().availableProcessors());
-
- /**
- * Constructor.
- *
- * @param serializationRegistry Serialization registry.
- */
- public ThreadLocalPartitionCommandsMarshaller(MessageSerializationRegistry
serializationRegistry) {
- marshaller = ThreadLocal.withInitial(() -> new
PartitionCommandsMarshallerImpl(serializationRegistry, pool));
- }
-
- @Override
- public byte[] marshall(Object o) {
- return marshaller.get().marshall(o);
- }
-
- @Override
- public <T> T unmarshall(ByteBuffer bytes) {
- return marshaller.get().unmarshall(bytes);
- }
-
- @Override
- public int readRequiredCatalogVersion(ByteBuffer raw) {
- return marshaller.get().readRequiredCatalogVersion(raw);
- }
-
- @Override
- public long readSafeTimestamp(ByteBuffer raw) {
- return marshaller.get().readSafeTimestamp(raw);
- }
-}
diff --git
a/modules/raft/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
b/modules/raft/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
index 4c3fb3710e7..a0e2ed962f2 100644
---
a/modules/raft/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
+++
b/modules/raft/src/integrationTest/java/org/apache/ignite/internal/raftsnapshot/ItTableRaftSnapshotsTest.java
@@ -67,6 +67,7 @@ import
org.apache.ignite.internal.metastorage.server.WatchListenerInhibitor;
import org.apache.ignite.internal.metastorage.server.raft.MetastorageGroupId;
import org.apache.ignite.internal.network.NetworkMessage;
import
org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshallerImpl;
import
org.apache.ignite.internal.partition.replicator.network.raft.SnapshotMetaResponse;
import
org.apache.ignite.internal.partition.replicator.network.raft.SnapshotMvDataResponse;
import
org.apache.ignite.internal.partition.replicator.raft.snapshot.incoming.IncomingSnapshotCopier;
@@ -81,7 +82,6 @@ import
org.apache.ignite.internal.storage.pagememory.PersistentPageMemoryStorage
import
org.apache.ignite.internal.storage.pagememory.VolatilePageMemoryStorageEngine;
import org.apache.ignite.internal.storage.rocksdb.RocksDbStorageEngine;
import org.apache.ignite.internal.table.InternalTable;
-import
org.apache.ignite.internal.table.distributed.schema.PartitionCommandsMarshallerImpl;
import org.apache.ignite.internal.testframework.IgniteTestUtils;
import org.apache.ignite.internal.testframework.log4j2.LogInspector;
import org.apache.ignite.internal.testframework.log4j2.LogInspector.Handler;
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java
index a25b1ca8cc1..65f5f9773aa 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequest.java
@@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
import org.apache.ignite.internal.catalog.CatalogService;
import org.apache.ignite.internal.logger.IgniteLogger;
import org.apache.ignite.internal.logger.Loggers;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshaller;
import org.apache.ignite.internal.raft.Loza;
import org.apache.ignite.internal.raft.Marshaller;
import org.apache.ignite.internal.raft.util.OptimizedMarshaller;
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnAppendEntries.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnAppendEntries.java
index 94e056aa9c2..52f52176ee9 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnAppendEntries.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnAppendEntries.java
@@ -17,13 +17,14 @@
package org.apache.ignite.internal.table.distributed.schema;
+import static
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshaller.NO_VERSION_REQUIRED;
import static
org.apache.ignite.internal.table.distributed.schema.CatalogVersionSufficiency.isMetadataAvailableFor;
-import static
org.apache.ignite.internal.table.distributed.schema.PartitionCommandsMarshaller.NO_VERSION_REQUIRED;
import java.nio.ByteBuffer;
import org.apache.ignite.internal.catalog.CatalogService;
import org.apache.ignite.internal.logger.IgniteLogger;
import org.apache.ignite.internal.logger.Loggers;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshaller;
import org.apache.ignite.internal.raft.Marshaller;
import org.apache.ignite.internal.raft.util.OptimizedMarshaller;
import org.apache.ignite.raft.jraft.Node;
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshaller.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshaller.java
deleted file mode 100644
index e98e1ed10ec..00000000000
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshaller.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.table.distributed.schema;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.raft.Marshaller;
-
-/**
- * {@link Marshaller} that first writes some metadata about an object and then
it writes the actual serialized
- * representation of the object.
- */
-public interface PartitionCommandsMarshaller extends Marshaller {
- /**
- * Used instead of a required catalog version when there is no requirement.
- */
- int NO_VERSION_REQUIRED = -1;
-
- /**
- * Reads required catalog version from the provided buffer.
- *
- * @param raw Buffer to read from.
- * @return Catalog version. {@value #NO_VERSION_REQUIRED} if version is
not required for the given command.
- */
- int readRequiredCatalogVersion(ByteBuffer raw);
-
- /**
- * Reads safe timestamp from the provided buffer.
- *
- * @param raw Buffer to read from.
- * @return The timestamp.
- */
- long readSafeTimestamp(ByteBuffer raw);
-}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImpl.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImpl.java
deleted file mode 100644
index 003024d31f5..00000000000
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImpl.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.table.distributed.schema;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.hlc.HybridTimestamp;
-import
org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
-import
org.apache.ignite.internal.partition.replicator.network.command.CatalogVersionAware;
-import org.apache.ignite.internal.raft.util.OptimizedMarshaller;
-import
org.apache.ignite.internal.replicator.command.SafeTimePropagatingCommand;
-
-/**
- * Default {@link PartitionCommandsMarshaller} implementation.
- */
-public class PartitionCommandsMarshallerImpl extends OptimizedMarshaller
implements PartitionCommandsMarshaller {
- public PartitionCommandsMarshallerImpl(MessageSerializationRegistry
serializationRegistry, ByteBuffersPool cache) {
- super(serializationRegistry, cache);
- }
-
- @Override
- public void patch(ByteBuffer raw, HybridTimestamp safeTs) {
- raw = raw.order() == ORDER ? raw : raw.duplicate().order(ORDER);
- raw.putLong(Integer.BYTES, safeTs.longValue());
- }
-
- @Override
- protected void beforeWriteMessage(Object o, ByteBuffer buffer) {
- int requiredCatalogVersion = o instanceof CatalogVersionAware
- ? ((CatalogVersionAware) o).requiredCatalogVersion()
- : NO_VERSION_REQUIRED;
-
- stream.setBuffer(buffer);
- // We need fixed values here to know the offset for binary patcher.
- // See org.apache.ignite.internal.raft.Marshaller.patch()
- stream.writeFixedInt(requiredCatalogVersion);
- // Allocates space for safe timestamp.
- stream.writeFixedLong(0);
- }
-
- @Override
- public <T> T unmarshall(ByteBuffer raw) {
- raw = raw.duplicate().order(ORDER);
-
- int requiredCatalogVersion = readRequiredCatalogVersion(raw);
- long safeTs = readSafeTimestamp(raw);
-
- T res = super.unmarshall(raw);
-
- if (res instanceof CatalogVersionAware) {
- ((CatalogVersionAware)
res).requiredCatalogVersion(requiredCatalogVersion);
- }
-
- if (res instanceof SafeTimePropagatingCommand && safeTs != 0) {
- ((SafeTimePropagatingCommand)
res).safeTime(HybridTimestamp.hybridTimestamp(safeTs));
- }
-
- return res;
- }
-
- /**
- * Reads required catalog version from the provided buffer.
- *
- * @param raw Buffer to read from.
- * @return Catalog version.
- */
- @Override
- public int readRequiredCatalogVersion(ByteBuffer raw) {
- return raw.getInt();
- }
-
- @Override
- public long readSafeTimestamp(ByteBuffer raw) {
- return raw.getLong();
- }
-}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/ThreadLocalPartitionCommandsMarshaller.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/ThreadLocalPartitionCommandsMarshaller.java
index a4fd4afbee1..67f00fd7e96 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/ThreadLocalPartitionCommandsMarshaller.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/distributed/schema/ThreadLocalPartitionCommandsMarshaller.java
@@ -20,6 +20,8 @@ package org.apache.ignite.internal.table.distributed.schema;
import java.nio.ByteBuffer;
import org.apache.ignite.internal.hlc.HybridTimestamp;
import
org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshaller;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshallerImpl;
import org.apache.ignite.internal.raft.util.DefaultByteBuffersPool;
import
org.apache.ignite.internal.raft.util.OptimizedMarshaller.ByteBuffersPool;
diff --git
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequestTest.java
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequestTest.java
index 3188d4667ad..6d1eb3370a1 100644
---
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequestTest.java
+++
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/CheckCatalogVersionOnActionRequestTest.java
@@ -38,6 +38,7 @@ import java.util.stream.Stream;
import org.apache.ignite.internal.catalog.CatalogService;
import org.apache.ignite.internal.hlc.HybridClock;
import org.apache.ignite.internal.hlc.HybridClockImpl;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshallerImpl;
import
org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessagesFactory;
import org.apache.ignite.internal.raft.WriteCommand;
import org.apache.ignite.internal.replicator.message.ReplicaMessagesFactory;
diff --git
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImplTest.java
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImplTest.java
index 81ab12949ac..51df1ae125c 100644
---
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImplTest.java
+++
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/schema/PartitionCommandsMarshallerImplTest.java
@@ -30,6 +30,8 @@ import org.apache.ignite.internal.hlc.HybridTimestamp;
import org.apache.ignite.internal.network.MessageSerializationRegistryImpl;
import org.apache.ignite.internal.network.NetworkMessage;
import
org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshaller;
+import
org.apache.ignite.internal.partition.replicator.marshaller.PartitionCommandsMarshallerImpl;
import
org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessageGroup;
import
org.apache.ignite.internal.partition.replicator.network.PartitionReplicationMessagesFactory;
import
org.apache.ignite.internal.partition.replicator.network.command.FinishTxCommand;