Created
February 10, 2019 11:12
-
-
Save ashkrit/8b0faec5d7ead4134394da7f08bc9707 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val metrics = client.clusterMetrics() | |
| val clusterQueueInfo = client.clusterQueue() | |
| val queueWithCapacity = client.freeQueues(metrics, clusterQueueInfo) | |
| val selectedYarnApps = client.appsBy(user, status) | |
| if (hasApps(selectedYarnApps)) { | |
| val now = System.currentTimeMillis() | |
| val appsByMaxWaitingTime = selectedYarnApps.apps.app.asScala.map(app => | |
| (app, TimeUnit.MILLISECONDS.toMinutes(now - app.startedTime)) | |
| ).filter(v => v._2 > WaitTimeThreshHoldInMinute) | |
| .sortBy(v => v._2)(Ordering[Long].reverse) | |
| appsByMaxWaitingTime.foreach { case (app, waitTime) => | |
| println(s" Application ${app.id} is waiting for ${waitTime} minutes") | |
| client.moveApp(app, queueWithCapacity) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment