Sha256: 188b9719e4496787538a9e847afd4568270d2bbff7e385902f3c1fed6eb82b17

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

package org.embulk.executor.remoteserver;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.kamatama41.nsocket.Command;
import com.github.kamatama41.nsocket.Connection;

class StartTaskCommand implements Command<StartTaskCommand.Data> {
    static final String ID = "start_task";
    private final ServerSessionRegistry sessionRegistry;

    StartTaskCommand(ServerSessionRegistry sessionRegistry) {
        this.sessionRegistry = sessionRegistry;
    }

    @Override
    public void execute(Data data, Connection connection) {
        ServerSession session = sessionRegistry.get(data.getSessionId());
        if (session == null) {
            throw new IllegalStateException("Session is not created.");
        }
        session.runTaskAsynchronously(data.getTaskIndex());
    }

    @Override
    public String getId() {
        return ID;
    }

    static class Data {
        private String sessionId;
        private int taskIndex;

        @JsonCreator
        Data(@JsonProperty("sessionId") String sessionId,
             @JsonProperty("taskIndex") int taskIndex) {
            this.sessionId = sessionId;
            this.taskIndex = taskIndex;
        }

        @JsonProperty
        String getSessionId() {
            return sessionId;
        }

        @JsonProperty
        int getTaskIndex() {
            return taskIndex;
        }
    }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
embulk-executor-remoteserver-0.4.0 src/main/java/org/embulk/executor/remoteserver/StartTaskCommand.java
embulk-executor-remoteserver-0.3.2 src/main/java/org/embulk/executor/remoteserver/StartTaskCommand.java
embulk-executor-remoteserver-0.3.1 src/main/java/org/embulk/executor/remoteserver/StartTaskCommand.java
embulk-executor-remoteserver-0.3.0 src/main/java/org/embulk/executor/remoteserver/StartTaskCommand.java
embulk-executor-remoteserver-0.2.1 src/main/java/org/embulk/executor/remoteserver/StartTaskCommand.java
embulk-executor-remoteserver-0.2.0 src/main/java/org/embulk/executor/remoteserver/StartTaskCommand.java