forked from opensci/piflow
rename piflow-api to piflow-server;add getFlowInfo Api
This commit is contained in:
parent
c347710084
commit
508f0639a9
|
@ -1,4 +1,9 @@
|
|||
server.ip=10.0.86.98
|
||||
server.port=8001
|
||||
|
||||
spark.version=2.1.0
|
||||
spark.master=10.0.86.89
|
||||
spark.port=6066
|
||||
|
||||
yarn.url=http://192.168.6.22:8032/ws/v1/cluster/apps/
|
||||
checkpoint.path=hdfs://10.0.86.89:9000/xjzhu/piflow/checkpoints/"
|
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>piflow-api</artifactId>
|
||||
<artifactId>piflow-server</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>piflow</groupId>
|
|
@ -6,7 +6,13 @@ import org.apache.spark.sql.SparkSession
|
|||
import cn.piflow.conf.util.{FileUtil, OptionUtil}
|
||||
import cn.piflow.Process
|
||||
import cn.piflow.api.util.PropertyUtil
|
||||
import com.github.ywilkof.sparkrestclient.{JobStatusResponse, SparkRestClient}
|
||||
import com.github.ywilkof.sparkrestclient.SparkRestClient.SparkRestClientBuilder
|
||||
import jodd.util.PropertiesUtil
|
||||
import org.apache.http.client.methods.{CloseableHttpResponse, HttpGet, HttpPost}
|
||||
import org.apache.http.entity.StringEntity
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
import org.apache.http.util.EntityUtils
|
||||
|
||||
import scala.util.parsing.json.JSON
|
||||
|
||||
|
@ -24,7 +30,7 @@ object API {
|
|||
//execute flow
|
||||
val spark = SparkSession.builder()
|
||||
.master("spark://10.0.86.89:7077")
|
||||
.appName("piflow-hive-bundle")
|
||||
.appName(flowBean.name)
|
||||
.config("spark.driver.memory", "1g")
|
||||
.config("spark.executor.memory", "2g")
|
||||
.config("spark.cores.max", "2")
|
||||
|
@ -32,6 +38,7 @@ object API {
|
|||
.enableHiveSupport()
|
||||
.getOrCreate()
|
||||
|
||||
|
||||
val process = Runner.create()
|
||||
.bind(classOf[SparkSession].getName, spark)
|
||||
.bind("checkpoint.path", PropertyUtil.getPropertyValue("checkpoint.path"))
|
||||
|
@ -46,4 +53,17 @@ object API {
|
|||
process.stop()
|
||||
"ok"
|
||||
}
|
||||
|
||||
def getFlowInfo(appID : String) : String = {
|
||||
|
||||
val url = PropertyUtil.getPropertyValue("yarn.url") + appID
|
||||
val client = HttpClients.createDefault()
|
||||
val get:HttpGet = new HttpGet(url)
|
||||
|
||||
val response:CloseableHttpResponse = client.execute(get)
|
||||
val entity = response.getEntity
|
||||
val str = EntityUtils.toString(entity,"UTF-8")
|
||||
println("Code is " + str)
|
||||
str
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package cn.piflow.api
|
||||
|
||||
import org.apache.http.client.methods.{CloseableHttpResponse, HttpPost}
|
||||
import cn.piflow.api.util.PropertyUtil
|
||||
import org.apache.http.client.methods.{CloseableHttpResponse, HttpGet, HttpPost}
|
||||
import org.apache.http.entity.StringEntity
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
import org.apache.http.util.EntityUtils
|
|
@ -42,6 +42,12 @@ object HTTPService extends DefaultJsonProtocol with Directives with SprayJsonSup
|
|||
Future.successful(HttpResponse(entity = "Get OK!"))
|
||||
}
|
||||
|
||||
case HttpRequest(GET, Uri.Path("/flow/info"), headers, entity, protocol) => {
|
||||
val appID = ""
|
||||
val result = API.getFlowInfo(appID)
|
||||
Future.successful(HttpResponse(entity = "Get OK!"))
|
||||
}
|
||||
|
||||
case HttpRequest(POST, Uri.Path("/flow/start"), headers, entity, protocol) =>{
|
||||
|
||||
entity match {
|
Loading…
Reference in New Issue