This repository has been archived by the owner on Jan 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
multi-dc-basic #115
Merged
BenWhitehead
merged 6 commits into
mesosphere-backup:master
from
dmitrypekar:multi-dc-basic
Jul 8, 2015
Merged
multi-dc-basic #115
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b6fbdb8
added support of RackDc info to CassandraNode/CassandraServerConfig, …
dmitrypekar 5c2db1d
added support of CASSANDRA_DEFAULT_RACK and CASSANDRA_DEFAULT_DC vars
dmitrypekar e771f14
misc CR fixes
dmitrypekar 211b690
changes /rackdc method to accept parameters as JSON object
dmitrypekar 7a8edb5
moved rackDc from CassandraFrameworkConfiguration to CassandraConfigRole
dmitrypekar 950acbe
added UT for PCFC.getDefaultRackDc
dmitrypekar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,42 @@ public void write(final JsonGenerator json) throws IOException { | |
}); | ||
} | ||
|
||
public static class RackDcParams { | ||
public String rack; | ||
public String dc; | ||
} | ||
|
||
/** | ||
* 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, | ||
RackDcParams params | ||
) { | ||
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 (params.rack != null) rackDc.setRack(params.rack); | ||
if (params.dc != null) rackDc.setDc(params.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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...re/mesos/frameworks/cassandra/scheduler/PersistedCassandraFrameworkConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.mesosphere.mesos.frameworks.cassandra.scheduler; | ||
|
||
import io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos; | ||
import org.apache.mesos.state.InMemoryState; | ||
import org.junit.Test; | ||
|
||
import static io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.CassandraConfigRole; | ||
import static io.mesosphere.mesos.frameworks.cassandra.CassandraFrameworkProtos.CassandraFrameworkConfiguration; | ||
import static junit.framework.Assert.assertEquals; | ||
|
||
public class PersistedCassandraFrameworkConfigurationTest { | ||
@Test | ||
public void testGetDefaultRackDc() { | ||
InMemoryState state = new InMemoryState(); | ||
|
||
PersistedCassandraFrameworkConfiguration config = new PersistedCassandraFrameworkConfiguration( | ||
state, | ||
"name", | ||
60, | ||
30, | ||
"2.1", | ||
0.5, | ||
1024, | ||
1024, | ||
512, | ||
1, | ||
1, | ||
"role", | ||
"", | ||
false, | ||
true, | ||
"RACK1", | ||
"DC1" | ||
); | ||
|
||
CassandraFrameworkProtos.RackDc rackDc = config.getDefaultRackDc(); | ||
assertEquals("RACK1", rackDc.getRack()); | ||
assertEquals("DC1", rackDc.getDc()); | ||
|
||
// backward compatibility: if rackDc is not defined - use defaults | ||
CassandraFrameworkConfiguration.Builder builder = CassandraFrameworkConfiguration.newBuilder(config.get()); | ||
builder.setDefaultConfigRole(CassandraConfigRole.newBuilder(builder.getDefaultConfigRole()).clearRackDc()); | ||
config.setValue(builder.build()); | ||
|
||
rackDc = config.getDefaultRackDc(); | ||
assertEquals("RACK0", rackDc.getRack()); | ||
assertEquals("DC0", rackDc.getDc()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 add
// TODO: Persistence Schema Update
so that we can more appropriately address the code needed to update object schemas in the future.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.