[
https://issues.apache.org/jira/browse/YUNIKORN-2235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798451#comment-17798451
]
Chia-Ping Tsai commented on YUNIKORN-2235:
------------------------------------------
[~mani]thanks for explanation. the following discussion is unrelated to this
issue. all I want to do is to improve my programming skill :)
{quote}
these 3 different types of apps are being stored in different maps. Please see
partition.go for more details. So, I don't think there is much additional cost
involved here.
{quote}
you are right. However, it still needs to 1) get lock, 2) iterate all objects,
3) check value, 4) add it to new list if we want to filter the specific state.
Hence, there are two questions:
1. if there is no much additional cost here, why we can't extend the method (or
restful API) with more queries?
2. if it does have additional cost, should we avoid adding such restful API?
{code:go}
func (pc *PartitionContext) getAppsByState(state string) []string {
pc.RLock()
defer pc.RUnlock()
var apps []string
for appID, app := range pc.applications {
if app.CurrentState() == state {
apps = append(apps, appID)
}
}
return apps
}
func (pc *PartitionContext) getCompletedAppsByState(state string) []string {
pc.RLock()
defer pc.RUnlock()
var apps []string
for appID, app := range pc.completedApplications {
if app.CurrentState() == state {
apps = append(apps, appID)
}
}
return apps
}
{code}
https://github.com/apache/yunikorn-core/blob/master/pkg/scheduler/partition.go#L1071
https://github.com/apache/yunikorn-core/blob/master/pkg/scheduler/partition.go#L1097
> Add new RESTful API for retrieving application
> ----------------------------------------------
>
> Key: YUNIKORN-2235
> URL: https://issues.apache.org/jira/browse/YUNIKORN-2235
> Project: Apache YuniKorn
> Issue Type: New Feature
> Components: core - scheduler
> Reporter: Xie YiFan
> Assignee: Xie YiFan
> Priority: Minor
> Labels: pull-request-available
>
> *Situation:*
> Currently, the path format of retrieving application is
> /ws/v1/partition/\{partitionName}/queue/\{queueName}/application/\{appId}.
> We have to give 3 parameters (partitionName, queueName & appID) to fetch
> application information. But one application can only be submitted to one
> queue and PartitionContext stores all applications. It means that we can
> fetch the target application without queue name.
> *Proposal:*
> As we have discussed in slack, we can add the following 2 RESTful API.
> # /ws/v1/partition/\{partitionName}/applications/\{type}
> aim to list applications IDs via the types: rejected, running and completed
> # /ws/v1/partition/\{partitionName}/application/\{applicationID}
> aim to retrieving one application object directly.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]