Netflix Conductor 源码分析—— 初始化

本系列基于 Conductor release v3.5.2

1. 概述

Conductor Server 是一个Spirng Boot 项目,因此它适用Spirng Boot所有规则。

2. application.properties 参数说明

官方文档介绍

# Database persistence model.  Possible values are memory, redis, redis_cluster, redis_sentinel and dynomite.
# If omitted, the persistence used is memory
#
# memory : The data is stored in memory and lost when the server dies.  Useful for testing or demo
# redis : non-Dynomite based redis instance
# redis_cluster: AWS Elasticache Redis (cluster mode enabled).See [http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Clusters.Create.CON.RedisCluster.html]
# redis_sentinel: Redis HA with Redis Sentinel. See [https://redis.io/topics/sentinel]
# dynomite : Dynomite cluster.  Use this for HA configuration.
conductor.db.type=dynomite

# Dynomite Cluster details.
# format is host:port:rack separated by semicolon
# for AWS Elasticache Redis (cluster mode enabled) the format is configuration_endpoint:port:us-east-1e. The region in this case does not matter
workflow.dynomite.cluster.hosts=host1:8102:us-east-1c;host2:8102:us-east-1d;host3:8102:us-east-1e

# If you are running using dynomite, also add the following line to the property 
# to set the rack/availability zone of the conductor server to be same as dynomite cluster config
EC2_AVAILABILTY_ZONE=us-east-1c

# Dynomite cluster name
workflow.dynomite.cluster.name=dyno_cluster_name

# Maximum connections to redis/dynomite
workflow.dynomite.connection.maxConnsPerHost=31

# Namespace for the keys stored in Dynomite/Redis
workflow.namespace.prefix=conductor

# Namespace prefix for the dyno queues
workflow.namespace.queue.prefix=conductor_queues

# No. of threads allocated to dyno-queues (optional)
queues.dynomite.threads=10

# Non-quorum port used to connect to local redis.  Used by dyno-queues.
# When using redis directly, set this to the same port as redis server.
# For Dynomite, this is 22122 by default or the local redis-server port used by Dynomite.
queues.dynomite.nonQuorum.port=22122

# Transport address to elasticsearch
# Specifying multiple node urls is not supported. specify one of the nodes' url, or a load balancer.
workflow.elasticsearch.url=localhost:9300

# Name of the elasticsearch cluster
workflow.elasticsearch.index.name=conductor

# Additional modules (optional)
conductor.additional.modules=class_extending_com.google.inject.AbstractModule

Conductor Server 启动时候会根据application.properties配置进行初始化,其中conductor.db.type的值直接决定了 Conductor Server 采用哪种方式进行持久化

  • memory
  • redis_cluster
  • redis_standalone
  • redis_sentinel
  • dynomite
  • cassandra
  • postgres
  • mysql

默认值是memory,该值官方说明:

The data is stored in memory and lost when the server dies. Useful for testing or demo

采用该值时候是不用依懒任何其它中间件,直接就可以运行 Conductor Server。

以上取值分别对应的初始化类是

  • com.netflix.conductor.redis.config.InMemoryRedisConfiguration
  • com.netflix.conductor.redis.config.RedisClusterConfiguration
  • com.netflix.conductor.redis.config.RedisStandaloneConfiguration
  • com.netflix.conductor.redis.config.RedisSentinelConfiguration
  • com.netflix.conductor.redis.config.DynomiteClusterConfiguration
  • com.netflix.conductor.cassandra.config.CassandraConfiguration
  • com.netflix.conductor.postgres.config.PostgresConfiguration
  • com.netflix.conductor.mysql.config.MySQLConfiguration

3.InMemoryRedisConfiguration

conductor.db.type=memory时,Conductor Server 在启动时会执行com.netflix.conductor.redis.config.InMemoryRedisConfiguration

  • 第36行:创建了一个Jedis Bean——JedisMock。
    JedisMock 继承了 Jedis 类,用于 Mock Jedis 功能,它运行在内存中采用org.rarefiedredis.redis包实现。

4. ElasticSearch

Conductor 采用 ElasticSearch 6/7 保存运行日志。

  • conductor.indexing.enabled当值为true 时,
    conductor.elasticsearch.*配置才会生效
    conductor.elasticsearch.version=6 对应的初始化类为com.netflix.conductor.es6.config.ElasticSearchV6Configuration
    conductor.elasticsearch.version=7 对应的初始化类为com.netflix.conductor.es7.config.ElasticSearchV7Configuration
  • conductor.indexing.enabled当值为false时,
    采用的是com.netflix.conductor.contribs.dao.indexNoopIndexDAOConfiguration
    配置类,该类会创建一个com.netflix.conductor.contribs.dao.index.NoopIndexDAO类,但这个类不会有任何实际上的操作。

你可能感兴趣的:(Netflix Conductor 源码分析—— 初始化)