com.hazelcast.mapreduce.JobTracker Maven / Gradle / Ivy
/*
* Copyright (c) 2008-2016, 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;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.spi.annotation.Beta;
/**
*
* The JobTracker interface is used to create instances of {@link Job}s depending
* on the given data structure / data source.
*
*
* The underlying created instance of the {@link Job} depends on whether it is used for a
* {@link com.hazelcast.client.HazelcastClient} or a {@link com.hazelcast.core.Hazelcast} member node.
*
*
* The default usage is same for both cases and looks similar to the following example:
*
*
* HazelcastInstance hz = getHazelcastInstance();
* IMap map = hz.getMap( getMapName() );
* JobTracker tracker = hz.getJobTracker( "default" );
* Job job = tracker.newJob( KeyValueSource.fromMap( map ) );
*
*
*
* The created instance of JobTracker is fully threadsafe and can be used concurrently and multiple times.
* Caution: Do not use the JobTracker with data structures of other {@link com.hazelcast.core.HazelcastInstance}
* instances than the one used for creation of the JobTracker. Unexpected results may happen!
*
*
* @since 3.2
*/
@Beta
public interface JobTracker
extends DistributedObject {
/**
* Builds a {@link Job} instance for the given {@link KeyValueSource} instance. The returning
* implementation depends on the {@link com.hazelcast.core.HazelcastInstance} that created
* the JobTracker.
* Caution: Do not use the JobTracker with data structures of other
* {@link com.hazelcast.core.HazelcastInstance} instances than the one used for creation of the
* JobTracker. Unexpected results may happen!
*
* @param source data source the created Job should work on
* @param type of the key
* @param type of the value
* @return instance of the Job bound to the given KeyValueSource
*/
Job newJob(KeyValueSource source);
/**
* Builds a complex {@link ProcessJob} instance for the given {@link KeyValueSource} instance. The returning
* implementation is depending on the {@link com.hazelcast.core.HazelcastInstance} that was creating the
* JobTracker.
* Caution: Do not use the JobTracker with data structures of other
* {@link com.hazelcast.core.HazelcastInstance} instances than the one used for creation of the JobTracker.
* Unexpected results may happen!
*
* @param source data source that the created Job should work on
* @return instance of the ProcessJob bound to the given KeyValueSource
*/
// This feature is moved to Hazelcast 3.3
// ProcessJob newProcessJob(KeyValueSource source);
/**
* Returns an implementation of {@link TrackableJob}, or null if the job id is not available
* or the job is already finished.
*
* @param jobId job id to search the TrackableJob for
* @param type of the resulting value
* @return a trackable job for given job id or null if the job id is not available
*/
TrackableJob getTrackableJob(String jobId);
}