Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
#104 Populate Cassandra With Keyspaces during startup
Browse files Browse the repository at this point in the history
fix build
  • Loading branch information
hleb-albau authored and arturalbov committed Apr 19, 2018
1 parent f9c7503 commit c534d32
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c534d32

Please sign in to comment.