|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.spark; |
| 19 | + |
| 20 | +import org.apache.spark.scheduler.*; |
| 21 | + |
| 22 | +/** |
| 23 | + * Class that allows users to receive all SparkListener events. |
| 24 | + * Users should override the onEvent method. |
| 25 | + * |
| 26 | + * This is a concrete Java class in order to ensure that we don't forget to update it when adding |
| 27 | + * new methods to SparkListener: forgetting to add a method will result in a compilation error (if |
| 28 | + * this was a concrete Scala class, default implementations of new event handlers would be inherited |
| 29 | + * from the SparkListener trait). |
| 30 | + */ |
| 31 | +public class SparkFirehoseListener implements SparkListener { |
| 32 | + |
| 33 | + public void onEvent(SparkListenerEvent event) { } |
| 34 | + |
| 35 | + @Override |
| 36 | + public final void onStageCompleted(SparkListenerStageCompleted stageCompleted) { |
| 37 | + onEvent(stageCompleted); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public final void onStageSubmitted(SparkListenerStageSubmitted stageSubmitted) { |
| 42 | + onEvent(stageSubmitted); |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public final void onTaskStart(SparkListenerTaskStart taskStart) { |
| 47 | + onEvent(taskStart); |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public final void onTaskGettingResult(SparkListenerTaskGettingResult taskGettingResult) { |
| 52 | + onEvent(taskGettingResult); |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public final void onTaskEnd(SparkListenerTaskEnd taskEnd) { |
| 57 | + onEvent(taskEnd); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public final void onJobStart(SparkListenerJobStart jobStart) { |
| 62 | + onEvent(jobStart); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public final void onJobEnd(SparkListenerJobEnd jobEnd) { |
| 67 | + onEvent(jobEnd); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public final void onEnvironmentUpdate(SparkListenerEnvironmentUpdate environmentUpdate) { |
| 72 | + onEvent(environmentUpdate); |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public final void onBlockManagerAdded(SparkListenerBlockManagerAdded blockManagerAdded) { |
| 77 | + onEvent(blockManagerAdded); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public final void onBlockManagerRemoved(SparkListenerBlockManagerRemoved blockManagerRemoved) { |
| 82 | + onEvent(blockManagerRemoved); |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public final void onUnpersistRDD(SparkListenerUnpersistRDD unpersistRDD) { |
| 87 | + onEvent(unpersistRDD); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public final void onApplicationStart(SparkListenerApplicationStart applicationStart) { |
| 92 | + onEvent(applicationStart); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public final void onApplicationEnd(SparkListenerApplicationEnd applicationEnd) { |
| 97 | + onEvent(applicationEnd); |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public final void onExecutorMetricsUpdate( |
| 102 | + SparkListenerExecutorMetricsUpdate executorMetricsUpdate) { |
| 103 | + onEvent(executorMetricsUpdate); |
| 104 | + } |
| 105 | + |
| 106 | + @Override |
| 107 | + public final void onExecutorAdded(SparkListenerExecutorAdded executorAdded) { |
| 108 | + onEvent(executorAdded); |
| 109 | + } |
| 110 | + |
| 111 | + @Override |
| 112 | + public final void onExecutorRemoved(SparkListenerExecutorRemoved executorRemoved) { |
| 113 | + onEvent(executorRemoved); |
| 114 | + } |
| 115 | +} |
0 commit comments