Skip to content

Commit 7b84203

Browse files
authored
Merge pull request #834 from scalecube/remove_jmx_support
Removed jmx support
2 parents 186db70 + 8ab12a6 commit 7b84203

File tree

2 files changed

+0
-160
lines changed

2 files changed

+0
-160
lines changed

services-discovery/src/main/java/io/scalecube/services/discovery/ScalecubeServiceDiscovery.java

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,9 @@
1818
import io.scalecube.services.discovery.api.ServiceDiscovery;
1919
import io.scalecube.services.discovery.api.ServiceDiscoveryContext;
2020
import io.scalecube.services.discovery.api.ServiceDiscoveryEvent;
21-
import java.lang.management.ManagementFactory;
2221
import java.nio.ByteBuffer;
23-
import java.util.List;
2422
import java.util.StringJoiner;
25-
import java.util.concurrent.CopyOnWriteArrayList;
2623
import java.util.function.UnaryOperator;
27-
import java.util.stream.Collectors;
28-
import javax.management.MBeanServer;
29-
import javax.management.ObjectName;
30-
import javax.management.StandardMBean;
3124
import org.slf4j.Logger;
3225
import org.slf4j.LoggerFactory;
3326
import reactor.core.Exceptions;
@@ -143,7 +136,6 @@ public void onMembershipEvent(MembershipEvent event) {
143136
this.cluster = cluster;
144137
discoveryContextBuilder.address(this.cluster.address());
145138
})
146-
.then(Mono.fromCallable(() -> JmxMonitorMBean.start(this)))
147139
.then();
148140
});
149141
}
@@ -213,61 +205,4 @@ public String toString() {
213205
.add("clusterConfig=" + clusterConfig)
214206
.toString();
215207
}
216-
217-
@SuppressWarnings("unused")
218-
public interface MonitorMBean {
219-
220-
String getClusterConfig();
221-
222-
String getRecentDiscoveryEvents();
223-
}
224-
225-
private static class JmxMonitorMBean implements MonitorMBean {
226-
227-
private static final String OBJECT_NAME_FORMAT = "io.scalecube.services.discovery:name=%s@%s";
228-
229-
public static final int RECENT_DISCOVERY_EVENTS_SIZE = 128;
230-
231-
private final ScalecubeServiceDiscovery discovery;
232-
private final List<ServiceDiscoveryEvent> recentDiscoveryEvents = new CopyOnWriteArrayList<>();
233-
234-
private JmxMonitorMBean(ScalecubeServiceDiscovery discovery) {
235-
this.discovery = discovery;
236-
}
237-
238-
private static JmxMonitorMBean start(ScalecubeServiceDiscovery instance) throws Exception {
239-
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
240-
JmxMonitorMBean jmxMBean = new JmxMonitorMBean(instance);
241-
jmxMBean.init();
242-
ObjectName objectName =
243-
new ObjectName(
244-
String.format(OBJECT_NAME_FORMAT, instance.cluster.member().id(), System.nanoTime()));
245-
StandardMBean standardMBean = new StandardMBean(jmxMBean, MonitorMBean.class);
246-
mbeanServer.registerMBean(standardMBean, objectName);
247-
return jmxMBean;
248-
}
249-
250-
private void init() {
251-
discovery.listen().subscribe(this::onDiscoveryEvent);
252-
}
253-
254-
@Override
255-
public String getClusterConfig() {
256-
return String.valueOf(discovery.clusterConfig);
257-
}
258-
259-
@Override
260-
public String getRecentDiscoveryEvents() {
261-
return recentDiscoveryEvents.stream()
262-
.map(ServiceDiscoveryEvent::toString)
263-
.collect(Collectors.joining(",", "[", "]"));
264-
}
265-
266-
private void onDiscoveryEvent(ServiceDiscoveryEvent event) {
267-
recentDiscoveryEvents.add(event);
268-
if (recentDiscoveryEvents.size() > RECENT_DISCOVERY_EVENTS_SIZE) {
269-
recentDiscoveryEvents.remove(0);
270-
}
271-
}
272-
}
273208
}

services/src/main/java/io/scalecube/services/Microservices.java

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import io.scalecube.services.exceptions.ServiceProviderErrorMapper;
1717
import io.scalecube.services.gateway.Gateway;
1818
import io.scalecube.services.gateway.GatewayOptions;
19-
import io.scalecube.services.methods.MethodInfo;
20-
import io.scalecube.services.methods.ServiceMethodInvoker;
2119
import io.scalecube.services.methods.ServiceMethodRegistry;
2220
import io.scalecube.services.methods.ServiceMethodRegistryImpl;
2321
import io.scalecube.services.registry.ServiceRegistryImpl;
@@ -29,7 +27,6 @@
2927
import io.scalecube.services.transport.api.ServerTransport;
3028
import io.scalecube.services.transport.api.ServiceMessageDataDecoder;
3129
import io.scalecube.services.transport.api.ServiceTransport;
32-
import java.lang.management.ManagementFactory;
3330
import java.net.InetAddress;
3431
import java.net.UnknownHostException;
3532
import java.util.ArrayList;
@@ -41,17 +38,13 @@
4138
import java.util.NoSuchElementException;
4239
import java.util.Objects;
4340
import java.util.Optional;
44-
import java.util.StringJoiner;
4541
import java.util.UUID;
4642
import java.util.concurrent.ConcurrentHashMap;
4743
import java.util.concurrent.CopyOnWriteArrayList;
4844
import java.util.function.Function;
4945
import java.util.function.Supplier;
5046
import java.util.function.UnaryOperator;
5147
import java.util.stream.Collectors;
52-
import javax.management.MBeanServer;
53-
import javax.management.ObjectName;
54-
import javax.management.StandardMBean;
5548
import org.slf4j.Logger;
5649
import org.slf4j.LoggerFactory;
5750
import reactor.core.Disposable;
@@ -227,7 +220,6 @@ private Mono<Microservices> start() {
227220
this, new ServiceDiscoveryOptions().serviceEndpoint(serviceEndpoint))
228221
.then(startGateway(new GatewayOptions().call(call)))
229222
.then(Mono.fromCallable(() -> Injector.inject(this, serviceInstances)))
230-
.then(Mono.fromCallable(() -> JmxMonitorMBean.start(this)))
231223
.then(compositeDiscovery.startListen())
232224
.thenReturn(this);
233225
})
@@ -847,91 +839,4 @@ private Mono<Void> shutdown() {
847839
.then());
848840
}
849841
}
850-
851-
@SuppressWarnings("unused")
852-
public interface MonitorMBean {
853-
854-
String getServiceEndpoint();
855-
856-
String getAllServiceEndpoints();
857-
858-
String getServiceMethodInvokers();
859-
860-
String getServiceInfos();
861-
}
862-
863-
private static class JmxMonitorMBean implements MonitorMBean {
864-
865-
private static final String OBJECT_NAME_FORMAT = "io.scalecube.services:name=%s@%s";
866-
867-
private final Microservices microservices;
868-
869-
private static JmxMonitorMBean start(Microservices instance) throws Exception {
870-
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
871-
JmxMonitorMBean jmxMBean = new JmxMonitorMBean(instance);
872-
ObjectName objectName =
873-
new ObjectName(String.format(OBJECT_NAME_FORMAT, instance.id(), System.nanoTime()));
874-
StandardMBean standardMBean = new StandardMBean(jmxMBean, MonitorMBean.class);
875-
mbeanServer.registerMBean(standardMBean, objectName);
876-
return jmxMBean;
877-
}
878-
879-
private JmxMonitorMBean(Microservices microservices) {
880-
this.microservices = microservices;
881-
}
882-
883-
@Override
884-
public String getServiceEndpoint() {
885-
return String.valueOf(microservices.serviceEndpoint);
886-
}
887-
888-
@Override
889-
public String getAllServiceEndpoints() {
890-
return microservices.serviceRegistry.listServiceEndpoints().stream()
891-
.map(ServiceEndpoint::toString)
892-
.collect(Collectors.joining(",", "[", "]"));
893-
}
894-
895-
@Override
896-
public String getServiceMethodInvokers() {
897-
return microservices.methodRegistry.listInvokers().stream()
898-
.map(JmxMonitorMBean::asString)
899-
.collect(Collectors.joining(",", "[", "]"));
900-
}
901-
902-
@Override
903-
public String getServiceInfos() {
904-
return microservices.methodRegistry.listServices().stream()
905-
.map(JmxMonitorMBean::asString)
906-
.collect(Collectors.joining(",", "[", "]"));
907-
}
908-
909-
private static String asString(ServiceMethodInvoker invoker) {
910-
return new StringJoiner(", ", ServiceMethodInvoker.class.getSimpleName() + "[", "]")
911-
.add("methodInfo=" + asString(invoker.methodInfo()))
912-
.add(
913-
"serviceMethod="
914-
+ invoker.service().getClass().getCanonicalName()
915-
+ "."
916-
+ invoker.methodInfo().methodName()
917-
+ "("
918-
+ invoker.methodInfo().parameterCount()
919-
+ ")")
920-
.toString();
921-
}
922-
923-
private static String asString(MethodInfo methodInfo) {
924-
return new StringJoiner(", ", MethodInfo.class.getSimpleName() + "[", "]")
925-
.add("qualifier=" + methodInfo.qualifier())
926-
.add("auth=" + methodInfo.isSecured())
927-
.toString();
928-
}
929-
930-
private static String asString(ServiceInfo serviceInfo) {
931-
return new StringJoiner(", ", ServiceMethodInvoker.class.getSimpleName() + "[", "]")
932-
.add("serviceInstance=" + serviceInfo.serviceInstance())
933-
.add("tags=" + serviceInfo.tags())
934-
.toString();
935-
}
936-
}
937842
}

0 commit comments

Comments
 (0)