This project has retired. For details please refer to its Attic page.
AdaptorManager 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.agent;
19  
20  import java.util.Collections;
21  import java.util.Map;
22  import org.apache.hadoop.conf.Configuration;
23  import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
24  import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorShutdownPolicy;
25  
26  /**
27   * The interface to the agent that is exposed to adaptors.
28   *
29   */
30  public interface AdaptorManager {
31    
32  
33    Configuration getConfiguration();
34    int adaptorCount();
35    @Deprecated
36    long stopAdaptor(String id, boolean gracefully);
37    
38  
39    long stopAdaptor(String id, AdaptorShutdownPolicy mode);
40    Adaptor getAdaptor(String id);
41    String processAddCommand(String cmd);
42    Map<String, String> getAdaptorList();
43    
44    /**
45     * Called to update the Agent status table.
46     * 
47     * Most adaptors should not call this. It is designed for adaptors that do
48     * some sort of local operation that needs checkpointing, but that doesn't
49     * emit chunks.  For instance, DirTailingAdaptor uses it to track sweeps. 
50     *  
51     * @param src the adaptor in question
52     * @param uuid the number to record as checkpoint.  Must be monotonically increasing.
53     * @return the adaptor ID of the associated adaptor, or null if not running.
54     */
55    public String reportCommit(Adaptor src, long uuid);
56  
57    static AdaptorManager NULL = new AdaptorManager() {
58  
59      @Override
60      public int adaptorCount() {
61        return 0;
62      }
63  
64      @Override
65      public Adaptor getAdaptor(String id) {
66        return null;
67      }
68  
69      @Override
70      public Map<String, String> getAdaptorList() {
71        return Collections.emptyMap();
72      }
73  
74      @Override
75      public Configuration getConfiguration() {
76        return new Configuration();
77      }
78  
79      @Override
80      public String processAddCommand(String cmd) {
81        return "";
82      }
83  
84      public long stopAdaptor(String id, boolean gracefully) {
85        return 0;
86      }
87  
88      @Override
89      public long stopAdaptor(String id, AdaptorShutdownPolicy mode) {
90        return 0;
91      }
92      
93      @Override
94      public String reportCommit(Adaptor a, long l) {
95        return null;
96      }
97    };
98    
99  }