mirror of https://github.com/apache/kafka.git
MINOR: Fix Jmxtool to honour wait option when MBean is not yet avaibale in MBean server (#13995)
In JmxTool.scala, we will wait till all the object names are available from MBean server. But in the newer version, we only wait for subset of object names. Due to this, we may not enforce wait option and prematurely return the result if the objects are not yet registered in MBean sever. Reviewers: Luke Chen <showuon@gmail.com>, Federico Valeri <fvaleri@redhat.com>
This commit is contained in:
parent
aafbe34443
commit
4e85bc9f80
|
@ -169,7 +169,7 @@ public class JmxTool {
|
|||
long waitTimeoutMs = 10_000;
|
||||
Set<ObjectName> result = new HashSet<>();
|
||||
Set<ObjectName> querySet = new HashSet<>(queries);
|
||||
BiPredicate<Set<ObjectName>, Set<ObjectName>> foundAllObjects = Set::containsAll;
|
||||
BiPredicate<Set<ObjectName>, Set<ObjectName>> foundAllObjects = Set::equals;
|
||||
long start = System.currentTimeMillis();
|
||||
do {
|
||||
if (!result.isEmpty()) {
|
||||
|
|
|
@ -337,6 +337,19 @@ public class JmxToolTest {
|
|||
assertTrue(validDateFormat(dateFormat, csv.get("time")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknownObjectName() {
|
||||
String[] args = new String[]{
|
||||
"--jmx-url", jmxUrl,
|
||||
"--object-name", "kafka.server:type=DummyMetrics,name=MessagesInPerSec",
|
||||
"--wait"
|
||||
};
|
||||
|
||||
String err = executeAndGetErr(args);
|
||||
assertCommandFailure();
|
||||
assertTrue(err.contains("Could not find all requested object names after 10000 ms"));
|
||||
}
|
||||
|
||||
private static int findRandomOpenPortOnAllLocalInterfaces() throws Exception {
|
||||
try (ServerSocket socket = new ServerSocket(0)) {
|
||||
return socket.getLocalPort();
|
||||
|
|
Loading…
Reference in New Issue