1 /** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * 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 and 17 * limitations under the License. 18 */ 19 package org.apache.hadoop.hbase.zookeeper; 20 21 import org.apache.hadoop.classification.InterfaceAudience; 22 import org.apache.hadoop.classification.InterfaceStability; 23 24 25 /** 26 * Base class for internal listeners of ZooKeeper events. 27 * 28 * The {@link ZooKeeperWatcher} for a process will execute the appropriate 29 * methods of implementations of this class. In order to receive events from 30 * the watcher, every listener must register itself via {@link ZooKeeperWatcher#registerListener}. 31 * 32 * Subclasses need only override those methods in which they are interested. 33 * 34 * Note that the watcher will be blocked when invoking methods in listeners so 35 * they must not be long-running. 36 */ 37 @InterfaceAudience.Private 38 public abstract class ZooKeeperListener { 39 40 // Reference to the zk watcher which also contains configuration and constants 41 protected ZooKeeperWatcher watcher; 42 43 /** 44 * Construct a ZooKeeper event listener. 45 */ 46 public ZooKeeperListener(ZooKeeperWatcher watcher) { 47 this.watcher = watcher; 48 } 49 50 /** 51 * Called when a new node has been created. 52 * @param path full path of the new node 53 */ 54 public void nodeCreated(String path) { 55 // no-op 56 } 57 58 /** 59 * Called when a node has been deleted 60 * @param path full path of the deleted node 61 */ 62 public void nodeDeleted(String path) { 63 // no-op 64 } 65 66 /** 67 * Called when an existing node has changed data. 68 * @param path full path of the updated node 69 */ 70 public void nodeDataChanged(String path) { 71 // no-op 72 } 73 74 /** 75 * Called when an existing node has a child node added or removed. 76 * @param path full path of the node whose children have changed 77 */ 78 public void nodeChildrenChanged(String path) { 79 // no-op 80 } 81 }