Skip to content

Commit 7b8b213

Browse files
kevinrr888ctubbsii
andauthored
Adds new accumulo command (apache#5073)
* Adds new accumulo command: Adds new `accumulo check-accumulo-properties` command which checks the provided Accumulo configuration file for errors. Only checks the file contents, and not any running instance, so useful for verifying config prior to init. Performs a subset of the checks that `accumulo check-server-config` does. Useful for (at least mostly) validating the `accumulo.properties` file without a running instance. Co-authored-by: Christopher Tubbs <ctubbsii@apache.org>
1 parent 78cbdbe commit 7b8b213

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.accumulo.server.conf;
20+
21+
import java.io.File;
22+
import java.io.IOException;
23+
24+
import org.apache.accumulo.core.conf.SiteConfiguration;
25+
import org.apache.accumulo.server.ServerDirs;
26+
import org.apache.accumulo.server.fs.VolumeManagerImpl;
27+
import org.apache.accumulo.start.spi.KeywordExecutable;
28+
import org.apache.hadoop.conf.Configuration;
29+
30+
import com.google.auto.service.AutoService;
31+
import com.google.common.base.Preconditions;
32+
33+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34+
35+
@AutoService(KeywordExecutable.class)
36+
public class CheckAccumuloProperties implements KeywordExecutable {
37+
38+
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "intentional user-provided path")
39+
public static void main(String[] args) throws IOException {
40+
Preconditions.checkArgument(args.length == 1,
41+
"Expected 1 argument (the properties file path), got " + args.length);
42+
var hadoopConfig = new Configuration();
43+
var siteConfig = SiteConfiguration.fromFile(new File(args[0])).build();
44+
45+
VolumeManagerImpl.get(siteConfig, hadoopConfig);
46+
new ServerDirs(siteConfig, hadoopConfig);
47+
}
48+
49+
@Override
50+
public String keyword() {
51+
return "check-accumulo-properties";
52+
}
53+
54+
@Override
55+
public String description() {
56+
return "Checks the provided Accumulo configuration file for errors. "
57+
+ "This only checks the contents of the file and not any running Accumulo system, "
58+
+ "so it can be used prior to init, but only performs a subset of the checks done by "
59+
+ (new CheckServerConfig().keyword());
60+
}
61+
62+
@Override
63+
public void execute(String[] args) throws Exception {
64+
main(args);
65+
}
66+
}

0 commit comments

Comments
 (0)