-
Notifications
You must be signed in to change notification settings - Fork 215
/
ConnectionConfig.java
249 lines (207 loc) · 7.65 KB
/
ConnectionConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
* Copyright (c) 2019 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.connectivity.service.config;
import java.time.Duration;
import java.util.Collection;
import javax.annotation.concurrent.Immutable;
import org.eclipse.ditto.base.service.config.supervision.WithSupervisorConfig;
import org.eclipse.ditto.internal.models.acks.config.AcknowledgementConfig;
import org.eclipse.ditto.internal.utils.config.KnownConfigValue;
import org.eclipse.ditto.internal.utils.persistence.mongo.config.SnapshotConfig;
import org.eclipse.ditto.internal.utils.persistence.mongo.config.WithActivityCheckConfig;
import org.eclipse.ditto.internal.utils.persistentactors.cleanup.WithCleanupConfig;
/**
* Provides configuration settings for Connectivity service's connection behaviour.
*/
@Immutable
public interface ConnectionConfig extends WithSupervisorConfig, WithActivityCheckConfig, WithCleanupConfig {
/**
* Returns the amount of time for how long the connection actor waits for response from client actors.
* By default this value is very high because connection establishment can take very long.
* If the timeout was set too low early, the connection would not be subscribed for events properly.
*
* @return the timeout.
*/
Duration getClientActorAskTimeout();
/**
* Returns how often the connection actor will retry starting a failing client actor. If exceeded, errors will
* be escalated to the supervisor, which will effectively cause the whole connection to be restarted.
*/
int getClientActorRestartsBeforeEscalation();
/**
* @return the list of allowed hostnames to which outgoing connections are allowed. This list overrides the list
* of blocked hostnames.
*/
Collection<String> getAllowedHostnames();
/**
* @return the list of blocked hostnames to which outgoing connections are prevented.
* Outgoing connections to private, wildcard, loopback and multicast addresses are also prevented
* when the list is nonempty.
*/
Collection<String> getBlockedHostnames();
/**
* @return the list of blocked subnets to which outgoing connections are prevented.
*/
Collection<String> getBlockedSubnets();
/**
* @return the regex to use for hostnames to which outgoing connections are prevented.
*/
String getBlockedHostRegex();
/**
* Returns the config of the connection snapshotting behaviour.
*
* @return the config.
*/
SnapshotConfig getSnapshotConfig();
/**
* Returns the maximum number of Targets within a connection.
*
* @return the config.
*/
Integer getMaxNumberOfTargets();
/**
* Returns the maximum number of Sources within a connection.
*
* @return the config.
*/
Integer getMaxNumberOfSources();
/**
* Returns the config specific to Acknowledgements for connections.
*
* @return the config.
*/
AcknowledgementConfig getAcknowledgementConfig();
/**
* Returns the config specific to the AMQP 1.0 protocol.
*
* @return the config.
*/
Amqp10Config getAmqp10Config();
/**
* Returns the config specific to the AMQP 0.9.1 protocol.
*
* @return the config.
* @since 1.2.0
*/
Amqp091Config getAmqp091Config();
/**
* Returns the config specific to the MQTT protocol.
*
* @return the config.
*/
MqttConfig getMqttConfig();
/**
* Returns the Kafka configuration settings.
*
* @return the config.
*/
KafkaConfig getKafkaConfig();
/**
* Returns the configuration for connection type http-push.
*
* @return the config.
*/
HttpPushConfig getHttpPushConfig();
/**
* Returns the acknowledgement label declaration interval.
*
* @return how often to declare acknowledgement labels for as long as it is not successful.
*/
Duration getAckLabelDeclareInterval();
/**
* Returns the priority update interval.
*
* @return how often to update the priority of a connection.
*/
Duration getPriorityUpdateInterval();
/**
* Whether to start all client actors on one node.
* Useful for single-connectivity-instance deployments.
*
* @return whether to start all client actors on the same node as the connection persistence actor.
*/
boolean areAllClientActorsOnOneNode();
/**
* Whether usernames and passwords in connection URIs should be double decoded, when creating the connection.
* @return whether double decoding in enabled.
*/
boolean doubleDecodingEnabled();
/**
* An enumeration of the known config path expressions and their associated default values for
* {@code ConnectionConfig}.
*/
enum ConnectionConfigValue implements KnownConfigValue {
/**
* The amount of time for how long the connection actor waits for response from client actors.
*/
CLIENT_ACTOR_ASK_TIMEOUT("client-actor-ask-timeout", Duration.ofSeconds(60L)),
/**
* How often the connection actor will retry starting a failing client actor before escalation to the supervisor.
*/
CLIENT_ACTOR_RESTARTS_BEFORE_ESCALATION("client-actor-restarts-before-escalation", 3),
/**
* Whether to start all client actors on 1 node.
*/
ALL_CLIENT_ACTORS_ON_ONE_NODE("all-client-actors-on-one-node", false),
/**
* A comma separated list of allowed hostnames to which http requests will be sent.
*/
ALLOWED_HOSTNAMES("allowed-hostnames", ""),
/**
* A comma separated list of blocked hostnames to which no http requests will be sent out.
*/
BLOCKED_HOSTNAMES("blocked-hostnames", ""),
/**
* A comma separated list of blocked subnets to which no http requests will be sent out.
*/
BLOCKED_SUBNETS("blocked-subnets", ""),
/**
* The regex to determine blocked hosts.
*/
BLOCKED_HOST_REGEX("blocked-host-regex", ""),
/**
* The limitation number of sources within a connection.
*/
MAX_SOURCE_NUMBER("max-source-number", 4),
/**
* The limitation number of targets within a connection.
*/
MAX_TARGET_NUMBER("max-target-number", 4),
/**
* How often to attempt acknowledgement label declaration for as long as it is not successful.
*/
ACK_LABEL_DECLARE_INTERVAL("ack-label-declare-interval", Duration.ofSeconds(10L)),
/**
* How often the priority of a connection is getting updated.
*/
PRIORITY_UPDATE_INTERVAL("priority-update-interval", Duration.ofHours(24L)),
/**
* Whether double decoding of usernames and passwords in connection URIs is enabled.
*/
DOUBLE_DECODING_ENABLED("double-decoding-enabled", true);
private final String path;
private final Object defaultValue;
private ConnectionConfigValue(final String thePath, final Object theDefaultValue) {
path = thePath;
defaultValue = theDefaultValue;
}
@Override
public Object getDefaultValue() {
return defaultValue;
}
@Override
public String getConfigPath() {
return path;
}
}
}