This repository was archived by the owner on May 11, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathClusterDefinition.java
More file actions
256 lines (214 loc) · 11.1 KB
/
ClusterDefinition.java
File metadata and controls
256 lines (214 loc) · 11.1 KB
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
250
251
252
253
254
255
256
/*
* JBoss, Home of Professional Open Source
* Copyright ${year}, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.extension.cassandra;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.wildfly.extension.cassandra.future.PersistentResourceDefinition;
import org.wildfly.extension.cassandra.future.ServiceRemoveStepHandler;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* The cluster resource definition. Carries the main cassanda configuration attributes.
*
* @author Heiko Braun
* @since 20/08/14
*/
public class ClusterDefinition extends PersistentResourceDefinition {
private ClusterDefinition() {
super(CassandraExtension.CLUSTER_PATH,
CassandraExtension.getResourceDescriptionResolver(CassandraModel.CLUSTER),
ClusterAdd.INSTANCE,
new ServiceRemoveStepHandler(ClusterAdd.SERVICE_NAME, ClusterAdd.INSTANCE));
}
// -----------
static final SimpleAttributeDefinition DEBUG =
new SimpleAttributeDefinitionBuilder(CassandraModel.DEBUG, ModelType.BOOLEAN, true)
.setAllowExpression(true)
.setDefaultValue(new ModelNode(false))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition NUM_TOKENS =
new SimpleAttributeDefinitionBuilder(CassandraModel.NUM_TOKENS, ModelType.INT, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode(256))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition HINTED_HANDOFF_ENABLED =
new SimpleAttributeDefinitionBuilder(CassandraModel.HINTED_HANDOFF_ENABLED, ModelType.BOOLEAN, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode(true))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition AUTHENTICATOR =
new SimpleAttributeDefinitionBuilder(CassandraModel.AUTHENTICATOR, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("AllowAllAuthenticator"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition AUTHORIZER =
new SimpleAttributeDefinitionBuilder(CassandraModel.AUTHORIZER, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("AllowAllAuthorizer"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition PARTIONER =
new SimpleAttributeDefinitionBuilder(CassandraModel.PARTITIONER, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("org.apache.cassandra.dht.Murmur3Partitioner"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition SEED_PROVIDER =
new SimpleAttributeDefinitionBuilder(CassandraModel.SEED_PROVIDER, ModelType.STRING, false)
.setAllowExpression(false)
.setRestartAllServices()
.build();
// TODO: this should become a list of seeds
static final SimpleAttributeDefinition SEEDS =
new SimpleAttributeDefinitionBuilder(CassandraModel.SEEDS, ModelType.STRING, false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition LISTEN_ADDRESS =
new SimpleAttributeDefinitionBuilder(CassandraModel.LISTEN_ADDRESS, ModelType.STRING, false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition BROADCAST_ADDRESS =
new SimpleAttributeDefinitionBuilder(CassandraModel.BROADCAST_ADDRESS, ModelType.STRING, false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition START_NATIVE_TRANSPORT =
new SimpleAttributeDefinitionBuilder(CassandraModel.START_NATIVE_TRANSPORT, ModelType.BOOLEAN, false)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition START_RPC =
new SimpleAttributeDefinitionBuilder(CassandraModel.START_RPC, ModelType.BOOLEAN, false)
.setAllowExpression(false)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition NATIVE_TRANSPORT_PORT =
new SimpleAttributeDefinitionBuilder(CassandraModel.NATIVE_TRANSPORT_PORT, ModelType.INT, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode(9042))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition RPC_PORT =
new SimpleAttributeDefinitionBuilder(CassandraModel.RPC_PORT, ModelType.INT, true)
.setAllowExpression(true)
.setDefaultValue(new ModelNode(9160))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition INTERNODE_AUTHENTICATOR =
new SimpleAttributeDefinitionBuilder(CassandraModel.INTERNODE_AUTHENTICATOR, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("org.apache.cassandra.auth.AllowAllInternodeAuthenticator"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition DATA_FILE_DIR =
new SimpleAttributeDefinitionBuilder(CassandraModel.DATA_FILE_DIR, ModelType.STRING, true)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition SAVED_CACHES_DIR =
new SimpleAttributeDefinitionBuilder(CassandraModel.SAVED_CACHES_DIR, ModelType.STRING, true)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition COMMIT_LOG_DIR =
new SimpleAttributeDefinitionBuilder(CassandraModel.COMMIT_LOG_DIR, ModelType.STRING, true)
.setAllowExpression(true)
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition COMMIT_LOG_SYNC =
new SimpleAttributeDefinitionBuilder(CassandraModel.COMMIT_LOG_SYNC, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("periodic"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition COMMIT_LOG_SYNC_PERIOD =
new SimpleAttributeDefinitionBuilder(CassandraModel.COMMIT_LOG_SYNC_PERIOD, ModelType.INT, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode(10000))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition ENDPOINT_SNITCH =
new SimpleAttributeDefinitionBuilder(CassandraModel.ENDPOINT_SNITCH, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("SimpleSnitch"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition REQUEST_SCHEDULER =
new SimpleAttributeDefinitionBuilder(CassandraModel.REQUEST_SCHEDULER, ModelType.STRING, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode("org.apache.cassandra.scheduler.NoScheduler"))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition SERVER_ENCRYPTION =
new SimpleAttributeDefinitionBuilder(CassandraModel.SERVER_ENCRYPTION, ModelType.BOOLEAN, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode(false))
.setRestartAllServices()
.build();
static final SimpleAttributeDefinition CLIENT_ENCRYPTION =
new SimpleAttributeDefinitionBuilder(CassandraModel.CLIENT_ENCRYPTION, ModelType.BOOLEAN, true)
.setAllowExpression(false)
.setDefaultValue(new ModelNode(false))
.setRestartAllServices()
.build();
// -----------
static final AttributeDefinition[] ATTRIBUTES = {
DEBUG, NUM_TOKENS,
HINTED_HANDOFF_ENABLED,
AUTHENTICATOR, AUTHORIZER,
PARTIONER,
SEED_PROVIDER, SEEDS,
LISTEN_ADDRESS, BROADCAST_ADDRESS,
START_NATIVE_TRANSPORT, NATIVE_TRANSPORT_PORT,
START_RPC, RPC_PORT,
COMMIT_LOG_DIR, SAVED_CACHES_DIR, DATA_FILE_DIR,
INTERNODE_AUTHENTICATOR,
COMMIT_LOG_SYNC, COMMIT_LOG_SYNC_PERIOD,
ENDPOINT_SNITCH,
REQUEST_SCHEDULER,
CLIENT_ENCRYPTION, SERVER_ENCRYPTION
};
private static final List CHILDREN = Collections.EMPTY_LIST;
static final ClusterDefinition INSTANCE = new ClusterDefinition();
@Override
public void registerAttributes(final ManagementResourceRegistration rootResourceRegistration) {
ClusterWriteAttributeHandler handler = new ClusterWriteAttributeHandler(ATTRIBUTES);
for (AttributeDefinition attr : ATTRIBUTES) {
rootResourceRegistration.registerReadWriteAttribute(attr, null, handler);
}
}
@Override
public Collection<AttributeDefinition> getAttributes() {
return Arrays.asList(ATTRIBUTES);
}
@Override
protected List<? extends PersistentResourceDefinition> getChildren() {
return CHILDREN;
}
}