1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.master.handler;
20
21 import java.io.IOException;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.apache.hadoop.hbase.classification.InterfaceAudience;
26 import org.apache.hadoop.hbase.Server;
27 import org.apache.hadoop.hbase.ServerName;
28 import org.apache.hadoop.hbase.executor.EventHandler;
29 import org.apache.hadoop.hbase.executor.EventType;
30 import org.apache.hadoop.hbase.master.DeadServer;
31 import org.apache.hadoop.hbase.master.MasterServices;
32
33
34
35
36
37
38
39
40
41 @InterfaceAudience.Private
42 public class LogReplayHandler extends EventHandler {
43 private static final Log LOG = LogFactory.getLog(LogReplayHandler.class);
44 private final ServerName serverName;
45 protected final Server master;
46 protected final MasterServices services;
47 protected final DeadServer deadServers;
48
49 public LogReplayHandler(final Server server, final MasterServices services,
50 final DeadServer deadServers, final ServerName serverName) {
51 super(server, EventType.M_LOG_REPLAY);
52 this.master = server;
53 this.services = services;
54 this.deadServers = deadServers;
55 this.serverName = serverName;
56 this.deadServers.add(serverName);
57 }
58
59 @Override
60 public String toString() {
61 String name = serverName.toString();
62 return getClass().getSimpleName() + "-" + name + "-" + getSeqid();
63 }
64
65 @Override
66 public void process() throws IOException {
67 try {
68 if (this.master != null && this.master.isStopped()) {
69
70 return;
71 }
72 this.services.getMasterFileSystem().splitLog(serverName);
73 } catch (Exception ex) {
74 if (ex instanceof IOException) {
75
76 this.services.getExecutorService().submit((LogReplayHandler) this);
77 this.deadServers.add(serverName);
78 throw new IOException("failed log replay for " + serverName + ", will retry", ex);
79 } else {
80 throw new IOException(ex);
81 }
82 } finally {
83 this.deadServers.finish(serverName);
84 }
85
86 LOG.info("Finished processing shutdown of " + serverName);
87 }
88 }