• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IgniteBiPredicate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.ignite.lang.IgniteBiPredicate的典型用法代码示例。如果您正苦于以下问题:Java IgniteBiPredicate类的具体用法?Java IgniteBiPredicate怎么用?Java IgniteBiPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IgniteBiPredicate类属于org.apache.ignite.lang包,在下文中一共展示了IgniteBiPredicate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testQuery

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testQuery() {
    IgniteCache<String, String> cache = ignite().getOrCreateCache("testcache1");
    Set<String> keys = new HashSet<>();

    for (int i = 0; i < 100; i++) {
        cache.put("k" + i, "v" + i);
        keys.add("k" + i);
    }

    Query<Entry<String, String>> query = new ScanQuery<String, String>(new IgniteBiPredicate<String, String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean apply(String key, String value) {
            return Integer.parseInt(key.replace("k", "")) >= 50;
        }
    });

    List results = template.requestBodyAndHeader("ignite:cache:testcache1?operation=QUERY", keys, IgniteConstants.IGNITE_CACHE_QUERY, query, List.class);
    assert_().that(results.size()).isEqualTo(50);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:IgniteCacheTest.java


示例2: subscribeToPutEvents

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @param expect Expected events number.
 * @return Event receive latch.
 */
private CountDownLatch subscribeToPutEvents(int expect) {
    Ignite ignite = grid();

    // Listen to cache PUT events and expect as many as messages as test data items
    final CountDownLatch latch = new CountDownLatch(expect);

    @SuppressWarnings("serial") IgniteBiPredicate<UUID, CacheEvent> cb = new IgniteBiPredicate<UUID, CacheEvent>() {
        @Override public boolean apply(UUID uuid, CacheEvent evt) {
            latch.countDown();
            return true;
        }
    };

    ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME)).remoteListen(cb, null, EVT_CACHE_OBJECT_PUT);
    return latch;
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:IgniteJmsStreamerTest.java


示例3: testScanQueryUsesDedicatedThreadPool

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * Tests that Scan queries are executed in dedicated pool
 * @throws Exception If failed.
 */
public void testScanQueryUsesDedicatedThreadPool() throws Exception {
    try (Ignite client = startGrid("client")) {
        IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME);

        cache.put(0, 0);

        QueryCursor<Cache.Entry<Object, Object>> cursor = cache.query(
            new ScanQuery<>(new IgniteBiPredicate<Object, Object>() {
                @Override public boolean apply(Object o, Object o2) {
                    return F.eq(GridIoManager.currentPolicy(), GridIoPolicy.QUERY_POOL);
                }
            }));

        assertEquals(1, cursor.getAll().size());

        cursor.close();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:IgniteQueryDedicatedPoolTest.java


示例4: scanQuery

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * Example for scan query based on a predicate using binary objects.
 */
private static void scanQuery() {
    IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite()
        .cache(PERSON_CACHE).withKeepBinary();

    ScanQuery<BinaryObject, BinaryObject> scan = new ScanQuery<>(
        new IgniteBiPredicate<BinaryObject, BinaryObject>() {
            @Override public boolean apply(BinaryObject key, BinaryObject person) {
                return person.<Double>field("salary") <= 1000;
            }
        }
    );

    // Execute queries for salary ranges.
    print("People with salaries between 0 and 1000 (queried with SCAN query): ", cache.query(scan).getAll());
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:CacheQueryExample.java


示例5: testResponseMessageOnRequestUnmarshallingFailed

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testResponseMessageOnRequestUnmarshallingFailed() throws Exception {
    readCnt.set(Integer.MAX_VALUE);

    try {
        jcache().query(new ScanQuery<>(new IgniteBiPredicate<TestKey, String>() {
            @Override public boolean apply(TestKey key, String val) {
                return false;
            }

            private void readObject(ObjectInputStream is) throws IOException {
                throw new IOException();
            }

            private void writeObject(ObjectOutputStream os) throws IOException {
                // No-op.
            }
        })).getAll();

        fail();
    }
    catch (Exception ignored) {
        // No-op.
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteCacheP2pUnmarshallingQueryErrorTest.java


示例6: subscribeToPutEvents

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * Subscribe to cache put events.
 */
private CountDownLatch subscribeToPutEvents(int expect) {
    Ignite ignite = grid();

    // Listen to cache PUT events and expect as many as messages as test data items
    final CountDownLatch latch = new CountDownLatch(expect);
    @SuppressWarnings("serial") IgniteBiPredicate<UUID, CacheEvent> callback =
        new IgniteBiPredicate<UUID, CacheEvent>() {
        @Override public boolean apply(UUID uuid, CacheEvent evt) {
            latch.countDown();

            return true;
        }
    };

    remoteLsnr = ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME))
        .remoteListen(callback, null, EVT_CACHE_OBJECT_PUT);

    return latch;
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:IgniteCamelStreamerTest.java


示例7: testDeployScanPredicate

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @throws Exception In case of error.
 */
public void testDeployScanPredicate() throws Exception {
    startGrids(4);

    awaitPartitionMapExchange();

    try {
        IgniteCache<Object, Object> cache = grid(3).cache(DEFAULT_CACHE_NAME);

        // It is important that there are no too many keys.
        for (int i = 0; i < 1; i++)
            cache.put(i, i);

        Class predCls = grid(3).configuration().getClassLoader().loadClass(TEST_PREDICATE);

        IgniteBiPredicate<Object, Object> pred = (IgniteBiPredicate<Object, Object>)predCls.newInstance();

        List<Cache.Entry<Object, Object>> all = cache.query(new ScanQuery<>(pred)).getAll();

        assertEquals(1, all.size());
    }
    finally {
        stopAllGrids();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteCacheScanPredicateDeploymentSelfTest.java


示例8: blockExchangeFinish

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @param crd Exchange coordinator.
 * @param topVer Exchange topology version.
 */
private void blockExchangeFinish(Ignite crd, long topVer) {
    final AffinityTopologyVersion topVer0 = new AffinityTopologyVersion(topVer);

    TestRecordingCommunicationSpi.spi(crd).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
        @Override public boolean apply(ClusterNode node, Message msg) {
            if (msg instanceof GridDhtPartitionsFullMessage) {
                GridDhtPartitionsFullMessage msg0 = (GridDhtPartitionsFullMessage)msg;

                return msg0.exchangeId() != null && msg0.exchangeId().topologyVersion().equals(topVer0);
            }

            return false;
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheExchangeMergeTest.java


示例9: subscribeToPutEvents

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @param expect Expected count.
 * @return Latch to be counted down in listener.
 */
private CountDownLatch subscribeToPutEvents(int expect) {
    Ignite ignite = grid();

    // Listen to cache PUT events and expect as many as messages as test data items
    final CountDownLatch latch = new CountDownLatch(expect);

    IgniteBiPredicate<UUID, CacheEvent> cb = new IgniteBiPredicate<UUID, CacheEvent>() {
        @Override public boolean apply(UUID uuid, CacheEvent evt) {
            latch.countDown();

            return true;
        }
    };

    remoteLsnr = ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME))
        .remoteListen(cb, null, EVT_CACHE_OBJECT_PUT);

    return latch;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:IgniteMqttStreamerTest.java


示例10: cacheQuery

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @param cache Cache.
 */
private void cacheQuery(IgniteCache cache) {
    int keys = 100;

    Map<Integer, Integer> data = generateDataMap(keys);

    cache.putAll(data);

    ScanQuery<Integer, Integer> qry = new ScanQuery<>(new IgniteBiPredicate<Integer, Integer>() {
        @Override public boolean apply(Integer key, Integer val) {
            return key % 2 == 0;
        }
    });

    List<Cache.Entry<Integer, Integer>> all = cache.query(qry).getAll();

    assertEquals(all.size(), data.size() / 2);

    for (Cache.Entry<Integer, Integer> entry : all) {
        assertEquals(0, entry.getKey() % 2);
        assertEquals(entry.getValue(), data.get(entry.getKey()));
    }

    tearDown(cache);
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:IgniteCacheGroupsTest.java


示例11: testNullTopicWithDeployment

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testNullTopicWithDeployment() throws Exception {
    Class<?> cls = getExternalClassLoader().loadClass(LSNR_CLS_NAME);

    grid(0).message().remoteListen(null, (IgniteBiPredicate<UUID, Object>)cls.newInstance());

    send();

    boolean s = GridTestUtils.waitForCondition(new PA() {
        @Override public boolean apply() {
            return checkDeployedListeners(GRID_CNT);
        }
    }, 2000);

    assertTrue(s);
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:GridMessageListenSelfTest.java


示例12: remoteListenAsync

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public <T extends Event> IgniteFuture<UUID> remoteListenAsync(int bufSize, long interval,
    boolean autoUnsubscribe, @Nullable IgniteBiPredicate<UUID, T> locLsnr, @Nullable IgnitePredicate<T> rmtFilter,
    @Nullable int... types) throws IgniteException {
    A.ensure(bufSize > 0, "bufSize > 0");
    A.ensure(interval >= 0, "interval >= 0");

    guard();

    try {
        GridEventConsumeHandler hnd = new GridEventConsumeHandler((IgniteBiPredicate<UUID, Event>)locLsnr,
            (IgnitePredicate<Event>)rmtFilter, types);

        return new IgniteFutureImpl<>(ctx.continuous().startRoutine(
            hnd,
            false,
            bufSize,
            interval,
            autoUnsubscribe,
            prj.predicate()));
    }
    finally {
        unguard();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:IgniteEventsImpl.java


示例13: GridCacheQueryAdapter

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @param cctx Context.
 * @param type Query type.
 * @param filter Scan filter.
 * @param part Partition.
 * @param keepBinary Keep binary flag.
 */
public GridCacheQueryAdapter(GridCacheContext<?, ?> cctx,
    GridCacheQueryType type,
    @Nullable IgniteBiPredicate<Object, Object> filter,
    @Nullable IgniteClosure<Map.Entry, Object> transform,
    @Nullable Integer part,
    boolean keepBinary) {
    assert cctx != null;
    assert type != null;
    assert part == null || part >= 0;

    this.cctx = cctx;
    this.type = type;
    this.filter = filter;
    this.transform = transform;
    this.part = part;
    this.keepBinary = keepBinary;

    log = cctx.logger(getClass());

    metrics = new GridCacheQueryMetricsAdapter();

    this.incMeta = false;
    this.clsName = null;
    this.clause = null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:33,代码来源:GridCacheQueryAdapter.java


示例14: testNonNullTopicWithDeployment

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testNonNullTopicWithDeployment() throws Exception {
    ClassLoader ldr = getExternalClassLoader();

    Class<?> topicCls = ldr.loadClass(TOPIC_CLS_NAME);
    Class<?> lsnrCls = ldr.loadClass(LSNR_CLS_NAME);

    Object topic = topicCls.newInstance();

    grid(0).message().remoteListen(topic, (IgniteBiPredicate<UUID, Object>)lsnrCls.newInstance());

    send(topic);

    boolean s = GridTestUtils.waitForCondition(new PA() {
        @Override public boolean apply() {
            return checkDeployedListeners(GRID_CNT);
        }
    }, 2000);

    assertTrue(s);
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:GridMessageListenSelfTest.java


示例15: remoteListen

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public UUID remoteListen(@Nullable Object topic, IgniteBiPredicate<UUID, ?> p) {
    A.notNull(p, "p");

    guard();

    try {
        GridContinuousHandler hnd = new GridMessageListenHandler(topic, (IgniteBiPredicate<UUID, Object>)p);

        return saveOrGet(ctx.continuous().startRoutine(hnd,
            false,
            1,
            0,
            false,
            prj.predicate()));
    }
    catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
    finally {
        unguard();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:IgniteMessagingImpl.java


示例16: remoteListenAsync

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public IgniteFuture<UUID> remoteListenAsync(@Nullable Object topic,
    IgniteBiPredicate<UUID, ?> p) throws IgniteException {
    A.notNull(p, "p");

    guard();

    try {
        GridContinuousHandler hnd = new GridMessageListenHandler(topic, (IgniteBiPredicate<UUID, Object>)p);

        return new IgniteFutureImpl<>(ctx.continuous().startRoutine(hnd,
            false,
            1,
            0,
            false,
            prj.predicate()));
    }
    finally {
        unguard();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteMessagingImpl.java


示例17: thenWhile

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * Combine this computation chain with other computation chain in the following way:
 * 1. perform this calculations chain and get result r.
 * 2. while 'cond(r)' is true, r = otherChain(r, context)
 * 3. return r.
 *
 * @param cond Condition checking if 'while' loop should continue.
 * @param otherChain Chain to be combined with this chain.
 * @return Combination of this chain and otherChain.
 */
default ComputationsChain<L, K, V, I, O> thenWhile(IgniteBiPredicate<O, L> cond,
                                                   ComputationsChain<L, K, V, O, O> otherChain) {
    ComputationsChain<L, K, V, I, O> me = this;
    return (input, context) -> {
        O res = me.process(input, context);

        while (cond.apply(res, context.localContext()))
            res = otherChain.process(res, context);

        return res;
    };
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:23,代码来源:ComputationsChain.java


示例18: expectJoinEvents

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * @param ignite     Node.
 * @param joinEvtCnt Expected events number.
 * @return Events latch.
 */
protected CountDownLatch expectJoinEvents(Ignite ignite, int joinEvtCnt) {
    final CountDownLatch latch = new CountDownLatch(joinEvtCnt);

    ignite.events().remoteListen(new IgniteBiPredicate<UUID, Event>() {
        @Override
        public boolean apply(UUID uuid, Event evt) {
            latch.countDown();
            return true;
        }
    }, null, EventType.EVT_NODE_JOINED);

    return latch;
}
 
开发者ID:aalda,项目名称:ignite-redis,代码行数:19,代码来源:TcpDiscoveryIpFinderBaseTest.java


示例19: createRegistry

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry answer = super.createRegistry();

    ScanQuery<Integer, Person> scanQuery1 = new ScanQuery<>(new IgniteBiPredicate<Integer, Person>() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean apply(Integer key, Person person) {
            return person.getId() > 50;
        }
    });

    CacheEntryEventSerializableFilter<Integer, Person> remoteFilter = new CacheEntryEventSerializableFilter<Integer, IgniteCacheContinuousQueryTest.Person>() {
        private static final long serialVersionUID = 5624973479995548199L;

        @Override
        public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Person> event) throws CacheEntryListenerException {
            return event.getValue().getId() > 150;
        }
    };

    answer.bind("query1", scanQuery1);
    answer.bind("remoteFilter1", remoteFilter);

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:IgniteCacheContinuousQueryTest.java


示例20: thenWhile

import org.apache.ignite.lang.IgniteBiPredicate; //导入依赖的package包/类
/**
 * Combine this computation chain with other computation chain in the following way:
 * 1. perform this calculations chain and get result r.
 * 2. while 'cond(r)' is true, r = otherChain(r, context)
 * 3. return r.
 *
 * @param cond Condition checking if 'while' loop should continue.
 * @param otherChain Chain to be combined with this chain.
 * @return Combination of this chain and otherChain.
 */
default ComputationsChain<L, K, V, I, O> thenWhile(IgniteBiPredicate<O, L> cond,
    ComputationsChain<L, K, V, O, O> otherChain) {
    ComputationsChain<L, K, V, I, O> me = this;
    return (input, context) -> {
        O res = me.process(input, context);

        while (cond.apply(res, context.localContext()))
            res = otherChain.process(res, context);

        return res;
    };
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:ComputationsChain.java



注:本文中的org.apache.ignite.lang.IgniteBiPredicate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReturnNode类代码示例发布时间:2022-05-22
下一篇:
Java OpenGLMatrix类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap