You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nemo.apache.org by GitBox <gi...@apache.org> on 2018/10/23 00:28:58 UTC

[GitHub] taegeonum commented on a change in pull request #126: [NEMO-224] Simple StreamingScheduler

taegeonum commented on a change in pull request #126: [NEMO-224] Simple StreamingScheduler
URL: https://github.com/apache/incubator-nemo/pull/126#discussion_r226884809
 
 

 ##########
 File path: runtime/master/src/main/java/org/apache/nemo/runtime/master/scheduler/StreamingScheduler.java
 ##########
 @@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2018 Seoul National University
+ *
+ * Licensed 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.nemo.runtime.master.scheduler;
+
+import com.google.common.collect.Lists;
+import org.apache.nemo.common.ir.Readable;
+import org.apache.nemo.runtime.common.RuntimeIdManager;
+import org.apache.nemo.runtime.common.plan.PhysicalPlan;
+import org.apache.nemo.runtime.common.plan.Stage;
+import org.apache.nemo.runtime.common.plan.StageEdge;
+import org.apache.nemo.runtime.common.plan.Task;
+import org.apache.nemo.runtime.common.state.TaskState;
+import org.apache.nemo.runtime.master.*;
+import org.apache.nemo.runtime.master.resource.ExecutorRepresenter;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.NotThreadSafe;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * A simple scheduler for streaming workloads.
+ * - Keeps track of new executors
+ * - Schedules all tasks in a reverse topological order.
+ * - Crashes the system upon any other events (should be fixed in the future)
+ * - Never stops running.
+ */
+@DriverSide
+@NotThreadSafe
+public final class StreamingScheduler implements Scheduler {
+  private static final Logger LOG = LoggerFactory.getLogger(StreamingScheduler.class.getName());
+
+  private final TaskDispatcher taskDispatcher;
+  private final PendingTaskCollectionPointer pendingTaskCollectionPointer;
+  private final ExecutorRegistry executorRegistry;
+  private final PlanStateManager planStateManager;
+
+  StreamingScheduler(final TaskDispatcher taskDispatcher,
+                     final PendingTaskCollectionPointer pendingTaskCollectionPointer,
+                     final ExecutorRegistry executorRegistry,
+                     final PlanStateManager planStateManager) {
+    this.taskDispatcher = taskDispatcher;
+    this.pendingTaskCollectionPointer = pendingTaskCollectionPointer;
+    this.executorRegistry = executorRegistry;
+    this.planStateManager = planStateManager;
+  }
+
+  @Override
+  public void schedulePlan(final PhysicalPlan submittedPhysicalPlan,
+                           final int maxScheduleAttempt) {
+    // Housekeeping stuff
+    taskDispatcher.run();
+    planStateManager.updatePlan(submittedPhysicalPlan, maxScheduleAttempt);
+    planStateManager.storeJSON("submitted");
+
+    // Prepare tasks
+    final List<Stage> reverseTopoStages = Lists.reverse(submittedPhysicalPlan.getStageDAG().getTopologicalSort());
+    final List<Task> reverseTopoTasks = reverseTopoStages.stream().flatMap(stageToSchedule -> {
+      // Helper variables for this stage
+      final List<StageEdge> stageIncomingEdges =
+        submittedPhysicalPlan.getStageDAG().getIncomingEdgesOf(stageToSchedule.getId());
+      final List<StageEdge> stageOutgoingEdges =
+        submittedPhysicalPlan.getStageDAG().getOutgoingEdgesOf(stageToSchedule.getId());
+      final List<Map<String, Readable>> vertexIdToReadables = stageToSchedule.getVertexIdToReadables();
+      final List<String> taskIdsToSchedule = planStateManager.getTaskAttemptsToSchedule(stageToSchedule.getId());
+
+      // Create tasks of this stage
+      return taskIdsToSchedule.stream().map(taskId -> new Task(
+        submittedPhysicalPlan.getPlanId(),
+        taskId,
+        stageToSchedule.getExecutionProperties(),
+        stageToSchedule.getSerializedIRDAG(),
+        stageIncomingEdges,
+        stageOutgoingEdges,
+        vertexIdToReadables.get(RuntimeIdManager.getIndexFromTaskId(taskId))));
+    }).collect(Collectors.toList());
+
+    // Schedule everything at once
+    pendingTaskCollectionPointer.setToOverwrite(reverseTopoTasks);
+  }
+
+  @Override
+  public void updatePlan(final PhysicalPlan newPhysicalPlan) {
+    throw new UnsupportedOperationException();
+  }
+
+  public void onTaskStateReportFromExecutor(final String executorId,
 
 Review comment:
   When does this method is called? This naming is confusing to me because I thought it is called whenever the task status is changed. (e.g., task is started, created, finished, failed...). Maybe we need to change this name to onTaskFinishedOrFailed? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services