diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java index 665618cf24d..040f08067dd 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsConfigKeys.java @@ -1,6 +1,6 @@ package org.apache.hadoop.hdds; -public class HddsConfigKeys { +public final class HddsConfigKeys { private HddsConfigKeys() { } } diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java index a0b5c47eeb5..48c6dce4240 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java @@ -48,7 +48,7 @@ import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ENABLED_DEFAULT; /** * HDDS specific stateless utility functions. */ -public class HddsUtils { +public final class HddsUtils { private static final Logger LOG = LoggerFactory.getLogger(HddsUtils.class); diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/HddsConfServlet.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/HddsConfServlet.java index 068e41ff3bd..b8d0b248470 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/HddsConfServlet.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/HddsConfServlet.java @@ -53,7 +53,8 @@ public class HddsConfServlet extends HttpServlet { private static final String COMMAND = "cmd"; private static final OzoneConfiguration OZONE_CONFIG = new OzoneConfiguration(); - transient Logger LOG = LoggerFactory.getLogger(HddsConfServlet.class); + private static final transient Logger LOG = + LoggerFactory.getLogger(HddsConfServlet.class); /** @@ -152,25 +153,25 @@ public class HddsConfServlet extends HttpServlet { Configuration config = getOzoneConfig(); switch (cmd) { - case "getOzoneTags": - out.write(gson.toJson(config.get("ozone.system.tags").split(","))); - break; - case "getPropertyByTag": - String tags = request.getParameter("tags"); - Map propMap = new HashMap<>(); + case "getOzoneTags": + out.write(gson.toJson(config.get("ozone.system.tags").split(","))); + break; + case "getPropertyByTag": + String tags = request.getParameter("tags"); + Map propMap = new HashMap<>(); - for (String tag : tags.split(",")) { - if (config.isPropertyTag(tag)) { - Properties properties = config.getAllPropertiesByTag(tag); - propMap.put(tag, properties); - } else { - LOG.debug("Not a valid tag" + tag); - } + for (String tag : tags.split(",")) { + if (config.isPropertyTag(tag)) { + Properties properties = config.getAllPropertiesByTag(tag); + propMap.put(tag, properties); + } else { + LOG.debug("Not a valid tag" + tag); } - out.write(gson.toJsonTree(propMap).toString()); - break; - default: - throw new IllegalArgumentException(cmd + " is not a valid command."); + } + out.write(gson.toJsonTree(propMap).toString()); + break; + default: + throw new IllegalArgumentException(cmd + " is not a valid command."); } } diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/package-info.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/package-info.java new file mode 100644 index 00000000000..d13dcb1f6c4 --- /dev/null +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/package-info.java @@ -0,0 +1,18 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hdds.scm.container; diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java new file mode 100644 index 00000000000..e5812c00d94 --- /dev/null +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/web/utils/package-info.java @@ -0,0 +1,19 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.web.utils; diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/HddsServerUtil.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/HddsServerUtil.java index 956aef26d9c..c734d9b03f6 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/HddsServerUtil.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/HddsServerUtil.java @@ -55,7 +55,10 @@ import static org.apache.hadoop.hdds.server.ServerUtils.sanitizeUserArgs; /** * Hdds stateless helper functions for server side components. */ -public class HddsServerUtil { +public final class HddsServerUtil { + + private HddsServerUtil() { + } private static final Logger LOG = LoggerFactory.getLogger( HddsServerUtil.class); diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/package-info.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/package-info.java new file mode 100644 index 00000000000..590546896a4 --- /dev/null +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/hdds/scm/package-info.java @@ -0,0 +1,19 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hdds.scm; diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java index ce7ca6f87ed..fa4187a254a 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java @@ -227,7 +227,7 @@ public class HddsDatanodeService implements ServicePlugin { return new HddsDatanodeService(conf); } - public static void main(String args[]) { + public static void main(String[] args) { try { StringUtils.startupShutdownMessage(HddsDatanodeService.class, args, LOG); HddsDatanodeService hddsDatanodeService = diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java index b0286b96d40..457c417b104 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ChunkManagerImpl.java @@ -107,6 +107,8 @@ public class ChunkManagerImpl implements ChunkManager { containerManager.incrWriteCount(containerName); containerManager.incrWriteBytes(containerName, info.getLen()); break; + default: + throw new IOException("Can not identify write operation."); } } catch (ExecutionException | NoSuchAlgorithmException | IOException e) { LOG.error("write data failed. error: {}", e); diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/Dispatcher.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/Dispatcher.java index 1c6e39ccdfc..d319565012e 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/Dispatcher.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/Dispatcher.java @@ -464,7 +464,7 @@ public class Dispatcher implements ContainerDispatcher { byte[] data = null; if (msg.getWriteChunk().getStage() == ContainerProtos.Stage.WRITE_DATA || msg.getWriteChunk().getStage() == ContainerProtos.Stage.COMBINED) { - data = msg.getWriteChunk().getData().toByteArray(); + data = msg.getWriteChunk().getData().toByteArray(); metrics.incContainerBytesStats(Type.WriteChunk, data.length); } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocol/commands/RegisteredCommand.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocol/commands/RegisteredCommand.java index 593b84b1eae..69f2c186fa9 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocol/commands/RegisteredCommand.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocol/commands/RegisteredCommand.java @@ -195,13 +195,13 @@ public class RegisteredCommand extends /** * sets the hostname. */ - public Builder setHostname(String hostname) { - this.hostname = hostname; + public Builder setHostname(String host) { + this.hostname = host; return this; } - public Builder setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; + public Builder setIpAddress(String ipAddr) { + this.ipAddress = ipAddr; return this; } diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/package-info.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/package-info.java new file mode 100644 index 00000000000..378a8f389cf --- /dev/null +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/protocolPB/package-info.java @@ -0,0 +1,19 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.protocolPB; diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ContainerTestUtils.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ContainerTestUtils.java index 9db792bc7b6..923440e2382 100644 --- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ContainerTestUtils.java +++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ContainerTestUtils.java @@ -34,7 +34,7 @@ import java.net.InetSocketAddress; /** * Helper utility to test containers. */ -public class ContainerTestUtils { +public final class ContainerTestUtils { private ContainerTestUtils() { } diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java index 2cf5b351a9a..a0e78dcc7fd 100644 --- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java +++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java @@ -32,7 +32,7 @@ import java.net.InetSocketAddress; /** * Generic utilities for all HDDS/Ozone servers. */ -public class ServerUtils { +public final class ServerUtils { private static final Logger LOG = LoggerFactory.getLogger( ServerUtils.class); diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestUtils.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestUtils.java index 13a78f65aa0..40d8a690272 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestUtils.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestUtils.java @@ -27,7 +27,7 @@ import java.util.UUID; /** * Stateless helper functions to handler scm/datanode connection. */ -public class TestUtils { +public final class TestUtils { private TestUtils() { } diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestContainerPlacement.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestContainerPlacement.java index 0801c255a72..651b77618e4 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestContainerPlacement.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/TestContainerPlacement.java @@ -89,8 +89,8 @@ public class TestContainerPlacement { capacityPlacer.chooseDatanodes(nodesRequired, containerSize); assertEquals(nodesRequired, nodesCapacity.size()); - List nodesRandom = randomPlacer.chooseDatanodes(nodesRequired, - containerSize); + List nodesRandom = + randomPlacer.chooseDatanodes(nodesRequired, containerSize); // One fifth of all calls are delete if (x % 5 == 0) { diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/OzoneCommandHandler.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/OzoneCommandHandler.java index f9b8fcd6350..641dd0ea9a7 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/OzoneCommandHandler.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/OzoneCommandHandler.java @@ -59,7 +59,7 @@ public abstract class OzoneCommandHandler { this.err = err; } - public void logOut(String msg, String ... variable) { + public void logOut(String msg, String... variable) { this.out.println(String.format(msg, variable)); } diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java index 34553ed371d..8d71d00551e 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SCMCLI.java @@ -148,8 +148,9 @@ public class SCMCLI extends OzoneBaseCLI { } private static void addTopLevelOptions(Options options) { - Option containerOps = new Option( - ContainerCommandHandler.CONTAINER_CMD, false, "Container related options"); + Option containerOps = + new Option(ContainerCommandHandler.CONTAINER_CMD, false, + "Container related options"); options.addOption(containerOps); // TODO : add pool, node and pipeline commands. } diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CloseContainerHandler.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CloseContainerHandler.java index ba420230fe3..9a44525461b 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CloseContainerHandler.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CloseContainerHandler.java @@ -66,8 +66,9 @@ public class CloseContainerHandler extends OzoneCommandHandler { Options options = new Options(); addOptions(options); HelpFormatter helpFormatter = new HelpFormatter(); - helpFormatter.printHelp(SCMCLI.CMD_WIDTH, "hdfs scm -container -close