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

Java ComputeJob类代码示例

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

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



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


示例16: map

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, GridifyArgument arg) {
    assert !subgrid.isEmpty() : "Subgrid should not be empty: " + subgrid;

    assert ignite != null : "Grid instance could not be injected";
    assert balancer != null : "Load balancer could not be injected";

    ComputeJob job = new GridifyJobAdapter(arg);

    ClusterNode node = balancer.getBalancedNode(job, Collections.<ClusterNode>singletonList(ignite.cluster().localNode()));

    if (node != null) {
        // Give preference to remote nodes.
        return Collections.singletonMap(job, node);
    }

    return Collections.singletonMap(job, balancer.getBalancedNode(job, null));
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:GridifyDefaultTask.java


示例17: getBalancedNode

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public ClusterNode getBalancedNode(ComputeTaskSession ses, List<ClusterNode> top, ComputeJob job) {
    A.notNull(ses, "ses");
    A.notNull(top, "top");
    A.notNull(job, "job");

    IgniteBiTuple<Boolean, WeightedTopology> weightedTop = taskTops.get(ses.getId());

    // Create new cached topology if there is no one. Do not
    // use cached topology after task has been mapped.
    if (weightedTop == null)
        // Called from ComputeTask#map(). Put new topology and false as not mapped yet.
        taskTops.put(ses.getId(), weightedTop = F.t(false, new WeightedTopology(top)));
    // We have topology - check if task has been mapped.
    else if (weightedTop.get1())
        // Do not use cache after ComputeTask#map().
        return new WeightedTopology(top).pickWeightedNode();

    return weightedTop.get2().pickWeightedNode();
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:AdaptiveLoadBalancingSpi.java


示例18: map

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

    attrVal = UUID.randomUUID();

    for (ClusterNode node : subgrid) {
        if (node.id().equals(arg))
            return Collections.singletonMap(new SessionTestJob(attrVal), node);
    }

    assert false;

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


示例19: map

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/** {@inheritDoc} */
@Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid,
    @Nullable Object arg) {
    taskSubjId = ((GridTaskSessionInternal)ses).subjectId();

    ClusterNode node = null;

    for (ClusterNode subgridNode : subgrid) {
        if (F.eq(targetNodeId, subgridNode.id())) {
            node = subgridNode;

            break;
        }
    }

    assert node != null;

    return Collections.singletonMap(new Job(), node);
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:GridJobSubjectIdSelfTest.java


示例20: mapToNode

import org.apache.ignite.compute.ComputeJob; //导入依赖的package包/类
/**
 * @param subgrid Subgrid.
 * @param args Args.
 * @param first First.
 * @param cache Cache.
 */
@Nullable private Map<? extends ComputeJob, ClusterNode> mapToNode(
    List<ClusterNode> subgrid,
    Map<String, Object> args,
    boolean first,
    String cache
) {
    GridDiscoveryManager discoMgr = ((IgniteKernal)ignite).context().discovery();

    for (ClusterNode n : subgrid) {
        if (discoMgr.cacheAffinityNode(n, cache)) {
            args.put("cache", cache);

            return F.asMap(new JdbcDriverJob(args, first), n);
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:GridCacheQueryJdbcTask.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MavenPluginActivator类代码示例发布时间:2022-05-22
下一篇:
Java SimplePair类代码示例发布时间: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