package com.redoop.mlsql
import java.net.URLEncoder
import java.nio.charset.Charset
import net.sf.json.JSONObject
import org.apache.http.client.fluent.{Form, Request}
import tech.mlsql.utils.PathFun
import com.google.gson.{JsonObject, JsonParser}
object RunScriptCommand {
var consoleUrl = s"http://192.168.72.128:9002"
var auth_secret = s"mlsql"
var owner = s"test@redoop.com" def main(args: Array[String]): Unit = {
var scriptfile = args(0)
var start = args(1)
var end = args(2) var id = getScriptId(scriptfile) var scriptFileGetUrl = PathFun(consoleUrl).add(s"/api_v1/script_file/get?id=${id}").toPath
val script = Request.Get(scriptFileGetUrl)
.connectTimeout(60 * 1000)
.socketTimeout(10 * 60 * 1000).addHeader("access-token", auth_secret)
.execute().returnContent().asString() val obj = JSONObject.fromObject(script)
val scriptContent = obj.getString("content")
//val owner = obj.getString("owner")
// 赋值
var newScriptContent = scriptContent.replace("&start",start).replace("&end",end) var runScriptUrl = PathFun(consoleUrl).add(s"/api_v1/run/script").toPath
val res = Request.Post(runScriptUrl).
connectTimeout(60 * 1000).socketTimeout(12 * 60 * 60 * 1000).
addHeader("access-token", auth_secret).
bodyForm(Form.form().add("sql", newScriptContent).
add("owner", owner).build(), Charset.forName("utf8"))
.execute().returnContent().asString()
println(res)
val address = res
val str = address.replaceAll("\\["," ").replaceAll("\\]","") println(str)
println(gson(str,"end")) } def getScriptId(path: String) = {
def encode(str: String) = {
URLEncoder.encode(str, "utf-8")
} var url = PathFun(consoleUrl).add(s"/api_v1/script_file/path/id?path=${encode(path)}&owner=${encode(owner)}").toPath
println(url)
val script = Request.Get(url)
.connectTimeout(60 * 1000)
.socketTimeout(10 * 60 * 1000).addHeader("access-token", auth_secret)
.execute().returnContent().asString()
script.toInt
}
//
def gson(str: String,name:String) ={
val json = new JsonParser()
val obj = json.parse(str).asInstanceOf[JsonObject]
obj.get(name) } }
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>allwefantasy</groupId>
<artifactId>mlsql-api-console</artifactId>
<version>1.5.0-SNAPSHOT</version> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scala.version>2.11.8</scala.version>
<scala.binary.version>2.11</scala.binary.version>
<scala.jline.version>2.11.0-M3</scala.jline.version>
<serviceframework.version>2.0.1</serviceframework.version>
</properties> <profiles>
<profile>
<id>shade</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles> <dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</dependency> <dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.11.5</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>3.11.5</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>3.11.5</version>
</dependency> <dependency>
<groupId>tech.mlsql</groupId>
<artifactId>streamingpro-api</artifactId>
<version>1.2.0</version>
</dependency> <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.18</version>
</dependency> <dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-json_2.11</artifactId>
<version>3.3.0</version>
</dependency> <dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-json-ext_2.11</artifactId>
<version>3.3.0</version>
</dependency> <dependency>
<groupId>net.csdn</groupId>
<artifactId>serviceframework-jetty-9-server_${scala.binary.version}</artifactId>
<version>${serviceframework.version}</version>
</dependency>
<dependency>
<groupId>net.csdn</groupId>
<artifactId>serviceframework-orm_${scala.binary.version}</artifactId>
<version>${serviceframework.version}</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.json4s</groupId>
<artifactId>json4s-jackson_2.11</artifactId>
<version>3.6.1</version>
</dependency> <dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.3.1</version>
</dependency> <dependency>
<groupId>net.csdn</groupId>
<artifactId>serviceframework-web_2.11</artifactId>
<version>${serviceframework.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion> <!--thrift相关-->
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</exclusion>
<exclusion>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</exclusion>
<exclusion>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.scala-lang</groupId>
<artifactId>jline</artifactId>
</exclusion> <exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency> <dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>repository.com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-ecs</artifactId>
<version>4.11.0</version>
</dependency> </dependencies> <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<includes>
<include>**/*.java</include>
<include>**/*.scala</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-g</compilerArgument>
<verbose>true</verbose>
<encoding>UTF-8</encoding>
</configuration> </plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<configuration>
<args>
<arg>
-g:vars
</arg>
</args>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 要将源码放上去,需要加入这个插件 -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> </project>

最新文章

  1. yourphp超出20记录自动删除
  2. 20145223《Java程序程序设计》课程总结
  3. Spring事务管理只对出现运行期异常进行回滚
  4. 自己写的一个关于Linq to Entity 动态查询的例子
  5. 快笑死,侯捷研究MFC的原因
  6. cocos2d-x回收池原理
  7. uva11549 Floyd判圈法
  8. iconv编码转换指令
  9. _WSAStartup@8,该符号在函数 _main 中被引用
  10. 拓扑序+dp Codeforces Round #374 (Div. 2) C
  11. wemall app商城源码机器人检测
  12. 实战Excel Add-in的三种玩法
  13. php消息队列之 think queue消息队列初体验
  14. windows PAE扩展和AWE编程
  15. 浏览器本地下拉框查询选择js
  16. [SQL]SQL 执行顺序
  17. OpenCV + python 实现人脸检测(基于照片和视频进行检测)
  18. Mongo学习---mongo入门1
  19. JAVA 中不错的开源FTP组件:commons-net
  20. [na]ip包格式

热门文章

  1. MySQL索引知识学习笔记
  2. Javascript模块化开发1——package.json详解
  3. SpringBoot开发案例之mail中文附件名字乱码
  4. 使用 FiddlerCore 自定义 HTTP/HTTPS 网络代理
  5. Java生鲜电商平台-Spring Cloud微服务架构图
  6. DevOps 工程师成长日记系列四:打包
  7. redis分享
  8. [20190522]How to get dump or list parameters set at session level.txt
  9. Mac遇到挖矿程序的应急方法
  10. 并发修改异常ConcurrentModificationException