-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-14816] Add thread dump feature for taskmanager
- Loading branch information
Showing
13 changed files
with
351 additions
and
9 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...untime-web/web-dashboard/src/app/pages/task-manager/dump/task-manager-dump.component.html
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,20 @@ | ||
<!-- | ||
~ 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://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. | ||
--> | ||
|
||
<flink-monaco-editor [value]="dump"></flink-monaco-editor> | ||
<flink-refresh-download [downloadHref]="'taskmanagers/'+taskManagerDetail?.id+'/dump'" [downloadName]="'taskmanager_'+taskManagerDetail?.id+'_dump'" (reload)="reload()"></flink-refresh-download> |
28 changes: 28 additions & 0 deletions
28
...untime-web/web-dashboard/src/app/pages/task-manager/dump/task-manager-dump.component.less
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,28 @@ | ||
/* | ||
* 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://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. | ||
*/ | ||
@import "theme"; | ||
|
||
flink-monaco-editor { | ||
height: calc(~"100vh - 310px"); | ||
} | ||
|
||
:host { | ||
position: relative; | ||
display: block; | ||
border: 1px solid @border-color-split; | ||
} |
60 changes: 60 additions & 0 deletions
60
...-runtime-web/web-dashboard/src/app/pages/task-manager/dump/task-manager-dump.component.ts
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,60 @@ | ||
/* | ||
* 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://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. | ||
*/ | ||
|
||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, ViewChild } from '@angular/core'; | ||
import { TaskManagerDetailInterface } from 'interfaces'; | ||
import { first } from 'rxjs/operators'; | ||
import { TaskManagerService } from 'services'; | ||
import { MonacoEditorComponent } from 'share/common/monaco-editor/monaco-editor.component'; | ||
|
||
@Component({ | ||
selector: 'flink-task-manager-dump', | ||
templateUrl: './task-manager-dump.component.html', | ||
styleUrls: ['./task-manager-dump.component.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class TaskManagerDumpComponent implements OnInit { | ||
@ViewChild(MonacoEditorComponent) monacoEditorComponent: MonacoEditorComponent; | ||
dump = ''; | ||
taskManagerDetail: TaskManagerDetailInterface; | ||
|
||
reload() { | ||
if (this.taskManagerDetail) { | ||
this.taskManagerService.loadDump(this.taskManagerDetail.id).subscribe( | ||
data => { | ||
this.monacoEditorComponent.layout(); | ||
this.dump = data; | ||
this.cdr.markForCheck(); | ||
}, | ||
() => { | ||
this.cdr.markForCheck(); | ||
} | ||
); | ||
} | ||
} | ||
|
||
constructor(private taskManagerService: TaskManagerService, private cdr: ChangeDetectorRef) {} | ||
|
||
ngOnInit() { | ||
this.taskManagerService.taskManagerDetail$.pipe(first()).subscribe(data => { | ||
this.taskManagerDetail = data; | ||
this.reload(); | ||
this.cdr.markForCheck(); | ||
}); | ||
} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
...a/org/apache/flink/runtime/rest/handler/taskmanager/TaskManagerThreadDumpFileHandler.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,59 @@ | ||
/* | ||
* 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://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.handler.taskmanager; | ||
|
||
import org.apache.flink.api.common.time.Time; | ||
import org.apache.flink.runtime.blob.TransientBlobKey; | ||
import org.apache.flink.runtime.blob.TransientBlobService; | ||
import org.apache.flink.runtime.clusterframework.types.ResourceID; | ||
import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway; | ||
import org.apache.flink.runtime.rest.messages.EmptyRequestBody; | ||
import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders; | ||
import org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters; | ||
import org.apache.flink.runtime.taskexecutor.FileType; | ||
import org.apache.flink.runtime.taskexecutor.TaskExecutor; | ||
import org.apache.flink.runtime.webmonitor.RestfulGateway; | ||
import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Rest handler which serves the thread dump files from {@link TaskExecutor}. | ||
*/ | ||
public class TaskManagerThreadDumpFileHandler extends AbstractTaskManagerFileHandler<TaskManagerMessageParameters> { | ||
|
||
public TaskManagerThreadDumpFileHandler( | ||
@Nonnull GatewayRetriever<? extends RestfulGateway> leaderRetriever, | ||
@Nonnull Time timeout, | ||
@Nonnull Map<String, String> responseHeaders, | ||
@Nonnull UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> untypedResponseMessageHeaders, | ||
@Nonnull GatewayRetriever<ResourceManagerGateway> resourceManagerGatewayRetriever, | ||
@Nonnull TransientBlobService transientBlobService, | ||
@Nonnull Time cacheEntryDuration) { | ||
super(leaderRetriever, timeout, responseHeaders, untypedResponseMessageHeaders, resourceManagerGatewayRetriever, transientBlobService, cacheEntryDuration); | ||
} | ||
|
||
@Override | ||
protected CompletableFuture<TransientBlobKey> requestFileUpload(ResourceManagerGateway resourceManagerGateway, ResourceID taskManagerResourceId) { | ||
return resourceManagerGateway.requestTaskManagerFileUpload(taskManagerResourceId, FileType.THREAD_DUMP, timeout); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
.../org/apache/flink/runtime/rest/messages/taskmanager/TaskManagerThreadDumpFileHeaders.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,60 @@ | ||
/* | ||
* 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://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.runtime.rest.HttpMethodWrapper; | ||
import org.apache.flink.runtime.rest.handler.taskmanager.TaskManagerThreadDumpFileHandler; | ||
import org.apache.flink.runtime.rest.messages.EmptyRequestBody; | ||
import org.apache.flink.runtime.rest.messages.UntypedResponseMessageHeaders; | ||
|
||
/** | ||
* Headers for the {@link TaskManagerThreadDumpFileHandler}. | ||
*/ | ||
public class TaskManagerThreadDumpFileHeaders implements UntypedResponseMessageHeaders<EmptyRequestBody, TaskManagerMessageParameters> { | ||
|
||
private static final TaskManagerThreadDumpFileHeaders INSTANCE = new TaskManagerThreadDumpFileHeaders(); | ||
|
||
private static final String URL = String.format("/taskmanagers/:%s/dump", TaskManagerIdPathParameter.KEY); | ||
|
||
private TaskManagerThreadDumpFileHeaders() {} | ||
|
||
@Override | ||
public Class<EmptyRequestBody> getRequestClass() { | ||
return EmptyRequestBody.class; | ||
} | ||
|
||
@Override | ||
public TaskManagerMessageParameters getUnresolvedMessageParameters() { | ||
return new TaskManagerMessageParameters(); | ||
} | ||
|
||
@Override | ||
public HttpMethodWrapper getHttpMethod() { | ||
return HttpMethodWrapper.GET; | ||
} | ||
|
||
@Override | ||
public String getTargetRestEndpointURL() { | ||
return URL; | ||
} | ||
|
||
public static TaskManagerThreadDumpFileHeaders getInstance() { | ||
return INSTANCE; | ||
} | ||
} |
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
Oops, something went wrong.