Skip to content

Commit

Permalink
chore(orca): Kotlin enhancements for Spring 1.5
Browse files Browse the repository at this point in the history
No longer need to use `open` and `@Autowired constructor` on most `@Component` classes.
  • Loading branch information
robfletcher committed Aug 29, 2017
1 parent 5ef9a58 commit bebf1a7
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import redis.clients.util.Pool
import java.time.Clock

class RedisDeadMessageHandler(
val deadLetterQueueName: String,
deadLetterQueueName: String,
private val pool: Pool<Jedis>,
private val clock: Clock
) : DeadMessageHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,38 @@ package com.netflix.spinnaker.orca.q.redis

import com.netflix.spinnaker.config.RedisQueueConfiguration
import com.netflix.spinnaker.orca.q.QueueIntegrationTest
import com.netflix.spinnaker.orca.q.TestConfig
import com.netflix.spinnaker.orca.q.memory.InMemoryQueue
import com.netflix.spinnaker.orca.test.redis.EmbeddedRedisConfiguration
import org.junit.runner.RunWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import org.springframework.test.context.junit4.SpringRunner
import redis.clients.jedis.Jedis
import redis.clients.util.Pool

/**
* This just runs [QueueIntegrationTest] with a [RedisQueue] instead of an
* [InMemoryQueue].
*/
@RunWith(SpringJUnit4ClassRunner::class)
@ContextConfiguration(classes = arrayOf(
EmbeddedRedisConfiguration::class,
RedisQueueConfiguration::class,
RedisQueuePoolFixery::class
))
@RunWith(SpringRunner::class)
@SpringBootTest(
classes = arrayOf(
EmbeddedRedisConfiguration::class,
RedisQueueConfiguration::class,
RedisQueuePoolFixery::class,
TestConfig::class
),
properties = arrayOf(
"queue.retry.delay.ms=10",
"logging.level.root=ERROR",
"logging.level.org.springframework.test=ERROR",
"logging.level.com.netflix.spinnaker=FATAL"
))
class RedisQueueIntegrationTest : QueueIntegrationTest()



@Configuration
open class RedisQueuePoolFixery {
@Bean(name = arrayOf("queueJedisPool")) open fun redisQueue(pool: Pool<Jedis>) = pool
Expand Down
1 change: 1 addition & 0 deletions orca-queue/orca-queue.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
compile "org.threeten:threeten-extra:1.0"
compile "org.funktionale:funktionale-partials:1.1"

testCompile "org.springframework.boot:spring-boot-test:${spinnaker.version('springBoot')}"
testCompile project(":orca-test")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
package com.netflix.spinnaker.orca.log

import com.netflix.spinnaker.orca.events.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationListener
import org.springframework.stereotype.Component

@Component
open class ExecutionLogListener
@Autowired constructor(
class ExecutionLogListener(
private val executionLogRepository: ExecutionLogRepository,
private val currentInstanceId: String
) : ApplicationListener<ExecutionEvent> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package com.netflix.spinnaker.orca.q
import com.netflix.spinnaker.orca.pipeline.ExecutionRunner
import com.netflix.spinnaker.orca.pipeline.model.Execution
import com.netflix.spinnaker.security.AuthenticatedRequest
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component open class QueueExecutionRunner @Autowired constructor(
@Component
class QueueExecutionRunner(
private val queue: Queue
) : ExecutionRunner {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.orca.discovery.DiscoveryActivated
import org.slf4j.Logger
import org.slf4j.LoggerFactory.getLogger
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component
import java.util.concurrent.RejectedExecutionException
import java.util.concurrent.atomic.AtomicBoolean
import javax.annotation.PostConstruct

@Component
open class QueueProcessor
@Autowired constructor(
class QueueProcessor(
private val queue: Queue,
private val queueExecutor: QueueExecutor,
private val registry: Registry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

package com.netflix.spinnaker.orca.q

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
import org.springframework.stereotype.Component

@Component
open class ThreadPoolQueueExecutor
@Autowired constructor(
class ThreadPoolQueueExecutor(
@Qualifier("messageHandlerPool") override val executor: ThreadPoolTaskExecutor) : QueueExecutor {
override fun hasCapacity(): Boolean = executor.threadPoolExecutor.activeCount < executor.threadPoolExecutor.maximumPoolSize
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ import com.netflix.spinnaker.orca.q.CancelExecution
import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import com.netflix.spinnaker.orca.q.ResumeStage
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class CancelExecutionHandler
@Autowired constructor(
class CancelExecutionHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<CancelExecution> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.CancelStage
import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Component
import java.util.concurrent.Executor

@Component
open class CancelStageHandler
@Autowired constructor(
class CancelStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
override val stageDefinitionBuilders: Collection<StageDefinitionBuilder>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import com.netflix.spinnaker.orca.pipeline.model.Stage
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.*
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component
import java.time.Duration

@Component
open class CompleteExecutionHandler
@Autowired constructor(
class CompleteExecutionHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
private val publisher: ApplicationEventPublisher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner.STAGE_BEFOR
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.*
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component
import java.time.Clock

@Component
open class CompleteStageHandler
@Autowired constructor(
class CompleteStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
private val publisher: ApplicationEventPublisher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ import com.netflix.spinnaker.orca.events.TaskComplete
import com.netflix.spinnaker.orca.pipeline.model.Stage
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component
import java.time.Clock

@Component
open class CompleteTaskHandler
@Autowired constructor(
class CompleteTaskHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
private val publisher: ApplicationEventPublisher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import com.netflix.spinnaker.orca.q.InvalidExecutionId
import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class ConfigurationErrorHandler
@Autowired constructor(
class ConfigurationErrorHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<ConfigurationError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.*
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
import java.time.Duration

@Component
open class ContinueParentStageHandler
@Autowired constructor(
class ContinueParentStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
@Value("\${queue.retry.delay.ms:5000}") retryDelayMs: Long
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.PauseStage
import com.netflix.spinnaker.orca.q.Queue
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class PauseStageHandler
@Autowired constructor(
class PauseStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<PauseStage> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.PauseStage
import com.netflix.spinnaker.orca.q.PauseTask
import com.netflix.spinnaker.orca.q.Queue
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class PauseTaskHandler
@Autowired constructor(
class PauseTaskHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<PauseTask> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import com.netflix.spinnaker.orca.q.RestartStage
import com.netflix.spinnaker.orca.q.StartStage
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import java.time.Clock

@Component
open class RestartStageHandler
@Autowired constructor(
class RestartStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
override val stageDefinitionBuilders: Collection<StageDefinitionBuilder>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import com.netflix.spinnaker.orca.q.ResumeExecution
import com.netflix.spinnaker.orca.q.ResumeStage
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class ResumeExecutionHandler
@Autowired constructor(
class ResumeExecutionHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<ResumeExecution> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import com.netflix.spinnaker.orca.q.ResumeStage
import com.netflix.spinnaker.orca.q.ResumeTask
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class ResumeStageHandler
@Autowired constructor(
class ResumeStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<ResumeStage> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import com.netflix.spinnaker.orca.q.ResumeTask
import com.netflix.spinnaker.orca.q.RunTask
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
open class ResumeTaskHandler
@Autowired constructor(
class ResumeTaskHandler(
override val queue: Queue,
override val repository: ExecutionRepository
) : MessageHandler<ResumeTask> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import com.netflix.spinnaker.orca.time.toInstant
import org.apache.commons.lang.time.DurationFormatUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory.getLogger
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import java.time.Clock
import java.time.Duration
Expand All @@ -46,8 +45,7 @@ import java.time.temporal.TemporalAmount
import java.util.concurrent.TimeUnit

@Component
open class RunTaskHandler
@Autowired constructor(
class RunTaskHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
override val stageNavigator: StageNavigator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import com.netflix.spinnaker.orca.ExecutionStatus.RUNNING
import com.netflix.spinnaker.orca.events.ExecutionStarted
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository
import com.netflix.spinnaker.orca.q.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component

@Component
open class StartExecutionHandler
@Autowired constructor(
class StartExecutionHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
private val publisher: ApplicationEventPublisher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ import com.netflix.spinnaker.orca.pipeline.util.StageNavigator
import com.netflix.spinnaker.orca.q.*
import com.netflix.spinnaker.orca.q.StartStage
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component
import java.time.Clock
import java.time.Duration

@Component
open class StartStageHandler
@Autowired constructor(
class StartStageHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
override val stageNavigator: StageNavigator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import com.netflix.spinnaker.orca.q.MessageHandler
import com.netflix.spinnaker.orca.q.Queue
import com.netflix.spinnaker.orca.q.RunTask
import com.netflix.spinnaker.orca.q.StartTask
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationEventPublisher
import org.springframework.stereotype.Component
import java.time.Clock

@Component
open class StartTaskHandler
@Autowired constructor(
class StartTaskHandler(
override val queue: Queue,
override val repository: ExecutionRepository,
private val publisher: ApplicationEventPublisher,
Expand Down
Loading

0 comments on commit bebf1a7

Please sign in to comment.