Skip to content

Commit

Permalink
Fix tools depending on the common jar (#5239)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Graves <tgraves@nvidia.com>
  • Loading branch information
tgravescs authored Apr 13, 2022
1 parent e85e17d commit cec1b7d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
6 changes: 0 additions & 6 deletions tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.nvidia</groupId>
<artifactId>rapids-4-spark-common_${scala.binary.version}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
Expand Down Expand Up @@ -105,7 +100,6 @@
<artifactSet>
<includes>
<include>org.rogach:scallop_${scala.binary.version}</include>
<include>com.nvidia:rapids-4-spark-common_${scala.binary.version}</include>
</includes>
</artifactSet>
<filters>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* Licensed 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 com.nvidia.spark.rapids.tool

import java.util.concurrent.{Executors, ThreadFactory}
import java.util.concurrent.atomic.AtomicLong

// This is similar to Guava ThreadFactoryBuilder
// Avoid to use Guava as it is a messy dependency in practice.
// This is copied from the common module
class ThreadFactoryBuilder {
private var nameFormat = Option.empty[String]
private var daemon = Option.empty[Boolean]

def setNameFormat(nameFormat: String): ThreadFactoryBuilder = {
nameFormat.format(0)
this.nameFormat = Some(nameFormat)
this
}

def setDaemon(daemon: Boolean): ThreadFactoryBuilder = {
this.daemon = Some(daemon)
this
}

def build(): ThreadFactory = {
val count = nameFormat.map(_ => new AtomicLong(0))
new ThreadFactory() {
private val defaultThreadFactory = Executors.defaultThreadFactory

override def newThread(r: Runnable): Thread = {
val thread = defaultThreadFactory.newThread(r)
nameFormat.foreach(f => thread.setName(f.format(count.get.getAndIncrement())))
daemon.foreach(b => thread.setDaemon(b))
thread
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import scala.collection.JavaConverters._
import scala.collection.mutable.{ArrayBuffer, HashMap}
import scala.util.control.NonFatal

import com.nvidia.spark.rapids.ThreadFactoryBuilder
import com.nvidia.spark.rapids.tool.{EventLogInfo, EventLogPathProcessor}
import com.nvidia.spark.rapids.tool.ThreadFactoryBuilder
import org.apache.hadoop.conf.Configuration

import org.apache.spark.internal.Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import java.util.concurrent.{ConcurrentLinkedQueue, Executors, ThreadPoolExecuto

import scala.collection.JavaConverters._

import com.nvidia.spark.rapids.ThreadFactoryBuilder
import com.nvidia.spark.rapids.tool.EventLogInfo
import com.nvidia.spark.rapids.tool.ThreadFactoryBuilder
import org.apache.hadoop.conf.Configuration

import org.apache.spark.internal.Logging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import java.util.regex.PatternSyntaxException

import scala.collection.JavaConverters._

import com.nvidia.spark.rapids.ThreadFactoryBuilder
import com.nvidia.spark.rapids.tool.EventLogInfo
import com.nvidia.spark.rapids.tool.ThreadFactoryBuilder
import com.nvidia.spark.rapids.tool.qualification.QualificationArgs
import org.apache.hadoop.conf.Configuration

Expand Down

0 comments on commit cec1b7d

Please sign in to comment.