Search in sources :

Example 6 with DataStreamerImpl

use of org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl in project ignite by apache.

the class ClusterReadOnlyModeTestUtils method assertDataStreamerReadOnlyMode.

/**
 * @param readOnly If {@code true} then data streamer must fail, else succeed.
 * @param cacheNames Checked cache names.
 */
public static void assertDataStreamerReadOnlyMode(boolean readOnly, Collection<String> cacheNames) {
    Random rnd = new Random();
    for (Ignite ignite : G.allGrids()) {
        for (String cacheName : cacheNames) {
            boolean failed = false;
            try (IgniteDataStreamer<Integer, Integer> streamer = ignite.dataStreamer(cacheName)) {
                for (int i = 0; i < 10; i++) {
                    ((DataStreamerImpl) streamer).maxRemapCount(5);
                    int key = rnd.nextInt(1000);
                    streamer.addData(key, rnd.nextInt());
                    streamer.removeData(key);
                }
            } catch (CacheException ignored) {
                failed = true;
            }
            if (failed != readOnly)
                fail("Streaming to " + cacheName + " must " + (readOnly ? "fail" : "succeed"));
        }
    }
}
Also used : Random(java.util.Random) CacheException(javax.cache.CacheException) DataStreamerImpl(org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl) Ignite(org.apache.ignite.Ignite)

Aggregations

DataStreamerImpl (org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl)6 Ignite (org.apache.ignite.Ignite)3 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)2 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 IgniteExternalizableExpiryPolicy (org.apache.ignite.internal.processors.cache.distributed.IgniteExternalizableExpiryPolicy)2 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)2 IgniteDrDataStreamerCacheUpdater (org.apache.ignite.internal.processors.dr.IgniteDrDataStreamerCacheUpdater)2 IgniteFuture (org.apache.ignite.lang.IgniteFuture)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Random (java.util.Random)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CacheException (javax.cache.CacheException)1 CacheLoaderException (javax.cache.integration.CacheLoaderException)1 CacheWriterException (javax.cache.integration.CacheWriterException)1 IgniteDataStreamer (org.apache.ignite.IgniteDataStreamer)1 IgniteException (org.apache.ignite.IgniteException)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 PlatformCacheEntryFilter (org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter)1