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数据信息代码的更多相关文章

  1. TensorFlow csv读取文件数据(代码实现)

    TensorFlow csv读取文件数据(代码实现) 大多数人了解 Pandas 及其在处理大数据文件方面的实用性.TensorFlow 提供了读取这种文件的方法. 前面章节中,介绍了如何在 Tens ...

  2. unity A*寻路 (二)读取NavMesh数据

    上一章节我们已经看了怎么获得NavMesh数据保存为obj 这一章节我们来读取NavMesh数据 首先我们要定义两个结构体 点 和 三角形 为什么不用unity自带的Vector3呢? 相信你们应该已 ...

  3. C/C++程序从文本文件中读取(保存)数据

    :本文仅供初学者参阅,解惑 在C程序中: 与程序代码外的数据(文件)打交道,我们使用到流(stream)这个概念,实现进程的虚拟内存与文件之间的数据交换. ——文件流:C标准库提供了FILE(之所以命 ...

  4. VS2017编译GDAL(64bit)+解决C#读取Shp数据中文路径的问题

    编译GDAL过程比较繁琐,查阅了网上相关资料,同时通过实践,完成GDAL的编译,同时解决了SHP数据中文路径及中文字段乱码的问题,本文以“gdal-2.3.2”版本为例阐述整个编译过程. 一.编译准备 ...

  5. Java读取Excel数据

    Java读取Excel数据,解析文本并格式化输出 Java读取Excel数据,解析文本并格式化输出 Java读取Excel数据,解析文本并格式化输出 下图是excel文件的路径和文件名 下图是exce ...

  6. Microsoft.Jet.OLEDB.4.0读取EXCEL数据

    用Microsoft.Jet.OLEDB.4.0读取EXCEL数据的代码是这样的:     string ConnStr="Provider=Microsoft.Jet.OLEDB.4.0; ...

  7. POI读取Excel数据保存到数据库,并反馈给用户处理信息(导入带模板的数据)

    今天遇到这么一个需求,将课程信息以Excel的形式导入数据库,并且课程编号再数据库中不能重复,也就是我们需要先读取Excel提取信息之后保存到数据库,并将处理的信息反馈给用户.于是想到了POI读取文件 ...

  8. 十图详解tensorflow数据读取机制(附代码)转知乎

    十图详解tensorflow数据读取机制(附代码) - 何之源的文章 - 知乎 https://zhuanlan.zhihu.com/p/27238630

  9. 读取 xml 文件 获取其中保存的数据信息

    建立一个存储过程来返回要读取的数据形成结果集: CREATE PROC dbo.getValuesFromXmlByPath@fileName NVARCHAR(128)asDECLARE @T XM ...

随机推荐

  1. appium 使用name 定位报错 Locator Strategy 'name' is not supported for this session【appium-desktop】

    RF中使用 name定位 报错提示: Locator Strategy 'name' is not supported for this session 解决: 1.打开本地文件 driver.js ...

  2. KeContextToKframes函数逆向

    在逆向_KiRaiseException(之后紧接着就是派发KiDispatchException)函数时,遇到一个 KeContextToKframes 函数,表面意思将CONTEXT转换为 TRA ...

  3. 2018-2-13-win10-UWP-MessageDialog-和-ContentDialog

    原文:2018-2-13-win10-UWP-MessageDialog-和-ContentDialog title author date CreateTime categories win10 U ...

  4. 练手WPF(三)——扫雷小游戏的简易实现(下)

    十四.响应鼠标点击事件    (1)设置对应坐标位置为相应的前景状态 /// <summary> /// 设置单元格图样 /// </summary> /// <para ...

  5. 浅谈Java面向对象思想

    本人免费整理了Java高级资料,涵盖了Java.Redis.MongoDB.MySQL.Zookeeper.Spring Cloud.Dubbo高并发分布式等教程,一共30G,需要自己领取.传送门:h ...

  6. CSS渐变的两种基本用法

    1.线性渐变(linear-gradient) 基础用法:background:linear-gradient(angle,start-color,soft-line,end-color); 依次解释 ...

  7. JavaScript操作数据库JS操作Access数据库

    avaScript操作数据库JS操作Access数据库,跟其他语言操作差不多,总结了一下习惯代码,仅供参考学习.现在在F盘有文件abc.mdf,表名为Student,一共2个字段,Id数字类型主键,s ...

  8. vue-cli3和element做一个简单的登陆页面

    1.先用vue-cli3创建一个项目 2.安装element模块 全局安装 npm i element-ui -S 3在main.js引入模块 import ElementUI from 'eleme ...

  9. Saltstack_使用指南10_配置管理-状态模块

    1. 主机规划 salt 版本 [root@salt100 ~]# salt --version salt (Oxygen) [root@salt100 ~]# salt-minion --versi ...

  10. Oracle第二话之调优工具

    Oracle第二话之调优工具 原创if 0 = -I can 发布于2019-04-09 19:53:12 阅读数 172  收藏 展开 目录 1.告警日志 2.用户进程trace文件 3.动态性能视 ...