JPPF,全称Java Parallel Processing Framework,即java并行处理框架,是一个开放源码的网格计算框架,它可以在一个分布执行环境中 同时运行多个java应用。
JPPF的突出特性
提供了负载平衡,故障转移和错误恢复等服务。
提供一个基 于JMX的管理控制台,它既可以监视节点也可以管理执行的任务。你可以远程取消和重启任务,或配置令其超时的截止日期或时间间隔。
想要运行JPPF并行计算任务,
需要至少一个Node节点(执行任务的节点),
一个driver节点(调度任务的节点),和本地调用节点
依次分别运行driver包里的startDriver.bat和
node包里的startNode.bat启动driver和node
然后开始写客户端:
/* * JPPF. * Copyright (C) 2005-2012 JPPF Team. * http://www.jppf.org * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jppf.application.template; import java.util.List; import org.jppf.client.*; import org.jppf.server.protocol.JPPFTask; /** * This is a template JPPF application runner. * It is fully commented and is designed to be used as a starting point * to write an application using JPPF. * @author Laurent Cohen */ public class TemplateApplicationRunner { /** * The JPPF client, handles all communications with the server. * It is recommended to only use one JPPF client per JVM, so it * should generally be created and used as a singleton. */ private static JPPFClient jppfClient = null; /** * The entry point for this application runner to be run from a Java command line. * @param args by default, we do not use the command line arguments, * however nothing prevents us from using them if need be. */ public static void main(final String...args) { try { // create the JPPFClient. This constructor call causes JPPF to read the configuration file // and connect with one or multiple JPPF drivers. jppfClient = new JPPFClient(); // create a runner instance. TemplateApplicationRunner runner = new TemplateApplicationRunner(); // Create a job JPPFJob job = runner.createJob(); // execute a blocking job runner.executeBlockingJob(job); // execute a non-blocking job //runner.executeNonBlockingJob(job); } catch(Exception e) { e.printStackTrace(); } finally { if (jppfClient != null) jppfClient.close(); } } /** * Create a JPPF job that can be submitted for execution. * @return an instance of the {@link org.jppf.client.JPPFJob JPPFJob} class. * @throws Exception if an error occurs while creating the job or adding tasks. */ public JPPFJob createJob() throws Exception { // create a JPPF job JPPFJob job = new JPPFJob(); // give this job a readable unique id that we can use to monitor and manage it. job.setName("Template Job Id"); // add a task to the job. job.addTask(new TemplateJPPFTask()); // add more tasks here ... // there is no guarantee on the order of execution of the tasks, // however the results are guaranteed to be returned in the same order as the tasks. return job; } /** * Execute a job in blocking mode. The application will be blocked until the job * execution is complete. * @param job the JPPF job to execute. * @throws Exception if an error occurs while executing the job. */ public void executeBlockingJob(final JPPFJob job) throws Exception { // set the job in blocking mode. job.setBlocking(true); // Submit the job and wait until the results are returned. // The results are returned as a list of JPPFTask instances, // in the same order as the one in which the tasks where initially added the job. List<JPPFTask> results = jppfClient.submit(job); // process the results processExecutionResults(results); } /** * Execute a job in non-blocking mode. The application has the responsibility * for handling the notification of job completion and collecting the results. * @param job the JPPF job to execute. * @throws Exception if an error occurs while executing the job. */ public void executeNonBlockingJob(final JPPFJob job) throws Exception { // set the job in non-blocking (or asynchronous) mode. job.setBlocking(false); // this call returns immediately. We will use the collector at a later time // to obtain the execution results asynchronously JPPFResultCollector collector = submitNonBlockingJob(job); // the non-blocking job execution is asynchronous, we can do anything else in the meantime System.out.println("Doing something while the job is executing ..."); // ... // We are now ready to get the results of the job execution. // We use JPPFResultCollector.waitForResults() for this. This method returns immediately with // the results if the job has completed, otherwise it waits until the job execution is complete. List<JPPFTask> results = collector.waitForResults(); // process the results processExecutionResults(results); } /** * Execute a job in non-blocking mode. The application has the responsibility * for handling the notification of job completion and collecting the results. * @param job the JPPF job to execute. * @return a JPPFResultCollector used to obtain the execution results at a later time. * @throws Exception if an error occurs while executing the job. */ public JPPFResultCollector submitNonBlockingJob(final JPPFJob job) throws Exception { // set the job in non-blocking (or asynchronous) mode. job.setBlocking(false); // We need to be notified of when the job execution has completed. // To this effect, we define an instance of the TaskResultListener interface, // which we will register with the job. // Here, we use an instance of JPPFResultCollector, conveniently provided by the JPPF API. // JPPFResultCollector implements TaskResultListener and has a constructor that takes // the number of tasks in the job as a parameter. JPPFResultCollector collector = new JPPFResultCollector(job); job.setResultListener(collector); // Submit the job. This call returns immediately without waiting for the execution of // the job to complete. As a consequence, the object returned for a non-blocking job is // always null. Note that we are calling the exact same method as in the blocking case. jppfClient.submit(job); // finally return the result collector, so it can be used to collect the exeuction results // at a time of our chosing. The collector can also be obtained at any time by calling // (JPPFResultCollector) job.getResultListener() return collector; } /** * Process the execution results of each submitted task. * @param results the tasks results after execution on the grid. */ public void processExecutionResults(final List<JPPFTask> results) { // process the results for (JPPFTask task: results) { // if the task execution resulted in an exception if (task.getException() != null) { // process the exception here ... } else { // process the result here ... } } } }
一个并行计算的任务,就是一个JPPFJob,每个job含有多个task,task之间是并行执行的,如果有多个nod节点,会按照其负载均衡策略分配到多个node上执行。通过client提交(submit)job后,会返回执行结果,为一个JPPFTask列表,列表里包含你add到job中每个task及其运行结果,作为后续计算处理之用。任务调用支持阻塞和非阻塞。
相关推荐
JPPF(Java Parallel Processing Framework)是一个开源的云计算和分布式计算框架,它允许开发者将计算任务分解成小单元,然后在分布式环境中并行处理。在JPPF中,服务器(Server)扮演着核心角色,负责管理和调度...
### JPPF安装和使用指南 #### 一、引言:理解JPPF的核心理念 Java Parallel Processing Framework(简称JPPF)是一个优秀的开源并行处理框架,它旨在简化并行计算过程,使得开发者和系统管理员能够快速部署并运行...
JPPF(Java Parallel Processing Framework)是一个开源的分布式计算框架,它允许开发者将计算任务分布到多台计算机上,以实现高性能计算。JPPF通过节点(node)和服务器(server)来构建分布式计算环境,其中节点是...
### jppf 2.1 用户手册知识点概览 #### 1. 引言与预备知识 - **目标读者**:本手册适用于那些希望利用Java Parallel Processing Framework (JPPF)进行并行处理任务的开发人员和技术团队。 - **先决条件**:读者需...
**JPPF-3.3.2:分布式计算框架详解** JPPF(Java Parallel Processing Foundation)是一个开源的Java分布式计算框架,版本3.3.2是其在2019年发布的一个稳定版本。该框架允许开发者将计算密集型任务分散到多个计算...
Java Parallel Processing Framework(JPPF) 是一个优秀的开源的基于Java的并行处理框架。这是它的API手册,因为网站上面不提供apidoc的下载,所以我自己就做了个chm,方便大家使用!
《JPPF客户端3.3.3与Maven插件详解》 在IT行业中,开源项目扮演着至关重要的角色,它们推动了技术创新,提供了丰富的工具和框架供开发者使用。"jppf-client-3.3.3.zip"是这样一个开源项目,它与Maven插件紧密相关,...
在传统的串行检索与基于JPPF的并行检索的对比实验中,以数据库查询为例,研究者们发现,在数据规模较大的情况下,基于JPPF的并行检索方式相较于传统的串行检索方式在效率上有显著提升。这表明,分布式并行计算技术...
【标题】"jppf-admin-4.1.1.zip" 涉及的知识点主要集中在JPPF(Java Parallel Processing Framework)平台的管理工具上。JPPF是一款开源的分布式计算框架,它允许开发者利用多核CPU和集群资源进行大规模并行计算。...
开源网格计算解决方案这是JPPF源代码的所在地。 其他服务可以在以下位置找到:JPPF模块: :包含构建脚本,网站和相关模板,以及作为LibreOffice文本文档的文档 :桌面(基于Swing)管理控制台的代码和资源 :Web...
Java Parallel Processing Framework(JPPF)是一个开源的Java框架,专为分布式并行计算而设计。它允许开发者利用多核处理器、集群以及云计算资源来执行大量计算任务,从而提高应用程序的性能和响应速度。JPPF的核心...
网格计算框架JPPF,Java Parallel Processing Framework,即java并行处理框架.一个开放源码的网格计算框架,它可以在一个分布执行环境中 同时运行多个java应用.这是他的最新版1.5版
【基于JPPF的异构分布式MTH1虚拟筛选系统】是针对癌症治疗研究中的一种高效计算解决方案。文章主要探讨了如何利用JPPF(Java Parallel Processing Framework)分布式并行框架,结合Autodock Vina软件,设计一个跨...
**JPPF:开源网格计算解决方案** JPPF(Java Parallel Processing Framework)是一个全面的开源网格计算框架,专为在分布式环境中执行计算密集型任务而设计。它提供了一个灵活、可扩展的平台,允许开发者将应用程序...
jppf-测试 此 repo 包含涉及测试。 安装先决条件 要运行这些测试,您需要: JDK 7 或更高版本 吉特 Maven JPPF 发行版 4.2.4 或更高版本 下载项目 git 克隆 JPPFExecutorService - 运行测试 mvn 清理包 exec:java ...
1. **JPPF.pdf**:JPPF(Java Parallel Processing Framework)是一个开源的网格计算框架,用于构建分布式应用程序。这份PDF可能包含JPPF的使用教程、原理介绍或者在面试中如何展示对分布式计算的理解。学习和了解...
JPPF支持跨多种平台,包括移动设备,使得科研人员可以利用手边的设备参与大型计算任务,这为科研工作提供了极大的便利。 网格技术(Grid Computing)在云计算之前是药物筛选常用的技术。网格技术虽然潜力巨大,但...
2. JPPF(Java Parallel Processing Framework):专注于分布式计算,允许开发者构建可扩展的P2P应用程序,尤其适合大数据处理。 3. JMF(Java Media Framework):虽然主要针对多媒体处理,但其流媒体能力也可用于...
2. **Java P2P框架**:Java中有多个P2P框架可供选择,如JXTA(Java XML-based Trading and Advertising)、JPPF(Java Peer-to-Peer Foundation)和J篦(Jini)。这些框架提供了一组工具和API,简化了开发过程。 3....