Hmily-Config

Edit
Update time: 2021-03-03

Configuration Detail:

  • File Name: hmily.yml

  • Path: The default path is the resource directory of the project, which can be specified by -Dhmily.conf, and you can also put the configuration in user.dir directory. Priority: -Dhmily.conf > user.dir > resource

hmily:
  server:
    configMode: local
    appName: xiaoyu  
  #  The following configuration will be read when server.configMode equals local
  config:
    appName: xiaoyu
    serializer: kryo
    contextTransmittalMode: threadLocal
    scheduledThreadMax: 16
    scheduledRecoveryDelay: 60
    scheduledCleanDelay: 60
    scheduledPhyDeletedDelay: 600
    scheduledInitDelay: 30
    recoverDelayTime: 60
    cleanDelayTime: 180
    limit: 200
    retryMax: 10
    bufferSize: 8192
    consumerThreads: 16
    asyncRepository: true
    autoSql: true
    phyDeleted: true
    storeDays: 3
    repository: mysql

repository:
  database:
    driverClassName: com.mysql.jdbc.Driver
    url :
    username:
    password:
    maxActive: 20
    minIdle: 10
    connectionTimeout: 30000
    idleTimeout: 600000
    maxLifetime: 1800000
  file:
    path:
    prefix: /hmily
  mongo:
    databaseName:
    url:
    userName:
    password:
  zookeeper:
    host: localhost:2181
    sessionTimeOut: 1000
    rootPath: /hmily
  redis:
    cluster: false
    sentinel: false
    clusterUrl:
    sentinelUrl:
    masterName:
    hostName:
    port:
    password:
    maxTotal: 8
    maxIdle: 8
    minIdle: 2
    maxWaitMillis: -1
    minEvictableIdleTimeMillis: 1800000
    softMinEvictableIdleTimeMillis: 1800000
    numTestsPerEvictionRun: 3
    testOnCreate: false
    testOnBorrow: false
    testOnReturn: false
    testWhileIdle: false
    timeBetweenEvictionRunsMillis: -1
    blockWhenExhausted: true
    timeOut: 1000

metrics:
  metricsName: prometheus
  host:
  port: 9091
  async: true
  threadCount : 16
  jmxConfig:

Hmily.server Configuration

NameTypeDefaultRequiredDescription
configModeStringlocalyesConfiguration mode supports local,zookeeper,nacos, and apollo now. If configuration is local, it will read the configuration from yml file;If the configuration is other modes, it will get the configuration form configuration centre.
appNameStringnullyesApplication name. AppName will be overwritten if also configured in hmilyConfig.

Hmily.config Configuration

  • This is the core configuration of the whole framework
NameTypeDefaultRequiredDescription
appNameStringnullyesIt filled in your Microservices application’s name generally, but don’t repeat it
serializerStringkryonoThis is mode of serializing the specified transaction log,and currently supports filling in kryo, hessian, jdk, jdk, protostuff
contextTransmittalModeStringthreadLocalnoThis is the mode of transaction context transfer, and currently supports filling in threadLocal, transmittable (Cross-thread mode)
scheduledThreadMaxintCPU * 2noMaximum number of scheduled threads
scheduledRecoveryDelayint(unit:sec)60noScheduling cycle of auto recovering transaction log
scheduledCleanDelayint(unit:sec)60noScheduling cycle of cleaning transaction log
scheduledPhyDeletedDelayint(unit:sec)60noScheduling cycle of deleting transaction log
scheduledInitDelayint(unit:sec)30noDelay time of starting scheduled task
recoverDelayTimeint(unit:sec)60noDelay time of recovering transaction log
cleanDelayTimeint(unit:sec)60noDelay time of cleaning transaction log
limitint100noTransaction log row size
retryMaxint10noMaximum number of retries
bufferSizeint4096 * 2 * 2noBuffer size of disruptor
consumerThreadsintCPU * 2noThe number of consumer thread of disruptor
asyncRepositorybooleantruenoWhether to store the transaction log asynchronously or not; If set to false, it will be synchronous
autoSqlbooleantruenoWhether automatically execute the SQL statement to create databases and tables (If they have been created, you can set false)
phyDeletedbooleantruenoIn running time,whether delete logs physically. Setting false will change the state of log.
storeDaysint(unit:day)3noIf phyDeleted set false,storeDays means days of storage
repositoryStringmysqlyesThis is specified storage mode of transaction log,and currently supports filling in mysql, oracle, postgresql, sqlserver, mongo, redis, file

Repository Configuration

Repository is a configuration for storing transaction logs by Hmily, and currently supports: database(mysql, oracle, postgresql, sqlserver), file(dev, test, prod), mongodb, zookeeper, redis.

  • database configuration(The default pool is hikari):
NameTypeDefaultRequiredDescription
driverClassNameStringcom.mysql.jdbc.Driveryesdriver name of your connection
urlStringnullyesurl connection of your database
usernameStringnullyesusername of your database
passwordStringnullyespassword of your database
maxActiveint20noMaximum active number of connections of pool
minIdleint10noMinimum idle number of connections of pool
connectionTimeoutlong30000noA timeout of connecting to your database
idleTimeoutlong60000noMaximum time(ms) of a idle connection,it will be retired when timeout,default:10 minutes
maxLifetimelong1800000noMaximum lifespan of a connection(ms),it will be retired when it is timeout and don’t be used,default:30 minutes; Suggest less 30 sec than timeout of database, please refer to MySQL wait_timeout parameter(show variables like ‘%timeout%’;
idleTimeoutlong60000noMaximum time(ms) of timeout ,it will be retired when timeout,default:10 minutes
dataSourcePropertyMapMapnullnoThe other property configuration of hikari
  • mongo configuration:
NameTypeDefaultRequiredDescription
databaseNameStringnullyesmongo name
urlStringnullyesmongo url
userNameStringnullyesmongo username
passwordStringnullyesmongo password
  • file configuration:
NameTypeDefaultRequiredDescription
pathStringnullnothe storage path to the file
prefixStringnullnoprefix of file storage
  • zookeeper configuration:
nameTypeDefaultRequiredDescription
hostStringlocalhost:2181yeszookeeper service ip and port
sessionTimeOutint(ms)1000yesthe timeout of session
rootPathString/hmilynoroot storage path
  • redis configuration:
NameTypeDefaultRequiredDescription
clusterbooleanfalsenoIs it cluster?
sentinelbooleanfalsenoIs it sentinel mode?
clusterUrlStringnullnoCluster url,multiple nodes use ; to separate
sentinelUrlStringnullnoSentinel url,multiple nodes use ; to separate
masterNameStringnullnoMain node name, and it can be empty if no setting
hostNameStringnullyesRedis host in redis standalone mode
portintnullyesRedis port in standalone mode
passwordStringnullyesPassword of redis service
maxTotalint8noMaximum number of connections
maxIdleint8noMaximum number of idle connections
minIdleint0noMinimum number of idle connections
maxWaitMillisint-1noWhen connections of the resource pool is exhausted, the maximum wait time of caller (ms); -1:never timeout, don’t suggest setting it
minEvictableIdleTimeMillisint1800000noMinimum idle time of resource pool (ms),idle resource will be removed when reaching to the value;The default is 1000*60 *30 = 30 minutes
softMinEvictableIdleTimeMillisint1800000noHow long evicted idle object, when idle time > the value and idle connection numbers > maximum idle connections, it will be evicted directly, no longer based on MinEvictableIdleTimeMillis to judge (Default eviction policy)
numTestsPerEvictionRunint3noMaximum number of evictions at each eviction check; If it is negative, it is : 1/abs(n), the default is 3
timeBetweenEvictionRunsMillisint-1noTime interval of eviction scan (milliseconds) If it is negative, the eviction thread will not run, and the default is -1
timeOutint1000notimeout
testOnCreatebooleanfalsenoIs the validity verified when obtaining the connection
testOnBorrowbooleanfalsenoWhether process alidate operation in advance when borrow a jedis instance; If it is true,the returned jedis instances are all avaiable
testOnReturnbooleanfalsenoWhether process validate operation in advance before return to pool
testWhileIdlebooleanfalsenoIf it is true,it means there is a idle object evitor thread that is scanning idle object; If validate fail,the object will be dropped from pool;This item only take effect when timeBetweenEvictionRunsMillis is greater than 0
blockWhenExhaustedbooleantruenoWhether block the connection when resource is exhausted, false will throw exception, true will block until timeout

Metrics Configuration

Metrics will record call numbers, runtime, transaction submission and failure in the runtime of the hmily framework,only supports prometheus currently.

NameTypeDefaultRequiredDescription
metricsNameStringprometheusyesSupported type,only supports prometheus currently
hostStringlocalhostnoExposed http services host;
portint9091yesExposed http services port;
asyncbooleantruenoAsynchronous mode record or not
threadCountint2 * cpunoNumber of threads in asynchronous mode
jmxConfigStringnullnojmxConfig configuration,is a json format,and please refer to prometheus official website for details