Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.hubspot.mesos.json;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class MesosMasterMetricsSnapshotObject {
private final int eventQueueMessages;

@JsonCreator
public MesosMasterMetricsSnapshotObject(@JsonProperty("master/event_queue_messages") int eventQueueMessages) {
this.eventQueueMessages = eventQueueMessages;
}

public int getEventQueueMessages() {
return eventQueueMessages;
}

@Override
public String toString() {
return "MesosMasterMetricsSnapshotObject{" +
"eventQueueMessages=" + eventQueueMessages +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.hubspot.horizon.HttpRequest;
import com.hubspot.horizon.HttpResponse;
import com.hubspot.mesos.JavaUtils;
import com.hubspot.mesos.json.MesosMasterMetricsSnapshotObject;
import com.hubspot.mesos.json.MesosMasterStateObject;
import com.hubspot.mesos.json.MesosSlaveStateObject;
import com.hubspot.mesos.json.MesosTaskMonitorObject;
Expand All @@ -27,6 +28,7 @@ public class MesosClient {
private static final String MASTER_STATE_FORMAT = "http://%s/master/state";
private static final String MESOS_SLAVE_JSON_URL = "http://%s:5051/slave(1)/state";
private static final String MESOS_SLAVE_STATISTICS_URL = "http://%s:5051/monitor/statistics";
private static final String MESOS_METRICS_SNAPSHOT_URL = "http://%s/metrics/snapshot";

private static final TypeReference<List<MesosTaskMonitorObject>> TASK_MONITOR_TYPE_REFERENCE = new TypeReference<List<MesosTaskMonitorObject>>() {};

Expand All @@ -41,6 +43,10 @@ public String getMasterUri(String hostnameAndPort) {
return String.format(MASTER_STATE_FORMAT, hostnameAndPort);
}

public String getMetricsSnapshotUri(String hostnameAndPort) {
return String.format(MESOS_METRICS_SNAPSHOT_URL, hostnameAndPort);
}

public static class MesosClientException extends RuntimeException {
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -90,6 +96,10 @@ public MesosMasterStateObject getMasterState(String uri) {
return getFromMesos(uri, MesosMasterStateObject.class);
}

public MesosMasterMetricsSnapshotObject getMasterMetricsSnapshot(String uri) {
return getFromMesos(uri, MesosMasterMetricsSnapshotObject.class);
}

public String getSlaveUri(String hostname) {
return String.format(MESOS_SLAVE_JSON_URL, hostname);
}
Expand Down