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

Remove reset toggling stores option in LoadBalancerClientCli to remove Java 17 incompatible code #930

Merged
merged 1 commit into from
Aug 21, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion d2-int-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions d2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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.");
Expand All @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
ZoabKapoor marked this conversation as resolved.
Show resolved Hide resolved
{

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<ObjectInstance> 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())
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.44.0
version=30.0.0
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Loading