forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-21794][metrics] Support retrieving slot details via rest api
This closes apache#15249
- Loading branch information
1 parent
ea0b91d
commit 99c2a41
Showing
17 changed files
with
293 additions
and
61 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
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
48 changes: 48 additions & 0 deletions
48
...time/src/main/java/org/apache/flink/runtime/resourcemanager/TaskManagerInfoWithSlots.java
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,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.runtime.resourcemanager; | ||
|
||
import org.apache.flink.runtime.rest.messages.taskmanager.SlotInfo; | ||
import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo; | ||
import org.apache.flink.runtime.taskexecutor.TaskExecutor; | ||
import org.apache.flink.util.Preconditions; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** Contains the base information about a {@link TaskExecutor} and its allocated slots. */ | ||
public class TaskManagerInfoWithSlots { | ||
|
||
private final TaskManagerInfo taskManagerInfo; | ||
private final Collection<SlotInfo> allocatedSlots; | ||
|
||
public TaskManagerInfoWithSlots( | ||
TaskManagerInfo taskManagerInfo, Collection<SlotInfo> allocatedSlots) { | ||
this.taskManagerInfo = Preconditions.checkNotNull(taskManagerInfo); | ||
this.allocatedSlots = Preconditions.checkNotNull(allocatedSlots); | ||
} | ||
|
||
public final Collection<SlotInfo> getAllocatedSlots() { | ||
return Collections.unmodifiableCollection(allocatedSlots); | ||
} | ||
|
||
public TaskManagerInfo getTaskManagerInfo() { | ||
return taskManagerInfo; | ||
} | ||
} |
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
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
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
95 changes: 95 additions & 0 deletions
95
flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/taskmanager/SlotInfo.java
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,95 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.runtime.rest.messages.taskmanager; | ||
|
||
import org.apache.flink.api.common.JobID; | ||
import org.apache.flink.runtime.clusterframework.types.ResourceProfile; | ||
import org.apache.flink.runtime.rest.messages.ResourceProfileInfo; | ||
import org.apache.flink.runtime.rest.messages.ResponseBody; | ||
import org.apache.flink.runtime.rest.messages.json.JobIDDeserializer; | ||
import org.apache.flink.runtime.rest.messages.json.JobIDSerializer; | ||
import org.apache.flink.util.Preconditions; | ||
|
||
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator; | ||
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonIgnore; | ||
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty; | ||
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Class containing information for a slot of {@link | ||
* org.apache.flink.runtime.resourcemanager.slotmanager.TaskManagerSlot}. | ||
*/ | ||
public class SlotInfo implements ResponseBody, Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public static final String FIELD_NAME_RESOURCE = "resource"; | ||
|
||
public static final String FIELD_NAME_JOB_ID = "jobId"; | ||
|
||
@JsonProperty(FIELD_NAME_RESOURCE) | ||
private final ResourceProfileInfo resource; | ||
|
||
@JsonProperty(FIELD_NAME_JOB_ID) | ||
@JsonSerialize(using = JobIDSerializer.class) | ||
private final JobID jobId; | ||
|
||
@JsonCreator | ||
public SlotInfo( | ||
@JsonDeserialize(using = JobIDDeserializer.class) @JsonProperty(FIELD_NAME_JOB_ID) | ||
JobID jobId, | ||
@JsonProperty(FIELD_NAME_RESOURCE) ResourceProfileInfo resource) { | ||
this.jobId = Preconditions.checkNotNull(jobId); | ||
this.resource = Preconditions.checkNotNull(resource); | ||
} | ||
|
||
public SlotInfo(JobID jobId, ResourceProfile resource) { | ||
this(jobId, ResourceProfileInfo.fromResrouceProfile(resource)); | ||
} | ||
|
||
@JsonIgnore | ||
public JobID getJobId() { | ||
return jobId; | ||
} | ||
|
||
@JsonIgnore | ||
public ResourceProfileInfo getResource() { | ||
return resource; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
SlotInfo that = (SlotInfo) o; | ||
return Objects.equals(jobId, that.jobId) && Objects.equals(resource, that.resource); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(jobId, resource); | ||
} | ||
} |
Oops, something went wrong.