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

Java IgniteRunnable类代码示例

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

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



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

示例1: main

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
public static void main(String[] args) {
	try (Ignite ignite =  Ignition.start(IgniteConfigurationHelper.helloworldConfiguration())) {
		IgniteRunnable task = new IgniteRunnable() {
			private static final long serialVersionUID = 787726700536869271L;

			@IgniteInstanceResource
			private transient Ignite ignite;
			@Override
			public void run() {
				System.out.println("Hello Gaurav Bytes from: " + ignite.name());
				
			}
		};
		ignite.compute().run(task);
	}
	Ignition.stop(true);
}
 
开发者ID:gauravrmazra,项目名称:gauravbytes,代码行数:18,代码来源:HelloworldIgniteExample.java


示例2: process

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void process(final Map<?, ?> entries) {
    long processingStartTime = System.currentTimeMillis();
    ignite.compute().run(new IgniteRunnable() {
        @IgniteInstanceResource
        private Ignite localIgnite;

        @Override public void run() {
            IgniteCache cache = localIgnite.cache(cacheName);

            if (transactional) {
                try (Transaction tx = localIgnite.transactions().txStart()) {
                    process(cache, entries);
                }
            }
            else {
                process(cache, entries);
            }
        }
    });
    Statistics.recordOperation(System.currentTimeMillis() - processingStartTime);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:23,代码来源:ServerSideEntryProcessor.java


示例3: start

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/** */
public void start() {
    long reportFrequency = TestsHelper.getLoadTestsStatisticsReportFrequency();

    executor.scheduleAtFixedRate(new Runnable() {
        @Override public void run() {
            int reportSize = LOCAL_OPERATION_DURATIONS.size();

            if (reportSize > 0 || RETRIES.get() > 0 || WORKERS.get() > 0) {
                final List<Long> currentDurations = new ArrayList<>(reportSize);
                final int currentRetries = RETRIES.getAndSet(0);
                final int workersStarted = WORKERS.getAndSet(0);

                for (int i = 0; i < reportSize; i++) {
                    currentDurations.add(LOCAL_OPERATION_DURATIONS.poll());
                }
                aggregatorNodeCompute.run(new IgniteRunnable() {
                    @Override public void run() {
                        reportServerPerformance(localNodeId, currentDurations, currentRetries, workersStarted);
                    }
                });
            }
        }
    }, reportFrequency, reportFrequency, TimeUnit.MILLISECONDS);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:26,代码来源:Statistics.java


示例4: deployServices

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * Deploys used services synchronously.
 */
public void deployServices() {
    ignite().compute().broadcast(new IgniteRunnable() {
        /** Auto-injected ignite instance. */
        @IgniteInstanceResource
        private transient Ignite ignite;

        @Override public void run() {
            ignite.cluster().nodeLocalMap().remove(Injection.CONTAINER);
        }
    });
    ignite().services().deployClusterSingleton(CommandService.SERVICE_NAME, activeStoreConfiguration.commandService());

    do {
        try {
            sleep(100);
        }
        catch (InterruptedException e) {
            break;
        }
    }
    while (head() == null);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:26,代码来源:TestResources.java


示例5: cancelServices

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * Cancels used services.
 */
public void cancelServices() {
    ignite().compute().broadcast(new IgniteRunnable() {
        /** Auto-injected ignite instance. */
        @IgniteInstanceResource
        private transient Ignite ignite;

        @Override public void run() {
            Injection container = (Injection)ignite.cluster().nodeLocalMap().get(Injection.CONTAINER);
            if (container != null) {
                container.stop();
            }
        }
    });
    ignite().services().cancel(CommandService.SERVICE_NAME);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:19,代码来源:TestResources.java


示例6: doBroadcast

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void doBroadcast(final Exchange exchange, final AsyncCallback callback, IgniteCompute compute) throws Exception {
    Object job = exchange.getIn().getBody();

    if (IgniteCallable.class.isAssignableFrom(job.getClass())) {
        compute.broadcast((IgniteCallable<?>) job);
    } else if (IgniteRunnable.class.isAssignableFrom(job.getClass())) {
        compute.broadcast((IgniteRunnable) job);
    } else if (IgniteClosure.class.isAssignableFrom(job.getClass())) {
        compute.broadcast((IgniteClosure<Object, Object>) job, exchange.getIn().getHeader(IgniteConstants.IGNITE_COMPUTE_PARAMS));
    } else {
        throw new RuntimeCamelException(
                String.format("Ignite Compute endpoint with BROADCAST executionType is only " + "supported for IgniteCallable, IgniteRunnable or IgniteClosure payloads. The payload type was: %s.",
                        job.getClass().getName()));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:IgniteComputeProducer.java


示例7: doRun

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
private void doRun(final Exchange exchange, final AsyncCallback callback, IgniteCompute compute) throws Exception {
    Object job = exchange.getIn().getBody();

    if (Collection.class.isAssignableFrom(job.getClass())) {
        Collection<?> col = (Collection<?>) job;
        TypeConverter tc = exchange.getContext().getTypeConverter();
        Collection<IgniteRunnable> runnables = new ArrayList<>(col.size());
        for (Object o : col) {
            runnables.add(tc.mandatoryConvertTo(IgniteRunnable.class, o));
        }
        compute.run(runnables);
    } else if (IgniteRunnable.class.isAssignableFrom(job.getClass())) {
        compute.run((IgniteRunnable) job);
    } else {
        throw new RuntimeCamelException(String.format(
                "Ignite Compute endpoint with RUN executionType is only " + "supported for IgniteRunnable payloads, or collections of them. The payload type was: %s.", job.getClass().getName()));
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:IgniteComputeProducer.java


示例8: main

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
public static void main(String[] args) {
	try (Ignite ignite = Ignition.start("config/default-config.xml")) {

		ExecutorService service = ignite.executorService();

		for (String word : "helo doctor, welcome to ignite world".split(" ")) {
			// 转型IgniteRunnable,分布式环境序列化的呀
			service.submit((IgniteRunnable) () -> System.out.println(word + " print on this node"));
		}

		service.shutdown();

	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:sdcuike,项目名称:Ignite-2015,代码行数:18,代码来源:IgniteExecutorServiceExample.java


示例9: notifyListener

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void notifyListener(UUID sndId, Message msg,
    IgniteRunnable msgC) {
    try {
        GridIoMessage ioMsg = (GridIoMessage)msg;

        boolean wait = ioMsg.message() instanceof GridCacheQueryResponse ||
                ioMsg.message() instanceof GridJobExecuteResponse;

        if (wait) {
            cancelLatch.countDown();

            assertTrue(U.await(resLatch, 5000, MILLISECONDS));
        }

        super.notifyListener(sndId, msg, msgC);

        if (wait)
            finishLatch.countDown();
    }
    catch (Exception e) {
        fail("Unexpected error: " + e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:GridOrderedMessageCancelSelfTest.java


示例10: initDone

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * Moves exchange future to state 'init done' using {@link #initFut}.
 */
private void initDone() {
    while (!isDone()) {
        List<IgniteRunnable> evts;

        synchronized (discoEvts) {
            if (discoEvts.isEmpty()) {
                init = true;

                break;
            }

            evts = new ArrayList<>(discoEvts);

            discoEvts.clear();
        }

        for (IgniteRunnable c : evts)
            c.run();
    }

    initFut.onDone(true);
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:GridDhtPartitionsExchangeFuture.java


示例11: StealingStripe

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @param idx Stripe index.
 * @param igniteInstanceName Ignite instance name.
 * @param poolName Pool name.
 * @param log Logger.
 * @param queues Other queues to steal tasks from.
 * @param unpark Unpark callback, unparks random parked stripe from the pool.
 */
private StealingStripe(
    int idx,
    String igniteInstanceName,
    String poolName,
    IgniteLogger log,
    Deque<Runnable>[] queues,
    IgniteRunnable unpark
) {
    super(
        igniteInstanceName,
        poolName,
        idx,
        log);

    this.queues = queues;
    this.unpark = unpark;

    queue = queues[idx];
}
 
开发者ID:apache,项目名称:ignite,代码行数:28,代码来源:StripedExecutor.java


示例12: affinityRunAsync0

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * Affinity run implementation.
 *
 * @param cacheName Cache name.
 * @param affKey Affinity key.
 * @param job Job.
 * @return Internal future.
 */
private IgniteInternalFuture<?> affinityRunAsync0(String cacheName, Object affKey, IgniteRunnable job) {
    A.notNull(affKey, "affKey");
    A.notNull(job, "job");

    guard();

    try {
        // In case cache key is passed instead of affinity key.
        final Object affKey0 = ctx.affinity().affinityKey(cacheName, affKey);
        int partId = ctx.affinity().partition(cacheName, affKey0);

        if (partId < 0)
            throw new IgniteCheckedException("Failed map key to partition: [cache=" + cacheName + " key="
                + affKey + ']');

        return ctx.closure().affinityRun(Collections.singletonList(cacheName), partId, job, prj.nodes(), execName);
    }
    catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
    finally {
        unguard();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:33,代码来源:IgniteComputeImpl.java


示例13: onMessage

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onMessage(UUID nodeId, Message msg, IgniteRunnable msgC) {
    msgC.run();

    if (msg instanceof GridTestMessage) {
        GridTestMessage testMsg = (GridTestMessage)msg;

        if (!testMsg.getSourceNodeId().equals(nodeId))
            fail("Listener nodeId is not equal to message nodeId.");

        if (!reject)
            rcvdMsgs.offer(testMsg);

        if (!locNodeId.equals(nodeId))
            rmtMsgCnt.incrementAndGet();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:GridTcpCommunicationSpiLanTest.java


示例14: onMessage

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onMessage(UUID nodeId, Message msg, IgniteRunnable msgC) {
    msgC.run();

    if (msg instanceof GridTestMessage) {
        GridTestMessage testMsg = (GridTestMessage)msg;

        if (!testMsg.getSourceNodeId().equals(nodeId))
            fail("Listener nodeId is not equal to message nodeId.");

        if (!reject)
            rcvdMsgs.offer(testMsg);

        if (!locNodeId.equals(nodeId))
            rmtMsgCnt.incrementAndGet();
    }
    else
        fail();
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:GridTcpCommunicationSpiMultithreadedSelfTest.java


示例15: testTestMarshalling

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testTestMarshalling() throws Exception {
    final String msg = "PASSED";

    byte[] buf = marshal(new IgniteRunnable() {
        @Override public void run() {
            c1.apply(msg);
            c2.apply(msg);

            c3.apply();
            c4.reduce();

            System.out.println("Test message: " + msg);
        }
    });

    Runnable r = unmarshal(buf);

    assertNotNull(r);

    r.run();
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:OptimizedMarshallerSelfTest.java


示例16: testNoTimeout

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testNoTimeout() throws Exception {
    Ignite ignite = ignite(0);

    IgniteFuture fut = null;

    for (int i = 0; i < 10000; i++) {
        fut =  ignite.compute().runAsync(new IgniteRunnable() {
            @Override public void run() {

            }
        });
    }

    fut.get();

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


示例17: testRuntimeException

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @throws Exception If fails.
 */
public void testRuntimeException() throws Exception {
    Ignite ignite = grid(0);

    ignite.compute().runAsync(new IgniteRunnable() {
        @Override public void run() {
            try {
                Thread.sleep(500);
            }
            catch (InterruptedException ignored) {
                // No-op.
            }
        }
    }).listen(new IgniteInClosure<IgniteFuture<Void>>() {
        @Override public void apply(IgniteFuture<Void> future) {
            throw new RuntimeException();
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:GridComputeJobExecutionErrorToLogManualTest.java


示例18: testRun

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testRun() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            IgniteRunnable job = (IgniteRunnable)factory.create();

            ignite.compute().run(job);
            // All checks are inside the run() method of the job.

            Collection<IgniteRunnable> jobs = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i)
                jobs.add((IgniteRunnable)factory.create());

            ignite.compute().run(jobs);
            // All checks are inside the run() method of the job.
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteComputeConfigVariationsFullApiTest.java


示例19: testRunAsync

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testRunAsync() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            IgniteRunnable job = (IgniteRunnable)factory.create();

            IgniteFuture<Void> fut0 = ignite.compute().runAsync(job);

            fut0.get();
            // All checks are inside the run() method of the job.

            Collection<IgniteRunnable> jobs = new ArrayList<>(MAX_JOB_COUNT);

            for (int i = 0; i < MAX_JOB_COUNT; ++i)
                jobs.add((IgniteRunnable)factory.create());

            IgniteFuture<Void> fut1 = ignite.compute().runAsync(jobs);

            fut1.get();
            // All checks are inside the run() method of the job.
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:IgniteComputeConfigVariationsFullApiTest.java


示例20: testAffinityRun

import org.apache.ignite.lang.IgniteRunnable; //导入依赖的package包/类
/**
 * @throws Exception If failed.
 */
public void testAffinityRun() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache(CACHE_NAME);

            final IgniteCompute comp = ignite.compute();

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                IgniteRunnable job = (IgniteRunnable)factory.create();

                comp.affinityRun("test", key(0), job);
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:IgniteComputeConfigVariationsFullApiTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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