-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3799: Apache Kafka procedures
- Loading branch information
Showing
112 changed files
with
14,576 additions
and
27 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package apoc.kafka | ||
|
||
import apoc.ApocConfig | ||
import apoc.ExtendedApocConfig.APOC_KAFKA_ENABLED | ||
import apoc.kafka.config.StreamsConfig | ||
import apoc.kafka.consumer.StreamsSinkConfigurationListener | ||
import apoc.kafka.producer.StreamsRouterConfigurationListener | ||
import org.neo4j.kernel.internal.GraphDatabaseAPI | ||
import org.neo4j.kernel.lifecycle.LifecycleAdapter | ||
import org.neo4j.logging.Log | ||
|
||
class KafkaHandler(): LifecycleAdapter() { | ||
|
||
private lateinit var db: GraphDatabaseAPI | ||
private lateinit var log: Log | ||
|
||
constructor(db: GraphDatabaseAPI, log: Log) : this() { | ||
this.db = db | ||
this.log = log | ||
} | ||
|
||
override fun start() { | ||
if(ApocConfig.apocConfig().getBoolean(APOC_KAFKA_ENABLED)) { | ||
// println("start db......") | ||
|
||
try { | ||
StreamsRouterConfigurationListener(db, log) | ||
.start(StreamsConfig.getConfiguration()) | ||
} catch (e: Exception) { | ||
log.error("Exception in StreamsRouterConfigurationListener {}", e.message) | ||
} | ||
|
||
try { | ||
StreamsSinkConfigurationListener(db, log) | ||
.start(StreamsConfig.getConfiguration()) | ||
} catch (e: Exception) { | ||
log.error("Exception in StreamsSinkConfigurationListener {}", e.message) | ||
} | ||
} | ||
} | ||
|
||
override fun stop() { | ||
if(ApocConfig.apocConfig().getBoolean(APOC_KAFKA_ENABLED)) { | ||
// println("stop db..........") | ||
|
||
StreamsRouterConfigurationListener(db, log).shutdown() | ||
StreamsSinkConfigurationListener(db, log).shutdown() | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
extended/src/main/kotlin/apoc/kafka/Neo4jStreamsStrategyStorage.kt
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,43 @@ | ||
//package apoc.kafka | ||
// | ||
//import apoc.kafka.consumer.StreamsSinkConfiguration | ||
//import apoc.kafka.consumer.StreamsTopicService | ||
//import apoc.kafka.extensions.isDefaultDb | ||
//import apoc.kafka.service.StreamsStrategyStorage | ||
//import apoc.kafka.service.TopicType | ||
//import apoc.kafka.service.sink.strategy.* | ||
//import org.neo4j.graphdb.GraphDatabaseService | ||
// | ||
//class Neo4jStreamsStrategyStorage(private val streamsTopicService: StreamsTopicService, | ||
// private val streamsConfig: Map<String, String>, | ||
// private val db: GraphDatabaseService): StreamsStrategyStorage() { | ||
// | ||
// override fun getTopicType(topic: String): TopicType? { | ||
// return streamsTopicService.getTopicType(topic) | ||
// } | ||
// | ||
// private fun <T> getTopicsByTopicType(topicType: TopicType): T = streamsTopicService.getByTopicType(topicType) as T | ||
// | ||
// override fun getStrategy(topic: String): IngestionStrategy = when (val topicType = getTopicType(topic)) { | ||
// TopicType.CDC_SOURCE_ID -> { | ||
// val strategyConfig = StreamsSinkConfiguration | ||
// .createSourceIdIngestionStrategyConfig(streamsConfig, db.databaseName(), db.isDefaultDb()) | ||
// SourceIdIngestionStrategy(strategyConfig) | ||
// } | ||
// TopicType.CDC_SCHEMA -> SchemaIngestionStrategy() | ||
// TopicType.CUD -> CUDIngestionStrategy() | ||
// TopicType.PATTERN_NODE -> { | ||
// val map = getTopicsByTopicType<Map<String, NodePatternConfiguration>>(topicType) | ||
// NodePatternIngestionStrategy(map.getValue(topic)) | ||
// } | ||
// TopicType.PATTERN_RELATIONSHIP -> { | ||
// val map = getTopicsByTopicType<Map<String, RelationshipPatternConfiguration>>(topicType) | ||
// RelationshipPatternIngestionStrategy(map.getValue(topic)) | ||
// } | ||
// TopicType.CYPHER -> { | ||
// CypherTemplateStrategy(streamsTopicService.getCypherTemplate(topic)!!) | ||
// } | ||
// else -> throw RuntimeException("Topic Type not Found") | ||
// } | ||
// | ||
//} |
Oops, something went wrong.