Skip to content

Commit

Permalink
Add the ability to specify remote rmi port/host
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Mar 20, 2024
1 parent 2f06701 commit 2f2af18
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/reference/98_create_clusters.adoc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 2f2af18

Please sign in to comment.