-
Notifications
You must be signed in to change notification settings - Fork 68
multi-dc-basic #115
multi-dc-basic #115
Changes from 2 commits
b6fbdb8
5c2db1d
e771f14
211b690
7a8edb5
950acbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,9 @@ message CassandraFrameworkConfiguration { | |
* target number of seed nodes. | ||
*/ | ||
optional int32 targetNumberOfSeeds = 9; | ||
|
||
/** Default rack/dc info */ | ||
optional RackDc defaultRackDc = 10; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this property into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once this has been moved, please also update io.mesosphere.mesos.frameworks.cassandra.scheduler.util.JaxRsUtils#writeConfigRole to write the default rack and dc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
} | ||
|
||
/** | ||
|
@@ -345,6 +348,17 @@ message ClusterJobKeyspaceStatus { | |
required int64 duration = 3; | ||
} | ||
|
||
/** | ||
* Describes node rack and dc. | ||
*/ | ||
message RackDc { | ||
/** Rack identifier */ | ||
optional string rack = 1 [default = "RACK0"]; | ||
|
||
/** DataCenter identifier */ | ||
optional string dc = 2 [default = "DC0"]; | ||
} | ||
|
||
/** | ||
* Describes a node. | ||
*/ | ||
|
@@ -435,6 +449,9 @@ message CassandraNode { | |
* need to be restarted. | ||
*/ | ||
optional bool needsConfigUpdate = 14; | ||
|
||
/** Rack/DC information */ | ||
optional RackDc rackDc = 15; | ||
} | ||
/** | ||
* Describes a data volume for a node. | ||
|
@@ -686,6 +703,9 @@ message CassandraServerConfig { | |
* Cassandra.yaml configuration details. | ||
*/ | ||
required TaskConfig cassandraYamlConfig = 3; | ||
|
||
/** Rack/DC information */ | ||
optional RackDc rackDc = 4; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,9 @@ public PersistedCassandraFrameworkConfiguration( | |
@NotNull final String mesosRole, | ||
@NotNull final String dataDirectory, | ||
final boolean jmxLocal, | ||
final boolean jmxNoAuthentication | ||
final boolean jmxNoAuthentication, | ||
final String defaultRack, | ||
final String defaultDc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
) { | ||
super( | ||
"CassandraFrameworkConfiguration", | ||
|
@@ -76,6 +78,7 @@ public CassandraFrameworkConfiguration get() { | |
.setBootstrapGraceTimeSeconds(bootstrapGraceTimeSec) | ||
.setTargetNumberOfNodes(executorCount) | ||
.setTargetNumberOfSeeds(seedCount) | ||
.setDefaultRackDc(CassandraFrameworkProtos.RackDc.newBuilder().setRack(defaultRack).setDc(defaultDc)) | ||
.build(); | ||
} | ||
}, | ||
|
@@ -144,6 +147,13 @@ public CassandraFrameworkProtos.CassandraConfigRole getDefaultConfigRole() { | |
return get().getDefaultConfigRole(); | ||
} | ||
|
||
@NotNull | ||
public CassandraFrameworkProtos.RackDc getDefaultRackDc() { | ||
CassandraFrameworkProtos.RackDc rackDc = get().getDefaultRackDc(); | ||
if (rackDc == null) rackDc = CassandraFrameworkProtos.RackDc.newBuilder().setRack("RACK0").setDc("DC0").build(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
return rackDc; | ||
} | ||
|
||
@NotNull | ||
public Duration healthCheckInterval() { | ||
return Duration.standardSeconds(get().getHealthCheckIntervalSeconds()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ public List<ApiEndpoint> indexPage(@Context final UriInfo uriInfo) { | |
new ApiEndpoint("POST", "node/{node}/restart/", newArrayList("application/json")), | ||
new ApiEndpoint("POST", "node/{node}/terminate/", newArrayList("application/json")), | ||
new ApiEndpoint("POST", "node/{node}/replace/", newArrayList("application/json")), | ||
new ApiEndpoint("POST", "node/{node}/rackdc?rack=$rack&dc=$dc", newArrayList("application/json")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See note below on the handler method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
new ApiEndpoint("POST", "node/{node}/make-seed/", newArrayList("application/json")), | ||
new ApiEndpoint("POST", "node/{node}/make-non-seed/", newArrayList("application/json")), | ||
new ApiEndpoint("GET", "live-nodes", newArrayList("application/json")), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,6 +181,13 @@ public void write(final JsonGenerator json) throws IOException { | |
json.writeStringField("targetRunState", cassandraNode.getTargetRunState().name()); | ||
json.writeNumberField("jmxPort", cassandraNode.getJmxConnect().getJmxPort()); | ||
json.writeBooleanField("seedNode", cassandraNode.getSeed()); | ||
|
||
CassandraFrameworkProtos.RackDc rackDc = cassandraNode.getRackDc(); | ||
json.writeObjectFieldStart("rackDc"); | ||
json.writeStringField("rack", rackDc.getRack()); | ||
json.writeStringField("dc", rackDc.getDc()); | ||
json.writeEndObject(); | ||
|
||
if (!cassandraNode.hasCassandraDaemonPid()) { | ||
json.writeNullField("cassandraDaemonPid"); | ||
} else { | ||
|
@@ -479,6 +486,38 @@ public void write(final JsonGenerator json) throws IOException { | |
}); | ||
} | ||
|
||
/** | ||
* Update node with specified parameters. Note: node should be restarted for changes to take effect. | ||
*/ | ||
@POST | ||
@Path("/{node}/rackdc") | ||
public Response nodeRackDc( | ||
@PathParam("node") String id, | ||
@FormParam("rack") final String rack, | ||
@FormParam("dc") String dc | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change Something like this: {
"dc": "DC_1",
"rack": "rack_5"
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
CassandraFrameworkProtos.CassandraNode node = cluster.findNode(id); | ||
if (node == null) return Response.status(404).build(); | ||
|
||
final CassandraFrameworkProtos.CassandraNode.Builder copy = CassandraFrameworkProtos.CassandraNode.newBuilder(node); | ||
CassandraFrameworkProtos.RackDc.Builder rackDc = CassandraFrameworkProtos.RackDc.newBuilder(node.getRackDc()); | ||
|
||
if (rack != null) rackDc.setRack(rack); | ||
if (dc != null) rackDc.setDc(dc); | ||
|
||
copy.setRackDc(rackDc); | ||
cluster.getClusterState().addOrSetNode(copy.build()); | ||
|
||
return JaxRsUtils.buildStreamingResponse(factory, new StreamingJsonResponse() { | ||
@Override | ||
public void write(final JsonGenerator json) throws IOException { | ||
json.writeBooleanField("success", true); | ||
json.writeStringField("rack", copy.getRackDc().getRack()); | ||
json.writeStringField("dc", copy.getRackDc().getDc()); | ||
} | ||
}); | ||
} | ||
|
||
private Response nodeStatusUpdate(final CassandraFrameworkProtos.CassandraNode cassandraNode) { | ||
if (cassandraNode == null) { | ||
return Response.status(Response.Status.NOT_FOUND).build(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this
final
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.