1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.chukwa.datacollection.adaptor;
19
20 import org.apache.hadoop.chukwa.datacollection.ChunkReceiver;
21 import org.apache.hadoop.chukwa.datacollection.agent.AdaptorManager;
22
23 public abstract class AbstractAdaptor implements Adaptor {
24
25
26 protected String type;
27 protected ChunkReceiver dest;
28 protected String adaptorID;
29 protected AdaptorManager control;
30
31 @Override
32 public final String getType() {
33 return type;
34 }
35
36 @Override
37 public final void start(String adaptorID, String type, long offset,
38 ChunkReceiver dest) throws AdaptorException {
39 this.adaptorID = adaptorID;
40 this.type = type;
41 this.dest=dest;
42 start(offset);
43 }
44
45 public abstract void start(long offset) throws AdaptorException;
46 public abstract String parseArgs(String s);
47
48 public void deregisterAndStop() {
49 control.stopAdaptor(adaptorID, AdaptorShutdownPolicy.HARD_STOP);
50 }
51
52 public String parseArgs(String d, String s, AdaptorManager c) {
53 control = c;
54 return parseArgs(s);
55 }
56
57
58
59 @Deprecated
60 public void hardStop() throws AdaptorException {
61 shutdown(AdaptorShutdownPolicy.HARD_STOP);
62 }
63
64 @Deprecated
65 public long shutdown() throws AdaptorException {
66 return shutdown(AdaptorShutdownPolicy.GRACEFULLY);
67 }
68
69 }