Skip to content

Commit 138f263

Browse files
committed
IGNITE-24098 Merged master.
2 parents 4c23e99 + a415970 commit 138f263

File tree

45 files changed

+550
-1930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+550
-1930
lines changed

modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/ExpiredEntriesIntegrationTest.java

+37-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import org.apache.ignite.IgniteCache;
2424
import org.apache.ignite.cache.query.annotations.QuerySqlField;
2525
import org.apache.ignite.configuration.CacheConfiguration;
26+
import org.apache.ignite.internal.metric.IoStatisticsHolder;
27+
import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
28+
import org.apache.ignite.internal.util.typedef.F;
2629
import org.apache.ignite.testframework.GridTestUtils;
2730
import org.junit.Test;
2831

@@ -35,23 +38,29 @@
3538
*/
3639
public class ExpiredEntriesIntegrationTest extends AbstractBasicIntegrationTest {
3740
/** */
38-
@Test
39-
public void testExpiration() throws Exception {
41+
@Override protected void beforeTest() throws Exception {
4042
CacheConfiguration<Integer, Developer> cacheCfg = new CacheConfiguration<Integer, Developer>()
4143
.setIndexedTypes(Integer.class, Developer.class)
4244
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, 1)));
4345

44-
IgniteCache<Integer, Developer> cache1 = client.getOrCreateCache(new CacheConfiguration<>(cacheCfg)
46+
client.createCache(new CacheConfiguration<>(cacheCfg)
4547
.setName("CACHE1")
4648
.setEagerTtl(false)
4749
);
4850

49-
IgniteCache<Integer, Developer> cache2 = client.getOrCreateCache(new CacheConfiguration<>(cacheCfg)
51+
client.createCache(new CacheConfiguration<>(cacheCfg)
5052
.setName("CACHE2")
5153
.setEagerTtl(true)
5254
);
5355

5456
awaitPartitionMapExchange();
57+
}
58+
59+
/** */
60+
@Test
61+
public void testExpiration() throws Exception {
62+
IgniteCache<Integer, Developer> cache1 = client.cache("CACHE1");
63+
IgniteCache<Integer, Developer> cache2 = client.cache("CACHE2");
5564

5665
for (int i = 0; i < 100; i++) {
5766
cache1.put(i, new Developer("dev" + i, i));
@@ -71,6 +80,30 @@ public void testExpiration() throws Exception {
7180
checkExpiration("CACHE2", true);
7281
}
7382

83+
/** Validate that check of expiry policy doesn't require additional page read. */
84+
@Test
85+
public void testIndexScanReadPageOnce() {
86+
for (String cacheName: F.asList("CACHE1", "CACHE2")) {
87+
IgniteCache<Integer, Developer> cache = client.cache(cacheName);
88+
89+
ExpiryPolicy expPlc = new CreatedExpiryPolicy(new Duration(TimeUnit.DAYS, 1));
90+
91+
int key = primaryKey(grid(0).cache(cacheName));
92+
93+
cache.withExpiryPolicy(expPlc).put(key, new Developer("dev0", 0));
94+
95+
IoStatisticsHolder statHld = grid(0).cachex(cacheName).context().group().statisticsHolderData();
96+
97+
long before = statHld.logicalReads();
98+
99+
assertQuery("SELECT /*+ FORCE_INDEX(DEVELOPER_DEPID_IDX) */ name, depId FROM " + cacheName + ".DEVELOPER where depId=0")
100+
.matches(QueryChecker.containsIndexScan(cacheName, "DEVELOPER", "DEVELOPER_DEPID_IDX"))
101+
.check();
102+
103+
assertEquals(1, statHld.logicalReads() - before);
104+
}
105+
}
106+
74107
/** */
75108
private void checkExpiration(String schema, boolean eagerTtl) {
76109
assertQuery("SELECT depId, name FROM " + schema + ".DEVELOPER WHERE name IS NOT NULL")

modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/CliIgniteClientInvoker.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
package org.apache.ignite.internal.commandline;
1919

20+
import java.util.Collection;
2021
import java.util.function.Consumer;
2122
import org.apache.ignite.Ignition;
2223
import org.apache.ignite.client.IgniteClient;
24+
import org.apache.ignite.cluster.ClusterNode;
2325
import org.apache.ignite.configuration.ClientConfiguration;
2426
import org.apache.ignite.internal.client.GridClientNode;
2527
import org.apache.ignite.internal.client.GridClientNodeStateBeforeStart;
@@ -34,6 +36,7 @@
3436
import org.jetbrains.annotations.Nullable;
3537

3638
import static org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.MANAGEMENT_CLIENT_ATTR;
39+
import static org.apache.ignite.internal.processors.odbc.ClientListenerProcessor.CLIENT_LISTENER_PORT;
3740

3841
/**
3942
* Adapter of new management API command for {@code control.sh} execution flow.
@@ -54,7 +57,16 @@ public CliIgniteClientInvoker(Command<A, ?> cmd, A arg, ClientConfiguration cfg)
5457

5558
/** {@inheritDoc} */
5659
@Override protected GridClientNode defaultNode() {
57-
return CommandUtils.clusterToClientNode(igniteClient().cluster().forOldest().node());
60+
String[] addr = cfg.getAddresses()[0].split(":");
61+
62+
String host = addr[0];
63+
String port = addr[1];
64+
65+
Collection<ClusterNode> nodes = igniteClient().cluster().nodes();
66+
67+
return CommandUtils.clusterToClientNode(F.find(nodes, U.oldest(nodes, null), node ->
68+
(node.hostNames().contains(host) || node.addresses().contains(host))
69+
&& port.equals(node.attribute(CLIENT_LISTENER_PORT).toString())));
5870
}
5971

6072
/** {@inheritDoc} */

modules/control-utility/src/test/java/org/apache/ignite/testsuites/IgniteControlUtilityTestSuite2.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.ignite.util.GridCommandHandlerPropertiesTest;
3535
import org.apache.ignite.util.GridCommandHandlerScheduleIndexRebuildTest;
3636
import org.apache.ignite.util.GridCommandHandlerTracingConfigurationTest;
37+
import org.apache.ignite.util.IdleVerifyDumpTest;
3738
import org.apache.ignite.util.MetricCommandTest;
3839
import org.apache.ignite.util.PerformanceStatisticsCommandTest;
3940
import org.apache.ignite.util.SystemViewCommandTest;
@@ -72,7 +73,9 @@
7273
CdcCommandTest.class,
7374
CdcResendCommandTest.class,
7475

75-
SecurityCommandHandlerPermissionsTest.class
76+
SecurityCommandHandlerPermissionsTest.class,
77+
78+
IdleVerifyDumpTest.class
7679
})
7780
public class IgniteControlUtilityTestSuite2 {
7881
}

modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerClusterByClassTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ public void testCacheIdleVerifyDump() throws Exception {
752752
String dumpWithZeros = new String(Files.readAllBytes(Paths.get(fileNameMatcher.group(1))));
753753

754754
assertContains(log, dumpWithZeros, "The check procedure has finished, found " + parts + " partitions");
755-
assertContains(log, dumpWithZeros, "Partition: PartitionKeyV2 [grpId=1544803905, grpName=default, partId=0]");
755+
assertContains(log, dumpWithZeros, "Partition: PartitionKey [grpId=1544803905, grpName=default, partId=0]");
756756
assertContains(log, dumpWithZeros, "updateCntr=0, partitionState=OWNING, size=0, partHash=0");
757757
assertContains(log, dumpWithZeros, "no conflicts have been found");
758758
assertCompactFooterStat(dumpWithZeros, 0, 0, 0, keysCnt);
@@ -769,7 +769,7 @@ public void testCacheIdleVerifyDump() throws Exception {
769769

770770
assertContains(log, dumpWithoutZeros, "The check procedure has finished, found " + keysCnt + " partitions");
771771
assertContains(log, dumpWithoutZeros, (parts - keysCnt) + " partitions was skipped");
772-
assertContains(log, dumpWithoutZeros, "Partition: PartitionKeyV2 [grpId=1544803905, grpName=default, partId=");
772+
assertContains(log, dumpWithoutZeros, "Partition: PartitionKey [grpId=1544803905, grpName=default, partId=");
773773

774774
assertNotContains(log, dumpWithoutZeros, "updateCntr=0, partitionState=OWNING, size=0, partHash=0");
775775

@@ -988,7 +988,7 @@ private void testCacheIdleVerifyMultipleCacheFilterOptionsCommon(
988988
*/
989989
private void assertSort(int expectedPartsCount, String output) {
990990
Pattern partIdPattern = Pattern.compile(".*partId=([0-9]*)");
991-
Pattern primaryPattern = Pattern.compile("Partition instances: \\[PartitionHashRecordV2 \\[isPrimary=true");
991+
Pattern primaryPattern = Pattern.compile("Partition instances: \\[PartitionHashRecord \\[isPrimary=true");
992992

993993
Matcher partIdMatcher = partIdPattern.matcher(output);
994994
Matcher primaryMatcher = primaryPattern.matcher(output);
@@ -1250,7 +1250,7 @@ public void testCacheIdleVerifyDumpExcludedCaches() throws Exception {
12501250
/**
12511251
* @return Build matcher for dump file name.
12521252
*/
1253-
@NotNull private Matcher dumpFileNameMatcher() {
1253+
@NotNull static Matcher dumpFileNameMatcher() {
12541254
Pattern fileNamePattern = Pattern.compile(".*" + IdleVerifyDumpTask.class.getSimpleName()
12551255
+ " successfully written output to '(.*)'");
12561256
return fileNamePattern.matcher(testOut.toString());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.util;
19+
20+
import java.io.File;
21+
import java.nio.file.Files;
22+
import java.nio.file.Path;
23+
import java.nio.file.Paths;
24+
import java.util.regex.Matcher;
25+
import org.apache.ignite.IgniteCheckedException;
26+
import org.apache.ignite.configuration.IgniteConfiguration;
27+
import org.apache.ignite.internal.util.typedef.internal.U;
28+
import org.junit.Test;
29+
30+
import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK;
31+
import static org.apache.ignite.testframework.GridTestUtils.assertContains;
32+
import static org.apache.ignite.util.GridCommandHandlerClusterByClassTest.dumpFileNameMatcher;
33+
34+
/** */
35+
public class IdleVerifyDumpTest extends GridCommandHandlerClusterByClassAbstractTest {
36+
/** {@inheritDoc} */
37+
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
38+
return super.getConfiguration(igniteInstanceName)
39+
.setWorkDirectory(nodeWorkDirectory(igniteInstanceName));
40+
}
41+
42+
/**
43+
* Test ensuring that idle verify dump output file is created exactly
44+
* on server node specified via the --host parameter.
45+
*/
46+
@Test
47+
public void testDumpResultMatchesConnection() throws Exception {
48+
injectTestSystemOut();
49+
50+
client.createCache(DEFAULT_CACHE_NAME).put(1, 1);
51+
52+
checkDump(0);
53+
54+
checkDump(1);
55+
}
56+
57+
/** */
58+
private void checkDump(int nodeIdx) throws Exception {
59+
assertEquals(EXIT_CODE_OK, execute("--cache", "idle_verify", "--dump", "--port", connectorPort(grid(nodeIdx))));
60+
61+
Matcher fileNameMatcher = dumpFileNameMatcher();
62+
63+
assertTrue(fileNameMatcher.find());
64+
65+
Path dumpFileName = Paths.get(fileNameMatcher.group(1));
66+
67+
String dumpRes = new String(Files.readAllBytes(dumpFileName));
68+
69+
assertContains(log, dumpRes, "The check procedure has finished, no conflicts have been found.");
70+
71+
assertContains(log, dumpFileName.toString(), nodeWorkDirectory(getTestIgniteInstanceName(nodeIdx)));
72+
}
73+
74+
/** */
75+
private String nodeWorkDirectory(String igniteInstanceName) throws IgniteCheckedException {
76+
return new File(U.defaultWorkDirectory(), igniteInstanceName).getAbsolutePath();
77+
}
78+
}

modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/InlineTreeFilterClosure.java

+15-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
2626
import org.apache.ignite.internal.util.typedef.internal.S;
2727
import org.apache.ignite.spi.indexing.IndexingQueryCacheFilter;
28+
import org.jetbrains.annotations.Nullable;
2829

2930
import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId;
3031

@@ -38,6 +39,9 @@ public class InlineTreeFilterClosure implements BPlusTree.TreeRowClosure<IndexRo
3839
/** */
3940
private final BPlusTree.TreeRowClosure<IndexRow, IndexRow> rowFilter;
4041

42+
/** Last index row analyzed by {@link #rowFilter}. */
43+
private @Nullable IndexRow lastRow;
44+
4145
/** Constructor. */
4246
public InlineTreeFilterClosure(IndexingQueryCacheFilter cacheFilter,
4347
BPlusTree.TreeRowClosure<IndexRow, IndexRow> rowFilter) {
@@ -53,15 +57,22 @@ public InlineTreeFilterClosure(IndexingQueryCacheFilter cacheFilter,
5357

5458
boolean val = cacheFilter == null || applyFilter((InlineIO)io, pageAddr, idx);
5559

56-
if (!val)
57-
return false;
58-
59-
if (rowFilter != null)
60+
if (val && rowFilter != null) {
6061
val = rowFilter.apply(tree, io, pageAddr, idx);
6162

63+
lastRow = rowFilter.lastRow();
64+
}
65+
else
66+
lastRow = null;
67+
6268
return val;
6369
}
6470

71+
/** {@inheritDoc} */
72+
@Override public @Nullable IndexRow lastRow() {
73+
return lastRow;
74+
}
75+
6576
/**
6677
* @param io Row IO.
6778
* @param pageAddr Page address.

modules/core/src/main/java/org/apache/ignite/internal/management/cache/IdleVerifyDumpResult.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.io.ObjectOutput;
2222
import java.util.List;
2323
import java.util.Map;
24-
import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecordV2;
24+
import org.apache.ignite.internal.processors.cache.verify.PartitionHashRecord;
2525
import org.apache.ignite.internal.util.typedef.internal.S;
2626
import org.apache.ignite.internal.util.typedef.internal.U;
2727
import org.apache.ignite.internal.visor.VisorDataTransferObject;
@@ -34,12 +34,12 @@ public class IdleVerifyDumpResult extends VisorDataTransferObject {
3434
private static final long serialVersionUID = 0L;
3535

3636
/** Cluster hashes. */
37-
private Map<PartitionKeyV2, List<PartitionHashRecordV2>> clusterHashes;
37+
private Map<PartitionKey, List<PartitionHashRecord>> clusterHashes;
3838

3939
/**
4040
* @param clusterHashes Cluster hashes.
4141
*/
42-
public IdleVerifyDumpResult(Map<PartitionKeyV2, List<PartitionHashRecordV2>> clusterHashes) {
42+
public IdleVerifyDumpResult(Map<PartitionKey, List<PartitionHashRecord>> clusterHashes) {
4343
this.clusterHashes = clusterHashes;
4444
}
4545

@@ -63,7 +63,7 @@ public IdleVerifyDumpResult() {
6363
/**
6464
* @return Cluster hashes.
6565
*/
66-
public Map<PartitionKeyV2, List<PartitionHashRecordV2>> clusterHashes() {
66+
public Map<PartitionKey, List<PartitionHashRecord>> clusterHashes() {
6767
return clusterHashes;
6868
}
6969

0 commit comments

Comments
 (0)