Skip to content

Commit cdad2b8

Browse files
committed
Merge branch 'main' into ignite-26722
2 parents 75ac84c + 671e44d commit cdad2b8

File tree

15 files changed

+228
-340
lines changed

15 files changed

+228
-340
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ tree-sitter = "0.25.3"
8787
tree-sitter-json = "0.24.8"
8888
tree-sitter-sql = "gh-pages-a"
8989
tree-sitter-hocon = "master-a"
90-
otel = "1.54.1"
90+
otel = "1.55.0"
9191
spring-boot = "3.5.6"
9292
spring-data = "3.5.4"
9393
testcontainers = "1.21.3"
9494
gradleToolingApi = "8.6"
95-
protobuf = "4.32.1"
95+
protobuf = "4.33.0"
9696
cytodynamics = "0.2.0"
9797
japicmp = "0.24.2"
9898

modules/cluster-management/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ dependencies {
5151
testImplementation project(':ignite-configuration')
5252
testImplementation project(':ignite-network')
5353
testImplementation project(':ignite-system-disaster-recovery')
54-
testImplementation project(':ignite-raft')
5554
testImplementation testFixtures(project(':ignite-core'))
5655
testImplementation testFixtures(project(':ignite-configuration'))
5756
testImplementation testFixtures(project(':ignite-network'))
5857
testImplementation testFixtures(project(':ignite-vault'))
5958
testImplementation testFixtures(project(':ignite-failure-handler'))
59+
testImplementation testFixtures(project(':ignite-raft'))
6060

6161
testFixturesImplementation project(':ignite-core')
6262
testFixturesImplementation project(':ignite-failure-handler')

modules/cluster-management/src/test/java/org/apache/ignite/internal/cluster/management/raft/commands/CmgCommandsCompatibilityTest.java

Lines changed: 22 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,44 @@
2020
import static org.junit.jupiter.api.Assertions.assertEquals;
2121
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
2222

23-
import java.util.Base64;
23+
import java.util.Collection;
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.Set;
27-
import java.util.UUID;
2827
import org.apache.ignite.internal.cluster.management.ClusterState;
2928
import org.apache.ignite.internal.cluster.management.ClusterTag;
3029
import org.apache.ignite.internal.cluster.management.network.messages.CmgMessagesFactory;
3130
import org.apache.ignite.internal.cluster.management.network.messages.CmgMessagesSerializationRegistryInitializer;
32-
import org.apache.ignite.internal.network.MessageSerializationRegistryImpl;
33-
import org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
31+
import org.apache.ignite.internal.network.serialization.MessageSerializationRegistryInitializer;
32+
import org.apache.ignite.internal.raft.BaseCommandsCompatibilityTest;
3433
import org.apache.ignite.internal.raft.Command;
35-
import org.apache.ignite.internal.raft.Marshaller;
36-
import org.apache.ignite.internal.raft.util.ThreadLocalOptimizedMarshaller;
37-
import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
38-
import org.junit.jupiter.api.BeforeEach;
3934
import org.junit.jupiter.api.Test;
4035

4136
/**
4237
* Compatibility testing for serialization/deserialization of CMG raft commands. It is verified that deserialization of commands that were
4338
* created on earlier versions of the product will be error-free.
44-
*
45-
* <p>For MAC users with aarch64 architecture, you will need to add {@code || "aarch64".equals(arch)} to the
46-
* {@code GridUnsafe#unaligned()} for the tests to pass. For more details, see
47-
* <a href="https://lists.apache.org/thread/67coyvm8mo7106mkndt24yqwtbvb7590">discussion</a>.</p>
48-
*
49-
* <p>To serialize commands, use {@link #serializeAll()} and insert the result into the appropriate tests.</p>
5039
*/
51-
public class CmgCommandsCompatibilityTest extends BaseIgniteAbstractTest {
52-
private final MessageSerializationRegistry registry = new MessageSerializationRegistryImpl();
53-
54-
private final Marshaller marshaller = new ThreadLocalOptimizedMarshaller(registry);
55-
40+
public class CmgCommandsCompatibilityTest extends BaseCommandsCompatibilityTest {
5641
private final CmgMessagesFactory factory = new CmgMessagesFactory();
5742

58-
@BeforeEach
59-
void setUp() {
60-
new CmgMessagesSerializationRegistryInitializer().registerFactories(registry);
43+
@Override
44+
protected Collection<MessageSerializationRegistryInitializer> initializers() {
45+
return List.of(new CmgMessagesSerializationRegistryInitializer());
46+
}
47+
48+
@Override
49+
protected Collection<Command> commandsToSerialize() {
50+
return List.of(
51+
createChangeMetaStorageInfoCommand(),
52+
createInitCmgStateCommand(),
53+
createJoinReadyCommand(),
54+
createJoinRequestCommand(),
55+
createNodesLeaveCommand(),
56+
createReadLogicalTopologyCommand(),
57+
createReadMetaStorageInfoCommand(),
58+
createReadStateCommand(),
59+
createReadValidatedNodesCommand()
60+
);
6161
}
6262

6363
@Test
@@ -138,10 +138,6 @@ void testReadValidatedNodesCommand() {
138138
assertInstanceOf(ReadValidatedNodesCommand.class, command);
139139
}
140140

141-
private static UUID uuid() {
142-
return new UUID(42, 69);
143-
}
144-
145141
private ClusterNodeMessage createClusterNodeMessage() {
146142
return factory.clusterNodeMessage()
147143
.id(uuid())
@@ -165,33 +161,6 @@ private ClusterState createClusterState() {
165161
.build();
166162
}
167163

168-
private <T extends Command> T deserializeCommand(byte[] bytes) {
169-
return marshaller.unmarshall(bytes);
170-
}
171-
172-
private <T extends Command> T decodeCommand(String base64) {
173-
return deserializeCommand(Base64.getDecoder().decode(base64));
174-
}
175-
176-
@SuppressWarnings("unused")
177-
private void serializeAll() {
178-
List<Command> commands = List.of(
179-
createChangeMetaStorageInfoCommand(),
180-
createInitCmgStateCommand(),
181-
createJoinReadyCommand(),
182-
createJoinRequestCommand(),
183-
createNodesLeaveCommand(),
184-
createReadLogicalTopologyCommand(),
185-
createReadMetaStorageInfoCommand(),
186-
createReadStateCommand(),
187-
createReadValidatedNodesCommand()
188-
);
189-
190-
for (Command c : commands) {
191-
log.info(">>>>> Serialized command: [c={}, base64='{}']", c.getClass().getSimpleName(), encodeCommand(c));
192-
}
193-
}
194-
195164
private ReadValidatedNodesCommand createReadValidatedNodesCommand() {
196165
return factory.readValidatedNodesCommand().build();
197166
}
@@ -241,12 +210,4 @@ private ChangeMetaStorageInfoCommand createChangeMetaStorageInfoCommand() {
241210
.metastorageRepairingConfigIndex(42L)
242211
.build();
243212
}
244-
245-
private byte[] serializeCommand(Command c) {
246-
return marshaller.marshall(c);
247-
}
248-
249-
private String encodeCommand(Command c) {
250-
return Base64.getEncoder().encodeToString(serializeCommand(c));
251-
}
252213
}

modules/metastorage/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ dependencies {
4444

4545
annotationProcessor project(':ignite-network-annotation-processor')
4646

47-
testImplementation project(':ignite-network')
4847
testImplementation testFixtures(project(':ignite-core'))
4948
testImplementation testFixtures(project(':ignite-vault'))
5049
testImplementation testFixtures(project(':ignite-configuration'))
5150
testImplementation testFixtures(project(':ignite-replicator'))
5251
testImplementation testFixtures(project(':ignite-failure-handler'))
5352
testImplementation testFixtures(project(':ignite-metrics'))
5453
testImplementation testFixtures(project(':ignite-configuration-system'))
54+
testImplementation testFixtures(project(':ignite-raft'))
5555

5656
integrationTestImplementation project(':ignite-cluster-management')
5757
integrationTestImplementation project(':ignite-network')

modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/command/MetastorageCommandsCompatibilityTest.java

Lines changed: 32 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
import static org.junit.jupiter.api.Assertions.assertTrue;
2525

2626
import java.nio.ByteBuffer;
27-
import java.util.Base64;
27+
import java.util.Collection;
2828
import java.util.List;
29-
import java.util.UUID;
3029
import org.apache.ignite.internal.hlc.HybridTimestamp;
3130
import org.apache.ignite.internal.lang.ByteArray;
3231
import org.apache.ignite.internal.metastorage.CommandId;
@@ -36,36 +35,46 @@
3635
import org.apache.ignite.internal.metastorage.dsl.MetaStorageMessagesSerializationRegistryInitializer;
3736
import org.apache.ignite.internal.metastorage.dsl.Operations;
3837
import org.apache.ignite.internal.metastorage.dsl.Statements;
39-
import org.apache.ignite.internal.network.MessageSerializationRegistryImpl;
40-
import org.apache.ignite.internal.network.serialization.MessageSerializationRegistry;
38+
import org.apache.ignite.internal.network.serialization.MessageSerializationRegistryInitializer;
39+
import org.apache.ignite.internal.raft.BaseCommandsCompatibilityTest;
4140
import org.apache.ignite.internal.raft.Command;
42-
import org.apache.ignite.internal.raft.Marshaller;
43-
import org.apache.ignite.internal.raft.util.ThreadLocalOptimizedMarshaller;
44-
import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
45-
import org.junit.jupiter.api.BeforeEach;
4641
import org.junit.jupiter.api.Test;
4742

4843
/**
4944
* Compatibility testing for serialization/deserialization of metastorage raft commands. It is verified that deserialization of commands
5045
* that were created on earlier versions of the product will be error-free.
51-
*
52-
* <p>For MAC users with aarch64 architecture, you will need to add {@code || "aarch64".equals(arch)} to the
53-
* {@code GridUnsafe#unaligned()} for the tests to pass. For more details, see
54-
* <a href="https://lists.apache.org/thread/67coyvm8mo7106mkndt24yqwtbvb7590">discussion</a>.</p>
55-
*
56-
* <p>To serialize commands, use {@link #serializeAll()} and insert the result into the appropriate tests.</p>
5746
*/
58-
public class MetastorageCommandsCompatibilityTest extends BaseIgniteAbstractTest {
59-
private final MessageSerializationRegistry registry = new MessageSerializationRegistryImpl();
60-
61-
private final Marshaller marshaller = new ThreadLocalOptimizedMarshaller(registry);
62-
47+
public class MetastorageCommandsCompatibilityTest extends BaseCommandsCompatibilityTest {
6348
private final MetaStorageCommandsFactory factory = new MetaStorageCommandsFactory();
6449

65-
@BeforeEach
66-
void setUp() {
67-
new MetaStorageCommandsSerializationRegistryInitializer().registerFactories(registry);
68-
new MetaStorageMessagesSerializationRegistryInitializer().registerFactories(registry);
50+
@Override
51+
protected Collection<MessageSerializationRegistryInitializer> initializers() {
52+
return List.of(
53+
new MetaStorageCommandsSerializationRegistryInitializer(),
54+
new MetaStorageMessagesSerializationRegistryInitializer()
55+
);
56+
}
57+
58+
@Override
59+
protected Collection<Command> commandsToSerialize() {
60+
return List.of(
61+
createCompactionCommand(),
62+
createEvictIdempotentCommandsCacheCommand(),
63+
createGetAllCommand(),
64+
createGetChecksumCommand(),
65+
createGetCommand(),
66+
createGetCurrentRevisionsCommand(),
67+
createGetPrefixCommand(),
68+
createGetRangeCommand(),
69+
createInvokeCommand(),
70+
createMultiInvokeCommand(),
71+
createPutAllCommand(),
72+
createPutCommand(),
73+
createRemoveAllCommand(),
74+
createRemoveByPrefixCommand(),
75+
createRemoveCommand(),
76+
createSyncTimeCommand()
77+
);
6978
}
7079

7180
@Test
@@ -255,18 +264,6 @@ void testSyncTimeCommand() {
255264
assertEquals(42, command.initiatorTerm());
256265
}
257266

258-
private static HybridTimestamp initiatorTime() {
259-
return HybridTimestamp.hybridTimestamp(70);
260-
}
261-
262-
private static HybridTimestamp safeTime() {
263-
return HybridTimestamp.hybridTimestamp(69);
264-
}
265-
266-
private static UUID uuid() {
267-
return new UUID(42, 69);
268-
}
269-
270267
private static CommandId commandId() {
271268
return CommandId.fromString(uuid() + "_cnt_" + 70);
272269
}
@@ -283,40 +280,6 @@ private static ByteArray keyAsByteArray(String key) {
283280
return ByteArray.fromString(key);
284281
}
285282

286-
private <T extends Command> T deserializeCommand(byte[] bytes) {
287-
return marshaller.unmarshall(bytes);
288-
}
289-
290-
private <T extends Command> T decodeCommand(String base64) {
291-
return deserializeCommand(Base64.getDecoder().decode(base64));
292-
}
293-
294-
@SuppressWarnings("unused")
295-
private void serializeAll() {
296-
List<Command> commands = List.of(
297-
createCompactionCommand(),
298-
createEvictIdempotentCommandsCacheCommand(),
299-
createGetAllCommand(),
300-
createGetChecksumCommand(),
301-
createGetCommand(),
302-
createGetCurrentRevisionsCommand(),
303-
createGetPrefixCommand(),
304-
createGetRangeCommand(),
305-
createInvokeCommand(),
306-
createMultiInvokeCommand(),
307-
createPutAllCommand(),
308-
createPutCommand(),
309-
createRemoveAllCommand(),
310-
createRemoveByPrefixCommand(),
311-
createRemoveCommand(),
312-
createSyncTimeCommand()
313-
);
314-
315-
for (Command c : commands) {
316-
log.info(">>>>> Serialized command: [c={}, base64='{}']", c.getClass().getSimpleName(), encodeCommand(c));
317-
}
318-
}
319-
320283
private SyncTimeCommand createSyncTimeCommand() {
321284
return factory.syncTimeCommand()
322285
.safeTime(safeTime())
@@ -472,12 +435,4 @@ private CompactionCommand createCompactionCommand() {
472435
.compactionRevision(42)
473436
.build();
474437
}
475-
476-
private byte[] serializeCommand(Command c) {
477-
return marshaller.marshall(c);
478-
}
479-
480-
private String encodeCommand(Command c) {
481-
return Base64.getEncoder().encodeToString(serializeCommand(c));
482-
}
483438
}

modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpoint.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class Checkpoint {
3030
/** Number of dirty pages. */
3131
final int dirtyPagesSize;
3232

33+
/** Number of written dirty pages. */
34+
int writtenPages;
35+
3336
/**
3437
* Constructor.
3538
*
@@ -49,7 +52,17 @@ class Checkpoint {
4952
/**
5053
* Returns {@code true} if this checkpoint contains at least one dirty page.
5154
*/
52-
public boolean hasDelta() {
55+
boolean hasDelta() {
5356
return dirtyPagesSize != 0;
5457
}
58+
59+
void finishCheckpoint() {
60+
if (hasDelta()) {
61+
writtenPages = progress.writtenPages();
62+
63+
progress.pagesToWrite(null);
64+
65+
progress.clearCounters();
66+
}
67+
}
5568
}

modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/CheckpointWorkflow.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,7 @@ public void markCheckpointEnd(Checkpoint chp) throws IgniteInternalCheckedExcept
318318
}
319319
}
320320

321-
if (chp.hasDelta()) {
322-
chp.progress.pagesToWrite(null);
323-
324-
chp.progress.clearCounters();
325-
}
321+
chp.finishCheckpoint();
326322

327323
for (CheckpointListener listener : collectCheckpointListeners(dataRegions)) {
328324
listener.afterCheckpointEnd(chp.progress);

modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/Checkpointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void doCheckpoint() throws IgniteInternalCheckedException {
428428

429429
if (chp.hasDelta()) {
430430
if (log.isInfoEnabled()) {
431-
int totalWrittenPages = chp.progress.writtenPages();
431+
int totalWrittenPages = chp.writtenPages;
432432
long totalWriteBytes = (long) pageSize * totalWrittenPages;
433433
long totalDurationInNanos = tracker.checkpointDuration(NANOSECONDS);
434434

modules/partition-replicator/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ dependencies {
5757
testImplementation testFixtures(project(':ignite-table'))
5858
testImplementation testFixtures(project(':ignite-transactions'))
5959
testImplementation testFixtures(project(':ignite-placement-driver-api'))
60+
testImplementation testFixtures(project(':ignite-raft'))
6061

6162
integrationTestImplementation testFixtures(project(':ignite-cluster-management'))
6263
integrationTestImplementation testFixtures(project(':ignite-core'))

0 commit comments

Comments
 (0)