ラベル ApacheSqoop の投稿を表示しています。 すべての投稿を表示
ラベル ApacheSqoop の投稿を表示しています。 すべての投稿を表示

2014年11月20日木曜日

groovyとScoop REST APIでjobを開始する

groovyとScoop REST APIでjobを開始するには、以下のようなコードを実行します。

サンプルコード
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5')
import org.apache.http.client.methods.*
import org.apache.http.impl.client.*
import org.apache.http.auth.*
import org.apache.http.entity.*
import groovy.json.*

def host = "localhost"
def port = 12000
def httpclient = new DefaultHttpClient()

def jobid = "1"
def method = new HttpPost(
  "http://${host}:${port}/sqoop/v1/submission/action/${jobid}"
)
response = httpclient.execute(method)

println response.getStatusLine().getStatusCode()
動作環境
groovy 2.3.6, JDK7 update67, Cloudera CDH 5.1.2

2014年11月13日木曜日

groovyとSqoop REST APIでconnectionを一覧表示する

groovyとSqoop REST APIでconnectionを一覧表示するには、以下のようなコードを実行します。

サンプルコード
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5')
import org.apache.http.client.methods.*
import org.apache.http.impl.client.*
import org.apache.http.auth.*
import groovy.json.*

def host = "localhost"
def port = 12000
def httpclient = new DefaultHttpClient()

def method = new HttpGet("http://${host}:${port}/sqoop/v1/connection/all")
response = httpclient.execute(method)

println response.getStatusLine().getStatusCode()
def json = new JsonSlurper().parseText(response.getEntity().getContent().text)
//println json
for(conn in json.all){
  println "id:${conn.id}, name:${conn.name}, connector id:${conn."connector-id"}"
}
動作環境
groovy 2.3.6, JDK7 update67, Cloudera CDH 5.1.2

2014年11月6日木曜日

groovyとSqoop REST APIでsqoopのバージョンを取得する

groovyとSqoop REST APIでsqoopのバージョンを取得するには、以下のようなコードを実行します。

サンプルコード
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5')
import org.apache.http.client.methods.*
import org.apache.http.impl.client.*
import org.apache.http.auth.*
import groovy.json.*

def host = "localhost"
def port = 12000
def httpclient = new DefaultHttpClient()

def method = new HttpGet("http://${host}:${port}/sqoop/version")
response = httpclient.execute(method)

println response.getStatusLine().getStatusCode()
def json = new JsonSlurper().parseText(response.getEntity().getContent().text)
println json.version
動作環境
groovy 2.3.6, JDK7 update67, Cloudera CDH 5.1.2

2014年10月11日土曜日

groovyとSqoop REST APIでconnectorを一覧表示する

groovyとSqoop REST APIでconnectorを一覧表示するには、以下のようなコードを実行します。

サンプルコード
@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.3.5')
import org.apache.http.client.methods.*
import org.apache.http.impl.client.*
import org.apache.http.auth.*
import groovy.json.*

def host = "localhost"
def port = 12000
def httpclient = new DefaultHttpClient()

def method = new HttpGet("http://${host}:${port}/sqoop/v1/connector/all")
response = httpclient.execute(method)

println response.getStatusLine().getStatusCode()
def json = new JsonSlurper().parseText(response.getEntity().getContent().text)
//println json
for(conn in json.all){
  println "id:${conn.id}, name:${conn.name}, class:${conn.class}"
}
動作環境
Cloudera CDH 5.1.2