This project has retired. For details please refer to its
Attic page.
TorqueDataLoader xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.chukwa.inputtools.mdl;
19
20
21 import java.sql.SQLException;
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.hadoop.chukwa.util.PidFile;
25 import org.apache.hadoop.chukwa.util.ExceptionUtil;
26
27 public class TorqueDataLoader {
28 private static Log log = LogFactory.getLog("TorqueDataLoader");
29
30 private TorqueInfoProcessor tp = null;
31 private PidFile loader = null;
32
33 public TorqueDataLoader(DataConfig mdlConfig, int interval) {
34 log.info("in torqueDataLoader");
35 tp = new TorqueInfoProcessor(mdlConfig, interval);
36 loader = new PidFile("TorqueDataLoader");
37 }
38
39 public void run() {
40 boolean first = true;
41 while (true) {
42 try {
43 tp.setup(first);
44 first = false;
45 } catch (Exception ex) {
46 tp.shutdown();
47
48 if (first) {
49 log.error("setup error");
50 ex.printStackTrace();
51 loader.clean();
52 System.exit(1);
53 }
54 log.error("setup fail, retry after 10 minutes");
55 try {
56 Thread.sleep(600 * 1000);
57 } catch (InterruptedException e) {
58
59 log.error(e.getMessage());
60
61 }
62 continue;
63
64 }
65
66 try {
67 tp.run_forever();
68 } catch (SQLException ex) {
69 tp.shutdown();
70 log.error("processor died, reconnect again after 10 minutes");
71 ex.printStackTrace();
72 try {
73 Thread.sleep(600 * 1000);
74 } catch (InterruptedException e) {
75
76 log.error(e.getMessage());
77
78 }
79 } catch (Exception ex) {
80 try {
81 Thread.sleep(16 * 1000);
82 } catch (InterruptedException e) {
83 log.debug(ExceptionUtil.getStackTrace(e));
84 }
85 tp.shutdown();
86 log.error("process died...." + ex.getMessage());
87 loader.clean();
88 System.exit(1);
89 }
90
91 }
92
93 }
94
95 public static void main(String[] args) {
96
97
98
99
100
101
102
103 int intervalValue = 60;
104
105 DataConfig mdlConfig = new DataConfig();
106
107 TorqueDataLoader tdl = new TorqueDataLoader(mdlConfig, intervalValue);
108 tdl.run();
109
110 }
111
112 }