Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to specify remote rmi port/host #166

Merged
merged 1 commit into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/reference/98_create_clusters.adoc
Expand Up @@ -282,6 +282,17 @@ Starting cluster member storage-3...
Cluster local and started
----

If you wish to enable remote RMI management on you cluster, as well as HTTP management,
you will need to use the following:
[source,bash]
----
cohctl start cluster local -J 9999 -j hostname
----

* `-J` is the rmi port
* `-j` is the rmi host. You should set this to the hostname the cluster is running on. It will default to WKA address if not set.


[#start-console]
==== Start Console

Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/cluster.go
Expand Up @@ -976,6 +976,8 @@ var (
replicaCountParam int32
metricsStartPortParam int32
healthStartPortParam int32
jmxRemotePortParam int32
jmxRemoteHostParam string
logLevelParam int32
heapMemoryParam string
useCommercialParam bool
Expand Down Expand Up @@ -1071,6 +1073,13 @@ NOTE: This is an experimental feature and my be altered or removed in the future
}
}

// validate jmx remote port
if jmxRemotePortParam > 0 {
if err = utils.ValidatePort(jmxRemotePortParam); err != nil {
return err
}
}

// validate health port
if healthStartPortParam > 0 {
if err = utils.ValidatePort(healthStartPortParam); err != nil {
Expand Down Expand Up @@ -1686,6 +1695,8 @@ func init() {
createClusterCmd.Flags().StringVarP(&logDestinationParam, logDestinationArg, "L", "", logDestinationMessage)
createClusterCmd.Flags().StringVarP(&cacheConfigParam, cacheConfigArg, "", "", cacheConfigMessage)
createClusterCmd.Flags().StringVarP(&operationalConfigParam, operationalConfigArg, "", "", operationalConfigMessage)
createClusterCmd.Flags().Int32VarP(&jmxRemotePortParam, jmxPortArg, "J", 0, jmxPortMessage)
createClusterCmd.Flags().StringVarP(&jmxRemoteHostParam, jmxHostArg, "j", "", jmxHostMessage)

stopClusterCmd.Flags().BoolVarP(&automaticallyConfirm, "yes", "y", false, confirmOptionMessage)

Expand All @@ -1697,6 +1708,8 @@ func init() {
startClusterCmd.Flags().Int32VarP(&logLevelParam, logLevelArg, "l", 5, logLevelMessage)
startClusterCmd.Flags().StringVarP(&startupDelayParam, startupDelayArg, "D", "0ms", startupDelayMessage)
startClusterCmd.Flags().StringVarP(&serverStartClassParam, startClassArg, "S", "", startClassMessage)
startClusterCmd.Flags().Int32VarP(&jmxRemotePortParam, jmxPortArg, "J", 0, jmxPortMessage)
startClusterCmd.Flags().StringVarP(&jmxRemoteHostParam, jmxHostArg, "j", "", jmxHostMessage)

startConsoleCmd.Flags().StringVarP(&heapMemoryParam, heapMemoryArg, "M", defaultHeap, heapMemoryMessage)
startConsoleCmd.Flags().Int32VarP(&logLevelParam, logLevelArg, "l", 5, logLevelMessage)
Expand Down
18 changes: 18 additions & 0 deletions pkg/cmd/cluster_utils.go
Expand Up @@ -261,6 +261,13 @@ func startCluster(cmd *cobra.Command, connection ClusterConnection, serverCount,
return err
}

if jmxRemotePortParam > 0 {
// validate jmx remote port
if err = utils.ValidatePort(jmxRemotePortParam); err != nil {
return err
}
}

for counter = existingCount; counter < serverCount+existingCount; counter++ {
var (
member = fmt.Sprintf("storage-%d", counter)
Expand Down Expand Up @@ -362,6 +369,17 @@ func getCacheServerArgs(member string, httpPort int32, version string) []string
baseArgs = append(baseArgs, "-Dcoherence.management.http=all", fmt.Sprintf("-Dcoherence.management.http.port=%d", httpPort),
"-Dcoherence.management=all", "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote",
"-Dcom.sun.management.jmxremote.authenticate=false")

// add remote JMX port is specified
if jmxRemotePortParam > 0 {
rmiHost := jmxRemoteHostParam
if rmiHost == "" {
rmiHost = wkaParam
}
baseArgs = append(baseArgs, fmt.Sprintf("-Dcom.sun.management.jmxremote.port=%d", jmxRemotePortParam),
fmt.Sprintf("-Dcom.sun.management.jmxremote.rmi.port=%d", jmxRemotePortParam),
fmt.Sprintf("-Djava.rmi.server.hostname=%s", rmiHost))
}
}

// if default heap is overridden, then use this
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/root.go
Expand Up @@ -82,12 +82,16 @@ const (
serverCountMessage = "number of replicas"
metricsPortMessage = "starting port for metrics"
healthPortMessage = "starting port for health"
jmxPortMessage = "remote JMX port for management member"
jmxHostMessage = "remote JMX RMI host for management member"
cacheConfigMessage = "cache configuration file"
operationalConfigMessage = "override override file"
cacheConfigArg = "cache-config"
operationalConfigArg = "override-config"
metricsPortArg = "metrics-port"
healthPortArg = "health-port"
jmxPortArg = "jmx-port"
jmxHostArg = "jmx-host"
logLevelMessage = "coherence log level"
profileMessage = "profile to add to cluster startup command line"
startClassMessage = "class name to start server with (default from Coherence version)"
Expand Down