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 
19 package org.apache.hadoop.yarn.nodelabels;
20 
21 import java.io.IOException;
22 import java.util.Collection;
23 import java.util.Map;
24 import java.util.Set;
25 
26 import org.apache.hadoop.conf.Configuration;
27 import org.apache.hadoop.yarn.api.records.NodeId;
28 import org.apache.hadoop.yarn.event.InlineDispatcher;
29 
30 public class DummyCommonNodeLabelsManager extends CommonNodeLabelsManager {
31   Map<NodeId, Set<String>> lastNodeToLabels = null;
32   Collection<String> lastAddedlabels = null;
33   Collection<String> lastRemovedlabels = null;
34 
35   @Override
initNodeLabelStore(Configuration conf)36   public void initNodeLabelStore(Configuration conf) {
37     this.store = new NodeLabelsStore(this) {
38 
39       @Override
40       public void recover() throws IOException {
41       }
42 
43       @Override
44       public void removeClusterNodeLabels(Collection<String> labels)
45           throws IOException {
46         lastRemovedlabels = labels;
47       }
48 
49       @Override
50       public void updateNodeToLabelsMappings(
51           Map<NodeId, Set<String>> nodeToLabels) throws IOException {
52         lastNodeToLabels = nodeToLabels;
53       }
54 
55       @Override
56       public void storeNewClusterNodeLabels(Set<String> label) throws IOException {
57         lastAddedlabels = label;
58       }
59 
60       @Override
61       public void close() throws IOException {
62         // do nothing
63       }
64     };
65   }
66 
67   @Override
initDispatcher(Configuration conf)68   protected void initDispatcher(Configuration conf) {
69     super.dispatcher = new InlineDispatcher();
70   }
71 
72   @Override
startDispatcher()73   protected void startDispatcher() {
74     // do nothing
75   }
76 
77   @Override
stopDispatcher()78   protected void stopDispatcher() {
79     // do nothing
80   }
81 
82   @Override
serviceStop()83   protected void serviceStop() throws Exception {
84     super.serviceStop();
85   }
86 }
87