Debian Codegraph @

api/v1/lib/master/calls/calls.go

raw symbols SCIP
1 package calls
2
3 import (
4 "time"
5
6 "github.com/mesos/mesos-go/api/v1/lib"
7 "github.com/mesos/mesos-go/api/v1/lib/maintenance"
8 "github.com/mesos/mesos-go/api/v1/lib/master"
9 "github.com/mesos/mesos-go/api/v1/lib/quota"
10 )
11
12 // GetHealth retrieves the health status of master.
13 func GetHealth() *master.Call {
14 return &master.Call{
15 Type: master.Call_GET_HEALTH,
16 }
17 }
18
19 // GetFlags retrieves the master's overall flag configuration.
20 func GetFlags() *master.Call {
21 return &master.Call{
22 Type: master.Call_GET_FLAGS,
23 }
24 }
25
26 // GetVersion retrieves the master's version information.
27 func GetVersion() *master.Call {
28 return &master.Call{
29 Type: master.Call_GET_VERSION,
30 }
31 }
32
33 // GetMetrics gives the snapshot of current metrics to the end user. If timeout is set in the call, it will be used to
34 // determine the maximum amount of time the API will take to respond. If the timeout is exceeded, some metrics may not
35 // be included in the response.
36 func GetMetrics(d *time.Duration) (call *master.Call) {
37 call = &master.Call{
38 Type: master.Call_GET_METRICS,
39 GetMetrics: &master.Call_GetMetrics{},
40 }
41 if d != nil {
42 call.GetMetrics.Timeout = &mesos.DurationInfo{
43 Nanoseconds: d.Nanoseconds(),
44 }
45 }
46 return
47 }
48
49 // GetLoggingLevel retrieves the master's logging level.
50 func GetLoggingLevel() *master.Call {
51 return &master.Call{
52 Type: master.Call_GET_LOGGING_LEVEL,
53 }
54 }
55
56 // SetLoggingLevel sets the logging verbosity level for a specified duration for master. Mesos uses glog for logging.
57 // The library only uses verbose logging which means nothing will be output unless the verbosity level is set (by
58 // default it's 0, libprocess uses levels 1, 2, and 3).
59 func SetLoggingLevel(level uint32, d time.Duration) *master.Call {
60 return &master.Call{
61 Type: master.Call_SET_LOGGING_LEVEL,
62 SetLoggingLevel: &master.Call_SetLoggingLevel{
63 Level: level,
64 Duration: mesos.DurationInfo{
65 Nanoseconds: d.Nanoseconds(),
66 },
67 },
68 }
69 }
70
71 // ListFiles retrieves the file listing for a directory in master.
72 func ListFiles(path string) *master.Call {
73 return &master.Call{
74 Type: master.Call_LIST_FILES,
75 ListFiles: &master.Call_ListFiles{
76 Path: path,
77 },
78 }
79 }
80
81 // ReadFile reads data from a file on the master. This call takes the path of the file to be read and the offset to
82 // start reading.
83 func ReadFile(path string, offset uint64) *master.Call {
84 return &master.Call{
85 Type: master.Call_READ_FILE,
86 ReadFile: &master.Call_ReadFile{
87 Path: path,
88 Offset: offset,
89 },
90 }
91 }
92
93 // ReadFileWithLength is similar to ReadFile but species the maximum number of bytes to read from the file.
94 func ReadFileWithLength(path string, offset, length uint64) *master.Call {
95 call := ReadFile(path, offset)
96 call.ReadFile.Length = &length
97 return call
98 }
99
100 // GetState retrieves the overall cluster state.
101 func GetState() *master.Call {
102 return &master.Call{
103 Type: master.Call_GET_STATE,
104 }
105 }
106
107 // GetAgents retrieves information about all the agents known to the master.
108 func GetAgents() *master.Call {
109 return &master.Call{
110 Type: master.Call_GET_AGENTS,
111 }
112 }
113
114 // GetFrameworks retrieves information about all the frameworks known to the master.
115 func GetFrameworks() *master.Call {
116 return &master.Call{
117 Type: master.Call_GET_FRAMEWORKS,
118 }
119 }
120
121 // GetExecutors retrieves information about all the executors known to the master.
122 func GetExecutors() *master.Call {
123 return &master.Call{
124 Type: master.Call_GET_EXECUTORS,
125 }
126 }
127
128 // GetTasks retrieves information about all the tasks known to the master.
129 func GetTasks() *master.Call {
130 return &master.Call{
131 Type: master.Call_GET_TASKS,
132 }
133 }
134
135 // GetRoles retrieves information about all the roles known to the master.
136 func GetRoles() *master.Call {
137 return &master.Call{
138 Type: master.Call_GET_ROLES,
139 }
140 }
141
142 // GetWeights retrieves the information about role weights.
143 func GetWeights() *master.Call {
144 return &master.Call{
145 Type: master.Call_GET_WEIGHTS,
146 }
147 }
148
149 // UpdateWeights updates weights for specific roles.
150 func UpdateWeights(weights ...mesos.WeightInfo) *master.Call {
151 return &master.Call{
152 Type: master.Call_UPDATE_WEIGHTS,
153 UpdateWeights: &master.Call_UpdateWeights{
154 WeightInfos: weights,
155 },
156 }
157 }
158
159 // GetMaster retrieves information about the master.
160 func GetMaster() *master.Call {
161 return &master.Call{
162 Type: master.Call_GET_MASTER,
163 }
164 }
165
166 // Subscribe results in a streaming response. The client is expected to keep a persistent connection open to the
167 // endpoint even after getting a SUBSCRIBED HTTP Response event. This is indicated by "Connection: keep-alive" and
168 // "Transfer-Encoding: chunked" headers with no "Content-Length" header set. All subsequent events generated by Mesos
169 // are streamed on this connection. The master encodes each Event in RecordIO format, i.e., string representation of
170 // length of the event in bytes followed by JSON or binary Protobuf encoded event.
171 func Subscribe() *master.Call {
172 return &master.Call{
173 Type: master.Call_SUBSCRIBE,
174 }
175 }
176
177 // ReserveResources reserves resources dynamically on a specific agent.
178 func ReserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call {
179 return &master.Call{
180 Type: master.Call_RESERVE_RESOURCES,
181 ReserveResources: &master.Call_ReserveResources{
182 AgentID: a,
183 Resources: r,
184 },
185 }
186 }
187
188 // UnreserveResources unreserves resources dynamically on a specific agent.
189 func UnreserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call {
190 return &master.Call{
191 Type: master.Call_UNRESERVE_RESOURCES,
192 UnreserveResources: &master.Call_UnreserveResources{
193 AgentID: a,
194 Resources: r,
195 },
196 }
197 }
198
199 // CreateVolumes creates persistent volumes on reserved resources. The request is forwarded asynchronously to the Mesos
200 // agent where the reserved resources are located. That asynchronous message may not be delivered or creating the
201 // volumes at the agent might fail.
202 func CreateVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call {
203 return &master.Call{
204 Type: master.Call_CREATE_VOLUMES,
205 CreateVolumes: &master.Call_CreateVolumes{
206 AgentID: a,
207 Volumes: v,
208 },
209 }
210 }
211
212 // DestroyVolumes destroys persistent volumes. The request is forwarded asynchronously to the Mesos agent where the
213 // reserved resources are located.
214 func DestroyVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call {
215 return &master.Call{
216 Type: master.Call_DESTROY_VOLUMES,
217 DestroyVolumes: &master.Call_DestroyVolumes{
218 AgentID: a,
219 Volumes: v,
220 },
221 }
222 }
223
224 // GetMaintenanceStatus retrieves the cluster's maintenance status.
225 func GetMaintenanceStatus() *master.Call {
226 return &master.Call{
227 Type: master.Call_GET_MAINTENANCE_STATUS,
228 }
229 }
230
231 //GetMaintenanceSchedule retrieves the cluster's maintenance schedule.
232 func GetMaintenanceSchedule() *master.Call {
233 return &master.Call{
234 Type: master.Call_GET_MAINTENANCE_SCHEDULE,
235 }
236 }
237
238 // UpdateMaintenanceSchedule updates the cluster's maintenance schedule.
239 func UpdateMaintenanceSchedule(s maintenance.Schedule) *master.Call {
240 return &master.Call{
241 Type: master.Call_UPDATE_MAINTENANCE_SCHEDULE,
242 UpdateMaintenanceSchedule: &master.Call_UpdateMaintenanceSchedule{
243 Schedule: s,
244 },
245 }
246 }
247
248 // StartMaintenance starts the maintenance of the cluster, this would bring a set of machines down.
249 func StartMaintenance(m ...mesos.MachineID) *master.Call {
250 return &master.Call{
251 Type: master.Call_START_MAINTENANCE,
252 StartMaintenance: &master.Call_StartMaintenance{
253 Machines: m,
254 },
255 }
256 }
257
258 // StopMaintenance stops the maintenance of the cluster, this would bring a set of machines back up.
259 func StopMaintenance(m ...mesos.MachineID) *master.Call {
260 return &master.Call{
261 Type: master.Call_STOP_MAINTENANCE,
262 StopMaintenance: &master.Call_StopMaintenance{
263 Machines: m,
264 },
265 }
266 }
267
268 // GetQuota retrieves the cluster's configured quotas.
269 func GetQuota() *master.Call {
270 return &master.Call{
271 Type: master.Call_GET_QUOTA,
272 }
273 }
274
275 // SetQuota sets the quota for resources to be used by a particular role.
276 func SetQuota(qr quota.QuotaRequest) *master.Call {
277 return &master.Call{
278 Type: master.Call_SET_QUOTA,
279 SetQuota: &master.Call_SetQuota{
280 QuotaRequest: qr,
281 },
282 }
283 }
284
285 // RemoveQuota removes the quota for a particular role.
286 func RemoveQuota(role string) *master.Call {
287 return &master.Call{
288 Type: master.Call_REMOVE_QUOTA,
289 RemoveQuota: &master.Call_RemoveQuota{
290 Role: role,
291 },
292 }
293 }