Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-965. Ozone: checkstyle improvements and code quality scripts. #457

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ public long getReplicatedMinCommitIndex() {
return minIndex.isPresent() ? minIndex.getAsLong() : 0;
}

private void getFailedServer(
Collection<RaftProtos.CommitInfoProto> commitInfos) {
for (RaftProtos.CommitInfoProto proto : commitInfos) {

}
}

@Override
public long watchForCommit(long index, long timeout)
Expand All @@ -217,7 +211,7 @@ public long watchForCommit(long index, long timeout)
.sendWatchAsync(index, RaftProtos.ReplicationLevel.ALL_COMMITTED);
RaftClientReply reply;
try {
reply = replyFuture.get(timeout, TimeUnit.MILLISECONDS);
replyFuture.get(timeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException toe) {
LOG.warn("3 way commit failed ", toe);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class BlockOutputStream extends OutputStream {
* @param watchTimeout watch timeout
* @param checksum checksum
*/
@SuppressWarnings("parameternumber")
public BlockOutputStream(BlockID blockID, String key,
XceiverClientManager xceiverClientManager, XceiverClientSpi xceiverClient,
String traceID, int chunkSize, long streamBufferFlushSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@

package org.apache.hadoop.hdds;

import com.google.common.base.Strings;
import com.google.common.net.HostAndPort;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.net.DNS;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.management.ObjectName;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -47,13 +31,26 @@
import java.util.Optional;
import java.util.TimeZone;

import static org.apache.hadoop.hdfs.DFSConfigKeys
.DFS_DATANODE_DNS_INTERFACE_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys
.DFS_DATANODE_DNS_NAMESERVER_KEY;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.metrics2.util.MBeans;
import org.apache.hadoop.net.DNS;
import org.apache.hadoop.net.NetUtils;

import com.google.common.base.Strings;
import com.google.common.net.HostAndPort;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_DNS_INTERFACE_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_DNS_NAMESERVER_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_HOST_NAME_KEY;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ENABLED;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ENABLED_DEFAULT;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* HDDS specific stateless utility functions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class HddsVersionProvider implements IVersionProvider {
@Override
public String[] getVersion() throws Exception {
String[] result = new String[] {
HddsVersionInfo.getBuildVersion()
HddsVersionInfo.HDDS_VERSION_INFO.getBuildVersion()
};
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ static void writeResponse(Configuration conf,
}
}

/**
* Exception for signal bad content type.
*/
public static class BadFormatException extends Exception {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class ContainerInfo implements Comparator<ContainerInfo>,
@JsonIgnore
private byte[] data;

@SuppressWarnings("parameternumber")
ContainerInfo(
long containerID,
HddsProtos.LifeCycleState state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.hdds.scm.pipeline;

import java.io.IOException;
import java.io.IOException;

/**
* Signals that a pipeline state is not recognized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* This class is the client-side translator to translate the requests made on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@
@InterfaceAudience.Public
@InterfaceStability.Stable
public class HddsVersionInfo {

private static final Logger LOG = LoggerFactory.getLogger(
HddsVersionInfo.class);

public static final HddsVersionInfo HDDS_VERSION_INFO =
new HddsVersionInfo("hdds");

private Properties info;

protected HddsVersionInfo(String component) {
info = new Properties();
String versionInfoFile = component + "-version-info.properties";
InputStream is = null;
try {
is = ThreadUtil.getResourceAsStream(HddsVersionInfo.class.getClassLoader(),
is = ThreadUtil.getResourceAsStream(
HddsVersionInfo.class.getClassLoader(),
versionInfoFile);
info.load(is);
} catch (IOException ex) {
Expand All @@ -57,127 +62,56 @@ protected HddsVersionInfo(String component) {
}
}

protected String _getVersion() {
protected String getVersion() {
return info.getProperty("version", "Unknown");
}

protected String _getRevision() {
protected String getRevision() {
return info.getProperty("revision", "Unknown");
}

protected String _getBranch() {
protected String getBranch() {
return info.getProperty("branch", "Unknown");
}

protected String _getDate() {
protected String getDate() {
return info.getProperty("date", "Unknown");
}

protected String _getUser() {
protected String getUser() {
return info.getProperty("user", "Unknown");
}

protected String _getUrl() {
protected String getUrl() {
return info.getProperty("url", "Unknown");
}

protected String _getSrcChecksum() {
protected String getSrcChecksum() {
return info.getProperty("srcChecksum", "Unknown");
}

protected String _getBuildVersion(){
return _getVersion() +
" from " + _getRevision() +
" by " + _getUser() +
" source checksum " + _getSrcChecksum();
public String getBuildVersion() {
return HDDS_VERSION_INFO.getVersion() +
" from " + HDDS_VERSION_INFO.getRevision() +
" by " + getUser() +
" source checksum " + getSrcChecksum();
}

protected String _getProtocVersion() {
protected String getProtocVersion() {
return info.getProperty("protocVersion", "Unknown");
}

private static final HddsVersionInfo HDDS_VERSION_INFO =
new HddsVersionInfo("hdds");
/**
* Get the HDDS version.
* @return the Hdds version string, eg. "0.6.3-dev"
*/
public static String getVersion() {
return HDDS_VERSION_INFO._getVersion();
}

/**
* Get the Git commit hash of the repository when compiled.
* @return the commit hash, eg. "18f64065d5db6208daf50b02c1b5ed4ee3ce547a"
*/
public static String getRevision() {
return HDDS_VERSION_INFO._getRevision();
}

/**
* Get the branch on which this originated.
* @return The branch name, e.g. "trunk" or "branches/branch-0.20"
*/
public static String getBranch() {
return HDDS_VERSION_INFO._getBranch();
}

/**
* The date that HDDS was compiled.
* @return the compilation date in unix date format
*/
public static String getDate() {
return HDDS_VERSION_INFO._getDate();
}

/**
* The user that compiled HDDS.
* @return the username of the user
*/
public static String getUser() {
return HDDS_VERSION_INFO._getUser();
}

/**
* Get the URL for the HDDS repository.
* @return the URL of the Hdds repository
*/
public static String getUrl() {
return HDDS_VERSION_INFO._getUrl();
}

/**
* Get the checksum of the source files from which HDDS was built.
* @return the checksum of the source files
*/
public static String getSrcChecksum() {
return HDDS_VERSION_INFO._getSrcChecksum();
}

/**
* Returns the buildVersion which includes version,
* revision, user and date.
* @return the buildVersion
*/
public static String getBuildVersion(){
return HDDS_VERSION_INFO._getBuildVersion();
}

/**
* Returns the protoc version used for the build.
* @return the protoc version
*/
public static String getProtocVersion(){
return HDDS_VERSION_INFO._getProtocVersion();
}

public static void main(String[] args) {
System.out.println("Using HDDS " + getVersion());
System.out.println("Source code repository " + getUrl() + " -r " +
getRevision());
System.out.println("Compiled by " + getUser() + " on " + getDate());
System.out.println("Compiled with protoc " + getProtocVersion());
System.out.println("From source with checksum " + getSrcChecksum());
System.out.println("Using HDDS " + HDDS_VERSION_INFO.getVersion());
System.out.println(
"Source code repository " + HDDS_VERSION_INFO.getUrl() + " -r " +
HDDS_VERSION_INFO.getRevision());
System.out.println("Compiled by " + HDDS_VERSION_INFO.getUser() + " on "
+ HDDS_VERSION_INFO.getDate());
System.out.println(
"Compiled with protoc " + HDDS_VERSION_INFO.getProtocVersion());
System.out.println(
"From source with checksum " + HDDS_VERSION_INFO.getSrcChecksum());
LOG.debug("This command was run using " +
ClassUtil.findContainingJar(HddsVersionInfo.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,27 @@

package org.apache.hadoop.utils;

import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.io.IOException;
import java.util.Optional;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.OzoneConfigKeys;

import com.google.common.annotations.VisibleForTesting;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_METADATA_STORE_IMPL_LEVELDB;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_METADATA_STORE_IMPL_ROCKSDB;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_METADATA_STORE_ROCKSDB_STATISTICS;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_METADATA_STORE_ROCKSDB_STATISTICS_DEFAULT;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_METADATA_STORE_ROCKSDB_STATISTICS_OFF;
import org.iq80.leveldb.Options;
import org.rocksdb.BlockBasedTableConfig;
import org.rocksdb.Statistics;
import org.rocksdb.StatsLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.util.Optional;
import java.util.function.Supplier;

import static org.apache.hadoop.ozone.OzoneConfigKeys
.OZONE_METADATA_STORE_IMPL_LEVELDB;
import static org.apache.hadoop.ozone.OzoneConfigKeys
.OZONE_METADATA_STORE_IMPL_ROCKSDB;
import static org.apache.hadoop.ozone.OzoneConfigKeys
.OZONE_METADATA_STORE_ROCKSDB_STATISTICS;
import static org.apache.hadoop.ozone.OzoneConfigKeys
.OZONE_METADATA_STORE_ROCKSDB_STATISTICS_DEFAULT;
import static org.apache.hadoop.ozone.OzoneConfigKeys
.OZONE_METADATA_STORE_ROCKSDB_STATISTICS_OFF;

/**
* Builder for metadata store.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* Dispatcher sends ContainerCommandRequests to Handler. Each Container Type
* should have an implementation for Handler.
*/
@SuppressWarnings("visibilitymodifier")
public abstract class Handler {

protected final Configuration conf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public EndpointStateMachine.EndPointStates call() throws Exception {
Preconditions.checkNotNull(clusterId, "Reply from SCM: clusterId " +
"cannot be null");

// If version file does not exist create version file and also set scmId
// If version file does not exist
// create version file and also set scmId

for (Map.Entry<String, HddsVolume> entry : volumeMap.entrySet()) {
HddsVolume hddsVolume = entry.getValue();
Expand Down
Loading