This project has retired. For details please refer to its Attic page.
AbstractAdaptor xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
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  }