Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-2687] [monitoring API] Extend vertex requests with subtask dat…
…a and accumulators
- Loading branch information
1 parent
ba31f83
commit 99a351e
Showing
17 changed files
with
431 additions
and
88 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
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
65 changes: 65 additions & 0 deletions
65
...eb/src/main/java/org/apache/flink/runtime/webmonitor/handlers/JobAccumulatorsHandler.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,65 @@ | |||
/* | |||
* 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.webmonitor.handlers; | |||
|
|||
import com.fasterxml.jackson.core.JsonGenerator; | |||
import org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult; | |||
import org.apache.flink.runtime.executiongraph.ExecutionGraph; | |||
import org.apache.flink.runtime.webmonitor.ExecutionGraphHolder; | |||
|
|||
import java.io.StringWriter; | |||
import java.util.Map; | |||
|
|||
/** | |||
* Request handler that returns the aggregated user accumulators of a job. | |||
*/ | |||
public class JobAccumulatorsHandler extends AbstractExecutionGraphRequestHandler implements RequestHandler.JsonResponse { | |||
|
|||
public JobAccumulatorsHandler(ExecutionGraphHolder executionGraphHolder) { | |||
super(executionGraphHolder); | |||
} | |||
|
|||
@Override | |||
public String handleRequest(ExecutionGraph graph, Map<String, String> params) throws Exception { | |||
StringifiedAccumulatorResult[] allAccumulators = graph.getAccumulatorResultsStringified(); | |||
|
|||
StringWriter writer = new StringWriter(); | |||
JsonGenerator gen = JsonFactory.jacksonFactory.createJsonGenerator(writer); | |||
|
|||
gen.writeStartObject(); | |||
|
|||
gen.writeArrayFieldStart("job-accumulators"); | |||
// empty for now | |||
gen.writeEndArray(); | |||
|
|||
gen.writeArrayFieldStart("user-task-accumulators"); | |||
for (StringifiedAccumulatorResult acc : allAccumulators) { | |||
gen.writeStartObject(); | |||
gen.writeStringField("name", acc.getName()); | |||
gen.writeStringField("type", acc.getType()); | |||
gen.writeStringField("value", acc.getValue()); | |||
gen.writeEndObject(); | |||
} | |||
gen.writeEndArray(); | |||
gen.writeEndObject(); | |||
|
|||
gen.close(); | |||
return writer.toString(); | |||
} | |||
} |
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
82 changes: 82 additions & 0 deletions
82
.../main/java/org/apache/flink/runtime/webmonitor/handlers/JobVertexAccumulatorsHandler.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,82 @@ | |||
/* | |||
* 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.webmonitor.handlers; | |||
|
|||
import com.fasterxml.jackson.core.JsonGenerator; | |||
|
|||
import org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult; | |||
import org.apache.flink.runtime.executiongraph.ExecutionGraph; | |||
import org.apache.flink.runtime.executiongraph.ExecutionJobVertex; | |||
import org.apache.flink.runtime.jobgraph.JobVertexID; | |||
import org.apache.flink.runtime.webmonitor.ExecutionGraphHolder; | |||
|
|||
import java.io.StringWriter; | |||
import java.util.Map; | |||
|
|||
|
|||
public class JobVertexAccumulatorsHandler extends AbstractExecutionGraphRequestHandler implements RequestHandler.JsonResponse { | |||
|
|||
public JobVertexAccumulatorsHandler(ExecutionGraphHolder executionGraphHolder) { | |||
super(executionGraphHolder); | |||
} | |||
|
|||
@Override | |||
public String handleRequest(ExecutionGraph graph, Map<String, String> params) throws Exception { | |||
String vidString = params.get("vertexid"); | |||
if (vidString == null) { | |||
throw new IllegalArgumentException("vertexId parameter missing"); | |||
} | |||
|
|||
JobVertexID vid; | |||
try { | |||
vid = JobVertexID.fromHexString(vidString); | |||
} | |||
catch (Exception e) { | |||
throw new IllegalArgumentException("Invalid JobVertexID string '" + vidString + "': " + e.getMessage()); | |||
} | |||
|
|||
ExecutionJobVertex jobVertex = graph.getJobVertex(vid); | |||
if (jobVertex == null) { | |||
throw new IllegalArgumentException("No vertex with ID '" + vidString + "' exists."); | |||
} | |||
|
|||
StringifiedAccumulatorResult[] accs = jobVertex.getAggregatedUserAccumulatorsStringified(); | |||
|
|||
StringWriter writer = new StringWriter(); | |||
JsonGenerator gen = JsonFactory.jacksonFactory.createJsonGenerator(writer); | |||
|
|||
gen.writeStartObject(); | |||
gen.writeStringField("id", jobVertex.getJobVertexId().toString()); | |||
|
|||
gen.writeArrayFieldStart("user-accumulators"); | |||
for (StringifiedAccumulatorResult acc : accs) { | |||
gen.writeStartObject(); | |||
gen.writeStringField("name", acc.getName()); | |||
gen.writeStringField("type", acc.getType()); | |||
gen.writeStringField("value", acc.getValue()); | |||
gen.writeEndObject(); | |||
} | |||
gen.writeEndArray(); | |||
|
|||
gen.writeEndObject(); | |||
|
|||
gen.close(); | |||
return writer.toString(); | |||
} | |||
} |
Oops, something went wrong.