Skip to content

Commit

Permalink
Merge pull request #51 from wyukawa/kill-rest-api
Browse files Browse the repository at this point in the history
Kill rest api
  • Loading branch information
wyukawa committed Feb 3, 2016
2 parents bc37752 + 31695f1 commit ca978b9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,20 @@ For this feature, shib should be executed by a user who can execute command `map
monitor: {
name: 'yarn',
host: 'resourcemanager.hostname.local',
port: 8088,
yarn: '/usr/bin/yarn' // 'yarn' in PATH by default
port: 8088
}
```
In this case, shib kills query with Resource Manager REST API.

For this feature, shib should be executed by a user who can execute command `yarn application -kill APP_ID`.
If you specify yarn command description, shib kills query with `yarn application -kill APP_ID`.
```js
monitor: {
name: 'yarn',
host: 'resourcemanager.hostname.local',
port: 8088,
yarn: '/usr/bin/yarn'
}
```

### Huahin Manager (obsolete)

Expand Down
34 changes: 30 additions & 4 deletions lib/shib/engines/yarn/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,34 @@ YARNClient.prototype.status = function(jobname, callback){
};

YARNClient.prototype.kill = function(appid, callback){
var command = this.yarn + " application -kill " + appid;
child_process.exec(command, function(err, stdout, stderr){
callback(err);
});
if(this.yarn) {
var command = this.yarn + " application -kill " + appid;
child_process.exec(command, function(err, stdout, stderr){
callback(err);
});
} else {
var options = {
host: this.host,
port: this.port,
path: "/ws/v1/cluster/apps/" + appid + "/state",
method: "PUT",
headers: {'Content-Type': 'application/json'}
};

var cb = function(res){
// status: 2xx
var code = String(res.statusCode);
if (!code.match(/^2/)) {
callback({message: "YARN REST API returns response code " + res.statusCode});
return;
}
};

var req = http.request(options, cb)
req.write('{"state":"KILLED"}');
req.on('error', function(error) {
callback(error);
});
req.end();
}
};
3 changes: 0 additions & 3 deletions lib/shib/engines/yarn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ var Monitor = exports.Monitor = function(conf, logger) {
throw "YARN WebUI host/port not specified";
}
var yarn = conf.yarn;
if (! conf.yarn) {
yarn = 'yarn';
}
this.logger = logger;
this._client = new YARNClient(conf.host, conf.port, yarn);
};
Expand Down

0 comments on commit ca978b9

Please sign in to comment.