Skip to content
This repository has been archived by the owner on May 21, 2018. It is now read-only.

Commit

Permalink
Merge pull request #237 from mesosphere/code-cleanup-tests
Browse files Browse the repository at this point in the history
cleaning up deadcode and adding tests for task detection.
  • Loading branch information
kensipe committed Nov 13, 2015
2 parents b09b4bb + 02dd221 commit 4f9632b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private void launchHealthCheck(ExecutorDriver driver, Task task) {
String taskIdStr = task.getTaskInfo().getTaskId().getValue();
log.info("Performing health check for task: " + taskIdStr);

boolean taskHealthy = nodeHealthChecker.runHealthCheckForTask(driver, task);
boolean taskHealthy = nodeHealthChecker.runHealthCheckForTask(task);
if (!taskHealthy) {
log.fatal("Node health check failed for task: " + taskIdStr);
killTask(driver, task.getTaskInfo().getTaskId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.mesos.ExecutorDriver;
import org.apache.mesos.hdfs.util.HDFSConstants;
import org.apache.mesos.stream.StreamUtil;

Expand All @@ -21,7 +20,7 @@ public class NodeHealthChecker {
public NodeHealthChecker() {
}

public boolean runHealthCheckForTask(ExecutorDriver driver, Task task) {
public boolean runHealthCheckForTask(Task task) {
String taskIdStr = task.getTaskInfo().getTaskId().getValue();
int healthCheckPort = getHealthCheckPort(taskIdStr);
boolean taskHealthy = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.apache.mesos.hdfs.executor

import org.apache.mesos.hdfs.util.HDFSConstants
import org.apache.mesos.protobuf.TaskInfoBuilder
import spock.lang.Specification

/**
*
*/
class TaskSpec extends Specification {

def "task type detection"() {

expect:
new Task(new TaskInfoBuilder(taskId, "name", "slaveID").build()).type == type

where:
taskId | type
"task.$HDFSConstants.JOURNAL_NODE_ID" | HDFSConstants.JOURNAL_NODE_ID
"task.$HDFSConstants.NAME_NODE_ID" | HDFSConstants.NAME_NODE_ID
"task.$HDFSConstants.DATA_NODE_ID" | HDFSConstants.DATA_NODE_ID
"task.$HDFSConstants.ZKFC_NODE_ID" | HDFSConstants.ZKFC_NODE_ID
"" | ""
"junk" | ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public Task(
String type,
String idName) {

this.info = new TaskInfoBuilder(String.format("task.%s.%s", type, idName), name)
this.info = new TaskInfoBuilder(String.format("task.%s.%s", type, idName), name, offer.getSlaveId().getValue())
.setExecutorInfo(execInfo)
.setSlaveId(offer.getSlaveId().getValue())
.addAllResources(resources)
.setData(String.format("bin/hdfs-mesos-%s", type))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ public class TaskInfoBuilder {

Protos.TaskInfo.Builder builder = Protos.TaskInfo.newBuilder();

public TaskInfoBuilder(String taskId) {
// min required fields to create a taskInfo
public TaskInfoBuilder(String taskId, String name, String slaveId) {
setId(taskId);
}

public TaskInfoBuilder(String taskId, String name) {
this(taskId);
setName(name);
setSlaveId(slaveId);
}

public TaskInfoBuilder setId(String taskId) {
Expand Down

0 comments on commit 4f9632b

Please sign in to comment.