Search in sources :

Example 56 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class JobSupervisor method asyncCancelRemoteOperations.

private void asyncCancelRemoteOperations(final Set<Address> addresses) {
    final NodeEngine nodeEngine = mapReduceService.getNodeEngine();
    TaskScheduler taskScheduler = nodeEngine.getExecutionService().getGlobalTaskScheduler();
    taskScheduler.execute(new Runnable() {

        @Override
        public void run() {
            String name = getConfiguration().getName();
            String jobId = getConfiguration().getJobId();
            for (Address address : addresses) {
                try {
                    CancelJobSupervisorOperation operation = new CancelJobSupervisorOperation(name, jobId);
                    mapReduceService.processRequest(address, operation);
                } catch (Exception ignore) {
                    // We can ignore this exception since we just want to cancel the job
                    // and the member may be crashed or unreachable in some way
                    ILogger logger = nodeEngine.getLogger(JobSupervisor.class);
                    logger.finest("Remote node may already be down", ignore);
                }
            }
        }
    });
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) ILogger(com.hazelcast.logging.ILogger) TaskScheduler(com.hazelcast.spi.TaskScheduler) CancelJobSupervisorOperation(com.hazelcast.mapreduce.impl.operation.CancelJobSupervisorOperation)

Example 57 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class KeyValueJobOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    Address jobOwner = getCallerAddress();
    if (jobOwner == null) {
        jobOwner = getNodeEngine().getThisAddress();
    }
    // Inject managed context
    injectManagedContext(mapper, combinerFactory, reducerFactory, keyValueSource);
    // Build immutable configuration
    JobTaskConfiguration config = new JobTaskConfiguration(jobOwner, getNodeEngine(), chunkSize, name, jobId, mapper, combinerFactory, reducerFactory, keyValueSource, communicateStats, topologyChangedStrategy);
    JobSupervisor supervisor = mapReduceService.createJobSupervisor(config);
    if (supervisor == null) {
        // Supervisor was cancelled prior to creation
        AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.getJobTracker(name);
        TrackableJobFuture future = jobTracker.unregisterTrackableJob(jobId);
        if (future != null) {
            Exception exception = new CancellationException("Operation was cancelled by the user");
            future.setResult(exception);
        }
    }
}
Also used : TrackableJobFuture(com.hazelcast.mapreduce.impl.task.TrackableJobFuture) Address(com.hazelcast.nio.Address) CancellationException(java.util.concurrent.CancellationException) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) JobTaskConfiguration(com.hazelcast.mapreduce.impl.task.JobTaskConfiguration) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException)

Example 58 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class MapKeyValueSource method open.

@Override
public boolean open(NodeEngine nodeEngine) {
    NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
    IPartitionService ps = nei.getPartitionService();
    MapService mapService = nei.getService(MapService.SERVICE_NAME);
    ss = nei.getSerializationService();
    Address partitionOwner = ps.getPartitionOwner(partitionId);
    if (partitionOwner == null) {
        return false;
    }
    RecordStore recordStore = mapService.getMapServiceContext().getRecordStore(partitionId, mapName);
    iterator = recordStore.iterator();
    return true;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService)

Example 59 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class MultiMapKeyValueSource method open.

@Override
public boolean open(NodeEngine nodeEngine) {
    NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
    IPartitionService ps = nei.getPartitionService();
    MultiMapService multiMapService = nei.getService(MultiMapService.SERVICE_NAME);
    ss = nei.getSerializationService();
    Address partitionOwner = ps.getPartitionOwner(partitionId);
    if (partitionOwner == null) {
        return false;
    }
    multiMapContainer = multiMapService.getOrCreateCollectionContainer(partitionId, multiMapName);
    isBinary = multiMapContainer.getConfig().isBinary();
    keyIterator = multiMapContainer.keySet().iterator();
    return true;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) MultiMapService(com.hazelcast.multimap.impl.MultiMapService)

Example 60 with Address

use of com.hazelcast.nio.Address in project hazelcast by hazelcast.

the class MemberAwareMapReduceNotification method readData.

@Override
public void readData(ObjectDataInput in) throws IOException {
    super.readData(in);
    address = new Address();
    address.readData(in);
}
Also used : Address(com.hazelcast.nio.Address)

Aggregations

Address (com.hazelcast.nio.Address)274 Test (org.junit.Test)44 QuickTest (com.hazelcast.test.annotation.QuickTest)36 HashMap (java.util.HashMap)33 ParallelTest (com.hazelcast.test.annotation.ParallelTest)29 Member (com.hazelcast.core.Member)27 ArrayList (java.util.ArrayList)27 Map (java.util.Map)26 ILogger (com.hazelcast.logging.ILogger)25 InetAddress (java.net.InetAddress)25 MemberImpl (com.hazelcast.instance.MemberImpl)21 List (java.util.List)20 HashSet (java.util.HashSet)18 Connection (com.hazelcast.nio.Connection)17 NodeEngine (com.hazelcast.spi.NodeEngine)16 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)16 IOException (java.io.IOException)16 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 IPartitionService (com.hazelcast.spi.partition.IPartitionService)13