use of com.alibaba.pegasus.service.protocol.PegasusClient.JobConfig in project GraphScope by alibaba.
the class JobBuilder method main.
public static void main(String[] args) {
JobConfig confPb = JobConfig.newBuilder().setJobId(1).setJobName("test").setWorkers(1).build();
// should be converted from pb to bytes
ByteString opBody = ByteString.EMPTY;
JobBuilder jobBuilder = new JobBuilder(confPb, opBody);
// for nested task
JobBuilder plan = new JobBuilder();
// build JobReq
JobRequest jobReq = jobBuilder.map(opBody).flatMap(opBody).repeat(3, plan.flatMap(opBody).flatMap(opBody)).count().unfold(opBody).count().build();
logger.info("send job req: {}", jobReq.toString());
}
use of com.alibaba.pegasus.service.protocol.PegasusClient.JobConfig in project GraphScope by alibaba.
the class ClientExample method main.
public static void main(String[] args) throws Exception {
RpcChannel rpcChannel0 = new RpcChannel("localhost", 1234);
RpcChannel rpcChannel1 = new RpcChannel("localhost", 1235);
List<RpcChannel> channels = new ArrayList<>();
channels.add(rpcChannel0);
channels.add(rpcChannel1);
RpcClient rpcClient = new RpcClient(channels);
logger.info("Will try to send request");
JobConfig confPb = JobConfig.newBuilder().setJobId(2).setJobName("ping_pong_example").setWorkers(2).setAll(PegasusClient.Empty.newBuilder().build()).build();
// for job build
JobBuilder jobBuilder = new JobBuilder(confPb);
// for nested task
JobBuilder start = new JobBuilder();
// construct job
jobBuilder.addSource(getSeed(0)).repeat(3, start.exchange(getRoute()).map(add(1)).flatMap(copy(8))).sink(getSink());
JobRequest req = jobBuilder.build();
CloseableIterator<JobResponse> iterator = rpcClient.submit(req);
// process response
try {
while (iterator.hasNext()) {
JobResponse response = iterator.next();
process(response);
}
} catch (Exception e) {
if (iterator != null) {
try {
iterator.close();
} catch (IOException ioe) {
// Ignore
}
}
error(Status.fromThrowable(e));
throw e;
}
finish();
rpcClient.shutdown();
}
Aggregations