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