-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SKYEDEN-3271 | consumer group cleanup
- Loading branch information
1 parent
f4099e4
commit e57248b
Showing
27 changed files
with
545 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ent/config/SubscriptionConfiguration.java → ...bscription/SubscriptionConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../config/SubscriptionHealthProperties.java → ...ription/SubscriptionHealthProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...gement/config/SubscriptionProperties.java → .../subscription/SubscriptionProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../tech/hermes/management/config/subscription/consumergroup/ConsumerGroupCleanUpConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package pl.allegro.tech.hermes.management.config.subscription.consumergroup; | ||
|
||
import java.time.Clock; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import pl.allegro.tech.hermes.management.domain.subscription.SubscriptionService; | ||
import pl.allegro.tech.hermes.management.domain.subscription.consumergroup.ConsumerGroupCleanUpService; | ||
import pl.allegro.tech.hermes.management.domain.subscription.consumergroup.ConsumerGroupToDeleteRepository; | ||
import pl.allegro.tech.hermes.management.infrastructure.kafka.MultiDCAwareService; | ||
import pl.allegro.tech.hermes.management.infrastructure.zookeeper.ZookeeperRepositoryManager; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(ConsumerGroupCleanUpProperties.class) | ||
@ConditionalOnProperty(value = "consumer-group-clean-up.enabled", havingValue = "true") | ||
public class ConsumerGroupCleanUpConfig { | ||
|
||
@Autowired | ||
ZookeeperRepositoryManager zookeeperRepositoryManager; | ||
|
||
@Bean | ||
ConsumerGroupCleanUpService consumerGroupCleanUpService( | ||
MultiDCAwareService multiDCAwareService, | ||
SubscriptionService subscriptionService, | ||
ConsumerGroupCleanUpProperties properties, | ||
Clock clock | ||
) { | ||
return new ConsumerGroupCleanUpService( | ||
multiDCAwareService, | ||
zookeeperRepositoryManager.getRepositoriesByType(ConsumerGroupToDeleteRepository.class), | ||
subscriptionService, | ||
properties, | ||
clock | ||
); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...h/hermes/management/config/subscription/consumergroup/ConsumerGroupCleanUpProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package pl.allegro.tech.hermes.management.config.subscription.consumergroup; | ||
|
||
import java.time.Duration; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties(prefix = "consumer-group-clean-up") | ||
public class ConsumerGroupCleanUpProperties { | ||
private boolean enabled = true; | ||
private Duration interval = Duration.ofMinutes(5); | ||
private Duration initialDelay = Duration.ofMinutes(1); | ||
private Duration timeout = Duration.ofHours(24); | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public Duration getInterval() { | ||
return interval; | ||
} | ||
|
||
public void setInterval(Duration interval) { | ||
this.interval = interval; | ||
} | ||
|
||
public Duration getInitialDelay() { | ||
return initialDelay; | ||
} | ||
|
||
public void setInitialDelay(Duration initialDelay) { | ||
this.initialDelay = initialDelay; | ||
} | ||
|
||
public Duration getTimeout() { | ||
return timeout; | ||
} | ||
|
||
public void setTimeout(Duration timeout) { | ||
this.timeout = timeout; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ent/domain/subscription/consumergroup/ConsumerGroupAlreadyScheduledToDeleteException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package pl.allegro.tech.hermes.management.domain.subscription.consumergroup; | ||
|
||
import pl.allegro.tech.hermes.api.ErrorCode; | ||
import pl.allegro.tech.hermes.management.domain.ManagementException; | ||
|
||
import static java.lang.String.format; | ||
import static pl.allegro.tech.hermes.api.ErrorCode.OTHER; | ||
|
||
public class ConsumerGroupAlreadyScheduledToDeleteException extends ManagementException { | ||
|
||
public ConsumerGroupAlreadyScheduledToDeleteException( | ||
ConsumerGroupToDelete consumerGroupToDelete, Throwable e) { | ||
super( | ||
format( | ||
"Consumer group already scheduled to delete, for subscription %s ", | ||
consumerGroupToDelete.subscriptionName().getQualifiedName()), | ||
e); | ||
} | ||
|
||
@Override | ||
public ErrorCode getCode() { | ||
return OTHER; | ||
} | ||
} |
Oops, something went wrong.