[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/incubator-gearpump/pull/81


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread huafengw
GitHub user huafengw opened a pull request:

https://github.com/apache/incubator-gearpump/pull/81

fix GEARPUMP-205 remove hdfs dependency from gear's classpath

raise the pr to use travis UT

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/huafengw/incubator-gearpump blob

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-gearpump/pull/81.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #81


commit acc150941d0dc0a4bae31aa6ea8949c79fcca0b1
Author: huafengw 
Date:   2016-08-09T11:34:35Z

fix GEARPUMP-205 remove hdfs dependency from gear's classpath




---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77628699
  
--- Diff: 
core/src/main/scala/org/apache/gearpump/jarstore/FileDirective.scala ---
@@ -96,24 +105,47 @@ object FileDirective {
   }
 
   // Downloads file from server
-  def downloadFile(file: File): Route = {
+  def downloadFileFrom(jarStore: JarStore, filePath: String): Route = {
 val responseEntity = HttpEntity(
   MediaTypes.`application/octet-stream`,
-  file.length,
-  FileIO.fromFile(file, CHUNK_SIZE))
+  StreamConverters.fromInputStream(
+() => jarStore.getFile(filePath), CHUNK_SIZE
+  ))
 complete(responseEntity)
   }
 
-  private def uploadFileImpl(rootDirectory: File)(implicit mat: 
Materializer, ec: ExecutionContext)
+  private def uploadFileImpl(jarStore: JarStore)
+(implicit mat: Materializer, ec: ExecutionContext): 
Directive1[Future[Map[Name, FilePath]]] = {
+Directive[Tuple1[Future[Map[Name, FilePath { inner =>
+  entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) =>
+val fileNameMap = formdata.parts.mapAsync(1) { p =>
+  if (p.filename.isDefined) {
+val path = Instant.now() + p.filename.get
+val sink = StreamConverters.fromOutputStream(() => 
jarStore.createFile(path), true)
+val written = p.entity.dataBytes.runWith(sink)
+written.map(written =>
--- End diff --

better use a different local name


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77628288
  
--- Diff: 
core/src/main/scala/org/apache/gearpump/cluster/client/ClientContext.scala ---
@@ -140,7 +139,7 @@ class ClientContext(config: Config, sys: ActorSystem, 
_master: ActorRef) {
 
   private def loadFile(jarPath: String): AppJar = {
 val jarFile = new java.io.File(jarPath)
-val path = jarStoreService.copyFromLocal(jarFile)
+val path = jarStoreClient.copyFromLocal(jarFile)
--- End diff --

Can we reuse `Util.uploadJar` here ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77628447
  
--- Diff: 
core/src/main/scala/org/apache/gearpump/jarstore/FileDirective.scala ---
@@ -67,25 +69,32 @@ object FileDirective {
   type FormField = Either[FileInfo, String]
 
   /**
-   * directive to uploadFile, it store the uploaded files
-   * to temporary directory, and return a Map from form field name
+   * Store the uploaded files to temporary directory, and return a Map 
from form field name
* to FileInfo.
*/
   def uploadFile: Directive1[Form] = {
-uploadFileTo(null)
+Directive[Tuple1[Form]] { inner =>
+  extractMaterializer {implicit mat =>
+extractExecutionContext {implicit ec =>
+  uploadFileImpl(mat, ec) { filesFuture =>
+ctx => {
+  filesFuture.map(map => inner(Tuple1(map))).flatMap(route => 
route(ctx))
--- End diff --

Can we improve code readability here ? It's hard to comprehend what it is 
doing.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77626721
  
--- Diff: core/src/main/scala/org/apache/gearpump/jarstore/JarStore.scala 
---
@@ -0,0 +1,82 @@
+/*
+ * 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.jarstore
+
+import java.io.{InputStream, OutputStream}
+import java.net.URI
+import java.util.ServiceLoader
+
+import com.typesafe.config.Config
+import org.apache.gearpump.util.Util
+
+import scala.collection.JavaConverters._
+
+case class FilePath(path: String)
+
+/**
+ * JarStoreService is used to manage the upload/download of binary files,
--- End diff --

`JarStoreService` ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77626272
  
--- Diff: 
core/src/main/scala/org/apache/gearpump/jarstore/JarStoreService.scala ---
@@ -15,72 +15,39 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.gearpump.jarstore
 
-import java.io.File
-import java.net.URI
-import java.util.ServiceLoader
-import scala.collection.JavaConverters._
-
-import akka.actor.ActorSystem
-import com.typesafe.config.Config
-
-import org.apache.gearpump.util.{Constants, Util}
-
-case class FilePath(path: String)
-
-/**
- * JarStoreService is used to manage the upload/download of binary files,
- * like user submitted application jar.
- */
-trait JarStoreService {
-  /**
-   * The scheme of the JarStoreService.
-   * Like "hdfs" for HDFS file system, and "file" for a local
-   * file system.
-   */
-  val scheme: String
-
-  /**
-   * Init the Jar Store.
-   */
-  def init(config: Config, system: ActorSystem)
-
-  /**
-   * This function will copy the local file to the remote JarStore, called 
from client side.
-   * @param localFile The local file
-   */
-  def copyFromLocal(localFile: File): FilePath
-
-  /**
-   * This function will copy the remote file to local file system, called 
from client side.
-   *
-   * @param localFile The destination of file path
-   * @param remotePath The remote file path from JarStore
-   */
-  def copyToLocalFile(localFile: File, remotePath: FilePath)
-}
-
-object JarStoreService {
-
-  /**
-   * Get a active JarStoreService by specifying a scheme.
-   *
-   * Please see config 
[[org.apache.gearpump.util.Constants#GEARPUMP_APP_JAR_STORE_ROOT_PATH]] for
-   * more information.
-   */
-  def get(config: Config): JarStoreService = {
-val jarStoreRootPath = 
config.getString(Constants.GEARPUMP_APP_JAR_STORE_ROOT_PATH)
-get(jarStoreRootPath)
+import akka.actor.{Actor, Stash}
+import akka.pattern.pipe
+import org.slf4j.Logger
+
+import org.apache.gearpump.cluster.ClientToMaster.{GetJarStoreServer, 
JarStoreServerAddress}
+import org.apache.gearpump.util._
+
+class JarStoreService(jarStoreRootPath: String) extends Actor with Stash {
+  val host = 
context.system.settings.config.getString(Constants.GEARPUMP_HOSTNAME)
--- End diff --

Are these values accessed elsewhere ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77625961
  
--- Diff: 
core/src/main/scala/org/apache/gearpump/jarstore/JarStoreService.scala ---
@@ -15,72 +15,39 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.gearpump.jarstore
 
-import java.io.File
-import java.net.URI
-import java.util.ServiceLoader
-import scala.collection.JavaConverters._
-
-import akka.actor.ActorSystem
-import com.typesafe.config.Config
-
-import org.apache.gearpump.util.{Constants, Util}
-
-case class FilePath(path: String)
-
-/**
- * JarStoreService is used to manage the upload/download of binary files,
- * like user submitted application jar.
- */
-trait JarStoreService {
-  /**
-   * The scheme of the JarStoreService.
-   * Like "hdfs" for HDFS file system, and "file" for a local
-   * file system.
-   */
-  val scheme: String
-
-  /**
-   * Init the Jar Store.
-   */
-  def init(config: Config, system: ActorSystem)
-
-  /**
-   * This function will copy the local file to the remote JarStore, called 
from client side.
-   * @param localFile The local file
-   */
-  def copyFromLocal(localFile: File): FilePath
-
-  /**
-   * This function will copy the remote file to local file system, called 
from client side.
-   *
-   * @param localFile The destination of file path
-   * @param remotePath The remote file path from JarStore
-   */
-  def copyToLocalFile(localFile: File, remotePath: FilePath)
-}
-
-object JarStoreService {
-
-  /**
-   * Get a active JarStoreService by specifying a scheme.
-   *
-   * Please see config 
[[org.apache.gearpump.util.Constants#GEARPUMP_APP_JAR_STORE_ROOT_PATH]] for
-   * more information.
-   */
-  def get(config: Config): JarStoreService = {
-val jarStoreRootPath = 
config.getString(Constants.GEARPUMP_APP_JAR_STORE_ROOT_PATH)
-get(jarStoreRootPath)
+import akka.actor.{Actor, Stash}
+import akka.pattern.pipe
+import org.slf4j.Logger
+
+import org.apache.gearpump.cluster.ClientToMaster.{GetJarStoreServer, 
JarStoreServerAddress}
+import org.apache.gearpump.util._
+
+class JarStoreService(jarStoreRootPath: String) extends Actor with Stash {
--- End diff --

Do you think `JarStoreServer` is better mapping to `JarStoreClient` ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-gearpump pull request #81: fix GEARPUMP-205 remove hdfs dependency...

2016-09-06 Thread manuzhang
Github user manuzhang commented on a diff in the pull request:

https://github.com/apache/incubator-gearpump/pull/81#discussion_r77625222
  
--- Diff: .gitignore ---
@@ -1,5 +1,5 @@
 # Gearpump
-jarstore/
+#jarstore/
--- End diff --

why comment this line ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---