89c629137d1830a99d1925755522daef1a3ae34f
[fluo-recipes.git] / modules / accumulo / src / main / java / io / fluo / recipes / accumulo / cmds / CompactTransient.java
1 /*
2 * Copyright 2015 Fluo authors (see AUTHORS)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
12 * the License.
13 */
14
15 package io.fluo.recipes.accumulo.cmds;
16
17 import javax.inject.Inject;
18
19 import io.fluo.api.config.FluoConfiguration;
20 import io.fluo.recipes.accumulo.ops.TableOperations;
21
22 public class CompactTransient {
23
24 // when run with fluo exec command, the applications fluo config will be injected
25 @Inject
26 private static FluoConfiguration fluoConfig;
27
28 public static void main(String[] args) throws Exception {
29
30 if ((args.length == 1 && args[0].startsWith("-h")) || (args.length > 2)) {
31 System.out
32 .println("Usage : " + CompactTransient.class.getName() + " [<interval> [<count>]] ");
33
34 System.exit(-1);
35 }
36
37 int interval = 0;
38 int count = 1;
39
40 if (args.length >= 1) {
41 interval = Integer.parseInt(args[0]);
42 if (args.length == 2) {
43 count = Integer.parseInt(args[1]);
44 } else {
45 count = Integer.MAX_VALUE;
46 }
47 }
48
49 System.out.print("Compacting transient ranges ... ");
50 TableOperations.compactTransient(fluoConfig);
51 System.out.println("done.");
52 count--;
53
54 while (count > 0) {
55 Thread.sleep(interval * 1000);
56 System.out.print("Compacting transient ranges ... ");
57 TableOperations.compactTransient(fluoConfig);
58 System.out.println("done.");
59 count--;
60 }
61 }
62 }