AZKABAN(三)curl命令

????因?yàn)楹芏喾?wù)器并不能連接外網(wǎng)诡蜓。那么這時(shí)web頁(yè)面就沒(méi)法使用了。這時(shí)可以使用azkaban接口代碼猎塞,寫(xiě)自己的交互式命令试读。也可以直接使用提供的curl命令。

? ??Azkaban 操作需要登錄鑒權(quán)荠耽。登錄成功后返回一個(gè)session.id钩骇,以后通過(guò)session.id進(jìn)行身份驗(yàn)證。因此每次使用curl指令除了登錄操作,其他都需要這個(gè)參數(shù)倘屹。

本文中$id $p 之類(lèi)银亲。都是 使用shell變量 保存id,工程id等變量纽匙。如有問(wèn)題可以留言务蝠。會(huì)一一解答。

登錄

curl -k -X POST --data "action=login&username=$name&password=$pw"https://localhost:8443

登錄成功返回體

{

? "status" :"success",

? "session.id" :"c001aba5-a90f-4daf-8f11-62330d034c0a"

}

Session.id 后續(xù)操作需要重復(fù)使用哄辣。

創(chuàng)建工程

curl -k -X POST --data "session.id=$id&name=sh&description=sh"https://localhost:8443/manager?action=create

?????? 成功返回體

?????? {

? "status":"success",

?"path":"manager?project=aaaa", //工程創(chuàng)建后路徑

????? ????? "action":"redirect"

}

刪除工程

curl -k --get --data "session.id=session.id&delete=true&project=工程名稱"https://localhost:8443/manager

沒(méi)有返回

上傳工程

curl -k -i -H "Content-Type:

multipart/mixed" -X POST --form “session.id=$id” --form 'ajax=upload'

--form 'file=@myproject.zip;type=application/zip' --form 'project=sh' https://localhost:8443/manager

原azkaban doc中工程名后面有 ;type/plain 但是執(zhí)行出錯(cuò)请梢。去掉執(zhí)行真確。正確返回為力穗。

HTTP/1.1 100 Continue


HTTP/1.1 200 OK

Content-Type: application/json

Content-Length: 42

Server: Jetty(6.1.26)


{

? "projectId" :"6",

? "version" :"1"

}

注意點(diǎn),上傳文件格式為zip气嫁。且注意上傳路徑当窗。

獲取工程流。

curl -k --get --data "session.id=$id&ajax=fetchprojectflows&project=$p"https://localhost:8443/manager

正確返回

{

? "flows" : [ {

??? "flowId" :"o2o_2_hive"

? } ],

? "project" :"curl-test",

? "projectId" : 6

}

獲取工作流

curl -k --get --data "session.id=$id&ajax=fetchflowgraph&project=$p&flow=$fd"https://localhost:8443/manager

正確返回:

{

? "nodes" : [ {

??? "in" : ["o2o_clean_data" ],

??? "id" :"o2o_2_hive",

??? "type" :"command "

? }, {

??? "in" : ["o2o_up_2_hdfs" ],

??? "id" :"o2o_clean_data",

??? "type" :"command "

? }, {

??? "id" :"o2o_get_file_ftp1",

??? "type" :"command "

? }, {

??? "id" :"o2o_get_file_ftp2",

??? "type" :"command "

? }, {

??? "in" : ["o2o_get_file_ftp1", "o2o_get_file_ftp2" ],

??? "id" : "o2o_up_2_hdfs",

??? "type" :"command "

? } ],

? "project" :"curl-test",

? "projectId" : 6,

? "flow" :"o2o_2_hive"

}

In表示依賴的意思寸宵。Id表示工程名崖面。Type表示job類(lèi)型。


獲取執(zhí)行流

curl -k --get --data "session.id=$id&ajax=fetchFlowExecutions&project=$p&flow=$fd&start=0&length=5"https://localhost:8443/manager

{

? "executions" : [ {

??? "startTime" :1407779928865,

??? "submitUser" :"1",

??? "status" :"FAILED",

??? "submitTime" :1407779928829,

??? "execId" : 306,

??? "projectId" :192,

??? "endTime" :1407779950602,

??? "flowId" :"test"

? }, {

??? "startTime" :1407779877807,

??? "submitUser" :"1",

??? "status" :"FAILED",

??? "submitTime" :1407779877779,

?? ?"execId" : 305,

??? "projectId" :192,

??? "endTime" :1407779899599,

??? "flowId" :"test"

? }, {

??? "startTime" :1407779473354,

??? "submitUser" :"1",

??? "status" :"FAILED",

??? "submitTime" :1407779473318,

??? "execId" : 304,

??? "projectId" : 192,

??? "endTime" :1407779495093,

??? "flowId" :"test"

? } ],

? "total" : 16,

? "project" : "curl-test",

? "length" : 3,

? "from" : 0,

? "flow" : "o2o_2_hive",

? "projectId" : 192

}

上面顯示了總共的執(zhí)行次數(shù)梯影,和開(kāi)始結(jié)束時(shí)間的等等信息巫员。




獲取運(yùn)行流。

curl -k --data "session.id=$id&ajax=getRunning&project=$p&flow=$fd"https://localhost:8443/executor

成功返回

{

? "execIds": [301,302]

}

執(zhí)行一個(gè)流

curl -k --get --data'session.id=189b956b-f39f-421e-9a95-e3117e7543c9' --data 'ajax=executeFlow' --data'project=azkaban-test-project' --data 'flow=test'https://localhost:8443/executor

成功返回

{

? "project" :"curl-test",

? "message" :"Execution submitted successfully with exec id 10",

? "flow" : "o2o_2_hive",

? "execid" : 10

}

?????? 具體參數(shù)如下:

?????? ParameterDescription

session.idThe user session id.

Example Values:30d538e2-4794-4e7e-8a35-25a9e2fd5300

ajax=executeFlowThe fixed parameter indicating the current ajax action is? executeFlow.

projectThe project name of the executing flow.

Example Values:?run-all-jobs

flowThe flow id to be executed.

Example Values:?test-flow

disabled (optional)A list of job names that should be disabled for this? execution. Should be formatted as a JSON Array String.

Example Values:?["job_name_1",? "job_name_2", "job_name_N"]

successEmails (optional)A list of emails to be notified if the execution succeeds. All? emails are delimitted with [,|;|\\s+].

Example Values:?foo@email.com,bar@email.com

failureEmails (optional)A list of emails to be notified if the execution fails. All? emails are delimitted with [,|;|\\s+].

Example Values:?foo@email.com,bar@email.com

successEmailsOverride (optional)Whether uses system default email settings to override? successEmails.

Possible Values:?true,? false

failureEmailsOverride (optional)Whether uses system default email settings to override? failureEmails.

Possible Values:?true,? false

notifyFailureFirst (optional)Whether sends out email notifications as long as the first? failure occurs.

Possible Values:?true,? false

notifyFailureLast (optional)Whether sends out email notifications as long as the last? failure occurs.

Possible Values:?true,? false

failureAction (Optional)If a failure occurs, how should the execution behaves.

Possible Values:?finishCurrent,? cancelImmediately, finishPossible

concurrentOption (Optional)Concurrent choices. Use ignore if nothing specifical is? required.

Possible Values:?ignore,? pipeline, skip

flowOverride[flowProperty] (Optional)Override specified flow property with specified value.

Example Values :?flowOverride[failure.email]=test@gmail.com

完整參數(shù)執(zhí)行如下:

curl -k --get --data'session.id=079f7617-1454-4c85-890fd829d1e3b502' --data 'ajax=executeFlow'--data 'project=curl-test' --data 'flow=o2o_2_hive' --data'disabled=["o2o_up_2_hdfs"]' --data'successEmails=15800968375@163.com' --data 'failureEmails=15800968375@163.com'--data 'notifyFailureFirst=true' --data 'failureEmailsOverride=true' --data'failureAction=finishCurrent'? https://localhost:8443/executor

其中如果想讓設(shè)置的email發(fā)送成功必須emailsoverride設(shè)置為true甲棍。英文描述有問(wèn)題简识,是當(dāng)前設(shè)置覆蓋默認(rèn)設(shè)置。描述反了感猛。





取消一個(gè)運(yùn)行流

curl -k --data "session.id=session.id&ajax=cancelFlow&execid=execid"https://localhost:8443/executor

如果沒(méi)有這個(gè)execid那么會(huì)報(bào)錯(cuò)七扰。

{

"error" : "Execution 14 of flow o2o_2_hive isn'trunning."

}

如果成功返回{}

設(shè)置定時(shí)任務(wù)

curl -k -X POST --data"session.id=$id&ajax=scheduleFlow&projectName=$p&projectId=$pd&flow=$fd&scheduleTime=10,30,am,UTC&scheduleDate=07/02/2018&is_recurring=on&period=1d"https://localhost:8443/schedule

成功返回

{

? "message" :"curl-test.o2o_2_hive scheduled.",

? "status" :"success"

}


ParameterDescription

session.idThe? user session id.

ajax=scheduleFlowThe? fixed parameter indicating the action is to schedule a flow.

projectNameThe? name of the project.

projectIdThe

? id of the project. You can find this with?Fetch

? Flows of a Project.

flowThe? name of the flow id.

scheduleTime(with? timezone)The? time to schedule the flow. Example: 12,00,pm,PDT (Unless UTC is specified,? Azkaban will take current server's default timezone instead)

scheduleDateThe? date to schedule the flow. Example: 07/22/2014

is_recurring=on? (optional)Flags? the schedule as a recurring schedule.

period? (optional)Specifies? the recursion period. Depends on the "is_recurring" flag being set.? Example: 5w

Possible Values:

MMonths

wWeeks

dDays

hHours

mMinutes

sSeconds

注:這個(gè)官方文檔有區(qū)別,測(cè)試過(guò)了官方文檔錯(cuò)的陪白。

使用cron設(shè)置定時(shí)任務(wù)(2.5不支持這是最新版本支持)

curl -k -X POST --data"session.id=$id&ajax=scheduleCronFlow&projectName=$p&flow=$fd&cronExpression=0031 10 ? ? ?"https://localhost:8443/schedule

cron定時(shí)任務(wù)工具:http://cron.qqe2.com/

查看定時(shí)工作

curl -k --get --data"session.id=$id&ajax=fetchSchedule&projectId=$pd&flowId=$fd"https://localhost:8443/schedule

成功返回為:

{

? "schedule" : {

??? "nextExecTime" :"2018-07-03 03:31:00",

??? "period" :"1 day(s)",

??? "submitUser" :"admin",

??? "scheduleId" :"9",

??? "firstSchedTime": "2018-07-02 03:31:00"

? }

}

?????? 請(qǐng)求體中projectId為工程id颈走。

取消一個(gè)定時(shí)任務(wù)

curl -k -X POST --data"session.id=$id&action=removeSched&scheduleId=9"https://localhost:8443/schedule

成功為:

{

? "message" :"flow o2o_2_hive removed from Schedules.",

? "status" :"success"

}

設(shè)置sla(定時(shí)任務(wù)執(zhí)行通知)

curl -k -X POST --data

"session.id=$id&ajax=setSla&scheduleId=$sd&slaEmails=15800968375@163.com&settings[0]=aaa,SUCCESS,5:00,true,false"

https://localhost:8443/schedule

成功返回:{}

Setting內(nèi)具體參數(shù)的意思是:第一個(gè)是id,第二個(gè)規(guī)則咱士,第三個(gè)時(shí)間間隔立由,第四個(gè)emailAction,第五個(gè)killAction

查看sla

curl -k --get --data "session.id=$id&ajax=slaInfo&scheduleId=$sd"https://localhost:8443/schedule

成功返回:

{

? "settings" : [ {

??? "duration" :"300m",

??? "rule" :"SUCCESS",

??? "id" :"aaa",

??? "actions" : ["EMAIL" ]

? } ],

? "slaEmails" : ["15800968375@163.com" ],

?"allJobNames" : [ "o2o_up_2_hdfs","o2o_2_hive", "o2o_get_file_ftp1","o2o_clean_data", "o2o_get_file_ftp2" ]

}

暫停一個(gè)工作流

curl -k --get --data"session.id=$id&ajax=pauseFlow&execid=3"https://localhost:8443/executor

如果execid不存在會(huì)返回如下:

{

? "error" :"Execution 3 of flow o2o_2_hive isn't running."

}

?????? 成功為{}

重新啟動(dòng)一個(gè)工作流

curl -k? --get --data"session.id=$id&ajax=resumeFlow&execid=3"https://localhost:8443/executor

如果exeid不存在:

{

? "resume" :"Execution 3 of flow o2o_2_hive isn't running."

}

?????? 成功返回{}

取得執(zhí)行流運(yùn)行狀況

curl -k --get --data"session.id=$id&ajax=pauseFlow&execid=3"https://localhost:8443/executor

如果id不存在:{

? "error" :"Execution 3 of flow o2o_2_hive isn't running."

}

成功返回:


{

? "attempt" : 0,

? "submitUser" :"1",

? "updateTime" :1407779495095,

? "status" :"FAILED",

? "submitTime" :1407779473318,

? "projectId" : 192,

? "flow" :"test",

? "endTime" :1407779495093,

? "type" : null,

? "nestedId" :"test",

? "startTime" :1407779473354,

? "id" :"test",

? "project" :"test-azkaban",

? "nodes" : [ {

??? "attempt" : 0,

??? "startTime" :1407779495077,

??? "id" :"test",

??? "updateTime" :1407779495077,

??? "status" :"CANCELLED",

??? "nestedId" :"test",

??? "type" :"command",

??? "endTime" :1407779495077,

??? "in" : ["test-foo" ]

? }, {

??? "attempt" : 0,

??? "startTime" :1407779473357,

??? "id" :"test-bar",

??? "updateTime" :1407779484241,

??? "status" :"SUCCEEDED",

??? "nestedId" :"test-bar",

??? "type" :"pig",

??? "endTime" :1407779484236

? }, {

??? "attempt" : 0,

??? "startTime" :1407779484240,

??? "id" :"test-foobar",

??? "updateTime" :1407779495073,

??? "status" :"FAILED",

??? "nestedId" :"test-foobar",

??? "type" :"java",

??? "endTime" : 1407779495068,

??? "in" : ["test-bar" ]

? }, {

??? "attempt" : 0,

??? "startTime" :1407779495069,

??? "id" :"test-foo",

??? "updateTime" :1407779495069,

??? "status" :"CANCELLED",

??? "nestedId" :"test-foo",

??? "type" :"java",

??? "endTime" :1407779495069,

??? "in" : ["test-foobar" ]

? } ],

? "flowId" :"test",

? "execid" : 304

}

取得執(zhí)行日志

curl -k --get --data"session.id=$id&ajax=fetchExecJobLogs&execid=7&jobId=6&offset=0&length=100"https://localhost:8443/executor

執(zhí)行成功:

{

? "data" :"05-08-2014 16:53:02 PDT test-foobar INFO - Starting job test-foobar at140728278",

? "length" : 100,

? "offset" : 0

}

?????? 失斝蚶鳌:

????????????? {

? ????????? "error" : "Job 6doesn't exist in 7"

}

獲得執(zhí)行流更新日志

curl -k --get? --data"session.id=$id&ajax=fetchexecflowupdateexecid=6&lastUpdateTime=-1"https://localhost:8443/executor

成功返回:

{

? "nodes" : [ {

??? "startTime" :1530194417779,

??? "updateTime" :1530194417779,

??? "id" :"o2o_up_2_hdfs",

??? "endTime" :1530194417779,

??? "attempt" : 0,

??? "status" :"CANCELLED"

? }, {

??? "startTime" :1530194417871,

??? "updateTime" :1530194417871,

??? "id" :"o2o_2_hive",

??? "endTime" :1530194417871,

??? "attempt" : 0,

??? "status" :"CANCELLED"

? }, {

??? "startTime" :1530194417688,

??? "updateTime" :1530194417819,

??? "id" :"o2o_get_file_ftp1",

??? "endTime" :1530194417773,

??? "attempt" : 0,

??? "status" :"FAILED"

? }, {

??? "startTime" :1530194417826,

??? "updateTime" :1530194417826,

??? "id" :"o2o_clean_data",

??? "endTime" :1530194417826,

??? "attempt" : 0,

??? "status" :"CANCELLED"

? }, {

??? "startTime" :1530194417696,

??? "updateTime" :1530194417785,

??? "id" :"o2o_get_file_ftp2",

??? "endTime" :1530194417727,

??? "attempt" : 0,

?? ?"status" : "FAILED"

? } ],

? "startTime" :1530194417642,

? "updateTime" :1530194417999,

? "id" :"o2o_2_hive",

? "endTime" :1530194417985,

? "attempt" : 0,

? "flow" :"o2o_2_hive",

? "status" :"FAILED"

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末锐膜,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子脂矫,更是在濱河造成了極大的恐慌枣耀,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,454評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異捞奕,居然都是意外死亡牺堰,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén)颅围,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)伟葫,“玉大人,你說(shuō)我怎么就攤上這事院促》ぱ” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 157,921評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵常拓,是天一觀的道長(zhǎng)渐溶。 經(jīng)常有香客問(wèn)我,道長(zhǎng)弄抬,這世上最難降的妖魔是什么茎辐? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,648評(píng)論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮掂恕,結(jié)果婚禮上拖陆,老公的妹妹穿的比我還像新娘。我一直安慰自己懊亡,他們只是感情好依啰,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,770評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著店枣,像睡著了一般速警。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上艰争,一...
    開(kāi)封第一講書(shū)人閱讀 49,950評(píng)論 1 291
  • 那天坏瞄,我揣著相機(jī)與錄音,去河邊找鬼甩卓。 笑死鸠匀,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的逾柿。 我是一名探鬼主播缀棍,決...
    沈念sama閱讀 39,090評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼机错!你這毒婦竟也來(lái)了爬范?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 37,817評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤弱匪,失蹤者是張志新(化名)和其女友劉穎青瀑,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,275評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡斥难,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,592評(píng)論 2 327
  • 正文 我和宋清朗相戀三年枝嘶,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片哑诊。...
    茶點(diǎn)故事閱讀 38,724評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡群扶,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出镀裤,到底是詐尸還是另有隱情竞阐,我是刑警寧澤,帶...
    沈念sama閱讀 34,409評(píng)論 4 333
  • 正文 年R本政府宣布暑劝,位于F島的核電站骆莹,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏担猛。R本人自食惡果不足惜汪疮,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,052評(píng)論 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望毁习。 院中可真熱鬧,春花似錦卖丸、人聲如沸纺且。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,815評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)载碌。三九已至,卻和暖如春衅枫,著一層夾襖步出監(jiān)牢的瞬間嫁艇,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,043評(píng)論 1 266
  • 我被黑心中介騙來(lái)泰國(guó)打工弦撩, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留步咪,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,503評(píng)論 2 361
  • 正文 我出身青樓益楼,卻偏偏與公主長(zhǎng)得像猾漫,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子感凤,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,627評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理悯周,服務(wù)發(fā)現(xiàn),斷路器陪竿,智...
    卡卡羅2017閱讀 134,637評(píng)論 18 139
  • 重要說(shuō)明:本方是翻譯自https://docs.spring.io/spring-cloud-dataflow/d...
    devilteam2006閱讀 10,478評(píng)論 1 12
  • 1. Java基礎(chǔ)部分 基礎(chǔ)部分的順序:基本語(yǔ)法禽翼,類(lèi)相關(guān)的語(yǔ)法,內(nèi)部類(lèi)的語(yǔ)法,繼承相關(guān)的語(yǔ)法闰挡,異常的語(yǔ)法锐墙,線程的語(yǔ)...
    子非魚(yú)_t_閱讀 31,599評(píng)論 18 399
  • 關(guān)鍵詞:小孩贮匕、發(fā)育、多動(dòng)花枫、注意力不集中刻盐、姿勢(shì)、情緒劳翰、語(yǔ)言敦锌、學(xué)習(xí)。 每個(gè)小孩都像天使一樣降臨到人間佳簸,帶著...
    原始反射整合閱讀 347評(píng)論 3 2
  • 我決定寫(xiě)下很多關(guān)于暗戀的小事生均。 二零一六年的八月二十五號(hào)晚上八點(diǎn)听想,她截圖下了《最好的我們》里路星河跟...
    你默默微笑閱讀 243評(píng)論 0 0