From 9502b47bd2a3cf32edae635293169883c2914475 Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Tue, 29 May 2018 09:54:06 -0700 Subject: [PATCH] HDDS-125. Cleanup HDDS CheckStyle issues. Contributed by Anu Engineer. --- .../hdds/scm/block/BlockManagerImpl.java | 1 - .../hdds/scm/block/DeletedBlockLogImpl.java | 2 +- .../hdds/scm/container/ContainerMapping.java | 6 +- .../scm/container/ContainerStateManager.java | 24 +++---- .../hadoop/hdds/scm/container/Mapping.java | 9 ++- .../scm/node/SCMNodeStorageStatMXBean.java | 4 +- .../hdds/scm/node/SCMNodeStorageStatMap.java | 19 +++--- .../hdds/scm/node/StorageReportResult.java | 8 +-- .../scm/node/states/Node2ContainerMap.java | 2 +- .../hdds/scm/pipelines/PipelineSelector.java | 5 +- .../scm/server/StorageContainerManager.java | 3 +- ...TestStorageContainerManagerHttpServer.java | 1 - .../hadoop/hdds/scm/block/package-info.java | 23 +++++++ .../scm/container/TestContainerMapping.java | 12 ++-- .../scm/container/closer/package-info.java | 22 +++++++ .../hdds/scm/container/package-info.java | 22 +++++++ .../scm/container/states/package-info.java | 22 +++++++ .../hadoop/hdds/scm/node/TestNodeManager.java | 66 +++++++++---------- .../scm/node/TestSCMNodeStorageStatMap.java | 32 +++++---- .../hadoop/hdds/scm/node/package-info.java | 22 +++++++ .../ozone/container/common/TestEndPoint.java | 2 - .../ozone/container/common/package-info.java | 22 +++++++ .../container/placement/package-info.java | 22 +++++++ .../replication/TestContainerSupervisor.java | 7 +- 24 files changed, 263 insertions(+), 95 deletions(-) create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/package-info.java create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/closer/package-info.java create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/package-info.java create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/states/package-info.java create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/package-info.java create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/package-info.java create mode 100644 hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/package-info.java diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java index 5a98e8537f..d17d6c07f0 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java @@ -41,7 +41,6 @@ import java.util.List; import java.util.Map; import java.util.Random; -import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java index cabcb46e1d..cedc506035 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java @@ -190,7 +190,7 @@ public void incrementCount(List txIDs) throws IOException { try { for(Long txID : txIDs) { try { - byte [] deleteBlockBytes = + byte[] deleteBlockBytes = deletedStore.get(Longs.toByteArray(txID)); if (deleteBlockBytes == null) { LOG.warn("Delete txID {} not found", txID); diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java index e569874aaf..2d886215ba 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerMapping.java @@ -152,7 +152,8 @@ public ContainerInfo getContainer(final long containerID) throws ContainerInfo containerInfo; lock.lock(); try { - byte[] containerBytes = containerStore.get(Longs.toByteArray(containerID)); + byte[] containerBytes = containerStore.get( + Longs.toByteArray(containerID)); if (containerBytes == null) { throw new SCMException( "Specified key does not exist. key : " + containerID, @@ -229,7 +230,8 @@ public ContainerInfo allocateContainer( containerStateManager.allocateContainer( pipelineSelector, type, replicationFactor, owner); - byte[] containerIDBytes = Longs.toByteArray(containerInfo.getContainerID()); + byte[] containerIDBytes = Longs.toByteArray( + containerInfo.getContainerID()); containerStore.put(containerIDBytes, containerInfo.getProtobuf() .toByteArray()); } finally { diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java index f11a50cf71..4895b786f9 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java @@ -230,18 +230,18 @@ public List getAllContainers() { * * Container State Flow: * - * [ALLOCATED]------->[CREATING]--------->[OPEN]---------->[CLOSING]------->[CLOSED] - * (CREATE) | (CREATED) (FINALIZE) (CLOSE) | - * | | - * | | - * |(TIMEOUT) (DELETE)| - * | | - * +------------------> [DELETING] <-------------------+ - * | - * | - * (CLEANUP)| - * | - * [DELETED] + * [ALLOCATED]---->[CREATING]------>[OPEN]-------->[CLOSING]------->[CLOSED] + * (CREATE) | (CREATED) (FINALIZE) (CLOSE) | + * | | + * | | + * |(TIMEOUT) (DELETE)| + * | | + * +-------------> [DELETING] <-------------------+ + * | + * | + * (CLEANUP)| + * | + * [DELETED] */ private void initializeStateMachine() { stateMachine.addTransition(LifeCycleState.ALLOCATED, diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/Mapping.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/Mapping.java index 61dee2b35d..f5601740c5 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/Mapping.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/Mapping.java @@ -45,7 +45,8 @@ public interface Mapping extends Closeable { * The max size of the searching range cannot exceed the * value of count. * - * @param startContainerID start containerID, >=0, start searching at the head if 0. + * @param startContainerID start containerID, >=0, + * start searching at the head if 0. * @param count count must be >= 0 * Usually the count will be replace with a very big * value instead of being unlimited in case the db is very big. @@ -53,7 +54,8 @@ public interface Mapping extends Closeable { * @return a list of container. * @throws IOException */ - List listContainer(long startContainerID, int count) throws IOException; + List listContainer(long startContainerID, int count) + throws IOException; /** * Allocates a new container for a given keyName and replication factor. @@ -64,7 +66,8 @@ public interface Mapping extends Closeable { * @throws IOException */ ContainerInfo allocateContainer(HddsProtos.ReplicationType type, - HddsProtos.ReplicationFactor replicationFactor, String owner) throws IOException; + HddsProtos.ReplicationFactor replicationFactor, String owner) + throws IOException; /** * Deletes a container from SCM. diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMXBean.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMXBean.java index d81ff0f3cb..32ecbad50a 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMXBean.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMXBean.java @@ -31,7 +31,7 @@ @InterfaceAudience.Private public interface SCMNodeStorageStatMXBean { /** - * Get the capacity of the dataNode + * Get the capacity of the dataNode. * @param datanodeID Datanode Id * @return long */ @@ -52,7 +52,7 @@ public interface SCMNodeStorageStatMXBean { long getUsedSpace(UUID datanodeId); /** - * Returns the total capacity of all dataNodes + * Returns the total capacity of all dataNodes. * @return long */ long getTotalCapacity(); diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMap.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMap.java index f8ad2af852..fa423bb6e7 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMap.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeStorageStatMap.java @@ -56,7 +56,7 @@ public class SCMNodeStorageStatMap implements SCMNodeStorageStatMXBean { // NodeStorageInfo MXBean private ObjectName scmNodeStorageInfoBean; /** - * constructs the scmNodeStorageReportMap object + * constructs the scmNodeStorageReportMap object. */ public SCMNodeStorageStatMap(OzoneConfiguration conf) { // scmNodeStorageReportMap = new ConcurrentHashMap<>(); @@ -73,6 +73,9 @@ public SCMNodeStorageStatMap(OzoneConfiguration conf) { HDDS_DATANODE_STORAGE_UTILIZATION_CRITICAL_THRESHOLD_DEFAULT); } + /** + * Enum that Describes what we should do at various thresholds. + */ public enum UtilizationThreshold { NORMAL, WARN, CRITICAL; } @@ -107,8 +110,8 @@ public List getDatanodeList( * @param datanodeID -- Datanode UUID * @param report - set if StorageReports. */ - public void insertNewDatanode(UUID datanodeID, Set report) - throws SCMException { + public void insertNewDatanode(UUID datanodeID, + Set report) throws SCMException { Preconditions.checkNotNull(report); Preconditions.checkState(report.size() != 0); Preconditions.checkNotNull(datanodeID); @@ -142,8 +145,8 @@ private void unregisterMXBean() { * @throws SCMException - if we don't know about this datanode, for new DN * use insertNewDatanode. */ - public void updateDatanodeMap(UUID datanodeID, Set report) - throws SCMException { + public void updateDatanodeMap(UUID datanodeID, + Set report) throws SCMException { Preconditions.checkNotNull(datanodeID); Preconditions.checkNotNull(report); Preconditions.checkState(report.size() != 0); @@ -301,7 +304,7 @@ public long getTotalFreeSpace() { } /** - * removes the dataNode from scmNodeStorageReportMap + * removes the dataNode from scmNodeStorageReportMap. * @param datanodeID * @throws SCMException in case the dataNode is not found in the map. */ @@ -339,11 +342,11 @@ private double truncateDecimals(double value) { } /** - * get the scmUsed ratio + * get the scmUsed ratio. */ public double getScmUsedratio(long scmUsed, long capacity) { double scmUsedRatio = - truncateDecimals (scmUsed / (double) capacity); + truncateDecimals(scmUsed / (double) capacity); return scmUsedRatio; } /** diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StorageReportResult.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StorageReportResult.java index 3436e7794d..0b63ceb578 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StorageReportResult.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StorageReportResult.java @@ -69,14 +69,14 @@ public ReportResultBuilder setStatus( } public ReportResultBuilder setFullVolumeSet( - Set fullVolumes) { - this.fullVolumes = fullVolumes; + Set fullVolumesSet) { + this.fullVolumes = fullVolumesSet; return this; } public ReportResultBuilder setFailedVolumeSet( - Set failedVolumes) { - this.failedVolumes = failedVolumes; + Set failedVolumesSet) { + this.failedVolumes = failedVolumesSet; return this; } diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/Node2ContainerMap.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/Node2ContainerMap.java index f850e7a298..1960604906 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/Node2ContainerMap.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/states/Node2ContainerMap.java @@ -92,7 +92,7 @@ public void updateDatanodeMap(UUID datanodeID, Set containers) } /** - * Removes datanode Entry from the map + * Removes datanode Entry from the map. * @param datanodeID - Datanode ID. */ public void removeDatanode(UUID datanodeID) { diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java index d29bb84c78..2e56043c6b 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java @@ -170,8 +170,9 @@ public Pipeline getReplicationPipeline(ReplicationType replicationType, throws IOException { PipelineManager manager = getPipelineManager(replicationType); Preconditions.checkNotNull(manager, "Found invalid pipeline manager"); - LOG.debug("Getting replication pipeline forReplicationType {} : ReplicationFactor {}", - replicationType.toString(), replicationFactor.toString()); + LOG.debug("Getting replication pipeline forReplicationType {} :" + + " ReplicationFactor {}", replicationType.toString(), + replicationFactor.toString()); return manager. getPipeline(replicationFactor, replicationType); } diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java index 0fd6843d35..78f13cb47c 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java @@ -45,7 +45,6 @@ import org.apache.hadoop.hdds.server.ServiceRuntimeInfoImpl; import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.io.IOUtils; -import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.util.MBeans; @@ -87,7 +86,7 @@ * create a container, which then can be used to store data. */ @InterfaceAudience.LimitedPrivate({"HDFS", "CBLOCK", "OZONE", "HBASE"}) -public class StorageContainerManager extends ServiceRuntimeInfoImpl +public final class StorageContainerManager extends ServiceRuntimeInfoImpl implements SCMMXBean { private static final Logger LOG = LoggerFactory diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java index 0dbb7c138a..d9e1425517 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/TestStorageContainerManagerHttpServer.java @@ -39,7 +39,6 @@ import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.Arrays; diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/package-info.java new file mode 100644 index 0000000000..a67df6982a --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + * + */ + +/** + * Make checkstyle happy. + * */ +package org.apache.hadoop.hdds.scm.block; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerMapping.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerMapping.java index a27068bb33..f318316a08 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerMapping.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestContainerMapping.java @@ -216,8 +216,10 @@ public void testFullContainerReport() throws IOException { mapping.processContainerReports(crBuilder.build()); - ContainerInfo updatedContainer = mapping.getContainer(info.getContainerID()); - Assert.assertEquals(100000000L, updatedContainer.getNumberOfKeys()); + ContainerInfo updatedContainer = + mapping.getContainer(info.getContainerID()); + Assert.assertEquals(100000000L, + updatedContainer.getNumberOfKeys()); Assert.assertEquals(2000000000L, updatedContainer.getUsedBytes()); } @@ -251,8 +253,10 @@ public void testContainerCloseWithContainerReport() throws IOException { mapping.processContainerReports(crBuilder.build()); - ContainerInfo updatedContainer = mapping.getContainer(info.getContainerID()); - Assert.assertEquals(500000000L, updatedContainer.getNumberOfKeys()); + ContainerInfo updatedContainer = + mapping.getContainer(info.getContainerID()); + Assert.assertEquals(500000000L, + updatedContainer.getNumberOfKeys()); Assert.assertEquals(5368705120L, updatedContainer.getUsedBytes()); NavigableSet pendingCloseContainers = mapping.getStateManager() .getMatchingContainerIDs( diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/closer/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/closer/package-info.java new file mode 100644 index 0000000000..2f35719816 --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/closer/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + * + */ +/** + * Make CheckStyle happy. + */ +package org.apache.hadoop.hdds.scm.container.closer; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/package-info.java new file mode 100644 index 0000000000..f93aea66e7 --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + * + */ +/** + * Make CheckStyle Happy. + */ +package org.apache.hadoop.hdds.scm.container; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/states/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/states/package-info.java new file mode 100644 index 0000000000..795dfc1e1b --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/states/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + * + */ +/** + * Make CheckStyle Happy. + */ +package org.apache.hadoop.hdds.scm.container.states; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java index 36e796f8cb..de87e50e1f 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeManager.java @@ -510,42 +510,42 @@ public void testScmCheckForErrorOnNullDatanodeDetails() throws IOException, * @throws InterruptedException * @throws TimeoutException */ + /** + * These values are very important. Here is what it means so you don't + * have to look it up while reading this code. + * + * OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL - This the frequency of the + * HB processing thread that is running in the SCM. This thread must run + * for the SCM to process the Heartbeats. + * + * OZONE_SCM_HEARTBEAT_INTERVAL - This is the frequency at which + * datanodes will send heartbeats to SCM. Please note: This is the only + * config value for node manager that is specified in seconds. We don't + * want SCM heartbeat resolution to be more than in seconds. + * In this test it is not used, but we are forced to set it because we + * have validation code that checks Stale Node interval and Dead Node + * interval is larger than the value of + * OZONE_SCM_HEARTBEAT_INTERVAL. + * + * OZONE_SCM_STALENODE_INTERVAL - This is the time that must elapse + * from the last heartbeat for us to mark a node as stale. In this test + * we set that to 3. That is if a node has not heartbeat SCM for last 3 + * seconds we will mark it as stale. + * + * OZONE_SCM_DEADNODE_INTERVAL - This is the time that must elapse + * from the last heartbeat for a node to be marked dead. We have an + * additional constraint that this must be at least 2 times bigger than + * Stale node Interval. + * + * With these we are trying to explore the state of this cluster with + * various timeouts. Each section is commented so that you can keep + * track of the state of the cluster nodes. + * + */ + @Test public void testScmClusterIsInExpectedState1() throws IOException, InterruptedException, TimeoutException { - /** - * These values are very important. Here is what it means so you don't - * have to look it up while reading this code. - * - * OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL - This the frequency of the - * HB processing thread that is running in the SCM. This thread must run - * for the SCM to process the Heartbeats. - * - * OZONE_SCM_HEARTBEAT_INTERVAL - This is the frequency at which - * datanodes will send heartbeats to SCM. Please note: This is the only - * config value for node manager that is specified in seconds. We don't - * want SCM heartbeat resolution to be more than in seconds. - * In this test it is not used, but we are forced to set it because we - * have validation code that checks Stale Node interval and Dead Node - * interval is larger than the value of - * OZONE_SCM_HEARTBEAT_INTERVAL. - * - * OZONE_SCM_STALENODE_INTERVAL - This is the time that must elapse - * from the last heartbeat for us to mark a node as stale. In this test - * we set that to 3. That is if a node has not heartbeat SCM for last 3 - * seconds we will mark it as stale. - * - * OZONE_SCM_DEADNODE_INTERVAL - This is the time that must elapse - * from the last heartbeat for a node to be marked dead. We have an - * additional constraint that this must be at least 2 times bigger than - * Stale node Interval. - * - * With these we are trying to explore the state of this cluster with - * various timeouts. Each section is commented so that you can keep - * track of the state of the cluster nodes. - * - */ - OzoneConfiguration conf = getConf(); conf.setTimeDuration(OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 100, MILLISECONDS); diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeStorageStatMap.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeStorageStatMap.java index 571de77986..b8244127b2 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeStorageStatMap.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeStorageStatMap.java @@ -42,11 +42,14 @@ import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; +/** + * Test Node Storage Map. + */ public class TestSCMNodeStorageStatMap { private final static int DATANODE_COUNT = 100; - final long capacity = 10L * OzoneConsts.GB; - final long used = 2L * OzoneConsts.GB; - final long remaining = capacity - used; + private final long capacity = 10L * OzoneConsts.GB; + private final long used = 2L * OzoneConsts.GB; + private final long remaining = capacity - used; private static OzoneConfiguration conf = new OzoneConfiguration(); private final Map> testData = new ConcurrentHashMap<>(); @@ -59,9 +62,10 @@ private void generateData() { UUID dnId = UUID.randomUUID(); Set reportSet = new HashSet<>(); String path = GenericTestUtils.getTempPath( - TestSCMNodeStorageStatMap.class.getSimpleName() + "-" + Integer - .toString(dnIndex)); - StorageLocationReport.Builder builder = StorageLocationReport.newBuilder(); + TestSCMNodeStorageStatMap.class.getSimpleName() + "-" + + Integer.toString(dnIndex)); + StorageLocationReport.Builder builder = + StorageLocationReport.newBuilder(); builder.setStorageType(StorageType.DISK).setId(dnId.toString()) .setStorageLocation(path).setScmUsed(used).setRemaining(remaining) .setCapacity(capacity).setFailed(false); @@ -139,12 +143,12 @@ public void testProcessNodeReportCheckOneNode() throws IOException { String path = GenericTestUtils.getRandomizedTempPath().concat("/" + storageId); StorageLocationReport report = reportSet.iterator().next(); - long capacity = report.getCapacity(); - long used = report.getScmUsed(); - long remaining = report.getRemaining(); + long reportCapacity = report.getCapacity(); + long reportScmUsed = report.getScmUsed(); + long reportRemaining = report.getRemaining(); List reports = TestUtils - .createStorageReport(capacity, used, remaining, path, null, storageId, - 1); + .createStorageReport(reportCapacity, reportScmUsed, reportRemaining, + path, null, storageId, 1); StorageReportResult result = map.processNodeReport(key, TestUtils.createNodeReport(reports)); Assert.assertEquals(result.getStatus(), @@ -158,7 +162,7 @@ public void testProcessNodeReportCheckOneNode() throws IOException { SCMNodeStorageStatMap.ReportStatus.ALL_IS_WELL); reportList.add(TestUtils - .createStorageReport(capacity, capacity, 0, path, null, + .createStorageReport(reportCapacity, reportCapacity, 0, path, null, UUID.randomUUID().toString(), 1).get(0)); result = map.processNodeReport(key, TestUtils.createNodeReport(reportList)); Assert.assertEquals(result.getStatus(), @@ -166,8 +170,8 @@ public void testProcessNodeReportCheckOneNode() throws IOException { // Mark a disk failed SCMStorageReport srb2 = SCMStorageReport.newBuilder() .setStorageUuid(UUID.randomUUID().toString()) - .setStorageLocation(srb.getStorageLocation()).setScmUsed(capacity) - .setCapacity(capacity).setRemaining(0).setFailed(true).build(); + .setStorageLocation(srb.getStorageLocation()).setScmUsed(reportCapacity) + .setCapacity(reportCapacity).setRemaining(0).setFailed(true).build(); reportList.add(srb2); nrb.addAllStorageReport(reportList); result = map.processNodeReport(key, nrb.addStorageReport(srb).build()); diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/package-info.java new file mode 100644 index 0000000000..dfd8397771 --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + * + */ +/** + * Make CheckStyle Happy. + */ +package org.apache.hadoop.hdds.scm.node; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java index e82dc98155..1d92cdc297 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/TestEndPoint.java @@ -32,8 +32,6 @@ .StorageContainerDatanodeProtocolProtos.ContainerReportsResponseProto; import org.apache.hadoop.hdds.protocol.proto .StorageContainerDatanodeProtocolProtos.SCMHeartbeatResponseProto; -import org.apache.hadoop.hdds.protocol.proto - .StorageContainerDatanodeProtocolProtos.SCMNodeReport; import org.apache.hadoop.hdds.protocol.proto .StorageContainerDatanodeProtocolProtos.SCMRegisteredCmdResponseProto; import org.apache.hadoop.hdds.protocol.proto diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/package-info.java new file mode 100644 index 0000000000..da2ae843e1 --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/common/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + * + */ +/** + * Make CheckStyle Happy. + */ +package org.apache.hadoop.ozone.container.common; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/package-info.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/package-info.java new file mode 100644 index 0000000000..ddd751c379 --- /dev/null +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/placement/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + * + */ +/** + * Make CheckStyle Happy. + */ +package org.apache.hadoop.ozone.container.placement; \ No newline at end of file diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/replication/TestContainerSupervisor.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/replication/TestContainerSupervisor.java index 01f70b1628..e197886e00 100644 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/replication/TestContainerSupervisor.java +++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/ozone/container/replication/TestContainerSupervisor.java @@ -202,8 +202,8 @@ public void testDetectOverReplica() throws TimeoutException, ppool.handleContainerReport(reportsProto); } - clist = datanodeStateManager.getContainerReport(wayOverReplicatedContainerID, - ppool.getPool().getPoolName(), 7); + clist = datanodeStateManager.getContainerReport( + wayOverReplicatedContainerID, ppool.getPool().getPoolName(), 7); for (ContainerReportsRequestProto reportsProto : clist) { ppool.handleContainerReport(reportsProto); @@ -264,7 +264,8 @@ public void testAddingNewPoolWorks() "PoolNew", 1); containerSupervisor.handleContainerReport(clist.get(0)); GenericTestUtils.waitFor(() -> - inProgressLog.getOutput().contains(Long.toString(newContainerID)) && inProgressLog + inProgressLog.getOutput() + .contains(Long.toString(newContainerID)) && inProgressLog .getOutput().contains(id.getUuidString()), 200, 10 * 1000); } finally {