@Override public void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo) { LOGGER.info("Launching task in PinUserProfileExecutor ..."); Protos.TaskStatus taskStatus = Protos.TaskStatus.newBuilder() .setTaskId(taskInfo.getTaskId()) .setState(Protos.TaskState.TASK_RUNNING) .build(); executorDriver.sendStatusUpdate(taskStatus); String url = taskInfo.getData().toStringUtf8(); byte[] message = new byte[0]; try { message = ("userprofile :" + getUserProfileInfo(url)).getBytes(); } catch (IOException e) { LOGGER.error("Error parsing the Pinterest URL :" + e.getMessage()); } LOGGER.info("Sending framework message and marking task finished." + getClass().getName()); executorDriver.sendFrameworkMessage(message); taskStatus = Protos.TaskStatus.newBuilder() .setTaskId(taskInfo.getTaskId()) .setState(Protos.TaskState.TASK_FINISHED) .build(); executorDriver.sendStatusUpdate(taskStatus); }
/** Let the scheduler know that the task has failed. */ private void sendTaskFailed(ExecutorDriver driver, Task task) { driver.sendStatusUpdate( TaskStatus.newBuilder() .setTaskId(task.getTaskInfo().getTaskId()) .setState(TaskState.TASK_FAILED) .build()); }