HDDS-137. Cleanup Hdds-ozone CheckStyle Issues.

Contributed by Anu Engineer.
This commit is contained in:
Anu Engineer 2018-06-01 12:54:47 -07:00
parent 6b21a599fb
commit 19560bb704
6 changed files with 43 additions and 11 deletions

View File

@ -285,7 +285,8 @@ public class ContainerData {
*
* @return String Name.
*/
// TODO: check the ContainerCache class to see if we are using the ContainerID instead.
// TODO: check the ContainerCache class to see if
// we are using the ContainerID instead.
/*
public String getName() {
return getContainerID();

View File

@ -314,7 +314,8 @@ public class ContainerManagerImpl implements ContainerManager {
writeLock();
try {
if (containerMap.containsKey(containerData.getContainerID())) {
LOG.debug("container already exists. {}", containerData.getContainerID());
LOG.debug("container already exists. {}",
containerData.getContainerID());
throw new StorageContainerException("container already exists.",
CONTAINER_EXISTS);
}
@ -595,7 +596,8 @@ public class ContainerManagerImpl implements ContainerManager {
@Override
public void updateContainer(long containerID, ContainerData data,
boolean forceUpdate) throws StorageContainerException {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative.");
Preconditions.checkState(containerID >= 0,
"Container ID cannot be negative.");
Preconditions.checkNotNull(data, "Container data cannot be null");
FileOutputStream containerStream = null;
DigestOutputStream dos = null;
@ -711,7 +713,7 @@ public class ContainerManagerImpl implements ContainerManager {
}
/**
* Returns LifeCycle State of the container
* Returns LifeCycle State of the container.
* @param containerID - Id of the container
* @return LifeCycle State of the container
* @throws StorageContainerException

View File

@ -72,8 +72,10 @@ public class KeyManagerImpl implements KeyManager {
*/
@Override
public void putKey(KeyData data) throws IOException {
Preconditions.checkNotNull(data, "KeyData cannot be null for put operation.");
Preconditions.checkState(data.getContainerID() >= 0, "Container ID cannot be negative");
Preconditions.checkNotNull(data,
"KeyData cannot be null for put operation.");
Preconditions.checkState(data.getContainerID() >= 0,
"Container ID cannot be negative");
containerManager.readLock();
try {
// We are not locking the key manager since LevelDb serializes all actions
@ -169,8 +171,10 @@ public class KeyManagerImpl implements KeyManager {
public List<KeyData> listKey(
long containerID, long startLocalID, int count)
throws IOException {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
Preconditions.checkState(startLocalID >= 0, "startLocal ID cannot be negative");
Preconditions.checkState(containerID >= 0,
"Container ID cannot be negative");
Preconditions.checkState(startLocalID >= 0,
"startLocal ID cannot be negative");
Preconditions.checkArgument(count > 0,
"Count must be a positive number.");
ContainerData cData = containerManager.readContainer(containerID);

View File

@ -265,7 +265,8 @@ public class ContainerStateMachine extends BaseStateMachine {
Message message = runCommand(requestProto);
if (cmdType == ContainerProtos.Type.CreateContainer) {
long containerID =
requestProto.getCreateContainer().getContainerData().getContainerID();
requestProto.getCreateContainer()
.getContainerData().getContainerID();
createContainerFutureMap.remove(containerID).complete(message);
}
return CompletableFuture.completedFuture(message);

View File

@ -125,7 +125,8 @@ public final class ContainerCache extends LRUMap {
*/
public MetadataStore getDB(long containerID, String containerDBPath)
throws IOException {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative.");
Preconditions.checkState(containerID >= 0,
"Container ID cannot be negative.");
lock.lock();
try {
MetadataStore db = (MetadataStore) this.get(containerID);
@ -153,7 +154,8 @@ public final class ContainerCache extends LRUMap {
* @param containerID - ID of the container.
*/
public void removeDB(long containerID) {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative.");
Preconditions.checkState(containerID >= 0,
"Container ID cannot be negative.");
lock.lock();
try {
MetadataStore db = (MetadataStore)this.get(containerID);

View File

@ -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.
*
*/
/**
* SCM Testing and Mocking Utils.
*/
package org.apache.hadoop.ozone.container.common;