Search in sources :

Example 1 with TaskletExecutionService

use of com.hazelcast.jet.impl.execution.TaskletExecutionService in project hazelcast-jet by hazelcast.

the class JobExecutionService method initExecution.

/**
 * Initiates the given execution if the local node accepts the coordinator
 * as its master, and has an up-to-date member list information.
 * <ul><li>
 *   If the local node has a stale member list, it retries the init operation
 *   until it receives the new member list from the master.
 * </li><li>
 *     If the local node detects that the member list changed after the init
 *     operation is sent but before executed, then it sends a graceful failure
 *     so that the job init will be retried properly.
 * </li><li>
 *     If there is an already ongoing execution for the given job, then the
 *     init execution is retried.
 * </li></ul>
 */
public void initExecution(long jobId, long executionId, Address coordinator, int coordinatorMemberListVersion, Set<MemberInfo> participants, ExecutionPlan plan) {
    verifyClusterInformation(jobId, executionId, coordinator, coordinatorMemberListVersion, participants);
    failIfNotRunning();
    if (!executionContextJobIds.add(jobId)) {
        ExecutionContext current = executionContexts.get(executionId);
        if (current != null) {
            throw new IllegalStateException(String.format("Execution context for %s for coordinator %s already exists for coordinator %s", jobAndExecutionId(jobId, executionId), coordinator, current.coordinator()));
        }
        executionContexts.values().stream().filter(e -> e.jobId() == jobId).forEach(e -> logger.fine(String.format("Execution context for %s for coordinator %s already exists" + " with local execution %s for coordinator %s", jobAndExecutionId(jobId, executionId), coordinator, idToString(e.jobId()), e.coordinator())));
        throw new RetryableHazelcastException();
    }
    Set<Address> addresses = participants.stream().map(MemberInfo::getAddress).collect(toSet());
    ExecutionContext created = new ExecutionContext(nodeEngine, taskletExecutionService, jobId, executionId, coordinator, addresses);
    try {
        created.initialize(plan);
    } finally {
        executionContexts.put(executionId, created);
    }
    logger.info("Execution plan for " + jobAndExecutionId(jobId, executionId) + " initialized");
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) DistributedFunctions.entryValue(com.hazelcast.jet.function.DistributedFunctions.entryValue) MembershipManager(com.hazelcast.internal.cluster.impl.MembershipManager) Address(com.hazelcast.nio.Address) SenderTasklet(com.hazelcast.jet.impl.execution.SenderTasklet) Util.jobAndExecutionId(com.hazelcast.jet.impl.util.Util.jobAndExecutionId) Supplier(java.util.function.Supplier) ConcurrentMap(java.util.concurrent.ConcurrentMap) Util.idToString(com.hazelcast.jet.impl.util.Util.idToString) Collections.newSetFromMap(java.util.Collections.newSetFromMap) Collectors.toMap(java.util.stream.Collectors.toMap) ILogger(com.hazelcast.logging.ILogger) ExceptionUtil.withTryCatch(com.hazelcast.jet.impl.util.ExceptionUtil.withTryCatch) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Map(java.util.Map) TaskletExecutionService(com.hazelcast.jet.impl.execution.TaskletExecutionService) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Collectors.toSet(java.util.stream.Collectors.toSet) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) Operation(com.hazelcast.spi.Operation) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) PrivilegedAction(java.security.PrivilegedAction) DistributedFunctions.entryKey(com.hazelcast.jet.function.DistributedFunctions.entryKey) TriggerMemberListPublishOp(com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp) ExecutionPlan(com.hazelcast.jet.impl.execution.init.ExecutionPlan) JetClassLoader(com.hazelcast.jet.impl.deployment.JetClassLoader) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException) AccessController(java.security.AccessController) ExecutionContext(com.hazelcast.jet.impl.execution.ExecutionContext) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) Address(com.hazelcast.nio.Address)

Example 2 with TaskletExecutionService

use of com.hazelcast.jet.impl.execution.TaskletExecutionService in project hazelcast by hazelcast.

the class JetServiceBackend method init.

// ManagedService
@Override
public void init(NodeEngine engine, Properties hzProperties) {
    this.nodeEngine = (NodeEngineImpl) engine;
    this.jet = new JetInstanceImpl(nodeEngine.getNode().hazelcastInstance, jetConfig);
    jobRepository = new JobRepository(engine.getHazelcastInstance());
    taskletExecutionService = new TaskletExecutionService(nodeEngine, jetConfig.getCooperativeThreadCount(), nodeEngine.getProperties());
    jobCoordinationService = createJobCoordinationService();
    jobClassLoaderService = new JobClassLoaderService(nodeEngine, jobRepository);
    jobExecutionService = new JobExecutionService(nodeEngine, taskletExecutionService, jobClassLoaderService);
    MetricsService metricsService = nodeEngine.getService(MetricsService.SERVICE_NAME);
    metricsService.registerPublisher(nodeEngine -> new JobMetricsPublisher(jobExecutionService, nodeEngine.getLocalMember()));
    nodeEngine.getMetricsRegistry().registerDynamicMetricsProvider(jobExecutionService);
    networking = new Networking(engine, jobExecutionService, jetConfig.getFlowControlPeriodMs());
    ClientEngine clientEngine = engine.getService(ClientEngineImpl.SERVICE_NAME);
    ClientExceptionFactory clientExceptionFactory = clientEngine.getExceptionFactory();
    if (clientExceptionFactory != null) {
        ExceptionUtil.registerJetExceptions(clientExceptionFactory);
    } else {
        logger.fine("Jet exceptions are not registered to the ClientExceptionFactory" + " since the ClientExceptionFactory is not accessible.");
    }
    logger.info("Setting number of cooperative threads and default parallelism to " + jetConfig.getCooperativeThreadCount());
}
Also used : JobMetricsPublisher(com.hazelcast.jet.impl.metrics.JobMetricsPublisher) ClientEngine(com.hazelcast.client.impl.ClientEngine) TaskletExecutionService(com.hazelcast.jet.impl.execution.TaskletExecutionService) MetricsService(com.hazelcast.internal.metrics.impl.MetricsService) ClientExceptionFactory(com.hazelcast.client.impl.protocol.ClientExceptionFactory)

Example 3 with TaskletExecutionService

use of com.hazelcast.jet.impl.execution.TaskletExecutionService in project hazelcast-jet by hazelcast.

the class JetService method init.

// ManagedService
@Override
public void init(NodeEngine engine, Properties properties) {
    if (config == null) {
        throw new IllegalStateException("JetConfig is not initialized");
    }
    jetInstance = new JetInstanceImpl((HazelcastInstanceImpl) engine.getHazelcastInstance(), config);
    taskletExecutionService = new TaskletExecutionService(nodeEngine.getHazelcastInstance(), config.getInstanceConfig().getCooperativeThreadCount());
    snapshotRepository = new SnapshotRepository(jetInstance);
    jobRepository = new JobRepository(jetInstance, snapshotRepository);
    jobExecutionService = new JobExecutionService(nodeEngine, taskletExecutionService);
    jobCoordinationService = new JobCoordinationService(nodeEngine, config, jobRepository, jobExecutionService, snapshotRepository);
    networking = new Networking(engine, jobExecutionService, config.getInstanceConfig().getFlowControlPeriodMs());
    ClientEngineImpl clientEngine = engine.getService(ClientEngineImpl.SERVICE_NAME);
    ExceptionUtil.registerJetExceptions(clientEngine.getClientExceptionFactory());
    jobCoordinationService.init();
    JetBuildInfo jetBuildInfo = BuildInfoProvider.getBuildInfo().getJetBuildInfo();
    logger.info(String.format("Starting Jet %s (%s - %s)", jetBuildInfo.getVersion(), jetBuildInfo.getBuild(), jetBuildInfo.getRevision()));
    logger.info("Setting number of cooperative threads and default parallelism to " + config.getInstanceConfig().getCooperativeThreadCount());
    logger.info('\n' + "\to   o   o   o---o o---o o     o---o   o   o---o o-o-o        o o---o o-o-o\n" + "\t|   |  / \\     /  |     |     |      / \\  |       |          | |       |  \n" + "\to---o o---o   o   o-o   |     o     o---o o---o   |          | o-o     |  \n" + "\t|   | |   |  /    |     |     |     |   |     |   |      \\   | |       |  \n" + "\to   o o   o o---o o---o o---o o---o o   o o---o   o       o--o o---o   o   ");
    logger.info("Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.");
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.HazelcastInstanceImpl) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) JetBuildInfo(com.hazelcast.instance.JetBuildInfo) TaskletExecutionService(com.hazelcast.jet.impl.execution.TaskletExecutionService)

Aggregations

TaskletExecutionService (com.hazelcast.jet.impl.execution.TaskletExecutionService)3 ClientEngine (com.hazelcast.client.impl.ClientEngine)1 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)1 ClientExceptionFactory (com.hazelcast.client.impl.protocol.ClientExceptionFactory)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 HazelcastInstanceImpl (com.hazelcast.instance.HazelcastInstanceImpl)1 JetBuildInfo (com.hazelcast.instance.JetBuildInfo)1 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 MembershipManager (com.hazelcast.internal.cluster.impl.MembershipManager)1 TriggerMemberListPublishOp (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOp)1 MetricsService (com.hazelcast.internal.metrics.impl.MetricsService)1 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)1 DistributedFunctions.entryKey (com.hazelcast.jet.function.DistributedFunctions.entryKey)1 DistributedFunctions.entryValue (com.hazelcast.jet.function.DistributedFunctions.entryValue)1 JetClassLoader (com.hazelcast.jet.impl.deployment.JetClassLoader)1 ExecutionContext (com.hazelcast.jet.impl.execution.ExecutionContext)1 SenderTasklet (com.hazelcast.jet.impl.execution.SenderTasklet)1 ExecutionPlan (com.hazelcast.jet.impl.execution.init.ExecutionPlan)1 JobMetricsPublisher (com.hazelcast.jet.impl.metrics.JobMetricsPublisher)1