当前位置: 首页>>代码示例>>Java>>正文


Java IgniteRunnable类代码示例

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


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


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