-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an api endpoint for getting the current leader (#741)
* add an api endpoint for getting the current leader This adds a /scheduler/leader endpoint for getting the current leader. It returns JSON in the structure of {'leader': leader}. * add documentation for the /leader endpoint
- Loading branch information
1 parent
0964cb3
commit ce61e75
Showing
4 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
18 changes: 18 additions & 0 deletions
18
src/main/scala/org/apache/mesos/chronos/scheduler/api/LeaderRestModule.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.apache.mesos.chronos.scheduler.api | ||
|
||
import org.apache.mesos.chronos.scheduler.jobs.JobScheduler | ||
import javax.ws.rs.core.{MediaType, Response} | ||
import javax.ws.rs.{GET, Path, Produces} | ||
import com.google.inject.Inject | ||
|
||
|
||
@Path(PathConstants.getLeaderPattern) | ||
@Produces(Array(MediaType.APPLICATION_JSON)) | ||
class LeaderResource @Inject()( | ||
val jobScheduler: JobScheduler | ||
) { | ||
@GET | ||
def getLeader(): Response = { | ||
Response.ok(Map("leader" -> jobScheduler.getLeader)).build | ||
} | ||
} |
This file contains 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