forked from patka/cassandra-migration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spring properties for keyspace strategy and replications (patka#68)
* feat: add spring properties for keyspace strategy and replications * Fix typo * improve properties * update readme * code cleanup * test with 2 datacenters * deprecate old keyspace-name property * typo * refactor similar to v3 branch feature * update readme * clean useless imports * fix thrown exception
- Loading branch information
Showing
13 changed files
with
292 additions
and
83 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
8 changes: 8 additions & 0 deletions
8
...g/cognitor/cassandra/migration/spring/keyspace/KeyspaceReplicationStrategyDefinition.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,8 @@ | ||
package org.cognitor.cassandra.migration.spring.keyspace; | ||
|
||
import org.cognitor.cassandra.migration.keyspace.ReplicationStrategy; | ||
|
||
public interface KeyspaceReplicationStrategyDefinition { | ||
|
||
ReplicationStrategy getStrategy(); | ||
} |
26 changes: 26 additions & 0 deletions
26
...main/java/org/cognitor/cassandra/migration/spring/keyspace/NetworkStrategyDefinition.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,26 @@ | ||
package org.cognitor.cassandra.migration.spring.keyspace; | ||
|
||
import org.cognitor.cassandra.migration.keyspace.NetworkStrategy; | ||
import org.cognitor.cassandra.migration.keyspace.ReplicationStrategy; | ||
|
||
import java.util.Map; | ||
|
||
public class NetworkStrategyDefinition implements KeyspaceReplicationStrategyDefinition { | ||
|
||
private Map<String, Integer> replications; | ||
|
||
public Map<String, Integer> getReplications() { | ||
return replications; | ||
} | ||
|
||
public void setReplications(Map<String, Integer> replications) { | ||
this.replications = replications; | ||
} | ||
|
||
@Override | ||
public ReplicationStrategy getStrategy() { | ||
NetworkStrategy networkStrategy = new NetworkStrategy(); | ||
replications.forEach(networkStrategy::with); | ||
return networkStrategy; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../main/java/org/cognitor/cassandra/migration/spring/keyspace/SimpleStrategyDefinition.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,22 @@ | ||
package org.cognitor.cassandra.migration.spring.keyspace; | ||
|
||
import org.cognitor.cassandra.migration.keyspace.ReplicationStrategy; | ||
import org.cognitor.cassandra.migration.keyspace.SimpleStrategy; | ||
|
||
public class SimpleStrategyDefinition implements KeyspaceReplicationStrategyDefinition { | ||
|
||
private int replicationFactor = 1; | ||
|
||
public int getReplicationFactor() { | ||
return replicationFactor; | ||
} | ||
|
||
public void setReplicationFactor(int replicationFactor) { | ||
this.replicationFactor = replicationFactor; | ||
} | ||
|
||
@Override | ||
public ReplicationStrategy getStrategy() { | ||
return new SimpleStrategy(replicationFactor); | ||
} | ||
} |
Oops, something went wrong.