add stop groups api
This commit is contained in:
parent
e2b2df0418
commit
4c3385ea9f
|
@ -10,7 +10,7 @@ import cn.piflow.conf.util.ClassUtil.findConfigurableStopPropertyDescriptor
|
|||
import org.apache.http.client.methods.{CloseableHttpResponse, HttpGet, HttpPost}
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
import org.apache.http.util.EntityUtils
|
||||
|
||||
import org.apache.spark.launcher.SparkLauncher
|
||||
|
||||
import scala.util.parsing.json.JSON
|
||||
|
||||
|
@ -53,6 +53,20 @@ object API {
|
|||
//spark.close();
|
||||
new Thread( new WaitProcessTerminateRunnable(spark, process)).start()
|
||||
(applicationId,process)
|
||||
|
||||
/*val launcher = new SparkLauncher
|
||||
launcher.setMaster(PropertyUtil.getPropertyValue("spark.master"))
|
||||
.setAppName("test")
|
||||
.setDeployMode(PropertyUtil.getPropertyValue("spark.deploy.mode"))
|
||||
.setConf("spark.hadoop.yarn.resourcemanager.hostname", PropertyUtil.getPropertyValue("yarn.resourcemanager.hostname"))
|
||||
.setConf("spark.hadoop.yarn.resourcemanager.address", PropertyUtil.getPropertyValue("yarn.resourcemanager.address")).setConf("spark.yarn.access.namenode", PropertyUtil.getPropertyValue("yarn.access.namenode"))
|
||||
.setConf("spark.yarn.stagingDir", PropertyUtil.getPropertyValue("yarn.stagingDir"))
|
||||
.setConf("spark.yarn.jars", PropertyUtil.getPropertyValue("yarn.jars"))
|
||||
.setConf("spark.jars", PropertyUtil.getPropertyValue("piflow.bundle"))
|
||||
.setConf("hive.metastore.uris", PropertyUtil.getPropertyValue("hive.metastore.uris"))
|
||||
.setMainClass("lalla")
|
||||
.addAppArgs(flowJson)*/
|
||||
|
||||
}
|
||||
|
||||
def stopFlow(process : Process): String = {
|
||||
|
@ -89,11 +103,16 @@ object API {
|
|||
|
||||
}
|
||||
|
||||
def getAllGroups() = {
|
||||
val groups = ClassUtil.findAllGroups().mkString(",")
|
||||
"""{"groups":"""" + groups + """"}"""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WaitProcessTerminateRunnable(spark : SparkSession, process: Process) extends Runnable {
|
||||
override def run(): Unit = {
|
||||
process.awaitTermination()
|
||||
spark.close()
|
||||
//spark.close()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package cn.piflow.api
|
||||
|
||||
import org.apache.http.client.methods.{CloseableHttpResponse, HttpGet}
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
import org.apache.http.util.EntityUtils
|
||||
|
||||
object HTTPClientGetGroups {
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
|
||||
val url = "http://10.0.86.98:8001/stop/groups"
|
||||
val client = HttpClients.createDefault()
|
||||
val getGroups:HttpGet = new HttpGet(url)
|
||||
|
||||
val response:CloseableHttpResponse = client.execute(getGroups)
|
||||
val entity = response.getEntity
|
||||
val str = EntityUtils.toString(entity,"UTF-8")
|
||||
println("Groups is: " + str)
|
||||
}
|
||||
|
||||
}
|
|
@ -98,6 +98,16 @@ object HTTPService extends DefaultJsonProtocol with Directives with SprayJsonSup
|
|||
case _ => Future.successful(HttpResponse(entity = "Can not found stop properties Error!"))
|
||||
}
|
||||
}
|
||||
}
|
||||
case HttpRequest(GET, Uri.Path("/stop/groups"), headers, entity, protocol) =>{
|
||||
|
||||
try{
|
||||
val stopGroups = API.getAllGroups()
|
||||
Future.successful(HttpResponse(entity = stopGroups))
|
||||
}catch {
|
||||
case _ => Future.successful(HttpResponse(entity = "Can not found stop properties Error!"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case _: HttpRequest =>
|
||||
|
|
Loading…
Reference in New Issue