1/**2 *3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing, software14 * distributed under the License is distributed on an "AS IS" BASIS,15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.16 * See the License for the specific language governing permissions and17 * limitations under the License.18 */19package org.apache.hadoop.hbase.zookeeper;
2021import org.apache.hadoop.hbase.classification.InterfaceAudience;
2223/**24 * Base class for internal listeners of ZooKeeper events.25 *26 * The {@link ZooKeeperWatcher} for a process will execute the appropriate27 * methods of implementations of this class. In order to receive events from28 * the watcher, every listener must register itself via {@link ZooKeeperWatcher#registerListener}.29 *30 * Subclasses need only override those methods in which they are interested.31 *32 * Note that the watcher will be blocked when invoking methods in listeners so33 * they must not be long-running.34 */35 @InterfaceAudience.Private
36publicabstractclassZooKeeperListener {
3738// Reference to the zk watcher which also contains configuration and constants39protectedZooKeeperWatcher watcher;
4041/**42 * Construct a ZooKeeper event listener.43 */44publicZooKeeperListener(ZooKeeperWatcher watcher) {
45this.watcher = watcher;
46 }
4748/**49 * Called when a new node has been created.50 * @param path full path of the new node51 */52publicvoid nodeCreated(String path) {
53// no-op54 }
5556/**57 * Called when a node has been deleted58 * @param path full path of the deleted node59 */60publicvoid nodeDeleted(String path) {
61// no-op62 }
6364/**65 * Called when an existing node has changed data.66 * @param path full path of the updated node67 */68publicvoid nodeDataChanged(String path) {
69// no-op70 }
7172/**73 * Called when an existing node has a child node added or removed.74 * @param path full path of the node whose children have changed75 */76publicvoid nodeChildrenChanged(String path) {
77// no-op78 }
7980/**81 * @return The watcher associated with this listener82 */83publicZooKeeperWatcher getWatcher() {
84returnthis.watcher;
85 }
86 }