From c534d32a7d789d9dc9f0689c6539b2a5d3f44a62 Mon Sep 17 00:00:00 2001 From: Hleb Albau Date: Thu, 19 Apr 2018 16:57:58 +0300 Subject: [PATCH] #104 Populate Cassandra With Keyspaces during startup fix build --- .../BitcoinRepositoryConfiguration.kt | 20 ++++++++++++++--- .../fund/cyber/cassandra/common/Keyspaces.kt | 5 +++-- .../EthereumRepositoryConfiguration.kt | 22 ++++++++++++++++--- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/cassandra-service/src/main/kotlin/fund/cyber/cassandra/bitcoin/configuration/BitcoinRepositoryConfiguration.kt b/cassandra-service/src/main/kotlin/fund/cyber/cassandra/bitcoin/configuration/BitcoinRepositoryConfiguration.kt index d03194a5..1181f58b 100644 --- a/cassandra-service/src/main/kotlin/fund/cyber/cassandra/bitcoin/configuration/BitcoinRepositoryConfiguration.kt +++ b/cassandra-service/src/main/kotlin/fund/cyber/cassandra/bitcoin/configuration/BitcoinRepositoryConfiguration.kt @@ -2,21 +2,35 @@ package fund.cyber.cassandra.bitcoin.configuration import com.datastax.driver.core.Cluster import com.datastax.driver.extras.codecs.jdk8.InstantCodec -import fund.cyber.cassandra.bitcoin.repository.* +import fund.cyber.cassandra.bitcoin.repository.BitcoinAddressSummaryRepository +import fund.cyber.cassandra.bitcoin.repository.BitcoinBlockRepository +import fund.cyber.cassandra.bitcoin.repository.BitcoinTxRepository +import fund.cyber.cassandra.bitcoin.repository.PageableBitcoinAddressMinedBlockRepository +import fund.cyber.cassandra.bitcoin.repository.PageableBitcoinAddressTxRepository +import fund.cyber.cassandra.bitcoin.repository.PageableBitcoinBlockTxRepository import fund.cyber.cassandra.common.NoChainCondition import fund.cyber.cassandra.common.defaultKeyspaceSpecification import fund.cyber.cassandra.configuration.CassandraRepositoriesConfiguration import fund.cyber.cassandra.configuration.keyspace import fund.cyber.cassandra.migration.BlockchainMigrationSettings import fund.cyber.cassandra.migration.MigrationSettings -import fund.cyber.search.configuration.* +import fund.cyber.search.configuration.CASSANDRA_HOSTS +import fund.cyber.search.configuration.CASSANDRA_HOSTS_DEFAULT +import fund.cyber.search.configuration.CASSANDRA_PORT +import fund.cyber.search.configuration.CASSANDRA_PORT_DEFAULT +import fund.cyber.search.configuration.CHAIN +import fund.cyber.search.configuration.env import fund.cyber.search.model.chains.BitcoinFamilyChain import fund.cyber.search.model.chains.Chain import org.springframework.beans.factory.InitializingBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.* +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Condition +import org.springframework.context.annotation.ConditionContext +import org.springframework.context.annotation.Conditional +import org.springframework.context.annotation.Configuration import org.springframework.context.support.GenericApplicationContext import org.springframework.core.type.AnnotatedTypeMetadata import org.springframework.data.cassandra.ReactiveSession diff --git a/cassandra-service/src/main/kotlin/fund/cyber/cassandra/common/Keyspaces.kt b/cassandra-service/src/main/kotlin/fund/cyber/cassandra/common/Keyspaces.kt index 173dda50..63ed6511 100644 --- a/cassandra-service/src/main/kotlin/fund/cyber/cassandra/common/Keyspaces.kt +++ b/cassandra-service/src/main/kotlin/fund/cyber/cassandra/common/Keyspaces.kt @@ -3,12 +3,13 @@ package fund.cyber.cassandra.common import org.springframework.data.cassandra.core.cql.keyspace.CreateKeyspaceSpecification import org.springframework.data.cassandra.core.cql.keyspace.DataCenterReplication +private const val RELIABLE_REPLICATION_FACTOR = 3L fun defaultKeyspaceSpecification(keyspaces: String): CreateKeyspaceSpecification { return CreateKeyspaceSpecification.createKeyspace(keyspaces) .withNetworkReplication( DataCenterReplication.of("WITHOUT_REPLICATION", 1), - DataCenterReplication.of("RELIABLE", 3) + DataCenterReplication.of("RELIABLE", RELIABLE_REPLICATION_FACTOR) ) .ifNotExists() -} \ No newline at end of file +} diff --git a/cassandra-service/src/main/kotlin/fund/cyber/cassandra/ethereum/configuration/EthereumRepositoryConfiguration.kt b/cassandra-service/src/main/kotlin/fund/cyber/cassandra/ethereum/configuration/EthereumRepositoryConfiguration.kt index dcad3299..86fc3846 100644 --- a/cassandra-service/src/main/kotlin/fund/cyber/cassandra/ethereum/configuration/EthereumRepositoryConfiguration.kt +++ b/cassandra-service/src/main/kotlin/fund/cyber/cassandra/ethereum/configuration/EthereumRepositoryConfiguration.kt @@ -5,17 +5,33 @@ import fund.cyber.cassandra.common.NoChainCondition import fund.cyber.cassandra.common.defaultKeyspaceSpecification import fund.cyber.cassandra.configuration.CassandraRepositoriesConfiguration import fund.cyber.cassandra.configuration.keyspace -import fund.cyber.cassandra.ethereum.repository.* +import fund.cyber.cassandra.ethereum.repository.EthereumAddressRepository +import fund.cyber.cassandra.ethereum.repository.EthereumBlockRepository +import fund.cyber.cassandra.ethereum.repository.EthereumTxRepository +import fund.cyber.cassandra.ethereum.repository.EthereumUncleRepository +import fund.cyber.cassandra.ethereum.repository.PageableEthereumAddressMinedBlockRepository +import fund.cyber.cassandra.ethereum.repository.PageableEthereumAddressMinedUncleRepository +import fund.cyber.cassandra.ethereum.repository.PageableEthereumAddressTxRepository +import fund.cyber.cassandra.ethereum.repository.PageableEthereumBlockTxRepository import fund.cyber.cassandra.migration.BlockchainMigrationSettings import fund.cyber.cassandra.migration.MigrationSettings -import fund.cyber.search.configuration.* +import fund.cyber.search.configuration.CASSANDRA_HOSTS +import fund.cyber.search.configuration.CASSANDRA_HOSTS_DEFAULT +import fund.cyber.search.configuration.CASSANDRA_PORT +import fund.cyber.search.configuration.CASSANDRA_PORT_DEFAULT +import fund.cyber.search.configuration.CHAIN +import fund.cyber.search.configuration.env import fund.cyber.search.model.chains.Chain import fund.cyber.search.model.chains.EthereumFamilyChain import org.springframework.beans.factory.InitializingBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.* +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Condition +import org.springframework.context.annotation.ConditionContext +import org.springframework.context.annotation.Conditional +import org.springframework.context.annotation.Configuration import org.springframework.context.support.GenericApplicationContext import org.springframework.core.type.AnnotatedTypeMetadata import org.springframework.data.cassandra.ReactiveSession