Skip to content
Merged
Changes from 1 commit
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
75 changes: 31 additions & 44 deletions common/src/main/scala/org/apache/comet/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package org.apache
import java.util.Properties

import org.apache.arrow.memory.RootAllocator
import org.apache.spark.internal.Logging

package object comet {

Expand All @@ -39,60 +40,46 @@ package object comet {
* benchmarking software to provide the source revision and repository. In addition, the build
* information is included to aid in future debugging efforts for releases.
*/
private object CometBuildInfo {
private object CometBuildInfo extends Logging {

val (
cometVersion: String,
cometBranch: String,
cometRevision: String,
cometBuildUserName: String,
cometBuildUserEmail: String,
cometRepoUrl: String,
cometBuildTimestamp: String) = {
val props: Properties = {
val props = new Properties()
val resourceStream = Thread
.currentThread()
.getContextClassLoader
.getResourceAsStream("comet-git-info.properties")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we can set comet-git-info.properties as a constant?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated.

if (resourceStream == null) {
throw new CometRuntimeException("Could not find comet-git-info.properties")
}

try {
val unknownProp = "<unknown>"
val props = new Properties()
props.load(resourceStream)
(
props.getProperty("git.build.version", unknownProp),
props.getProperty("git.branch", unknownProp),
props.getProperty("git.commit.id.full", unknownProp),
props.getProperty("git.build.user.name", unknownProp),
props.getProperty("git.build.user.email", unknownProp),
props.getProperty("git.remote.origin.url", unknownProp),
props.getProperty("git.build.time", unknownProp))
} catch {
case e: Exception =>
throw new CometRuntimeException(
"Error loading properties from comet-git-info.properties",
e)
} finally {
if (resourceStream != null) {
try {
resourceStream.close()
} catch {
case e: Exception =>
throw new CometRuntimeException("Error closing Comet build info resource stream", e)
if (resourceStream != null) {
try {
props.load(resourceStream)
} catch {
case e: Exception =>
logError("Error loading properties from comet-git-info.properties", e)
} finally {
if (resourceStream != null) {
try {
resourceStream.close()
} catch {
case e: Exception =>
logError("Error closing Comet build info resource stream", e)
}
}
}
} else {
logWarning("Could not find comet-git-info.properties")
}
props
}
}

val COMET_VERSION = CometBuildInfo.cometVersion
val COMET_BRANCH = CometBuildInfo.cometBranch
val COMET_REVISION = CometBuildInfo.cometRevision
val COMET_BUILD_USER_EMAIL = CometBuildInfo.cometBuildUserEmail
val COMET_BUILD_USER_NAME = CometBuildInfo.cometBuildUserName
val COMET_REPO_URL = CometBuildInfo.cometRepoUrl
val COMET_BUILD_TIMESTAMP = CometBuildInfo.cometBuildTimestamp
private def getProp(name: String): String = {
CometBuildInfo.props.getProperty(name, "<unknown>")
}

val COMET_VERSION: String = getProp("git.build.version")
val COMET_BRANCH: String = getProp("git.branch")
val COMET_REVISION: String = getProp("git.commit.id.full")
val COMET_BUILD_USER_EMAIL: String = getProp("git.build.user.name")
val COMET_BUILD_USER_NAME: String = getProp("git.build.user.email")
val COMET_REPO_URL: String = getProp("git.remote.origin.url")
val COMET_BUILD_TIMESTAMP: String = getProp("git.build.time")
}