1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.replication;
20
21 import java.io.IOException;
22 import java.util.ArrayList;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.hadoop.hbase.classification.InterfaceAudience;
27 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
28 import com.google.common.collect.Lists;
29 import com.google.common.util.concurrent.AbstractService;
30
31
32
33
34
35
36 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.REPLICATION)
37 public abstract class BaseReplicationEndpoint extends AbstractService
38 implements ReplicationEndpoint {
39
40 private static final Log LOG = LogFactory.getLog(BaseReplicationEndpoint.class);
41 protected Context ctx;
42
43 @Override
44 public void init(Context context) throws IOException {
45 this.ctx = context;
46
47 if (this.ctx != null){
48 ReplicationPeer peer = this.ctx.getReplicationPeer();
49 if (peer != null){
50 peer.trackPeerConfigChanges(this);
51 } else {
52 LOG.warn("Not tracking replication peer config changes for Peer Id " + this.ctx.getPeerId() +
53 " because there's no such peer");
54 }
55 }
56 }
57
58 @Override
59
60
61
62 public void peerConfigUpdated(ReplicationPeerConfig rpc){
63
64 }
65
66
67 @Override
68 public WALEntryFilter getWALEntryfilter() {
69 ArrayList<WALEntryFilter> filters = Lists.newArrayList();
70 WALEntryFilter scopeFilter = getScopeWALEntryFilter();
71 if (scopeFilter != null) {
72 filters.add(scopeFilter);
73 }
74 WALEntryFilter tableCfFilter = getTableCfWALEntryFilter();
75 if (tableCfFilter != null) {
76 filters.add(tableCfFilter);
77 }
78 return filters.isEmpty() ? null : new ChainWALEntryFilter(filters);
79 }
80
81
82
83 protected WALEntryFilter getScopeWALEntryFilter() {
84 return new ScopeWALEntryFilter();
85 }
86
87
88
89 protected WALEntryFilter getTableCfWALEntryFilter() {
90 return new TableCfWALEntryFilter(ctx.getReplicationPeer());
91 }
92
93 @Override
94 public boolean canReplicateToSameCluster() {
95 return false;
96 }
97
98 }