Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved.
*
* 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 com.hazelcast.mapreduce.impl.client;
import com.hazelcast.client.ClientEndpoint;
import com.hazelcast.client.impl.client.InvocationClientRequest;
import com.hazelcast.cluster.ClusterService;
import com.hazelcast.config.JobTrackerConfig;
import com.hazelcast.core.ExecutionCallback;
import com.hazelcast.core.ICompletableFuture;
import com.hazelcast.instance.MemberImpl;
import com.hazelcast.mapreduce.CombinerFactory;
import com.hazelcast.mapreduce.JobTracker;
import com.hazelcast.mapreduce.KeyPredicate;
import com.hazelcast.mapreduce.KeyValueSource;
import com.hazelcast.mapreduce.Mapper;
import com.hazelcast.mapreduce.ReducerFactory;
import com.hazelcast.mapreduce.TopologyChangedStrategy;
import com.hazelcast.mapreduce.impl.AbstractJobTracker;
import com.hazelcast.mapreduce.impl.HashMapAdapter;
import com.hazelcast.mapreduce.impl.MapReducePortableHook;
import com.hazelcast.mapreduce.impl.MapReduceService;
import com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation;
import com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation;
import com.hazelcast.mapreduce.impl.task.TrackableJobFuture;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.spi.NodeEngine;
import com.hazelcast.spi.Operation;
import java.io.IOException;
import java.security.Permission;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
import static com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation;
/**
* This class is used to prepare and start a map reduce job emitted by a client
* on a random node in the cluster (making it the job owner).
*
* @param type of the input key
* @param type of the input value
*/
public class ClientMapReduceRequest extends InvocationClientRequest {
protected String name;
protected String jobId;
protected Collection keys;
protected KeyPredicate predicate;
protected Mapper mapper;
protected CombinerFactory combinerFactory;
protected ReducerFactory reducerFactory;
protected KeyValueSource keyValueSource;
protected int chunkSize;
protected TopologyChangedStrategy topologyChangedStrategy;
public ClientMapReduceRequest() {
}
public ClientMapReduceRequest(String name, String jobId, Collection keys, KeyPredicate predicate, Mapper mapper,
CombinerFactory combinerFactory, ReducerFactory reducerFactory, KeyValueSource keyValueSource,
int chunkSize, TopologyChangedStrategy topologyChangedStrategy) {
this.name = name;
this.jobId = jobId;
this.keys = keys;
this.predicate = predicate;
this.mapper = mapper;
this.combinerFactory = combinerFactory;
this.reducerFactory = reducerFactory;
this.keyValueSource = keyValueSource;
this.chunkSize = chunkSize;
this.topologyChangedStrategy = topologyChangedStrategy;
}
@Override
protected void invoke() {
try {
final ClientEndpoint endpoint = getEndpoint();
MapReduceService mapReduceService = getService();
NodeEngine nodeEngine = mapReduceService.getNodeEngine();
AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.createDistributedObject(name);
TrackableJobFuture jobFuture = new TrackableJobFuture(name, jobId, jobTracker, nodeEngine, null);
if (jobTracker.registerTrackableJob(jobFuture)) {
ICompletableFuture