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.hbase.hbtop.terminal.impl.batch;
19  
20  import edu.umd.cs.findbugs.annotations.Nullable;
21  import org.apache.hadoop.hbase.hbtop.terminal.CursorPosition;
22  import org.apache.hadoop.hbase.hbtop.terminal.KeyPress;
23  import org.apache.hadoop.hbase.hbtop.terminal.Terminal;
24  import org.apache.hadoop.hbase.hbtop.terminal.TerminalPrinter;
25  import org.apache.hadoop.hbase.hbtop.terminal.TerminalSize;
26  
27  /**
28   * An implementation of the {@link Terminal} interface for batch mode.
29   *
30   * This implementation produces output that's more sensible for collecting to a log file or for
31   * parsing. There is no limit on the number of output lines, and the output doesn't contain any
32   * escape sequences for formatting.
33   */
34  public class BatchTerminal implements Terminal {
35  
36    private static final TerminalPrinter TERMINAL_PRINTER = new BatchTerminalPrinter();
37  
38    @Override
39    public void clear() {
40    }
41  
42    @Override
43    public void refresh() {
44      // Add a new line
45      TERMINAL_PRINTER.endOfLine();
46    }
47  
48    @Nullable
49    @Override
50    public TerminalSize getSize() {
51      return null;
52    }
53  
54    @Nullable
55    @Override
56    public TerminalSize doResizeIfNecessary() {
57      return null;
58    }
59  
60    @Nullable
61    @Override
62    public KeyPress pollKeyPress() {
63      return null;
64    }
65  
66    @Override
67    public CursorPosition getCursorPosition() {
68      return null;
69    }
70  
71    @Override
72    public void setCursorPosition(int column, int row) {
73    }
74  
75    @Override
76    public void hideCursor() {
77    }
78  
79    @Override
80    public TerminalPrinter getTerminalPrinter(int startRow) {
81      return TERMINAL_PRINTER;
82    }
83  
84    @Override
85    public void close() {
86    }
87  }