Mlsql内部资源调度读取opentsdb数据信息代码
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>
Mlsql内部资源调度读取opentsdb数据信息代码的更多相关文章
- TensorFlow csv读取文件数据(代码实现)
TensorFlow csv读取文件数据(代码实现) 大多数人了解 Pandas 及其在处理大数据文件方面的实用性.TensorFlow 提供了读取这种文件的方法. 前面章节中,介绍了如何在 Tens ...
- unity A*寻路 (二)读取NavMesh数据
上一章节我们已经看了怎么获得NavMesh数据保存为obj 这一章节我们来读取NavMesh数据 首先我们要定义两个结构体 点 和 三角形 为什么不用unity自带的Vector3呢? 相信你们应该已 ...
- C/C++程序从文本文件中读取(保存)数据
:本文仅供初学者参阅,解惑 在C程序中: 与程序代码外的数据(文件)打交道,我们使用到流(stream)这个概念,实现进程的虚拟内存与文件之间的数据交换. ——文件流:C标准库提供了FILE(之所以命 ...
- VS2017编译GDAL(64bit)+解决C#读取Shp数据中文路径的问题
编译GDAL过程比较繁琐,查阅了网上相关资料,同时通过实践,完成GDAL的编译,同时解决了SHP数据中文路径及中文字段乱码的问题,本文以“gdal-2.3.2”版本为例阐述整个编译过程. 一.编译准备 ...
- Java读取Excel数据
Java读取Excel数据,解析文本并格式化输出 Java读取Excel数据,解析文本并格式化输出 Java读取Excel数据,解析文本并格式化输出 下图是excel文件的路径和文件名 下图是exce ...
- Microsoft.Jet.OLEDB.4.0读取EXCEL数据
用Microsoft.Jet.OLEDB.4.0读取EXCEL数据的代码是这样的: string ConnStr="Provider=Microsoft.Jet.OLEDB.4.0; ...
- POI读取Excel数据保存到数据库,并反馈给用户处理信息(导入带模板的数据)
今天遇到这么一个需求,将课程信息以Excel的形式导入数据库,并且课程编号再数据库中不能重复,也就是我们需要先读取Excel提取信息之后保存到数据库,并将处理的信息反馈给用户.于是想到了POI读取文件 ...
- 十图详解tensorflow数据读取机制(附代码)转知乎
十图详解tensorflow数据读取机制(附代码) - 何之源的文章 - 知乎 https://zhuanlan.zhihu.com/p/27238630
- 读取 xml 文件 获取其中保存的数据信息
建立一个存储过程来返回要读取的数据形成结果集: CREATE PROC dbo.getValuesFromXmlByPath@fileName NVARCHAR(128)asDECLARE @T XM ...
随机推荐
- Java设计模式:Proxy(代理)模式
概念定义 代理模式是一种使用代理对象来执行目标对象的方法并在代理对象中增强目标对象方法的一种设计模式. 使用代理模式的原因有: 中介隔离作用:在某些情况下,一个客户类不想或者不能直接引用一个委托对象, ...
- 前端之移动端库和框架bootstrap
学习移动端场景下的js事件:制作移动端特效常用的js库:介绍移动端常用开发框架Bootstrap:介绍动态样式语言less.sass.stylus的基本使用. 移动端js事件 移动端的操作方式和PC端 ...
- wpf 单例模式和异常处理 (原发布 csdn 2017-04-12 20:34:12)
第一次写博客,如有错误,请大家及时告知,本人立即改之. 如果您有好的想法或者建议,我随时与我联系. 如果发现代码有误导时,请与我联系,我立即改之. 好了不多说,直接贴代码. 一般的错误,使用下面三个就 ...
- 练手WPF(二)——2048游戏的简易实现(上)
1.创建游戏界面编辑MainWindow.xaml,修改代码如下: <Window.Resources> <Style TargetType="Label"> ...
- 为什么要做外链建设?seo优化与发布外链速度有哪些联系?
对于SEO员工来说,我们每天都在处理网页.从内容创建的角度来看,我们每天创建大量的URL并进入索引状态.与网站的受欢迎程度相比,网站每天也会生成大量的外部链接. 实际上,相对于链接而言,它满足了搜索引 ...
- 深入理解JVM,类加载器
虚拟机设计团队把类加载阶段中的“通过一个类的全限定名来获取描述此类的二进制字节流(即字节码)”这个动作放到Java虚拟机外部去实现,以便让应用程序自己决定如何去获取所需要的类.实现这个动作的代码模块称 ...
- 顺F速运国际版,你的密码漏点了
- 加密情况分析 对APP的分析过程,当然首先是安装,使用,抓包啦. 同样地,登录,抓包看看. 使用账号密码登录. - 壳呢? 虽然直接解密了顺F国际版的加密数据,但还是有必要看看它的APK. 经过分 ...
- [转]English - 开口说话工具箱: 27个高频词单词
本文转自:https://blog.csdn.net/weixin_34247032/article/details/87125465 英语初学者注意力不要放在语法上, 首先要懂得如何让自己开口说英语 ...
- [20190523]修改参数后一些细节注意2.txt
[20190523]修改参数后一些细节注意2.txt --//上午想模拟链接遇到的情况,链接http://blog.itpub.net/267265/viewspace-2645262/--//就是修 ...
- mysql 之优化
# ### part1 : sql语句优化 # (1) mysql 执行流程 客户端: 发送链接请求,然后发送sql语句 服务端: 1.连接层: 提供和客户端链接的服务 show processlis ...