Skip to content

Commit

Permalink
Enable GUI headers also through reaper configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Radovan Zvoncek authored and varjoranta committed Apr 10, 2015
1 parent eb3f51c commit d94e70c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Current version supports running Cassandra cluster repairs in segmented manner,
opportunistically running multiple parallel repairs at the same time on different nodes
within the cluster. Basic repair scheduling functionality is also supported.

Cassandra Reaper does not come with a GUI, but please check
[this project](https://github.com/spodkowinski/cassandra-reaper-ui) if you'd like to use one.

Please see the [Issues](https://github.com/spotify/cassandra-reaper/issues) section for more
information on planned development, and known issues.

Expand Down Expand Up @@ -121,6 +124,10 @@ The Reaper service specific configuration values are:
Optional setting for giving username and password credentials for the used JMX connections
in case you are using password based JMX authentication with your Cassandra clusters.

* enableCrossOrigin:

Optional setting which you can set to be "true", if you wish to enable the CORS headers
for running an external GUI application, like [this project](https://github.com/spodkowinski/cassandra-reaper-ui).

Notice that in the *server* section of the configuration, if you want to bind the service
to all interfaces, use value "0.0.0.0", or just leave the *bindHost* line away completely.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/spotify/reaper/ReaperApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public void run(ReaperApplicationConfiguration config,
context.jmxConnectionFactory.setJmxPorts(jmxPorts);
}

// enable cross-origin requests for testing cassandra-reaper-ui
if (System.getProperty("enableCrossOrigin") != null) {
final FilterRegistration.Dynamic cors =
environment.servlets().addFilter("crossOriginRequests", CrossOriginFilter.class);
// Enable cross-origin requests for using external GUI applications.
if (config.isEnableCrossOrigin() || System.getProperty("enableCrossOrigin") != null) {
final FilterRegistration.Dynamic cors = environment.servlets()
.addFilter("crossOriginRequests", CrossOriginFilter.class);
cors.setInitParameter("allowedOrigins", "*");
cors.setInitParameter("allowedHeaders", "X-Requested-With,Content-Type,Accept,Origin");
cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ public class ReaperApplicationConfiguration extends Configuration {
@NotEmpty
private String storageType;

private String enableCrossOrigin;

@Valid
@NotNull
@JsonProperty
private DataSourceFactory database = new DataSourceFactory();

@JsonProperty
private Map<String, Integer> jmxPorts;

@JsonProperty
private JmxCredentials jmxAuth;

Expand Down Expand Up @@ -103,6 +105,18 @@ public String getStorageType() {
return storageType;
}

public void setEnableCrossOrigin(String enableCrossOrigin) {
this.enableCrossOrigin = enableCrossOrigin;
}

public String getEnableCrossOrigin() {
return this.enableCrossOrigin;
}

public boolean isEnableCrossOrigin() {
return this.enableCrossOrigin != null && this.enableCrossOrigin.equalsIgnoreCase("true");
}

public void setStorageType(String storageType) {
this.storageType = storageType;
}
Expand Down Expand Up @@ -139,21 +153,21 @@ public JmxCredentials getJmxAuth() {
public void setJmxAuth(JmxCredentials jmxAuth) {
this.jmxAuth = jmxAuth;
}

public static class JmxCredentials {

@JsonProperty
private String username;
@JsonProperty
private String password;

public String getUsername() {
return username;
}
public String getPassword() {
return password;
}

}

}
4 changes: 4 additions & 0 deletions src/test/resources/cassandra-reaper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ hangingRepairTimeoutMins: 30
# storageType is either "database" or "memory"
storageType: memory

# Enable HTTP headers to that GUI can work
# GUI lives at https://github.com/spodkowinski/cassandra-reaper-ui
enableCrossOrigin: true

# custom jmx port mappings that will be used instead of the default port for specified hosts (optional)
#jmxPorts:
# 127.0.0.1: 7100
Expand Down

0 comments on commit d94e70c

Please sign in to comment.