From notifications-return-621-archive-asf-public=cust-asf.ponee.io@nemo.apache.org Mon Jun 24 03:32:26 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id BE9D3180791 for ; Mon, 24 Jun 2019 05:32:25 +0200 (CEST) Received: (qmail 18676 invoked by uid 500); 24 Jun 2019 03:32:25 -0000 Mailing-List: contact notifications-help@nemo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nemo.apache.org Delivered-To: mailing list notifications@nemo.apache.org Received: (qmail 18575 invoked by uid 99); 24 Jun 2019 03:32:24 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jun 2019 03:32:24 +0000 From: GitBox To: notifications@nemo.apache.org Subject: [GitHub] [incubator-nemo] taegeonum commented on a change in pull request #216: [NEMO-387] LambdaScheduler Message-ID: <156134714491.13790.17225070779804994603.gitbox@gitbox.apache.org> Date: Mon, 24 Jun 2019 03:32:24 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit taegeonum commented on a change in pull request #216: [NEMO-387] LambdaScheduler URL: https://github.com/apache/incubator-nemo/pull/216#discussion_r296542320 ########## File path: runtime/master/src/main/java/org/apache/nemo/runtime/master/scheduler/LambdaScheduler.java ########## @@ -0,0 +1,193 @@ +/* + * 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.amazonaws.ClientConfiguration; +import com.amazonaws.services.lambda.AWSLambda; +import com.amazonaws.services.lambda.AWSLambdaAsync; +import com.amazonaws.services.lambda.AWSLambdaAsyncClientBuilder; +import com.amazonaws.services.lambda.AWSLambdaClientBuilder; +import com.amazonaws.services.lambda.model.InvokeRequest; +import com.amazonaws.services.lambda.model.InvokeResult; +import io.netty.channel.group.ChannelGroup; +import io.netty.channel.group.DefaultChannelGroup; +import io.netty.util.concurrent.GlobalEventExecutor; +import org.apache.nemo.common.ir.Readable; +import org.apache.nemo.offloading.client.NettyServerSideChannelHandler; +import org.apache.nemo.offloading.client.NettyServerTransport; +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.state.TaskState; +import org.apache.nemo.runtime.master.PipeManagerMaster; +import org.apache.nemo.runtime.master.PlanStateManager; +import org.apache.nemo.runtime.master.resource.ExecutorRepresenter; +import org.apache.reef.annotations.audience.DriverSide; +import org.apache.reef.tang.Injector; +import org.apache.reef.tang.JavaConfigurationBuilder; +import org.apache.reef.tang.Tang; +import org.apache.reef.wake.remote.ports.TcpPortProvider; +import org.apache.reef.wake.remote.ports.parameters.TcpPortRangeBegin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.NotThreadSafe; +import javax.inject.Inject; +import java.util.List; +import java.util.Map; + +/** + * A simple scheduler for batch job with Nemo Lambda Executor. + * - Keeps track of new executors + * - Schedules all tasks in the plan at once. + * - Crashes the system upon any other events (should be fixed in the future) + * - Never stops running. + */ +@DriverSide +@NotThreadSafe +public final class LambdaScheduler implements Scheduler { + private static final Logger LOG = LoggerFactory.getLogger(StreamingScheduler.class.getName()); + + private final PlanStateManager planStateManager; + + @Inject + private LambdaScheduler(final TaskDispatcher taskDispatcher, + final PendingTaskCollectionPointer pendingTaskCollectionPointer, + final ExecutorRegistry executorRegistry, + final PlanStateManager planStateManager, + final PipeManagerMaster pipeManagerMaster) { + this.planStateManager = planStateManager; + LOG.info("Using Lambda Scheduler"); + } + + @Override + public void schedulePlan(final PhysicalPlan submittedPhysicalPlan, + final int maxScheduleAttempt) { + + if (maxScheduleAttempt > 1) { + throw new UnsupportedOperationException(); + } + + planStateManager.updatePlan(submittedPhysicalPlan, maxScheduleAttempt); + planStateManager.storeJSON("submitted"); + + // We presume serverless function has been deployed and uploaded + + // Prepare tasks + final List allStages = submittedPhysicalPlan.getStageDAG().getTopologicalSort(); + allStages.stream().forEach(stageToSchedule -> { + LOG.info("Execute new stage"); + final List stageIncomingEdges = + submittedPhysicalPlan.getStageDAG().getIncomingEdgesOf(stageToSchedule.getId()); + final List stageOutgoingEdges = + submittedPhysicalPlan.getStageDAG().getOutgoingEdgesOf(stageToSchedule.getId()); + + // the list of maps between vertex ID and readables. + final List> vertexIdToReadables = stageToSchedule.getVertexIdToReadables(); + final List taskIdsToSchedule = planStateManager.getTaskAttemptsToSchedule(stageToSchedule.getId()); + + + taskIdsToSchedule.forEach(taskId -> { + AWSLambda client = AWSLambdaClientBuilder.standard().build(); + final JavaConfigurationBuilder jcb = Tang.Factory.getTang().newConfigurationBuilder(); + jcb.bindNamedParameter(TcpPortRangeBegin.class, "5000"); + LOG.info("Schedule task" + taskId + "Init Conf builder"); + + final Injector injector = Tang.Factory.getTang().newInjector(jcb.build()); + try { + final TcpPortProvider tcpPortProvider = injector.getInstance(TcpPortProvider.class); + final ChannelGroup serverChannelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); + LOG.info("Get tcp port"); + + //final OffloadingEventHandler nemoEventHandler = null; + // assigning event handler is not assigned so we pass null + + NettyServerTransport nettyServerTransport = new NettyServerTransport( + tcpPortProvider, new NettyServerSideChannelHandler(serverChannelGroup, null));; + + LOG.info("Init netty server"); + AWSLambdaAsync awsLambda = AWSLambdaAsyncClientBuilder.standard().withClientConfiguration( Review comment: please reuse this object ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services