-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b03cee
commit c9fcf61
Showing
3 changed files
with
71 additions
and
1 deletion.
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/redhat/rhjmc/containerjfr/core/net/discovery/DiscoveredJvmDescriptor.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,29 @@ | ||
package com.redhat.rhjmc.containerjfr.core.net.discovery; | ||
|
||
import java.net.MalformedURLException; | ||
import java.util.Map; | ||
|
||
import javax.management.remote.JMXServiceURL; | ||
|
||
public class DiscoveredJvmDescriptor { | ||
|
||
private final Map<String, String> o; | ||
|
||
DiscoveredJvmDescriptor(Map<String, String> o) { | ||
this.o = o; | ||
} | ||
|
||
public String getMainClass() { | ||
return o.get("MAIN_CLASS"); | ||
} | ||
|
||
public JMXServiceURL getJmxServiceUrl() throws MalformedURLException { | ||
return new JMXServiceURL(o.get("JMX_SERVICE_URL")); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return o.toString(); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/redhat/rhjmc/containerjfr/core/net/discovery/JvmDiscoveryClient.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,38 @@ | ||
package com.redhat.rhjmc.containerjfr.core.net.discovery; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import com.redhat.rhjmc.containerjfr.core.log.Logger; | ||
|
||
import org.openjdk.jmc.jdp.client.JDPClient; | ||
|
||
public class JvmDiscoveryClient { | ||
|
||
private final Logger logger; | ||
private final JDPClient jdp; | ||
|
||
public JvmDiscoveryClient(Logger logger) { | ||
this.logger = logger; | ||
this.jdp = new JDPClient(); | ||
} | ||
|
||
public void start() throws IOException { | ||
this.logger.info("JDP Discovery started"); | ||
this.jdp.start(); | ||
} | ||
|
||
public void stop() { | ||
this.logger.info("JDP Discovery stopped"); | ||
this.jdp.stop(); | ||
} | ||
|
||
public List<DiscoveredJvmDescriptor> getDiscoveredJvmDescriptors() { | ||
return this.jdp.getDiscoverables() | ||
.stream() | ||
.map(d -> new DiscoveredJvmDescriptor(d.getPayload())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
} |