1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */18package org.apache.hadoop.chukwa.datacollection.agent;
1920import java.util.Collections;
21import java.util.Map;
22import org.apache.hadoop.conf.Configuration;
23import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
24import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorShutdownPolicy;
2526/**27 * The interface to the agent that is exposed to adaptors.28 *29 */30publicinterfaceAdaptorManager {
313233 Configuration getConfiguration();
34int adaptorCount();
35 @Deprecated
36long stopAdaptor(String id, boolean gracefully);
373839long stopAdaptor(String id, AdaptorShutdownPolicy mode);
40Adaptor getAdaptor(String id);
41 String processAddCommand(String cmd);
42 Map<String, String> getAdaptorList();
4344/**45 * Called to update the Agent status table.46 * 47 * Most adaptors should not call this. It is designed for adaptors that do48 * some sort of local operation that needs checkpointing, but that doesn't49 * emit chunks. For instance, DirTailingAdaptor uses it to track sweeps. 50 * 51 * @param src the adaptor in question52 * @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 */55public String reportCommit(Adaptor src, long uuid);
5657staticAdaptorManager NULL = newAdaptorManager() {
5859 @Override
60publicint adaptorCount() {
61return 0;
62 }
6364 @Override
65publicAdaptor getAdaptor(String id) {
66returnnull;
67 }
6869 @Override
70public Map<String, String> getAdaptorList() {
71return Collections.emptyMap();
72 }
7374 @Override
75public Configuration getConfiguration() {
76returnnew Configuration();
77 }
7879 @Override
80public String processAddCommand(String cmd) {
81return"";
82 }
8384publiclong stopAdaptor(String id, boolean gracefully) {
85return 0;
86 }
8788 @Override
89publiclong stopAdaptor(String id, AdaptorShutdownPolicy mode) {
90return 0;
91 }
9293 @Override
94public String reportCommit(Adaptor a, long l) {
95returnnull;
96 }
97 };
9899 }