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.Public
38 @InterfaceStability.Evolving
39 public abstract class ZooKeeperListener {
40
41 // Reference to the zk watcher which also contains configuration and constants
42 protected ZooKeeperWatcher watcher;
43
44 /**
45 * Construct a ZooKeeper event listener.
46 */
47 public ZooKeeperListener(ZooKeeperWatcher watcher) {
48 this.watcher = watcher;
49 }
50
51 /**
52 * Called when a new node has been created.
53 * @param path full path of the new node
54 */
55 public void nodeCreated(String path) {
56 // no-op
57 }
58
59 /**
60 * Called when a node has been deleted
61 * @param path full path of the deleted node
62 */
63 public void nodeDeleted(String path) {
64 // no-op
65 }
66
67 /**
68 * Called when an existing node has changed data.
69 * @param path full path of the updated node
70 */
71 public void nodeDataChanged(String path) {
72 // no-op
73 }
74
75 /**
76 * Called when an existing node has a child node added or removed.
77 * @param path full path of the node whose children have changed
78 */
79 public void nodeChildrenChanged(String path) {
80 // no-op
81 }
82 }