Akka手册译(一)——配置(4)

akka-cluster-metrics

1.##############################################
2.# Akka Cluster Metrics Reference Config File #
3.##############################################
4. 
5.# This is the reference config file that contains all the default settings.
6.# Make your edits in your application.conf in order to override these settings.
7. 
8.# Sigar provisioning:
9.#
10.#  User can provision sigar classes and native library in one of the following ways:
11.# 
12.#  1) Use https://github.com/kamon-io/sigar-loader Kamon sigar-loader as a project dependency for the user project.
13.#  Metrics extension will extract and load sigar library on demand with help of Kamon sigar provisioner.
14.# 
15.#  2) Use https://github.com/kamon-io/sigar-loader Kamon sigar-loader as java agent: `java -javaagent:/path/to/sigar-loader.jar`
16.#  Kamon sigar loader agent will extract and load sigar library during JVM start.
17.# 
18.#  3) Place `sigar.jar` on the `classpath` and sigar native library for the o/s on the `java.library.path`
19.#  User is required to manage both project dependency and library deployment manually.
20. 
21.# Cluster metrics extension.
22.# Provides periodic statistics collection and publication throughout the cluster.
23.akka.cluster.metrics {
24.    # Full path of dispatcher configuration key.
25.    # Use "" for default key `akka.actor.default-dispatcher`.
26.    dispatcher = ""
27.    # How long should any actor wait before starting the periodic tasks.
28.    periodic-tasks-initial-delay = 1s
29.    # Sigar native library extract location.
30.    # Use per-application-instance scoped location, such as program working directory.
31.    native-library-extract-folder = ${user.dir}"/native"
32.    # Metrics supervisor actor.
33.    supervisor {
34.        # Actor name. Example name space: /system/cluster-metrics
35.        name = "cluster-metrics"
36.        # Supervision strategy.
37.        strategy {
38.            #
39.            # FQCN of class providing `akka.actor.SupervisorStrategy`.
40.            # Must have a constructor with signature `<init>(com.typesafe.config.Config)`.
41.            # Default metrics strategy provider is a configurable extension of `OneForOneStrategy`.
42.            provider = "akka.cluster.metrics.ClusterMetricsStrategy"
43.            #
44.            # Configuration of the default strategy provider.
45.            # Replace with custom settings when overriding the provider.
46.            configuration = {
47.                # Log restart attempts.
48.                loggingEnabled = true
49.                # Child actor restart-on-failure window.
50.                withinTimeRange = 3s
51.                # Maximum number of restart attempts before child actor is stopped.
52.                maxNrOfRetries = 3
53.            }
54.        }
55.    }
56.    # Metrics collector actor.
57.    collector {
58.        # Enable or disable metrics collector for load-balancing nodes.
59.        # Metrics collection can also be controlled at runtime by sending control messages
60.        # to /system/cluster-metrics actor: `akka.cluster.metrics.{CollectionStartMessage,CollectionStopMessage}`
61.        enabled = on
62.        # FQCN of the metrics collector implementation.
63.        # It must implement `akka.cluster.metrics.MetricsCollector` and
64.        # have public constructor with akka.actor.ActorSystem parameter.
65.        # Will try to load in the following order of priority: 
66.        # 1) configured custom collector 2) internal `SigarMetricsCollector` 3) internal `JmxMetricsCollector`
67.        provider = ""
68.        # Try all 3 available collector providers, or else fail on the configured custom collector provider.
69.        fallback = true
70.        # How often metrics are sampled on a node.
71.        # Shorter interval will collect the metrics more often.
72.        # Also controls frequency of the metrics publication to the node system event bus. 
73.        sample-interval = 3s
74.        # How often a node publishes metrics information to the other nodes in the cluster.
75.        # Shorter interval will publish the metrics gossip more often.
76.        gossip-interval = 3s
77.        # How quickly the exponential weighting of past data is decayed compared to
78.        # new data. Set lower to increase the bias toward newer values.
79.        # The relevance of each data sample is halved for every passing half-life
80.        # duration, i.e. after 4 times the half-life, a data sample’s relevance is
81.        # reduced to 6% of its original relevance. The initial relevance of a data
82.        # sample is given by 1 – 0.5 ^ (collect-interval / half-life).
83.        # See http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
84.        moving-average-half-life = 12s
85.    }
86.}
87. 
88.# Cluster metrics extension serializers and routers.
89.akka.actor {
90.    # Protobuf serializer for remote cluster metrics messages.
91.    serializers {
92.       akka-cluster-metrics = "akka.cluster.metrics.protobuf.MessageSerializer"
93.    }
94.    # Interface binding for remote cluster metrics messages.
95.    serialization-bindings {
96.       "akka.cluster.metrics.ClusterMetricsMessage" = akka-cluster-metrics
97.    }
98.    # Globally unique metrics extension serializer identifier.
99.    serialization-identifiers {
100.      "akka.cluster.metrics.protobuf.MessageSerializer" = 10
101.    }
102.    #  Provide routing of messages based on cluster metrics.
103.    router.type-mapping {
104.        cluster-metrics-adaptive-pool  = "akka.cluster.metrics.AdaptiveLoadBalancingPool"
105.        cluster-metrics-adaptive-group = "akka.cluster.metrics.AdaptiveLoadBalancingGroup"
106.    }
107.}

akka-cluster-tools

1.############################################
2.# Akka Cluster Tools Reference Config File #
3.############################################
4. 
5.# This is the reference config file that contains all the default settings.
6.# Make your edits/overrides in your application.conf.
7. 
8.# //#pub-sub-ext-config
9.# Settings for the DistributedPubSub extension
10.akka.cluster.pub-sub {
11.  # Actor name of the mediator actor, /system/distributedPubSubMediator
12.  name = distributedPubSubMediator
13. 
14.  # Start the mediator on members tagged with this role.
15.  # All members are used if undefined or empty.
16.  role = ""
17. 
18.  # The routing logic to use for 'Send'
19.  # Possible values: random, round-robin, broadcast
20.  routing-logic = random
21. 
22.  # How often the DistributedPubSubMediator should send out gossip information
23.  gossip-interval = 1s
24. 
25.  # Removed entries are pruned after this duration
26.  removed-time-to-live = 120s
27. 
28.  # Maximum number of elements to transfer in one message when synchronizing the registries.
29.  # Next chunk will be transferred in next round of gossip.
30.  max-delta-elements = 3000
31.  
32.  # The id of the dispatcher to use for DistributedPubSubMediator actors. 
33.  # If not specified default dispatcher is used.
34.  # If specified you need to define the settings of the actual dispatcher.
35.  use-dispatcher = ""
36.}
37.# //#pub-sub-ext-config
38. 
39.# Protobuf serializer for cluster DistributedPubSubMeditor messages
40.akka.actor {
41.  serializers {
42.    akka-pubsub = "akka.cluster.pubsub.protobuf.DistributedPubSubMessageSerializer"
43.  }
44.  serialization-bindings {
45.    "akka.cluster.pubsub.DistributedPubSubMessage" = akka-pubsub
46.  }
47.  serialization-identifiers {
48.    "akka.cluster.pubsub.protobuf.DistributedPubSubMessageSerializer" = 9
49.  }
50.  # adds the protobuf serialization of pub sub messages to groups
51.  additional-serialization-bindings {
52.    "akka.cluster.pubsub.DistributedPubSubMediator$Internal$SendToOneSubscriber" = akka-pubsub
53.  }
54.}
55. 
56. 
57.# //#receptionist-ext-config
58.# Settings for the ClusterClientReceptionist extension
59.akka.cluster.client.receptionist {
60.  # Actor name of the ClusterReceptionist actor, /system/receptionist
61.  name = receptionist
62. 
63.  # Start the receptionist on members tagged with this role.
64.  # All members are used if undefined or empty.
65.  role = ""
66. 
67.  # The receptionist will send this number of contact points to the client
68.  number-of-contacts = 3
69. 
70.  # The actor that tunnel response messages to the client will be stopped
71.  # after this time of inactivity.
72.  response-tunnel-receive-timeout = 30s
73.  
74.  # The id of the dispatcher to use for ClusterReceptionist actors. 
75.  # If not specified default dispatcher is used.
76.  # If specified you need to define the settings of the actual dispatcher.
77.  use-dispatcher = ""
78. 
79.  # How often failure detection heartbeat messages should be received for
80.  # each ClusterClient
81.  heartbeat-interval = 2s
82. 
83.  # Number of potentially lost/delayed heartbeats that will be
84.  # accepted before considering it to be an anomaly.
85.  # The ClusterReceptionist is using the akka.remote.DeadlineFailureDetector, which
86.  # will trigger if there are no heartbeats within the duration
87.  # heartbeat-interval + acceptable-heartbeat-pause, i.e. 15 seconds with
88.  # the default settings.
89.  acceptable-heartbeat-pause = 13s
90. 
91.  # Failure detection checking interval for checking all ClusterClients
92.  failure-detection-interval = 2s
93.}
94.# //#receptionist-ext-config
95. 
96.# //#cluster-client-config
97.# Settings for the ClusterClient
98.akka.cluster.client {
99.  # Actor paths of the ClusterReceptionist actors on the servers (cluster nodes)
100.  # that the client will try to contact initially. It is mandatory to specify
101.  # at least one initial contact. 
102.  # Comma separated full actor paths defined by a string on the form of
103.  # "akka.tcp://system@hostname:port/system/receptionist"
104.  initial-contacts = []
105.  
106.  # Interval at which the client retries to establish contact with one of 
107.  # ClusterReceptionist on the servers (cluster nodes)
108.  establishing-get-contacts-interval = 3s
109.  
110.  # Interval at which the client will ask the ClusterReceptionist for
111.  # new contact points to be used for next reconnect.
112.  refresh-contacts-interval = 60s
113.  
114.  # How often failure detection heartbeat messages should be sent
115.  heartbeat-interval = 2s
116.  
117.  # Number of potentially lost/delayed heartbeats that will be
118.  # accepted before considering it to be an anomaly.
119.  # The ClusterClient is using the akka.remote.DeadlineFailureDetector, which
120.  # will trigger if there are no heartbeats within the duration 
121.  # heartbeat-interval + acceptable-heartbeat-pause, i.e. 15 seconds with
122.  # the default settings.
123.  acceptable-heartbeat-pause = 13s
124.  
125.  # If connection to the receptionist is not established the client will buffer
126.  # this number of messages and deliver them the connection is established.
127.  # When the buffer is full old messages will be dropped when new messages are sent
128.  # via the client. Use 0 to disable buffering, i.e. messages will be dropped
129.  # immediately if the location of the singleton is unknown.
130.  # Maximum allowed buffer size is 10000.
131.  buffer-size = 1000
132. 
133.  # If connection to the receiptionist is lost and the client has not been
134.  # able to acquire a new connection for this long the client will stop itself.
135.  # This duration makes it possible to watch the cluster client and react on a more permanent
136.  # loss of connection with the cluster, for example by accessing some kind of
137.  # service registry for an updated set of initial contacts to start a new cluster client with.
138.  # If this is not wanted it can be set to "off" to disable the timeout and retry
139.  # forever.
140.  reconnect-timeout = off
141.}
142.# //#cluster-client-config
143. 
144.# Protobuf serializer for ClusterClient messages
145.akka.actor {
146.  serializers {
147.    akka-cluster-client = "akka.cluster.client.protobuf.ClusterClientMessageSerializer"
148.  }
149.  serialization-bindings {
150.    "akka.cluster.client.ClusterClientMessage" = akka-cluster-client
151.  }
152.  serialization-identifiers {
153.    "akka.cluster.client.protobuf.ClusterClientMessageSerializer" = 15
154.  }
155.}
156. 
157.# //#singleton-config
158.akka.cluster.singleton {
159.  # The actor name of the child singleton actor.
160.  singleton-name = "singleton"
161.  
162.  # Singleton among the nodes tagged with specified role.
163.  # If the role is not specified it's a singleton among all nodes in the cluster.
164.  role = ""
165.  
166.  # When a node is becoming oldest it sends hand-over request to previous oldest, 
167.  # that might be leaving the cluster. This is retried with this interval until 
168.  # the previous oldest confirms that the hand over has started or the previous 
169.  # oldest member is removed from the cluster (+ akka.cluster.down-removal-margin).
170.  hand-over-retry-interval = 1s
171.  
172.  # The number of retries are derived from hand-over-retry-interval and
173.  # akka.cluster.down-removal-margin (or ClusterSingletonManagerSettings.removalMargin),
174.  # but it will never be less than this property.
175.  min-number-of-hand-over-retries = 10
176.}
177.# //#singleton-config
178. 
179.# //#singleton-proxy-config
180.akka.cluster.singleton-proxy {
181.  # The actor name of the singleton actor that is started by the ClusterSingletonManager
182.  singleton-name = ${akka.cluster.singleton.singleton-name}
183.  
184.  # The role of the cluster nodes where the singleton can be deployed. 
185.  # If the role is not specified then any node will do.
186.  role = ""
187.  
188.  # Interval at which the proxy will try to resolve the singleton instance.
189.  singleton-identification-interval = 1s
190.  
191.  # If the location of the singleton is unknown the proxy will buffer this
192.  # number of messages and deliver them when the singleton is identified. 
193.  # When the buffer is full old messages will be dropped when new messages are
194.  # sent via the proxy.
195.  # Use 0 to disable buffering, i.e. messages will be dropped immediately if
196.  # the location of the singleton is unknown.
197.  # Maximum allowed buffer size is 10000.
198.  buffer-size = 1000 
199.}
200.# //#singleton-proxy-config
201. 
202.# Serializer for cluster ClusterSingleton messages
203.akka.actor {
204.  serializers {
205.    akka-singleton = "akka.cluster.singleton.protobuf.ClusterSingletonMessageSerializer"
206.  }
207.  serialization-bindings {
208.    "akka.cluster.singleton.ClusterSingletonMessage" = akka-singleton
209.  }
210.  serialization-identifiers {
211.    "akka.cluster.singleton.protobuf.ClusterSingletonMessageSerializer" = 14
212.  }
213.}

akka-cluster-sharding

1.###############################################
2.# Akka Cluster Sharding Reference Config File #
3.###############################################
4. 
5.# This is the reference config file that contains all the default settings.
6.# Make your edits/overrides in your application.conf.
7. 
8. 
9.# //#sharding-ext-config
10.# Settings for the ClusterShardingExtension
11.akka.cluster.sharding {
12. 
13.  # The extension creates a top level actor with this name in top level system scope,
14.  # e.g. '/system/sharding'
15.  guardian-name = sharding
16. 
17.  # Specifies that entities runs on cluster nodes with a specific role.
18.  # If the role is not specified (or empty) all nodes in the cluster are used.
19.  role = ""
20. 
21.  # When this is set to 'on' the active entity actors will automatically be restarted
22.  # upon Shard restart. i.e. if the Shard is started on a different ShardRegion
23.  # due to rebalance or crash.
24.  remember-entities = off
25. 
26.  # If the coordinator can't store state changes it will be stopped
27.  # and started again after this duration, with an exponential back-off
28.  # of up to 5 times this duration.
29.  coordinator-failure-backoff = 5 s
30. 
31.  # The ShardRegion retries registration and shard location requests to the
32.  # ShardCoordinator with this interval if it does not reply.
33.  retry-interval = 2 s
34. 
35.  # Maximum number of messages that are buffered by a ShardRegion actor.
36.  buffer-size = 100000
37. 
38.  # Timeout of the shard rebalancing process.
39.  handoff-timeout = 60 s
40. 
41.  # Time given to a region to acknowledge it's hosting a shard.
42.  shard-start-timeout = 10 s
43. 
44.  # If the shard is remembering entities and can't store state changes
45.  # will be stopped and then started again after this duration. Any messages
46.  # sent to an affected entity may be lost in this process.
47.  shard-failure-backoff = 10 s
48. 
49.  # If the shard is remembering entities and an entity stops itself without
50.  # using passivate. The entity will be restarted after this duration or when
51.  # the next message for it is received, which ever occurs first.
52.  entity-restart-backoff = 10 s
53. 
54.  # Rebalance check is performed periodically with this interval.
55.  rebalance-interval = 10 s
56. 
57.  # Absolute path to the journal plugin configuration entity that is to be
58.  # used for the internal persistence of ClusterSharding. If not defined
59.  # the default journal plugin is used. Note that this is not related to
60.  # persistence used by the entity actors.
61.  journal-plugin-id = ""
62. 
63.  # Absolute path to the snapshot plugin configuration entity that is to be
64.  # used for the internal persistence of ClusterSharding. If not defined
65.  # the default snapshot plugin is used. Note that this is not related to
66.  # persistence used by the entity actors.
67.  snapshot-plugin-id = ""
68. 
69.  # Parameter which determines how the coordinator will be store a state
70.  # valid values either "persistence" or "ddata"
71.  # The "ddata" mode is experimental, since it depends on the experimental
72.  # module akka-distributed-data-experimental.
73.  state-store-mode = "persistence"
74. 
75.  # The shard saves persistent snapshots after this number of persistent
76.  # events. Snapshots are used to reduce recovery times.
77.  snapshot-after = 1000
78. 
79.  # Setting for the default shard allocation strategy
80.  least-shard-allocation-strategy {
81.    # Threshold of how large the difference between most and least number of
82.    # allocated shards must be to begin the rebalancing.
83.    rebalance-threshold = 10
84. 
85.    # The number of ongoing rebalancing processes is limited to this number.
86.    max-simultaneous-rebalance = 3
87.  }
88. 
89.  # Timeout of waiting the initial distributed state (an initial state will be queried again if the timeout happened)
90.  # works only for state-store-mode = "ddata"
91.  waiting-for-state-timeout = 5 s
92. 
93.  # Timeout of waiting for update the distributed state (update will be retried if the timeout happened)
94.  # works only for state-store-mode = "ddata"
95.  updating-state-timeout = 5 s
96. 
97.  # The shard uses this strategy to determines how to recover the underlying entity actors. The strategy is only used
98.  # by the persistent shard when rebalancing or restarting. The value can either be "all" or "constant". The "all"
99.  # strategy start all the underlying entity actors at the same time. The constant strategy will start the underlying
100.  # entity actors at a fix rate. The default strategy "all".
101.  entity-recovery-strategy = "all"
102. 
103.  # Default settings for the constant rate entity recovery strategy
104.  entity-recovery-constant-rate-strategy {
105.    # Sets the frequency at which a batch of entity actors is started.
106.    frequency = 100 ms
107.    # Sets the number of entity actors to be restart at a particular interval
108.    number-of-entities = 5
109.  }
110. 
111.  # Settings for the coordinator singleton. Same layout as akka.cluster.singleton.
112.  # The "role" of the singleton configuration is not used. The singleton role will
113.  # be the same as "akka.cluster.sharding.role".
114.  coordinator-singleton = ${akka.cluster.singleton}
115. 
116.  # The id of the dispatcher to use for ClusterSharding actors.
117.  # If not specified default dispatcher is used.
118.  # If specified you need to define the settings of the actual dispatcher.
119.  # This dispatcher for the entity actors is defined by the user provided
120.  # Props, i.e. this dispatcher is not used for the entity actors.
121.  use-dispatcher = ""
122.}
123.# //#sharding-ext-config
124. 
125. 
126.# Protobuf serializer for Cluster Sharding messages
127.akka.actor {
128.  serializers {
129.    akka-sharding = "akka.cluster.sharding.protobuf.ClusterShardingMessageSerializer"
130.  }
131.  serialization-bindings {
132.    "akka.cluster.sharding.ClusterShardingSerializable" = akka-sharding
133.  }
134.  serialization-identifiers {
135.    "akka.cluster.sharding.protobuf.ClusterShardingMessageSerializer" = 13
136.  }
137.}

akka-distributed-data

1.##############################################
2.# Akka Distributed DataReference Config File #
3.##############################################
4. 
5.# This is the reference config file that contains all the default settings.
6.# Make your edits/overrides in your application.conf.
7. 
8. 
9.#//#distributed-data
10.# Settings for the DistributedData extension
11.akka.cluster.distributed-data {
12.  # Actor name of the Replicator actor, /system/ddataReplicator
13.  name = ddataReplicator
14. 
15.  # Replicas are running on members tagged with this role.
16.  # All members are used if undefined or empty.
17.  role = ""
18. 
19.  # How often the Replicator should send out gossip information
20.  gossip-interval = 2 s
21. 
22.  # How often the subscribers will be notified of changes, if any
23.  notify-subscribers-interval = 500 ms
24. 
25.  # Maximum number of entries to transfer in one gossip message when synchronizing
26.  # the replicas. Next chunk will be transferred in next round of gossip.
27.  max-delta-elements = 1000
28.  
29.  # The id of the dispatcher to use for Replicator actors. If not specified
30.  # default dispatcher is used.
31.  # If specified you need to define the settings of the actual dispatcher.
32.  use-dispatcher = ""
33. 
34.  # How often the Replicator checks for pruning of data associated with
35.  # removed cluster nodes.
36.  pruning-interval = 30 s
37.  
38.  # How long time it takes (worst case) to spread the data to all other replica nodes.
39.  # This is used when initiating and completing the pruning process of data associated
40.  # with removed cluster nodes. The time measurement is stopped when any replica is 
41.  # unreachable, so it should be configured to worst case in a healthy cluster.
42.  max-pruning-dissemination = 60 s
43.  
44.  # Serialized Write and Read messages are cached when they are sent to 
45.  # several nodes. If no further activity they are removed from the cache
46.  # after this duration.
47.  serializer-cache-time-to-live = 10s
48.  
49.  durable {
50.    # List of keys that are durable. Prefix matching is supported by using * at the
51.    # end of a key.  
52.    keys = []
53.    
54.    # Fully qualified class name of the durable store actor. It must be a subclass
55.    # of akka.actor.Actor and handle the protocol defined in 
56.    # akka.cluster.ddata.DurableStore. The class must have a constructor with 
57.    # com.typesafe.config.Config parameter.
58.    store-actor-class = akka.cluster.ddata.LmdbDurableStore
59.    
60.    use-dispatcher = akka.cluster.distributed-data.durable.pinned-store
61.    
62.    pinned-store {
63.      executor = thread-pool-executor
64.      type = PinnedDispatcher
65.    }
66.    
67.    # Config for the LmdbDurableStore
68.    lmdb {
69.      # Directory of LMDB file. There are two options:
70.      # 1. A relative or absolute path to a directory that ends with 'ddata'
71.      #    the full name of the directory will contain name of the ActorSystem
72.      #    and its remote port.
73.      # 2. Otherwise the path is used as is, as a relative or absolute path to
74.      #    a directory.
75.      dir = "ddata"
76.      
77.      # Size in bytes of the memory mapped file.
78.      map-size = 100 MiB
79.      
80.      # Accumulate changes before storing improves performance with the
81.      # risk of losing the last writes if the JVM crashes.
82.      # The interval is by default set to 'off' to write each update immediately.
83.      # Enabling write behind by specifying a duration, e.g. 200ms, is especially 
84.      # efficient when performing many writes to the same key, because it is only 
85.      # the last value for each key that will be serialized and stored.  
86.      # write-behind-interval = 200 ms
87.      write-behind-interval = off
88.    }
89.  }
90.  
91.}
92.#//#distributed-data
93. 
94.# Protobuf serializer for cluster DistributedData messages
95.akka.actor {
96.  serializers {
97.    akka-data-replication = "akka.cluster.ddata.protobuf.ReplicatorMessageSerializer"
98.    akka-replicated-data = "akka.cluster.ddata.protobuf.ReplicatedDataSerializer"
99.  }
100.  serialization-bindings {
101.    "akka.cluster.ddata.Replicator$ReplicatorMessage" = akka-data-replication
102.    "akka.cluster.ddata.ReplicatedDataSerialization" = akka-replicated-data
103.  }
104.  serialization-identifiers {
105.    "akka.cluster.ddata.protobuf.ReplicatedDataSerializer" = 11
106.    "akka.cluster.ddata.protobuf.ReplicatorMessageSerializer" = 12
107.  }
108.}

推荐阅读更多精彩内容