Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0834A200C0E for ; Wed, 18 Jan 2017 06:16:37 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 06C55160B52; Wed, 18 Jan 2017 05:16:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5157B160B46 for ; Wed, 18 Jan 2017 06:16:36 +0100 (CET) Received: (qmail 44106 invoked by uid 500); 18 Jan 2017 05:16:35 -0000 Mailing-List: contact dev-help@gearpump.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@gearpump.incubator.apache.org Delivered-To: mailing list dev@gearpump.incubator.apache.org Delivered-To: moderator for dev@gearpump.incubator.apache.org Received: (qmail 30149 invoked by uid 99); 18 Jan 2017 02:05:44 -0000 X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -7.018 X-Spam-Level: X-Spam-Status: No, score=-7.018 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999, URIBL_BLOCKED=0.001] autolearn=disabled From: manuzhang To: dev@gearpump.incubator.apache.org Reply-To: dev@gearpump.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-gearpump pull request #133: [GEARPUMP-252] return meaningful resul... Content-Type: text/plain Message-Id: <20170118020540.7E5BAE964D@git1-us-west.apache.org> Date: Wed, 18 Jan 2017 02:05:40 +0000 (UTC) archived-at: Wed, 18 Jan 2017 05:16:37 -0000 Github user manuzhang commented on a diff in the pull request: https://github.com/apache/incubator-gearpump/pull/133#discussion_r96554483 --- Diff: core/src/main/scala/org/apache/gearpump/cluster/client/RunningApplication.scala --- @@ -0,0 +1,60 @@ +/* + * 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.gearpump.cluster.client + +import akka.pattern.ask +import akka.actor.ActorRef +import akka.util.Timeout +import org.apache.gearpump.cluster.ClientToMaster.{ResolveAppId, ShutdownApplication} +import org.apache.gearpump.cluster.MasterToClient.{ResolveAppIdResult, ShutdownApplicationResult} +import org.apache.gearpump.util.ActorUtil + +import scala.concurrent.Future +import scala.util.{Failure, Success} + +class RunningApplication(val appId: Int, master: ActorRef, timeout: Timeout) { + import scala.concurrent.ExecutionContext.Implicits.global + lazy val appMaster: ActorRef = resolveAppMaster(appId) + + def shutDown(): Unit = { + val result = ActorUtil.askActor[ShutdownApplicationResult](master, + ShutdownApplication(appId), timeout) + result.appId match { + case Success(_) => + case Failure(ex) => throw ex + } + } + + def askMaster[T](msg: Any): Future[T] = { + appMaster.ask(msg)(timeout).asInstanceOf[Future[T]] + } + +// Todo --- End diff -- I'm afraid the intention for these lines could be forgotten after a while so maybe better just remove them for now. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---