Search in sources :

Example 1 with PARTITION_STATE_FAILED_MSG

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.PARTITION_STATE_FAILED_MSG in project ignite by apache.

the class DiagnosticLogForPartitionStatesTest method doTest.

/**
 * @param cfgs Cache configurations.
 * @param msgExp {@code true} if warning message is expected.
 * @throws Exception If failed.
 */
private void doTest(List<CacheConfiguration<Integer, Integer>> cfgs, boolean msgExp) throws Exception {
    String name = (cfgs.size() == 1) ? cfgs.get(0).getName() : cfgs.get(0).getGroupName();
    LogListener lsnr = LogListener.matches(s -> s.startsWith(String.format(PARTITION_STATE_FAILED_MSG, name, ANY_MSG))).times(msgExp ? 1 : 0).build();
    log.registerListener(lsnr);
    IgniteEx node1 = startGrid(0);
    IgniteEx node2 = startGrid(1);
    node1.cluster().active(true);
    List<IgniteCache<Integer, Integer>> caches = cfgs.stream().map(cfg -> node1.getOrCreateCache(cfg)).collect(Collectors.toList());
    Map<String, Set<Integer>> clearKeys = new HashMap<>();
    for (IgniteCache<Integer, Integer> cache : caches) {
        String cacheName = cache.getName();
        Set<Integer> clr = new HashSet<>();
        for (int i = 0; i < 100; i++) {
            cache.put(i, i);
            if (node2.affinity(cacheName).isPrimary(node2.localNode(), i))
                clr.add(i);
        }
        clearKeys.put(cacheName, clr);
    }
    for (IgniteCache<Integer, Integer> c : caches) {
        node2.context().cache().cache(c.getName()).clearLocallyAll(clearKeys.get(c.getName()), true, true, true);
    }
    // Trigger partition map exchange and therefore trigger partitions validation.
    startGrid(2);
    awaitPartitionMapExchange();
    assertTrue(lsnr.check());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) Arrays(java.util.Arrays) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) AccessedExpiryPolicy(javax.cache.expiry.AccessedExpiryPolicy) Collectors(java.util.stream.Collectors) IgniteCache(org.apache.ignite.IgniteCache) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) EternalExpiryPolicy(javax.cache.expiry.EternalExpiryPolicy) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Map(java.util.Map) After(org.junit.After) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Collections(java.util.Collections) Duration(javax.cache.expiry.Duration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PARTITION_STATE_FAILED_MSG(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.PARTITION_STATE_FAILED_MSG) Set(java.util.Set) HashSet(java.util.HashSet) LogListener(org.apache.ignite.testframework.LogListener) HashMap(java.util.HashMap) IgniteCache(org.apache.ignite.IgniteCache) HashSet(java.util.HashSet)

Aggregations

Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 AccessedExpiryPolicy (javax.cache.expiry.AccessedExpiryPolicy)1 Duration (javax.cache.expiry.Duration)1 EternalExpiryPolicy (javax.cache.expiry.EternalExpiryPolicy)1 IgniteCache (org.apache.ignite.IgniteCache)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 PARTITION_STATE_FAILED_MSG (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.PARTITION_STATE_FAILED_MSG)1 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)1 LogListener (org.apache.ignite.testframework.LogListener)1