快速并行异步 HTTP/SSH/TCP/UDP/Ping 客户端 Java 库。聚合 100,000 个 API,在 20 行代码中即可发送。在 12 秒内对 8000 个服务器进行 Ping/HTTP 调用
快速并行异步 HTTP/SSH/TCP/UDP/Ping 客户端 Java 库。聚合 100,000 个 API,在 20 行代码中即可发送。在 12 秒内对 8000 个服务器进行 Ping/HTTP 调用
[ Get-Started | Features | Use Cases | Samples | Change Log / What's New / Versions | User Group | Motivation | Demos | Performance | Compare | Contributors | About | News | Plugin | 中文介绍 ]
[ API Overview | Generate & Submit Task | Track Status & Examine Responses | Configurations ]
Tweeted by the Creator of Akka & Featured in [ This Week in #Scala | OSChina - 2015 Top 100 ]
Parallec is a fast parallel async HTTP(S)/SSH/TCP/UDP/Ping client java library based on Akka. Scalably aggregate and handle API responses anyway and send it anywhere by writing 20 lines of code. A super convenient response context let you pass in/out any object when handling the responses. Now you can conduct scalable API calls, then effortlessly pass aggregated data anywhere to elastic search, kafka, MongoDB, graphite, memcached, etc. Flexible task level concurrency control without creating a 1,000 threads thread pool. Parallec means Parallel Client (pronounced as "Para-like"). Visit www.parallec.io
Watch Demo: 8,000 web server HTTP response aggregation to memory in 12 seconds / to ElasticSearch in 16 seconds.
Aggregated error messages - Debug friendly with full visibility: Having trouble debugging in concurrent environment? Not any more! All exceptions, timeout, stack traces, request sent and response received time are captured and aggregated in the response map. It is available in ParallelTask for polling right after you execute a task asynchronously. Multi-level (worker/manager) timeout guarantees tasks return even for 100,000s of requests.
Production Use Cases: widely used in infrastructure software as the polling and aggregation engine
Donwload the latest JAR or grab from Maven:
io.parallec
parallec-core
0.10.6
Snapshots of the development version are available in Sonatype's snapshots repository.
or Gradle:
compile 'io.parallec:parallec-core:0.10.6'
6 Line Example
In the example below, simply changing prepareHttpGet() to prepareSsh(), prepareTcp(), prepareUdp(), preparePing() enables you to conduct parallel SSH/TCP/Ping. Details please refer to the Java Doc and Example Code.
import io.parallec.core.*;
import java.util.Map;
ParallelClient pc = new ParallelClient();
pc.prepareHttpGet("").setTargetHostsFromString("www.google.com www.ebay.com www.yahoo.com")
.execute(new ParallecResponseHandler() {
public void onCompleted(ResponseOnSingleTask res,
Map responseContext) {
System.out.println( res.toString() ); }
});
```
**20 Line Example**
Now that you have learned the basics, check out how easy to pass an elastic search client using the convenient **response context** to aggregate data anywhere you like. You can also pass a hash map to the `responseContext`, save the processed results to the map during `onCompleted`, and use the map outside for further work.
…
**Different Requests to the Same Target**
Now see **how easy** to use the request template to send multiple different requests to the same target. Variable replacement is allowed in post body, url and headers. [Read more..](http://www.parallec.io/docs/submit-task/#apis-on-variable-replacement-for-heterogeneous-requests)
```java
pc.prepareHttpGet("/userdata/sample_weather_$ZIP.txt")
.setReplaceVarMapToSingleTargetSingleVar("ZIP",
Arrays.asList("95037","48824"), "www.parallec.io")
.execute(new ParallecResponseHandler() {...}...
More details please check the Change Log.
0.10.x, where we use in production.async-http-client (currently using AHC version 2.0.15) is 0.20.0-SNAPSHOT. This version has passed comprehensive unit tests but has not been used yet in production. This version requires JDK8 due to AHC 2.x and can be used with the parallec-plugins with the same version 0.20.0-SNAPSHOT, details please check #37.Parallec is built on Akka actors and Async HTTP Client / Netty / Jsch. The library focuses on HTTP while also enables scalable communication over SSH/Ping/TCP.
90%+ Test coverage assures you always find an example of each of feature.
暂无开放 Issues,或尚未同步最近议题。