Skip to content

Commit

Permalink
Fix scala 2.12 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones committed Aug 13, 2024
1 parent 5e628ae commit 9617337
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import scala.jdk.CollectionConverters._
*/
object Admin {

private val logger: Logger = LoggerFactory.getLogger(classOf[Admin.type])
private val logger: Logger = LoggerFactory.getLogger(this.getClass)
sys.addShutdownHook {
logger.info("Shutting down Bigtable clients")
Instance.clients.values.foreach(_.close())
Expand All @@ -50,13 +50,11 @@ object Admin {
object Table {

sealed trait CreateDisposition

object CreateDisposition {
case object Never extends CreateDisposition

case object CreateIfNeeded extends CreateDisposition

val default: CreateDisposition = CreateIfNeeded
val Default: CreateDisposition = CreateIfNeeded
}

private[bigtable] val clients: concurrent.Map[(String, String), BigtableTableAdminClient] =
Expand Down Expand Up @@ -95,7 +93,7 @@ object Admin {
instanceId: String,
tableId: String,
columnFamilies: Iterable[String],
createDisposition: CreateDisposition = CreateDisposition.default
createDisposition: CreateDisposition = CreateDisposition.Default
): Unit = {
val tcf = columnFamilies.map(cf => cf -> None)
ensureTableImpl(projectId, instanceId, tableId, tcf, createDisposition)
Expand All @@ -116,7 +114,7 @@ object Admin {
instanceId: String,
tableId: String,
columnFamilies: Iterable[(String, Option[Duration])],
createDisposition: CreateDisposition = CreateDisposition.default
createDisposition: CreateDisposition = CreateDisposition.Default
): Unit = {
// Convert Duration to GcRule
val x = columnFamilies.map { case (columnFamily, duration) =>
Expand All @@ -142,7 +140,7 @@ object Admin {
instanceId: String,
tableId: String,
columnFamilies: Iterable[(String, Option[GCRule])],
createDisposition: CreateDisposition = CreateDisposition.default
createDisposition: CreateDisposition = CreateDisposition.Default
): Unit = ensureTableImpl(projectId, instanceId, tableId, columnFamilies, createDisposition)

/**
Expand Down Expand Up @@ -242,17 +240,19 @@ object Admin {
sleepDuration: Duration
): Unit = {
val client = getOrCreateClient(projectId)
val ids =
if (clusterIds.isEmpty) client.listClusters(instanceId).asScala.map(_.getId)
else clusterIds
val ids: Iterable[String] = if (clusterIds.isEmpty) {
client.listClusters(instanceId).asScala.map(_.getId)
} else {
clusterIds
}

ids.foreach { clusterId =>
logger.info("Updating number of nodes to {} for cluster {}", numberOfNodes, clusterId)
client.resizeCluster(instanceId, clusterId, numberOfNodes)
}

if (sleepDuration.getMillis > 0) {
logger.info("Sleeping for {} after update", sleepDuration.toPeriod)
if (sleepDuration.isLongerThan(Duration.ZERO)) {
logger.info("Sleeping for {} after update", sleepDuration)
Thread.sleep(sleepDuration.getMillis)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ final class ScioContextOps(private val self: ScioContext) extends AnyVal {
instanceId: String,
tableId: String,
columnFamilies: Iterable[String],
createDisposition: Admin.Table.CreateDisposition = Admin.Table.CreateDisposition.default
createDisposition: Admin.Table.CreateDisposition = Admin.Table.CreateDisposition.Default
): Unit =
if (!self.isTest) {
Admin.Table.ensureTable(projectId, instanceId, tableId, columnFamilies, createDisposition)
Expand All @@ -172,7 +172,7 @@ final class ScioContextOps(private val self: ScioContext) extends AnyVal {
instanceId: String,
tableId: String,
columnFamiliesWithExpiration: Iterable[(String, Option[Duration])],
createDisposition: Admin.Table.CreateDisposition = Admin.Table.CreateDisposition.default
createDisposition: Admin.Table.CreateDisposition = Admin.Table.CreateDisposition.Default
): Unit =
if (!self.isTest) {
Admin.Table.ensureTablesWithExpiration(
Expand Down

0 comments on commit 9617337

Please sign in to comment.