Skip to content
Merged
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
@@ -0,0 +1,61 @@
/*
* 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.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.hadoop.util.ThreadUtil;

import org.slf4j.LoggerFactory;

/**
* This class returns build information about Ratis projects.
*/
public class RatisVersionInfo {

private static final String RATIS_VERSION_PROPERTIES =
"ratis-version.properties";

private final Properties info = new Properties();

public RatisVersionInfo() {
try (InputStream is = ThreadUtil.getResourceAsStream(
getClass().getClassLoader(),
RATIS_VERSION_PROPERTIES)) {
info.load(is);
} catch (IOException ex) {
LoggerFactory.getLogger(getClass()).warn("Could not read " +
RATIS_VERSION_PROPERTIES, ex);
}
}

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

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

public String getBuildVersion() {
return getVersion() +
" from " + getRevision();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
*/
package org.apache.hadoop.hdds.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.annotation.InterfaceStability;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.ThreadUtil;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.slf4j.LoggerFactory;

/**
* This class returns build information about Hadoop components.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.annotation.InterfaceStability;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.util.ClassUtil;
import org.apache.hadoop.hdds.utils.HddsVersionInfo;
import org.apache.hadoop.hdds.utils.RatisVersionInfo;
import org.apache.hadoop.hdds.utils.VersionInfo;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.util.ClassUtil;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,6 +41,9 @@ public final class OzoneVersionInfo {
public static final VersionInfo OZONE_VERSION_INFO =
new VersionInfo(OzoneConsts.OZONE);

public static final RatisVersionInfo RATIS_VERSION_INFO =
new RatisVersionInfo();

private OzoneVersionInfo() {}

public static void main(String[] args) {
Expand Down Expand Up @@ -69,8 +74,10 @@ public static void main(String[] args) {
System.out.println(
"Compiled with protoc " + OZONE_VERSION_INFO.getProtocVersion());
System.out.println(
"From source with checksum " + OZONE_VERSION_INFO.getSrcChecksum()
+ "\n");
"From source with checksum " + OZONE_VERSION_INFO.getSrcChecksum());
System.out.println(
"With Apache Ratis: " + RATIS_VERSION_INFO.getBuildVersion());
System.out.println();
LOG.debug("This command was run using " +
ClassUtil.findContainingJar(OzoneVersionInfo.class));
HddsVersionInfo.main(args);
Expand Down