Technoboy-
5 years ago
22 changed files with 107 additions and 328 deletions
@ -1 +1 @@ |
|||||||
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
public enum CommandType {
/**
* roll view log request
*/
ROLL_VIEW_LOG_REQUEST,
/**
* roll view log response
*/
ROLL_VIEW_LOG_RESPONSE,
/**
* view whole log request
*/
VIEW_WHOLE_LOG_REQUEST,
/**
* view whole log response
*/
VIEW_WHOLE_LOG_RESPONSE,
/**
* get log bytes request
*/
GET_LOG_BYTES_REQUEST,
/**
* get log bytes response
*/
GET_LOG_BYTES_RESPONSE,
WORKER_REQUEST,
MASTER_RESPONSE,
/**
* execute task request
*/
EXECUTE_TASK_REQUEST,
/**
* execute task ack
*/
EXECUTE_TASK_ACK,
/**
* execute task response
*/
EXECUTE_TASK_RESPONSE,
/**
* kill task
*/
EXECUTE_TASK_REQUEST,
/**
EXECUTE_TASK_REQUEST,
EXECUTE_TASK_REQUEST,
*/
EXECUTE_TASK_REQUEST,
_RESPONSE,
/**
* ping
*/
PING,
/**
* pong
*/
PONG;
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
public enum CommandType {
/**
* roll view log request
*/
ROLL_VIEW_LOG_REQUEST,
/**
* roll view log response
*/
ROLL_VIEW_LOG_RESPONSE,
/**
* view whole log request
*/
VIEW_WHOLE_LOG_REQUEST,
/**
* view whole log response
*/
VIEW_WHOLE_LOG_RESPONSE,
/**
* get log bytes request
*/
GET_LOG_BYTES_REQUEST,
/**
* get log bytes response
*/
GET_LOG_BYTES_RESPONSE,
WORKER_REQUEST,
MASTER_RESPONSE,
/**
* execute task request
*/
EXECUTE_TASK_REQUEST,
/**
EXECUTE_TASK_REQUEST,
* execute task ack
EXECUTE_TASK_REQUEST,
*/
EXECUTE_TASK_REQUEST,
EXECUTE_TASK_ACK,
*/
TASK_EXECUTE_ACK,
EXECUTE_TASK_REQUEST,
*/
* execute task response
*/
TASK_EXECUTE_RESPONSE,
EXECUTE_TASK_REQUEST,
*/
EXECUTE_TASK_REQUEST,
*/
EXECUTE_TASK_REQUEST,
* execute task ack
EXECUTE_TASK_REQUEST,
*/
* kill task response
EXECUTE_TASK_REQUEST,
* execute task response
* execute task ack
_RESPONSE,
/**
* ping
*/
PING,
/**
* pong
*/
PONG;
} |
@ -1 +1 @@ |
|||||||
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
import java.util.Date;
/**
* execute task request command
*/
public class ExecuteTaskAckCommand implements Serializable {
/**
* taskInstanceId
*/
private int taskInstanceId;
/**
* startTime
*/
private Date startTime;
/**
* host
*/
private String host;
/**
* status
*/
private int status;
/**
* logPath
*/
private String logPath;
/**
* executePath
*/
private String executePath;
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getTaskInstanceId() {
return taskInstanceId;
}
public void setTaskInstanceId(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
public String getLogPath() {
return logPath;
}
public void setLogPath(String logPath) {
this.logPath = logPath;
}
public String getExecutePath() {
return executePath;
}
public void setExecutePath(String executePath) {
this.executePath = executePath;
}
/**
* package request command
*
* @return command
*/
public Command convert2Command(){
Command command = new Command();
command.setType(CommandType.EXECUTE_TASK_ACK);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return "ExecuteTaskAckCommand{" +
"taskInstanceId=" + taskInstanceId +
", startTime=" + startTime +
", host='" + host + '\'' +
", status=" + status +
", logPath='" + logPath + '\'' +
", executePath='" + executePath + '\'' +
'}';
}
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
import java.util.Date;
/**
* execute task request command
*/
public class TaskExecuteAckCommand implements Serializable {
/**
* taskInstanceId
*/
private int taskInstanceId;
/**
* startTime
*/
private Date startTime;
/**
* host
*/
private String host;
/**
* status
*/
private int status;
/**
* logPath
*/
private String logPath;
/**
* executePath
*/
private String executePath;
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getTaskInstanceId() {
return taskInstanceId;
}
public void setTaskInstanceId(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
public String getLogPath() {
return logPath;
}
public void setLogPath(String logPath) {
this.logPath = logPath;
}
public String getExecutePath() {
return executePath;
}
public void setExecutePath(String executePath) {
this.executePath = executePath;
}
/**
* package request command
*
* @return command
*/
public Command convert2Command(){
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_ACK);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return "TaskExecuteAckCommand{" +
"taskInstanceId=" + taskInstanceId +
", startTime=" + startTime +
", host='" + host + '\'' +
", status=" + status +
", logPath='" + logPath + '\'' +
", executePath='" + executePath + '\'' +
'}';
}
} |
@ -1 +1 @@ |
|||||||
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
/**
* execute task request command
*/
public class ExecuteTaskRequestCommand implements Serializable {
/**
* task execution context
*/
private String taskExecutionContext;
public String getTaskExecutionContext() {
return taskExecutionContext;
}
ExecuteTaskRequestCommand implements Serializable {
ExecuteTaskRequestCommand implements Serializable {
ExecuteTaskRequestCommand implements Serializable {
}
ExecuteTaskRequestCommand implements Serializable {
}
ExecuteTaskRequestCommand implements Serializable {
/**
this.taskExecutionContext = taskExecutionContext;
}
/**
ExecuteTaskRequestCommand implements Serializable {
* task execution context
*
ExecuteTaskRequestCommand implements Serializable {
private String taskExecutionContext;
*/
ExecuteTaskRequestCommand implements Serializable {
public String getTaskExecutionContext() {
ExecuteTaskRequestCommand implements Serializable {
return taskExecutionContext;
ExecuteTaskRequestCommand implements Serializable {
}
ExecuteTaskRequestCommand implements Serializable {
}
/**
* task execution context
*/
RequestCommand{" +
"taskExecutionContext='" + taskExecutionContext + '\'' +
'}';
}
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
/**
* execute task request command
*/
public class
private String taskExecutionContext;
public String getTaskExecutionContext() {
return taskExecutionContext;
}
/**
/**
ExecuteTaskRequestCommand implements Serializable {
public String getTaskExecutionContext() {
/**
return taskExecutionContext;
}
public String getTaskExecutionContext() {
/**
*/
this.taskExecutionContext = taskExecutionContext;
}
public String getTaskExecutionContext() {
/**
public String getTaskExecutionContext() {
/**
* task execution context
public TaskExecuteRequestCommand(String taskExecutionContext) {
/**
private String taskExecutionContext;
}
public String getTaskExecutionContext() {
return taskExecutionContext;
/**
}
* task execution context
* task execution context
ExecuteTaskRequestCommand implements Serializable {
*/
* task execution context
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_REQUEST);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
/**
* task execution context
public String getTaskExecutionContext() {
* task execution context
return taskExecutionContext;
public String toString() {
*/
RequestCommand{" +
"taskExecutionContext='" + taskExecutionContext + '\'' +
'}';
}
} |
@ -1 +1 @@ |
|||||||
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
import java.util.Date;
/**
* execute task response command
*/
public class ExecuteTaskResponseCommand implements Serializable {
public ExecuteTaskResponseCommand() {
}
public ExecuteTaskResponseCommand(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
/**
* task instance id
*/
private int taskInstanceId;
/**
* status
*/
private int status;
/**
* end time
*/
private Date endTime;
/**
* processId
*/
private int processId;
/**
* appIds
*/
private String appIds;
public int getTaskInstanceId() {
return taskInstanceId;
}
public void setTaskInstanceId(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getProcessId() {
return processId;
}
public void setProcessId(int processId) {
this.processId = processId;
}
public String getAppIds() {
return appIds;
}
public void setAppIds(String appIds) {
this.appIds = appIds;
}
/**
* package response command
* @return command
*/
public Command convert2Command(){
Command command = new Command();
command.setType(CommandType.EXECUTE_TASK_RESPONSE);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return "ExecuteTaskResponseCommand{" +
"taskInstanceId=" + taskInstanceId +
", status=" + status +
", endTime=" + endTime +
", processId=" + processId +
", appIds='" + appIds + '\'' +
'}';
}
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
import java.util.Date;
/**
* execute task response command
*/
public class TaskExecuteResponseCommand implements Serializable {
public TaskExecuteResponseCommand() {
}
public TaskExecuteResponseCommand(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
/**
* task instance id
*/
private int taskInstanceId;
/**
* status
*/
private int status;
/**
* end time
*/
private Date endTime;
/**
* processId
*/
private int processId;
/**
* appIds
*/
private String appIds;
public int getTaskInstanceId() {
return taskInstanceId;
}
public void setTaskInstanceId(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
public int getProcessId() {
return processId;
}
public void setProcessId(int processId) {
this.processId = processId;
}
public String getAppIds() {
return appIds;
}
public void setAppIds(String appIds) {
this.appIds = appIds;
}
/**
* package response command
* @return command
*/
public Command convert2Command(){
Command command = new Command();
command.setType(CommandType.TASK_EXECUTE_RESPONSE);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return "TaskExecuteResponseCommand{" +
"taskInstanceId=" + taskInstanceId +
", status=" + status +
", endTime=" + endTime +
", processId=" + processId +
", appIds='" + appIds + '\'' +
'}';
}
} |
@ -1 +1 @@ |
|||||||
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
/**
* kill task request command
*/
public class KillTaskRequestCommand implements Serializable {
/**
* task execution context
*/
private String taskExecutionContext;
public String getTaskExecutionContext() {
return taskExecutionContext;
}
KillTaskRequestCommand implements Serializable {
KillTaskRequestCommand implements Serializable {
KillTaskRequestCommand implements Serializable {
}
KillTaskRequestCommand implements Serializable {
}
KillTaskRequestCommand implements Serializable {
/**
this.taskExecutionContext = taskExecutionContext;
}
/**
KillTaskRequestCommand implements Serializable {
* task execution context
*
KillTaskRequestCommand implements Serializable {
private String taskExecutionContext;
*/
KillTaskRequestCommand implements Serializable {
public String getTaskExecutionContext() {
KillTaskRequestCommand implements Serializable {
return taskExecutionContext;
KillTaskRequestCommand implements Serializable {
}
KillTaskRequestCommand implements Serializable {
}
/**
* task execution context
*/
RequestCommand{" +
"taskExecutionContext='" + taskExecutionContext + '\'' +
'}';
}
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
/**
* kill task request command
*/
public class
private String taskExecutionContext;
public String getTaskExecutionContext() {
return taskExecutionContext;
}
/**
/**
KillTaskRequestCommand implements Serializable {
public String getTaskExecutionContext() {
/**
return taskExecutionContext;
}
public String getTaskExecutionContext() {
/**
*/
this.taskExecutionContext = taskExecutionContext;
}
public String getTaskExecutionContext() {
/**
public String getTaskExecutionContext() {
/**
* task execution context
public TaskKillRequestCommand(String taskExecutionContext) {
/**
private String taskExecutionContext;
}
public String getTaskExecutionContext() {
return taskExecutionContext;
/**
}
* task execution context
* task execution context
KillTaskRequestCommand implements Serializable {
*/
* task execution context
Command command = new Command();
command.setType(CommandType.TASK_KILL_REQUEST);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
/**
* task execution context
public String getTaskExecutionContext() {
* task execution context
return taskExecutionContext;
public String toString() {
*/
RequestCommand{" +
"taskExecutionContext='" + taskExecutionContext + '\'' +
'}';
}
} |
@ -1 +1 @@ |
|||||||
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* kill task response command
*/
public class KillTaskResponseCommand implements Serializable {
/**
* taskInstanceId
*/
private int taskInstanceId;
/**
* host
*/
private String host;
/**
* status
*/
private int status;
/**
* processId
*/
private int processId;
/**
* other resource manager appId , for example : YARN etc
*/
protected List<String> appIds;
public int getTaskInstanceId() {
return taskInstanceId;
}
public void setTaskInstanceId(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getProcessId() {
return processId;
}
public void setProcessId(int processId) {
this.processId = processId;
}
public List<String> getAppIds() {
return appIds;
}
public void setAppIds(List<String> appIds) {
this.appIds = appIds;
}
/**
* package request command
*
* @return command
*/
public Command convert2Command(){
Command command = new Command();
command.setType(CommandType.KILL_TASK_RESPONSE);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return "KillTaskResponseCommand{" +
"taskInstanceId=" + taskInstanceId +
", host='" + host + '\'' +
", status=" + status +
", processId=" + processId +
", appIds=" + appIds +
'}';
}
} |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.command;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* kill task response command
*/
public class TaskKillResponseCommand implements Serializable {
/**
* taskInstanceId
*/
private int taskInstanceId;
/**
* host
*/
private String host;
/**
* status
*/
private int status;
/**
* processId
*/
private int processId;
/**
* other resource manager appId , for example : YARN etc
*/
protected List<String> appIds;
public int getTaskInstanceId() {
return taskInstanceId;
}
public void setTaskInstanceId(int taskInstanceId) {
this.taskInstanceId = taskInstanceId;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getProcessId() {
return processId;
}
public void setProcessId(int processId) {
this.processId = processId;
}
public List<String> getAppIds() {
return appIds;
}
public void setAppIds(List<String> appIds) {
this.appIds = appIds;
}
/**
* package request command
*
* @return command
*/
public Command convert2Command(){
Command command = new Command();
command.setType(CommandType.TASK_KILL_RESPONSE);
byte[] body = FastJsonSerializer.serialize(this);
command.setBody(body);
return command;
}
@Override
public String toString() {
return "TaskKillResponseCommand{" +
"taskInstanceId=" + taskInstanceId +
", host='" + host + '\'' +
", status=" + status +
", processId=" + processId +
", appIds=" + appIds +
'}';
}
} |
@ -1,119 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.server.master.dispatch.executor; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.remote.NettyRemotingClient; |
|
||||||
import org.apache.dolphinscheduler.remote.command.Command; |
|
||||||
import org.apache.dolphinscheduler.remote.command.CommandType; |
|
||||||
import org.apache.dolphinscheduler.remote.command.KillTaskRequestCommand; |
|
||||||
import org.apache.dolphinscheduler.remote.config.NettyClientConfig; |
|
||||||
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer; |
|
||||||
import org.apache.dolphinscheduler.remote.utils.Host; |
|
||||||
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext; |
|
||||||
import org.apache.dolphinscheduler.server.master.dispatch.context.ExecutionContext; |
|
||||||
import org.apache.dolphinscheduler.server.master.dispatch.exceptions.ExecuteException; |
|
||||||
import org.apache.dolphinscheduler.server.master.processor.TaskKillResponseProcessor; |
|
||||||
import org.slf4j.Logger; |
|
||||||
import org.slf4j.LoggerFactory; |
|
||||||
import org.springframework.stereotype.Service; |
|
||||||
|
|
||||||
import java.util.Collection; |
|
||||||
import java.util.Collections; |
|
||||||
import java.util.HashSet; |
|
||||||
import java.util.Set; |
|
||||||
|
|
||||||
/** |
|
||||||
* netty executor manager |
|
||||||
*/ |
|
||||||
@Service |
|
||||||
public class NettyKillManager extends AbstractExecutorManager<Boolean>{ |
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(NettyKillManager.class); |
|
||||||
/** |
|
||||||
* netty remote client |
|
||||||
*/ |
|
||||||
private final NettyRemotingClient nettyRemotingClient; |
|
||||||
|
|
||||||
public NettyKillManager(){ |
|
||||||
final NettyClientConfig clientConfig = new NettyClientConfig(); |
|
||||||
this.nettyRemotingClient = new NettyRemotingClient(clientConfig); |
|
||||||
/** |
|
||||||
* register KILL_TASK_RESPONSE command type TaskKillResponseProcessor |
|
||||||
*/ |
|
||||||
this.nettyRemotingClient.registerProcessor(CommandType.KILL_TASK_RESPONSE, new TaskKillResponseProcessor()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* execute logic |
|
||||||
* |
|
||||||
* @param context context |
|
||||||
* @return result |
|
||||||
* @throws ExecuteException |
|
||||||
*/ |
|
||||||
@Override |
|
||||||
public Boolean execute(ExecutionContext context) throws ExecuteException { |
|
||||||
Host host = context.getHost(); |
|
||||||
Command command = buildCommand(context); |
|
||||||
try { |
|
||||||
doExecute(host, command); |
|
||||||
return true; |
|
||||||
}catch (ExecuteException ex) { |
|
||||||
logger.error(String.format("execute context : %s error", context.getContext()), ex); |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private Command buildCommand(ExecutionContext context) { |
|
||||||
KillTaskRequestCommand requestCommand = new KillTaskRequestCommand(); |
|
||||||
TaskExecutionContext taskExecutionContext = context.getContext(); |
|
||||||
|
|
||||||
requestCommand.setTaskExecutionContext(FastJsonSerializer.serializeToString(taskExecutionContext)); |
|
||||||
return requestCommand.convert2Command(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* execute logic |
|
||||||
* @param host host |
|
||||||
* @param command command |
|
||||||
* @throws ExecuteException |
|
||||||
*/ |
|
||||||
private void doExecute(final Host host, final Command command) throws ExecuteException { |
|
||||||
/** |
|
||||||
* retry count,default retry 3 |
|
||||||
*/ |
|
||||||
int retryCount = 3; |
|
||||||
boolean success = false; |
|
||||||
do { |
|
||||||
try { |
|
||||||
nettyRemotingClient.send(host, command); |
|
||||||
success = true; |
|
||||||
} catch (Exception ex) { |
|
||||||
logger.error(String.format("send command : %s to %s error", command, host), ex); |
|
||||||
retryCount--; |
|
||||||
try { |
|
||||||
Thread.sleep(100); |
|
||||||
} catch (InterruptedException ignore) {} |
|
||||||
} |
|
||||||
} while (retryCount >= 0 && !success); |
|
||||||
|
|
||||||
if (!success) { |
|
||||||
throw new ExecuteException(String.format("send command : %s to %s error", command, host)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,116 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You 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 org.apache.dolphinscheduler.server.worker.processor; |
|
||||||
|
|
||||||
|
|
||||||
import io.netty.channel.Channel; |
|
||||||
import io.netty.channel.ChannelFuture; |
|
||||||
import io.netty.channel.ChannelFutureListener; |
|
||||||
import org.apache.dolphinscheduler.remote.NettyRemotingClient; |
|
||||||
import org.apache.dolphinscheduler.remote.command.ExecuteTaskAckCommand; |
|
||||||
import org.apache.dolphinscheduler.remote.command.ExecuteTaskResponseCommand; |
|
||||||
import org.apache.dolphinscheduler.remote.command.KillTaskResponseCommand; |
|
||||||
import org.apache.dolphinscheduler.remote.config.NettyClientConfig; |
|
||||||
import org.slf4j.Logger; |
|
||||||
import org.slf4j.LoggerFactory; |
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap; |
|
||||||
|
|
||||||
/** |
|
||||||
* taks callback service |
|
||||||
*/ |
|
||||||
public class KillTaskCallbackService { |
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(KillTaskCallbackService.class); |
|
||||||
|
|
||||||
/** |
|
||||||
* remote channels |
|
||||||
*/ |
|
||||||
private static final ConcurrentHashMap<Integer, NettyRemoteChannel> REMOTE_CHANNELS = new ConcurrentHashMap<>(); |
|
||||||
|
|
||||||
/** |
|
||||||
* netty remoting client |
|
||||||
*/ |
|
||||||
private final NettyRemotingClient nettyRemotingClient; |
|
||||||
|
|
||||||
|
|
||||||
public KillTaskCallbackService(){ |
|
||||||
final NettyClientConfig clientConfig = new NettyClientConfig(); |
|
||||||
this.nettyRemotingClient = new NettyRemotingClient(clientConfig); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* add callback channel |
|
||||||
* @param taskInstanceId taskInstanceId |
|
||||||
* @param channel channel |
|
||||||
*/ |
|
||||||
public void addRemoteChannel(int taskInstanceId, NettyRemoteChannel channel){ |
|
||||||
REMOTE_CHANNELS.put(taskInstanceId, channel); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* get callback channel |
|
||||||
* @param taskInstanceId taskInstanceId |
|
||||||
* @return callback channel |
|
||||||
*/ |
|
||||||
public NettyRemoteChannel getRemoteChannel(int taskInstanceId){ |
|
||||||
NettyRemoteChannel nettyRemoteChannel = REMOTE_CHANNELS.get(taskInstanceId); |
|
||||||
if(nettyRemoteChannel.isActive()){ |
|
||||||
return nettyRemoteChannel; |
|
||||||
} |
|
||||||
Channel newChannel = nettyRemotingClient.getChannel(nettyRemoteChannel.getHost()); |
|
||||||
if(newChannel != null){ |
|
||||||
NettyRemoteChannel remoteChannel = new NettyRemoteChannel(newChannel, nettyRemoteChannel.getOpaque()); |
|
||||||
addRemoteChannel(taskInstanceId, remoteChannel); |
|
||||||
return remoteChannel; |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* remove callback channels |
|
||||||
* @param taskInstanceId taskInstanceId |
|
||||||
*/ |
|
||||||
public void remove(int taskInstanceId){ |
|
||||||
REMOTE_CHANNELS.remove(taskInstanceId); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* send result |
|
||||||
* |
|
||||||
* @param taskInstanceId taskInstanceId |
|
||||||
* @param killTaskResponseCommand killTaskResponseCommand |
|
||||||
*/ |
|
||||||
public void sendKillResult(int taskInstanceId, KillTaskResponseCommand killTaskResponseCommand){ |
|
||||||
NettyRemoteChannel nettyRemoteChannel = getRemoteChannel(taskInstanceId); |
|
||||||
if(nettyRemoteChannel == null){ |
|
||||||
//TODO
|
|
||||||
} else{ |
|
||||||
nettyRemoteChannel.writeAndFlush(killTaskResponseCommand.convert2Command()).addListener(new ChannelFutureListener(){ |
|
||||||
|
|
||||||
@Override |
|
||||||
public void operationComplete(ChannelFuture future) throws Exception { |
|
||||||
if(future.isSuccess()){ |
|
||||||
remove(taskInstanceId); |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue