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  
19  package org.apache.hadoop.hbase.regionserver.compactions;
20  
21  import java.util.Iterator;
22  import java.util.List;
23  
24  import org.apache.hadoop.hbase.regionserver.StoreFile;
25  
26  /**
27   * Class to create list of mock storefiles of specified length.
28   * This is great for testing edge cases.
29   */
30  class ExplicitFileListGenerator extends StoreFileListGenerator {
31    /** The explicit files size lists to return. */
32    private int[][] fileSizes = new int[][]{
33        {1000, 350, 200, 100, 20, 10, 10},
34        {1000, 450, 200, 100, 20, 10, 10},
35        {1000, 550, 200, 100, 20, 10, 10},
36        {1000, 650, 200, 100, 20, 10, 10},
37        {1, 1, 600, 1, 1, 1, 1},
38        {1, 1, 600, 600, 600, 600, 600, 1, 1, 1, 1},
39        {1, 1, 600, 600, 600, 1, 1, 1, 1},
40        {1000, 250, 25, 25, 25, 25, 25, 25},
41        {25, 25, 25, 25, 25, 25, 500},
42        {1000, 1000, 1000, 1000, 900},
43        {107, 50, 10, 10, 10, 10},
44        {2000, 107, 50, 10, 10, 10, 10},
45        {9, 8, 7, 6, 5, 4, 3, 2, 1},
46        {11, 18, 9, 8, 7, 6, 5, 4, 3, 2, 1},
47        {110, 18, 18, 18, 18, 9, 8, 7, 6, 5, 4, 3, 2, 1},
48        {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15}
49    };
50  
51    ExplicitFileListGenerator() {
52      super(ExplicitFileListGenerator.class);
53    }
54  
55    @Override
56    public final Iterator<List<StoreFile>> iterator() {
57      return new Iterator<List<StoreFile>>() {
58        private int nextIndex = 0;
59        @Override
60        public boolean hasNext() {
61          return nextIndex < fileSizes.length;
62        }
63  
64        @Override
65        public List<StoreFile> next() {
66          List<StoreFile> files =  createStoreFileList(fileSizes[nextIndex]);
67          nextIndex += 1;
68          return files;
69        }
70  
71        @Override
72        public void remove() {
73        }
74      };
75    }
76  }