|
29 | 29 | import java.util.concurrent.atomic.AtomicBoolean;
|
30 | 30 | import java.util.concurrent.atomic.AtomicInteger;
|
31 | 31 | import java.util.function.Consumer;
|
| 32 | +import java.util.stream.Collectors; |
32 | 33 | import java.util.stream.IntStream;
|
| 34 | +import java.util.stream.Stream; |
33 | 35 | import javax.cache.expiry.Duration;
|
34 | 36 | import javax.cache.expiry.ExpiryPolicy;
|
35 | 37 | import javax.cache.processor.MutableEntry;
|
36 | 38 | import org.apache.ignite.Ignite;
|
37 | 39 | import org.apache.ignite.IgniteCache;
|
38 | 40 | import org.apache.ignite.IgniteCheckedException;
|
| 41 | +import org.apache.ignite.IgniteDataStreamer; |
39 | 42 | import org.apache.ignite.IgniteException;
|
40 | 43 | import org.apache.ignite.cache.CacheEntryProcessor;
|
| 44 | +import org.apache.ignite.cluster.ClusterState; |
41 | 45 | import org.apache.ignite.configuration.CacheConfiguration;
|
42 | 46 | import org.apache.ignite.configuration.IgniteConfiguration;
|
43 | 47 | import org.apache.ignite.dump.DumpEntry;
|
|
52 | 56 | import org.apache.ignite.internal.util.typedef.internal.CU;
|
53 | 57 | import org.apache.ignite.internal.util.typedef.internal.U;
|
54 | 58 | import org.apache.ignite.platform.model.Key;
|
| 59 | +import org.apache.ignite.platform.model.User; |
55 | 60 | import org.apache.ignite.platform.model.Value;
|
56 | 61 | import org.apache.ignite.testframework.GridTestUtils;
|
| 62 | +import org.apache.ignite.util.AttributeNodeFilter; |
57 | 63 | import org.junit.Test;
|
58 | 64 |
|
59 | 65 | import static java.lang.Boolean.FALSE;
|
|
63 | 69 | import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.CreateDumpFutureTask.DUMP_FILE_EXT;
|
64 | 70 | import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
|
65 | 71 | import static org.junit.Assume.assumeFalse;
|
| 72 | +import static org.junit.Assume.assumeTrue; |
66 | 73 |
|
67 | 74 | /** */
|
68 | 75 | public class IgniteCacheDumpSelfTest extends AbstractCacheDumpTest {
|
@@ -110,6 +117,68 @@ public class IgniteCacheDumpSelfTest extends AbstractCacheDumpTest {
|
110 | 117 | return cfg;
|
111 | 118 | }
|
112 | 119 |
|
| 120 | + /** */ |
| 121 | + @Test |
| 122 | + public void testDumpWithNodeFilterCache() throws Exception { |
| 123 | + assumeTrue(nodes > 1); |
| 124 | + |
| 125 | + CacheConfiguration<?, ?> ccfg0 = cacheConfiguration(getConfiguration(getTestIgniteInstanceName()), DEFAULT_CACHE_NAME) |
| 126 | + .setNodeFilter(new AttributeNodeFilter(DEFAULT_CACHE_NAME, null)); |
| 127 | + |
| 128 | + CacheConfiguration<?, ?> ccfg1 = cacheConfiguration(getConfiguration(getTestIgniteInstanceName()), CACHE_0) |
| 129 | + .setNodeFilter(ccfg0.getNodeFilter()); |
| 130 | + |
| 131 | + for (int i = 0; i <= nodes; ++i) { |
| 132 | + IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(i)); |
| 133 | + |
| 134 | + if (i == 0) |
| 135 | + cfg.setUserAttributes(F.asMap(DEFAULT_CACHE_NAME, "")); |
| 136 | + |
| 137 | + cfg.setCacheConfiguration(null); |
| 138 | + |
| 139 | + cfg.setClientMode(i == nodes); |
| 140 | + |
| 141 | + IgniteEx ig = startGrid(cfg); |
| 142 | + |
| 143 | + cli = i == nodes ? ig : null; |
| 144 | + } |
| 145 | + |
| 146 | + cli.cluster().state(ClusterState.ACTIVE); |
| 147 | + |
| 148 | + cli.createCache(ccfg0); |
| 149 | + cli.createCache(ccfg1); |
| 150 | + |
| 151 | + try (IgniteDataStreamer<Integer, Integer> ds0 = cli.dataStreamer(DEFAULT_CACHE_NAME); |
| 152 | + IgniteDataStreamer<Integer, User> ds1 = cli.dataStreamer(CACHE_0)) { |
| 153 | + IgniteCache<Integer, Integer> cache0 = cli.cache(DEFAULT_CACHE_NAME); |
| 154 | + IgniteCache<Integer, User> cache1 = cli.cache(CACHE_0); |
| 155 | + |
| 156 | + for (int i = 0; i < KEYS_CNT; ++i) { |
| 157 | + if (useDataStreamer) { |
| 158 | + ds0.addData(i, i); |
| 159 | + ds1.addData(i, USER_FACTORY.apply(i)); |
| 160 | + } |
| 161 | + else { |
| 162 | + cache0.put(i, i); |
| 163 | + cache1.put(i, USER_FACTORY.apply(i)); |
| 164 | + } |
| 165 | + } |
| 166 | + } |
| 167 | + |
| 168 | + createDump(cli, DMP_NAME, null); |
| 169 | + |
| 170 | + checkDump(cli, |
| 171 | + DMP_NAME, |
| 172 | + new String[] {DEFAULT_CACHE_NAME, GRP}, |
| 173 | + Stream.of(DEFAULT_CACHE_NAME, CACHE_0).collect(Collectors.toSet()), |
| 174 | + KEYS_CNT + (onlyPrimary ? 0 : KEYS_CNT * backups), |
| 175 | + KEYS_CNT + (onlyPrimary ? 0 : KEYS_CNT * backups), |
| 176 | + 0, |
| 177 | + false, |
| 178 | + false |
| 179 | + ); |
| 180 | + } |
| 181 | + |
113 | 182 | /** */
|
114 | 183 | @Test
|
115 | 184 | public void testCacheDump() throws Exception {
|
|
0 commit comments