-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize topic replicas + partitions (#52)
* Display previous value for topic config update * Implement replication and partitions synchronisation * Cleanup + respect the includeUnchanged flag
- Loading branch information
1 parent
19fa471
commit 4309147
Showing
66 changed files
with
1,024 additions
and
298 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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/devshawn/kafka/gitops/domain/plan/TopicDetailsPlan.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 com.devshawn.kafka.gitops.domain.plan; | ||
|
||
import java.util.Optional; | ||
import org.inferred.freebuilder.FreeBuilder; | ||
import com.devshawn.kafka.gitops.enums.PlanAction; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
|
||
@FreeBuilder | ||
@JsonDeserialize(builder = TopicDetailsPlan.Builder.class) | ||
public interface TopicDetailsPlan { | ||
Optional<Integer> getPartitions(); | ||
Optional<Integer> getPreviousPartitions(); | ||
PlanAction getPartitionsAction(); | ||
|
||
Optional<Integer> getReplication(); | ||
Optional<Integer> getPreviousReplication(); | ||
PlanAction getReplicationAction(); | ||
|
||
public static Optional<TopicDetailsPlan> toChangesOnlyPlan(Optional<TopicDetailsPlan> topicDetailsPlan) { | ||
if(! topicDetailsPlan.isPresent()) { | ||
return topicDetailsPlan; | ||
} | ||
TopicDetailsPlan.Builder builder = new TopicDetailsPlan.Builder(); | ||
builder.setReplicationAction(topicDetailsPlan.get().getReplicationAction()); | ||
builder.setPartitionsAction(topicDetailsPlan.get().getPartitionsAction()); | ||
boolean nochanges = true; | ||
if ( topicDetailsPlan.get().getReplicationAction() != null && ! topicDetailsPlan.get().getReplicationAction().equals(PlanAction.NO_CHANGE)) { | ||
builder.setReplication(topicDetailsPlan.get().getReplication()); | ||
builder.setPreviousReplication(topicDetailsPlan.get().getPreviousReplication()); | ||
nochanges = false; | ||
} | ||
if (topicDetailsPlan.get().getPartitionsAction() != null && ! topicDetailsPlan.get().getPartitionsAction().equals(PlanAction.NO_CHANGE)) { | ||
builder.setPartitions(topicDetailsPlan.get().getPartitions()); | ||
builder.setPreviousPartitions(topicDetailsPlan.get().getPreviousPartitions()); | ||
nochanges = false; | ||
} | ||
if(nochanges) { | ||
return Optional.<TopicDetailsPlan>empty(); | ||
} | ||
return Optional.of(builder.build()); | ||
} | ||
class Builder extends TopicDetailsPlan_Builder { | ||
} | ||
} |
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
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
Oops, something went wrong.