From 08d98b3ad777513a52168eea3e4b50e318458372 Mon Sep 17 00:00:00 2001 From: Elaman Nazarkulov Date: Mon, 23 Oct 2023 23:16:47 +0600 Subject: [PATCH] Hikari fix for sqlite --- .../openfuture/chain/core/sync/ChainSynchronizer.kt | 11 +++++------ .../chain/network/component/ChannelsHolder.kt | 1 + src/main/resources/application-chain-1.properties | 8 ++++---- src/main/resources/application-chain-2.properties | 8 ++++---- src/main/resources/application-chain-3.properties | 8 ++++---- src/main/resources/application.properties | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/io/openfuture/chain/core/sync/ChainSynchronizer.kt b/src/main/kotlin/io/openfuture/chain/core/sync/ChainSynchronizer.kt index 3f0a5715..41d18771 100644 --- a/src/main/kotlin/io/openfuture/chain/core/sync/ChainSynchronizer.kt +++ b/src/main/kotlin/io/openfuture/chain/core/sync/ChainSynchronizer.kt @@ -23,7 +23,7 @@ import io.openfuture.chain.network.message.sync.GenesisBlockMessage import io.openfuture.chain.network.service.NetworkApiService import org.slf4j.Logger import org.slf4j.LoggerFactory -//import org.springframework.boot.autoconfigure.jdbc.DataSourceSchemaCreatedEvent +import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.ApplicationListener import org.springframework.context.event.EventListener import org.springframework.stereotype.Component @@ -43,8 +43,7 @@ class ChainSynchronizer( private val dbChecker: DBChecker, private val nodeConfigurator: NodeConfigurator, private val syncSession: SyncSession -) { - //: ApplicationListener { +) : ApplicationListener { companion object { private val log: Logger = LoggerFactory.getLogger(ChainSynchronizer::class.java) @@ -58,9 +57,9 @@ class ChainSynchronizer( fun forceSynchronizationCheck() { checkLastBlock() } -// override fun onApplicationEvent(event: DataSourceSchemaCreatedEvent) { -// prepareDB(nodeConfigurator.getConfig().mode) -// } + override fun onApplicationEvent(event: ApplicationReadyEvent) { + prepareDB(nodeConfigurator.getConfig().mode) + } @EventListener fun eventSyncMode(syncMode: SyncMode) { diff --git a/src/main/kotlin/io/openfuture/chain/network/component/ChannelsHolder.kt b/src/main/kotlin/io/openfuture/chain/network/component/ChannelsHolder.kt index dd71119a..4b5372d4 100644 --- a/src/main/kotlin/io/openfuture/chain/network/component/ChannelsHolder.kt +++ b/src/main/kotlin/io/openfuture/chain/network/component/ChannelsHolder.kt @@ -97,6 +97,7 @@ class ChannelsHolder( fun hasChannel(channel: Channel): Boolean = channelGroup.contains(channel) fun findNewPeer() { + //log.info("PEER NUMBER: ${nodeProperties.peersNumber} and CHANNEL SIZE: ${channelGroup.size} and CONNECTION TASK : $connectionTask") if (nodeProperties.peersNumber!! > channelGroup.size && (null == connectionTask || connectionTask!!.isDone)) { connectionTask = executor.submit { findNewPeer0() } } diff --git a/src/main/resources/application-chain-1.properties b/src/main/resources/application-chain-1.properties index 6a74d1d0..4cb67906 100644 --- a/src/main/resources/application-chain-1.properties +++ b/src/main/resources/application-chain-1.properties @@ -3,9 +3,9 @@ spring.datasource.driver-class-name=org.sqlite.JDBC spring.datasource.url=jdbc:sqlite:./db/chain_1 spring.datasource.username=admin spring.datasource.password=admin -spring.jpa.open-in-view=true +#spring.jpa.open-in-view=true spring.jpa.database-platform=org.hibernate.dialect.SQLiteDialect -spring.jpa.hibernate.ddl-auto=update +#spring.jpa.hibernate.ddl-auto=update # Logging logging.level.io.openfuture.chain=INFO @@ -15,6 +15,6 @@ server.port=8081 # NODE node.port=9191 -node.root-nodes=openchain:9192,openchain:9193 +node.root-nodes=localhost:9192,localhost:9193 -#node.config-path=config-1.json \ No newline at end of file +node.config-path=config-1.json \ No newline at end of file diff --git a/src/main/resources/application-chain-2.properties b/src/main/resources/application-chain-2.properties index 463e7b94..2e1f6897 100644 --- a/src/main/resources/application-chain-2.properties +++ b/src/main/resources/application-chain-2.properties @@ -3,9 +3,9 @@ spring.datasource.driver-class-name=org.sqlite.JDBC spring.datasource.url=jdbc:sqlite:./db/chain_2 spring.datasource.username=admin spring.datasource.password=admin -spring.jpa.open-in-view=true +#spring.jpa.open-in-view=true spring.jpa.database-platform=org.hibernate.dialect.SQLiteDialect -spring.jpa.hibernate.ddl-auto=update +#spring.jpa.hibernate.ddl-auto=update # Logging logging.level.io.openfuture.chain=INFO @@ -15,6 +15,6 @@ server.port=8082 # NODE node.port=9192 -node.root-nodes=openchain:9191,openchain:9193 +node.root-nodes=localhost:9191,localhost:9193 -#node.config-path=config-2.json \ No newline at end of file +node.config-path=config-2.json \ No newline at end of file diff --git a/src/main/resources/application-chain-3.properties b/src/main/resources/application-chain-3.properties index d063408b..905523fb 100644 --- a/src/main/resources/application-chain-3.properties +++ b/src/main/resources/application-chain-3.properties @@ -3,9 +3,9 @@ spring.datasource.driver-class-name=org.sqlite.JDBC spring.datasource.url=jdbc:sqlite:./db/chain_3 spring.datasource.username=admin spring.datasource.password=admin -spring.jpa.open-in-view=true +#spring.jpa.open-in-view=true spring.jpa.database-platform=org.hibernate.dialect.SQLiteDialect -spring.jpa.hibernate.ddl-auto=update +#spring.jpa.hibernate.ddl-auto=update # Logging logging.level.io.openfuture.chain=INFO @@ -15,6 +15,6 @@ server.port=8083 # NODE node.port=9193 -node.root-nodes=openchain:9191,openchain:9192 +node.root-nodes=localhost:9191,localhost:9192 -#node.config-path=config-3.json \ No newline at end of file +node.config-path=config-3.json \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0a7b5a27..bf27751b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -36,9 +36,9 @@ node.ntp-offset-threshold=1000 # CONSENSUS consensus.epoch-height=21 consensus.delegates-count=3 -consensus.block-capacity=10000 -consensus.time-slot-duration=50000 -consensus.time-slot-interval=15000 +consensus.block-capacity=1000 +consensus.time-slot-duration=5000 +consensus.time-slot-interval=1500 consensus.genesis-address=0x0000000000000000000000000000000000000000 consensus.reward-block=10 consensus.fee-vote-tx-for=3 @@ -61,7 +61,7 @@ management.metrics.export.prometheus.step=15s #spring.jpa.properties.hibernate.generate_statistics=true ### HIKARI -spring.datasource.hikari.maximum-pool-size=50 +spring.datasource.hikari.maximum-pool-size=1 spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.idleTimeout=600000 spring.datasource.hikari.maxLifetime=1800000 \ No newline at end of file