[jira] [Created] (IGNITE-8995) FailureHandler executed on error in ScanQuery's IgniteBiPredicate

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (IGNITE-8995) FailureHandler executed on error in ScanQuery's IgniteBiPredicate

JIRA jira@apache.org
Dmitriy Gladkikh created IGNITE-8995:
----------------------------------------

             Summary: FailureHandler executed on error in ScanQuery's IgniteBiPredicate
                 Key: IGNITE-8995
                 URL: https://issues.apache.org/jira/browse/IGNITE-8995
             Project: Ignite
          Issue Type: Bug
    Affects Versions: 2.5
            Reporter: Dmitriy Gladkikh


This code demonstrates this behavior:


{code:java}
import java.util.Collections;
import javax.cache.Cache;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;

/**
 * -ea -DIGNITE_QUIET=false
 */
public class ScanQueryIgniteBiPredicateWithError {
    private static final String CACHE_NAME = "test_cache_name";

    public static void main(String[] args) {
        try (Ignite igniteServer = Ignition.start(getCfg("node_server", false));
             Ignite igniteClient = Ignition.start(getCfg("node_client", true)))
        {
            IgniteCache<Integer, BinaryObject> cache = igniteClient.cache(CACHE_NAME);

            cache.put(1, igniteClient.binary().builder("test_type").setField("field_0", "field_0_val").build());

            try (QueryCursor<Cache.Entry<Integer, BinaryObject>> cursor = cache.withKeepBinary().query(new ScanQuery<>(
                new IgniteBiPredicate<Integer, BinaryObject>() {
                    @Override public boolean apply(Integer key, BinaryObject value) {
                        throw new AssertionError(); // Error.
                        //return value.field(null) != null; // Error.
                        //return true; // Ok.
                    }
                })))
            {
                for (Cache.Entry<Integer, BinaryObject> entry : cursor)
                    // Without error in IgniteBiPredicate:
                    // Key = 1, Val = test_type [idHash=2024711353, hash=394028655, field_0=val_0]
                    System.out.printf("Key = %s, Val = %s%n", entry.getKey(), entry.getValue());
            }
        }
    }

    /**
     * @param instanceName Ignite instance name.
     * @param clientMode Client mode.
     * @return Ignite configuration.
     */
    private static IgniteConfiguration getCfg(String instanceName, boolean clientMode) {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
        ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));

        TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi();
        tcpDiscoverySpi.setIpFinder(ipFinder);

        DataRegionConfiguration dataRegionCfg = new DataRegionConfiguration();
        dataRegionCfg.setPersistenceEnabled(true);

        DataStorageConfiguration dataStorageCfg = new DataStorageConfiguration();
        dataStorageCfg.setDefaultDataRegionConfiguration(dataRegionCfg);

        CacheConfiguration<Integer, BinaryObject> ccfg = new CacheConfiguration<Integer, BinaryObject>(CACHE_NAME)
            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
            .setCacheMode(CacheMode.PARTITIONED);

        IgniteConfiguration cfg = new IgniteConfiguration();
        cfg.setIgniteInstanceName(instanceName);
        cfg.setDiscoverySpi(tcpDiscoverySpi);
        cfg.setDataStorageConfiguration(dataStorageCfg);
        cfg.setCacheConfiguration(ccfg);

        if (!clientMode)
            cfg.setAutoActivationEnabled(true);
        else
            cfg.setClientMode(true);

        return cfg;
    }
}
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)