From 098516fca93692bed8a7b9a2c0ab6ffd479922cb Mon Sep 17 00:00:00 2001 From: Zoab Kapoor Date: Mon, 21 Aug 2023 09:32:21 -0600 Subject: [PATCH] Remove reset toggling stores option in LoadBalancerClientCli to remove Java 17 incompatible code (#930) --- CHANGELOG.md | 6 +- d2-int-test/build.gradle | 1 - d2/build.gradle | 13 --- .../balancer/util/LoadBalancerClientCli.java | 93 ------------------- gradle.properties | 2 +- 5 files changed, 6 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47f99f11d..d3d5dc2174 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and what APIs have changed, if applicable. ## [Unreleased] +## [30.0.0] - 2023-08-15 +- Remove resetTogglingStores functionality from LoadBalancerClientCli, which is incompatible with Java 17 + ## [29.44.0] - 2023-08-06 - dynamically switch jmx/sensor names based on dual read mode and source type @@ -5515,7 +5518,8 @@ patch operations can re-use these classes for generating patch messages. ## [0.14.1] -[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.44.0...master +[Unreleased]: https://github.com/linkedin/rest.li/compare/v30.0.0...master +[30.0.0]: https://github.com/linkedin/rest.li/compare/v29.44.0...v30.0.0 [29.44.0]: https://github.com/linkedin/rest.li/compare/v29.43.11...v29.44.0 [29.43.11]: https://github.com/linkedin/rest.li/compare/v29.43.10...v29.43.11 [29.43.10]: https://github.com/linkedin/rest.li/compare/v29.43.9...v29.43.10 diff --git a/d2-int-test/build.gradle b/d2-int-test/build.gradle index 73de004d66..8725d79df5 100644 --- a/d2-int-test/build.gradle +++ b/d2-int-test/build.gradle @@ -11,7 +11,6 @@ dependencies { compile externalDependency.commonsIo compile externalDependency.commonsHttpClient compile externalDependency.zookeeper - compile externalDependency.jdkTools compile externalDependency.netty testCompile externalDependency.testng testCompile externalDependency.commonsIo diff --git a/d2/build.gradle b/d2/build.gradle index f8f4483de9..6496c71137 100644 --- a/d2/build.gradle +++ b/d2/build.gradle @@ -2,18 +2,6 @@ plugins { id "com.google.protobuf" version "0.8.10" } -// internal api inaccessible starting 1.9 -if (JavaVersion.current() > JavaVersion.VERSION_1_9) { - project.tasks.withType(JavaCompile) { - options.compilerArgs += [ "--add-exports", "jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED" ] - } - javadoc { - options { - addStringOption('-add-exports', 'jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED') - } - } -} - dependencies { compile project(':degrader') compile project(':r2-core') @@ -32,7 +20,6 @@ dependencies { compile externalDependency.zookeeper compile externalDependency.jacksonCore compile externalDependency.jacksonDataBind - compile externalDependency.jdkTools compile externalDependency.zero_allocation_hashing compile externalDependency.xchart compileOnly externalDependency.findbugs diff --git a/d2/src/main/java/com/linkedin/d2/balancer/util/LoadBalancerClientCli.java b/d2/src/main/java/com/linkedin/d2/balancer/util/LoadBalancerClientCli.java index 68867781a8..fa3c9b6126 100644 --- a/d2/src/main/java/com/linkedin/d2/balancer/util/LoadBalancerClientCli.java +++ b/d2/src/main/java/com/linkedin/d2/balancer/util/LoadBalancerClientCli.java @@ -16,10 +16,8 @@ package com.linkedin.d2.balancer.util; - import com.linkedin.common.callback.FutureCallback; import com.linkedin.common.util.None; -import com.linkedin.d2.balancer.LoadBalancerState; import com.linkedin.d2.balancer.clients.DynamicClient; import com.linkedin.d2.balancer.properties.ClusterProperties; import com.linkedin.d2.balancer.properties.ClusterPropertiesJsonSerializer; @@ -62,15 +60,7 @@ import com.linkedin.r2.transport.common.TransportClientFactory; import com.linkedin.r2.transport.http.client.HttpClientFactory; import com.linkedin.r2.util.NamedThreadFactory; - import com.linkedin.util.clock.SystemClock; -import java.util.concurrent.ScheduledExecutorService; -import javax.management.MBeanServerConnection; -import javax.management.ObjectInstance; -import javax.management.ObjectName; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; import java.io.File; import java.io.IOException; import java.net.URI; @@ -88,7 +78,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.GnuParser; @@ -99,8 +88,6 @@ import org.apache.zookeeper.Watcher.Event.KeeperState; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import sun.jvmstat.monitor.HostIdentifier; -import sun.jvmstat.monitor.MonitoredHost; public class LoadBalancerClientCli @@ -141,8 +128,6 @@ public LoadBalancerClientCli(String[] args) throws Exception OPTIONS.addOption("h", "help", false, "Show help."); OPTIONS.addOption("z", "zkserver", true, "Zookeeper server string (example:zk://localhost:2121)."); OPTIONS.addOption("p", "path", true, "Discovery path (example: /d2)."); - OPTIONS.addOption("h", "host", true, "Host name."); - OPTIONS.addOption("b", "enabled", true, "Enabled toggling store (value either 'true' or 'false'."); OPTIONS.addOption("f", "file", true, "D2 clusters/services configuration file."); OPTIONS.addOption("c", "cluster", true, "Cluster name."); OPTIONS.addOption("s", "service", true, "Service name."); @@ -157,7 +142,6 @@ public LoadBalancerClientCli(String[] args) throws Exception OPTIONS.addOption("H", "printschema", false, "Print service schema."); OPTIONS.addOption("R", "sendrequest", false, "Send request to service."); OPTIONS.addOption("e", "endpoints", false, "Print service endpoints."); - OPTIONS.addOption("T", "toggle", false, "Reset toggling store."); CommandLine cl = null; try @@ -192,13 +176,6 @@ else if (cl.hasOption("S")) { System.err.println(printStores(clobj.getZKClient(), cl.getOptionValue("z"), cl.getOptionValue("p"))); } - else if (cl.hasOption("T") && cl.hasOption("h") && cl.hasOption("b")) - { - String host = cl.getOptionValue("h"); - boolean toggled = !"false".equals(cl.getOptionValue("b")); - - resetTogglingStores((host == null) ? "localhost" : host, toggled); - } else if (cl.hasOption("c") && cl.hasOption("s")) { String requestType = "rest"; @@ -300,8 +277,6 @@ private void usage() throws IOException sb.append("\nExample Send request to service: lb-client.sh --zkserver zk://localhost:2181 --path /d2 --cluster 'cluster-1' --service service-1_1 --request 'test' --sendrequest"); sb.append("\nExample Send request to service: lb-client.sh -z zk://localhost:2181 -p /d2 -c 'history-write-1' -s HistoryService -m getCube -r 'test' -R"); sb.append("\nExample Send request to service: lb-client.sh --zkserver zk://localhost:2181 --path /d2 --cluster 'history-write-1' --service HistoryService --method getCube --request 'test' --sendrequest"); - sb.append("\nExample Reset toggling stores: lb-client.sh -z zk://localhost:2121 -p /d2 -h localhost -b false -T"); - sb.append("\nExample Reset toggling stores: lb-client.sh --zkserver zk://localhost:2121 --path /d2 --host localhost --enabled false --toggle"); sb.append("\n"); final HelpFormatter formatter = new HelpFormatter(); @@ -1090,74 +1065,6 @@ public static String printStores(ZKConnection zkclient, String zkserver, String return sb.toString(); } - public static void resetTogglingStores(String host, boolean enabled) throws Exception - { - - MonitoredHost _host = MonitoredHost.getMonitoredHost(new HostIdentifier(host)); - - for (Object pidObj : _host.activeVms()) - { - int pid = (Integer) pidObj; - - System.out.println("checking pid: " + pid); - - JMXServiceURL jmxUrl = null; - com.sun.tools.attach.VirtualMachine vm = - com.sun.tools.attach.VirtualMachine.attach(pid + ""); - - try - { - // get the connector address - String connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); - // establish connection to connector server - if (connectorAddress != null) - { - jmxUrl = new JMXServiceURL(connectorAddress); - } - } - finally - { - vm.detach(); - } - - if (jmxUrl != null) - { - System.out.println("got jmx url: " + jmxUrl); - - // connect to jmx - JMXConnector connector = JMXConnectorFactory.connect(jmxUrl); - - connector.connect(); - - MBeanServerConnection mbeanServer = connector.getMBeanServerConnection(); - - // look for all beans in the d2 name space - Set objectInstances = - mbeanServer.queryMBeans(new ObjectName("com.linkedin.d2:*"), null); - - for (ObjectInstance objectInstance : objectInstances) - { - System.err.println("checking object: " + objectInstance.getObjectName()); - - // if we've found a toggling store, then toggle it - if (objectInstance.getObjectName().toString().endsWith("TogglingStore")) - { - System.out.println("found toggling zk store, so toggling to: " + enabled); - - mbeanServer.invoke(objectInstance.getObjectName(), - "setEnabled", - new Object[] { enabled }, - new String[] { "boolean" }); - } - } - } - else - { - System.out.println("pid is not a jmx process: " + pid); - } - } - } - private void deleteTempDir() throws IOException { if (_tmpDir.exists()) diff --git a/gradle.properties b/gradle.properties index 93304a77b9..914f80ac85 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=29.44.0 +version=30.0.0 group=com.linkedin.pegasus org.gradle.configureondemand=true org.gradle.parallel=true