Skip to content

Commit

Permalink
Merge pull request #651 from zmarois/3.11jmxauth
Browse files Browse the repository at this point in the history
Enabling auth on jmx port
  • Loading branch information
arunagrawal-84 authored Feb 26, 2018
2 parents 28715a6 + 2d4ea3b commit 5113133
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
10 changes: 10 additions & 0 deletions priam/src/main/java/com/netflix/priam/IConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ public interface IConfiguration {
*/
public int getJmxPort();

/**
* @return Cassandra's JMX username
*/
public String getJmxUsername();

/**
* @return Cassandra's JMX password
*/
public String getJmxPassword();

/**
* @return Enables Remote JMX connections n C*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class PriamConfiguration implements IConfiguration {
private static final String CONFIG_MR_ENABLE = PRIAM_PRE + ".multiregion.enable";
private static final String CONFIG_CL_LOCATION = PRIAM_PRE + ".commitlog.location";
private static final String CONFIG_JMX_LISTERN_PORT_NAME = PRIAM_PRE + ".jmx.port";
private static final String CONFIG_JMX_USERNAME = PRIAM_PRE + ".jmx.username";
private static final String CONFIG_JMX_PASSWORD = PRIAM_PRE + ".jmx.password";
private static final String CONFIG_JMX_ENABLE_REMOTE = PRIAM_PRE + ".jmx.remote.enable";
private static final String CONFIG_AVAILABILITY_ZONES = PRIAM_PRE + ".zones.available";
private static final String CONFIG_SAVE_CACHE_LOCATION = PRIAM_PRE + ".cache.location";
Expand Down Expand Up @@ -474,6 +476,16 @@ public int getJmxPort() {
return config.get(CONFIG_JMX_LISTERN_PORT_NAME, DEFAULT_JMX_PORT);
}

@Override
public String getJmxUsername() {
return config.get(CONFIG_JMX_USERNAME, "");
}

@Override
public String getJmxPassword() {
return config.get(CONFIG_JMX_PASSWORD, "");
}

/**
* @return Enables Remote JMX connections n C*
*/
Expand Down
15 changes: 14 additions & 1 deletion priam/src/main/java/com/netflix/priam/utils/JMXNodeTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public JMXNodeTool(String host, int port) throws IOException, InterruptedExcepti
super(host, port);
}

public JMXNodeTool(String host, int port, String username, String password) throws IOException, InterruptedException {
super(host, port, username, password);
}


@Inject
public JMXNodeTool(IConfiguration config) throws IOException, InterruptedException {
super("localhost", config.getJmxPort());
Expand Down Expand Up @@ -167,7 +172,15 @@ private static JMXNodeTool createConnection(final IConfiguration config) throws
tool = new BoundedExponentialRetryCallable<JMXNodeTool>() {
@Override
public JMXNodeTool retriableCall() throws Exception {
JMXNodeTool nodetool = new JMXNodeTool("localhost", config.getJmxPort());
JMXNodeTool nodetool;
if ((config.getJmxUsername() == null || config.getJmxUsername().isEmpty()) &&
(config.getJmxPassword() == null || config.getJmxPassword().isEmpty())) {
nodetool = new JMXNodeTool("localhost", config.getJmxPort());
}
else {
nodetool = new JMXNodeTool("localhost", config.getJmxPort(), config.getJmxUsername(), config.getJmxPassword());
}

Field fields[] = NodeProbe.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
if (!fields[i].getName().equals("mbeanServerConn"))
Expand Down
12 changes: 12 additions & 0 deletions priam/src/test/java/com/netflix/priam/FakeConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ public int getJmxPort()
return 7199;
}

@Override
public String getJmxUsername()
{
return null;
}

@Override
public String getJmxPassword()
{
return null;
}

/**
* @return Enables Remote JMX connections n C*
*/
Expand Down

0 comments on commit 5113133

Please sign in to comment.