johnyangk commented on a change in pull request #288: [NEMO-438] Create a Simulator for Simulating an Execution of an Execution Plan URL: https://github.com/apache/incubator-nemo/pull/288#discussion_r385644817
########## File path: runtime/master/src/main/java/org/apache/nemo/runtime/master/scheduler/SimulationScheduler.java ########## @@ -0,0 +1,579 @@ +/* + * 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.nemo.runtime.master.scheduler; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.lang3.SerializationUtils; +import org.apache.nemo.common.Pair; +import org.apache.nemo.common.Util; +import org.apache.nemo.common.exception.IllegalMessageException; +import org.apache.nemo.common.exception.SimulationException; +import org.apache.nemo.common.exception.UnknownExecutionStateException; +import org.apache.nemo.common.exception.UnrecoverableFailureException; +import org.apache.nemo.common.ir.executionproperty.ResourceSpecification; +import org.apache.nemo.conf.JobConf; +import org.apache.nemo.runtime.common.RuntimeIdManager; +import org.apache.nemo.runtime.common.comm.ControlMessage; +import org.apache.nemo.runtime.common.message.MessageSender; +import org.apache.nemo.runtime.common.message.MessageUtils; +import org.apache.nemo.runtime.common.metric.JobMetric; +import org.apache.nemo.runtime.common.metric.Metric; +import org.apache.nemo.runtime.common.plan.PhysicalPlan; +import org.apache.nemo.runtime.common.plan.PlanRewriter; +import org.apache.nemo.runtime.common.plan.Stage; +import org.apache.nemo.runtime.common.plan.Task; +import org.apache.nemo.runtime.common.state.StageState; +import org.apache.nemo.runtime.common.state.TaskState; +import org.apache.nemo.runtime.master.BlockManagerMaster; +import org.apache.nemo.runtime.master.PlanAppender; +import org.apache.nemo.runtime.master.PlanStateManager; +import org.apache.nemo.runtime.master.metric.MetricStore; +import org.apache.nemo.runtime.master.resource.DefaultExecutorRepresenter; +import org.apache.nemo.runtime.master.resource.ExecutorRepresenter; +import org.apache.reef.annotations.audience.DriverSide; +import org.apache.reef.driver.context.ActiveContext; +import org.apache.reef.driver.evaluator.EvaluatorDescriptor; +import org.apache.reef.tang.Configuration; +import org.apache.reef.tang.annotations.Parameter; +import org.apache.reef.util.Optional; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.NotThreadSafe; +import javax.inject.Inject; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +/** + * Scheduler for simulating an execution, not controlled by the runtime master. + */ +@DriverSide +@NotThreadSafe +public final class SimulationScheduler implements Scheduler { + private static final Logger LOG = LoggerFactory.getLogger(SimulationScheduler.class.getName()); + + /** + * Run-time optimizations. + */ + private final PlanRewriter planRewriter; + + /** + * Components related to scheduling the given plan. + */ + private TaskDispatcher taskDispatcher; + private final PendingTaskCollectionPointer pendingTaskCollectionPointer; + private ExecutorRegistry executorRegistry; + private PlanStateManager planStateManager; + private final ExecutorService serializationExecutorService; // Executor service for scheduling message serialization. + private final BlockManagerMaster blockManagerMaster; + private final MetricStore actualMetricStore; + private MetricStore metricStore; + private CountDownLatch metricCountDownLatch; + + private final SchedulingConstraintRegistry schedulingConstraintRegistry; + private final SchedulingPolicy schedulingPolicy; + private final String resourceSpecificationString; + private final String dagDirectory; + + private final Map<String, SimulatedTaskExecutor> simulatedTaskExecutorMap; + + /** + * The below variables depend on the submitted plan to execute. + */ + private List<List<Stage>> sortedScheduleGroups; + + @Inject + private SimulationScheduler(final PlanRewriter planRewriter, Review comment: The purpose of this class seems to somehow 'mirror' the behaviors of batch scheduler with similar code. Does this mean this class should be modified when the batch scheduler is modified? Can you leave a comment about this so we don't forget later when we make changes to the batch scheduler? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
