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


Java ComputeJob类代码示例

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


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

示例1: setupCrossOver

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/**
 * Helper method to help assign ComputeJobs to respective ClusterNodes
 * 
 * @param clusterNode
 * @param keys
 * @param map
 * @return Map<ComputeJob, ClusterNode>
 */

private Map<ComputeJob, ClusterNode> setupCrossOver(ClusterNode clusterNode, List<Long> keys,
    Map<ComputeJob, ClusterNode> map) {
    // Calculate number of Jobs = keys / 2
    // as we desire pairs of Chromosomes to be swapped
    int numberOfJobs = keys.size() / 2;
    int k = 0;
    for (int i = 0; i < numberOfJobs; i++) {
        Long key1 = keys.get(k);
        Long key2 = keys.get(k + 1);

        CrossOverJob job = new CrossOverJob(key1, key2, this.config.getCrossOverRate());
        map.put(job, clusterNode);
        k = k + 2;
    }
    return map;
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:26,代码来源:CrossOverTask.java

示例2: invalidate

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void invalidate(Iterable<Metadata> subPath, final IgniteBiInClosure<String, Set<Object>> action) {
    Map<String, List<Metadata>> names = getSnapshotsByCache(subPath);
    if (!names.isEmpty()) {
        ignite.compute().execute(new ComputeTaskSplitAdapter<Map<String, List<Metadata>>, Void>() {
            /** {@inheritDoc} */
            @Override protected Collection<? extends ComputeJob> split(int gridSize,
                Map<String, List<Metadata>> byCache) throws IgniteException {
                List<ComputeJob> result = new ArrayList<>();
                for (Map.Entry<String, List<Metadata>> entry : byCache.entrySet()) {
                    String cacheName = entry.getKey();
                    for (Metadata metadata : entry.getValue()) {
                        result.add(new ProcessAllKeysJob(cacheName, metadata, action));
                    }
                }
                return result;
            }

            /** {@inheritDoc} */
            @Override public Void reduce(List<ComputeJobResult> results) throws IgniteException {
                return null;
            }
        }, names);
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:26,代码来源:KeyValueManagerImpl.java

示例3: restoreData

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/**
 * Performs restore operaton on given resource names.
 *
 * @param source base path to existing backup.
 * @param names of resources included in this backup.
 */
private void restoreData(final URI source, Iterable<String> names) {
    failOnExistingTransactions();
    ignite.compute().execute(new ComputeTaskSplitAdapter<Iterable<String>, Object>() {
        /** {@inheritDoc} */
        @Override protected Collection<? extends ComputeJob> split(int gridSize,
            Iterable<String> arg) throws IgniteException {
            List<ComputeJob> result = new ArrayList<>();
            for (String name : arg) {
                result.add(new RestoreJob(source, name));
            }
            return result;
        }

        /** {@inheritDoc} */
        @Nullable @Override public Object reduce(List<ComputeJobResult> results) throws IgniteException {
            return null;
        }
    }, names);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:26,代码来源:CommandServiceImpl.java

示例4: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
@Override
protected Collection<? extends ComputeJob> split(int gridSize, final Integer arg) throws IgniteException {
    Set<ComputeJob> answer = new HashSet<>();
    for (int i = 0; i < arg; i++) {
        final int c = i;
        answer.add(new ComputeJob() {
            private static final long serialVersionUID = 3365213549618276779L;

            @Override
            public Object execute() throws IgniteException {
                return "a" + c;
            }

            @Override
            public void cancel() {
                // nothing
            }
        });
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:TestIgniteComputeResources.java

示例5: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) throws IgniteException {
    List<ComputeJob> jobs = new ArrayList<>(gridSize * 2);

    for (int i = 0; i < gridSize * 2; ++i) {
        jobs.add(new ComputeJobAdapter() {
            @Override public Object execute() throws IgniteException {
                assertTrue(Thread.currentThread().getName().contains(EXEC_NAME0));

                return null;
            }
        });
    }

    return jobs;
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:IgniteComputeCustomExecutorSelfTest.java

示例6: map

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable ClusterNode arg) {
    for (ClusterNode node : subgrid) {
        if (node.id().equals(arg.id()))
            return Collections.singletonMap(new ComputeJobAdapter() {
                @TaskSessionResource
                private ComputeTaskSession ses;

                @Nullable @Override public Object execute() {
                    ses.saveCheckpoint("checkpoint-key", "checkpoint-value");

                    return null;
                }
            }, node);
    }

    assert false : "Expected node wasn't found in grid";

    // Never accessible.
    return null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:GridJobCheckpointCleanupSelfTest.java

示例7: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, List<Object> args) {
    Collection<ComputeJobAdapter> jobs = new ArrayList<>(args.size());

    for (final Object arg : args) {
        jobs.add(new ComputeJobAdapter() {
            @SuppressWarnings("OverlyStrongTypeCast")
            @Override public Object execute() {
                try {
                    return ((String)arg).length();
                }
                catch (ClassCastException ignored) {
                    assert arg instanceof Integer;

                    return arg;
                }
            }
        });
    }

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

示例8: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) {
    return F.asSet(new ComputeJobAdapter() {
        @TaskSessionResource
        private ComputeTaskSession ses;

        @Override public Object execute() {
            CNT.incrementAndGet();

            if (fail)
                throw new ComputeExecutionRejectedException("Expected error.");

            return ses.getTaskName();
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:GridTaskExecutionContextSelfTest.java

示例9: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, String arg) {
    Collection<ComputeJobAdapter> jobs = new ArrayList<>();

    if (arg != null)
        for (final Object val : arg.split(""))
            jobs.add(new ComputeJobAdapter() {
                @Override public Object execute() {
                    try {
                        Thread.sleep(5);
                    }
                    catch (InterruptedException ignored) {
                        Thread.currentThread().interrupt();
                    }

                    return val == null ? 0 : val.toString().length();
                }
            });

    return jobs;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:ClientStringLengthTask.java

示例10: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Collection<? extends ComputeJob> split(int gridSize, String arg) {
    return Collections.singleton(new ComputeJobAdapter(arg) {
        @Override public Object execute() {
            try {
                Thread.sleep(10000);

                String val = argument(0);

                return val == null ? 0 : val.length();
            }
            catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:SleepTestTask.java

示例11: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/**
 * Splits the received string to words, creates a child job for each word, and sends
 * these jobs to other nodes for processing. Each such job simply prints out the received word.
 *
 * @param clusterSize Number of available cluster nodes. Note that returned number of
 *      jobs can be less, equal or greater than this cluster size.
 * @param arg Task execution argument. Can be {@code null}.
 * @return The list of child jobs.
 */
@Override protected Collection<? extends ComputeJob> split(int clusterSize, String arg) {
    Collection<ComputeJob> jobs = new LinkedList<>();

    for (final String word : arg.split(" ")) {
        jobs.add(new ComputeJobAdapter() {
            @Nullable @Override public Object execute() {
                System.out.println();
                System.out.println(">>> Printing '" + word + "' on this node from ignite job.");

                // Return number of letters in the word.
                return word.length();
            }
        });
    }

    return jobs;
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:ComputeTaskSplitExample.java

示例12: map

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, String arg) {
    assert ignite != null;

    UUID locNodeId = ignite.configuration().getNodeId();

    assert locNodeId != null;

    ClusterNode remoteNode = null;

    for (ClusterNode node : subgrid) {
        if (!node.id().equals(locNodeId))
            remoteNode = node;
    }

    return Collections.singletonMap(new ComputeJobAdapter(arg) {
        @Override public Serializable execute() {
            throw new IgniteException("Job exception.");
        }
    }, remoteNode);
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:GridFailoverTopologySelfTest.java

示例13: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int clusterSize, String arg) {
    Collection<ComputeJob> jobs = new ArrayList<>(clusterSize);

    for (int i = 0; i < clusterSize; i++) {
        jobs.add(new ComputeJobAdapter() {
            @Nullable @Override public Serializable execute() {
                System.out.println(">>> Executing deployment example job on this node.");

                // This job does not return any result.
                return null;
            }
        });
    }

    return jobs;
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:DeploymentExample.java

示例14: map

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Void arg) {
    try {
        JobMapper mapper = new JobMapper(args.size());

        for (T jobArg : args) {
            ComputeJob job = job(this.job, jobArg);

            ClusterNode node = lb.getBalancedNode(job, null);

            mapper.map(job, node);
        }

        return mapper.map();
    }
    catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:GridClosureProcessor.java

示例15: split

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, Object arg) {
    return Collections.singletonList(new ComputeJobAdapter() {
        @IgniteInstanceResource
        private Ignite ignite;

        @Override public Object execute() throws IgniteException {
            MyService svc = ignite.services().service("my-service");

            while (!isCancelled()) {
                try {
                    Thread.sleep(1000);

                    svc.hello();
                }
                catch (InterruptedException ignored) {
                    // No-op.
                }
            }

            assertTrue(isCancelled());

            return svc.hello();
        }
    });
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:ComputeJobCancelWithServiceSelfTest.java


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