|
16 | 16 | import io.scalecube.services.exceptions.ServiceProviderErrorMapper; |
17 | 17 | import io.scalecube.services.gateway.Gateway; |
18 | 18 | import io.scalecube.services.gateway.GatewayOptions; |
19 | | -import io.scalecube.services.methods.MethodInfo; |
20 | | -import io.scalecube.services.methods.ServiceMethodInvoker; |
21 | 19 | import io.scalecube.services.methods.ServiceMethodRegistry; |
22 | 20 | import io.scalecube.services.methods.ServiceMethodRegistryImpl; |
23 | 21 | import io.scalecube.services.registry.ServiceRegistryImpl; |
|
29 | 27 | import io.scalecube.services.transport.api.ServerTransport; |
30 | 28 | import io.scalecube.services.transport.api.ServiceMessageDataDecoder; |
31 | 29 | import io.scalecube.services.transport.api.ServiceTransport; |
32 | | -import java.lang.management.ManagementFactory; |
33 | 30 | import java.net.InetAddress; |
34 | 31 | import java.net.UnknownHostException; |
35 | 32 | import java.util.ArrayList; |
|
41 | 38 | import java.util.NoSuchElementException; |
42 | 39 | import java.util.Objects; |
43 | 40 | import java.util.Optional; |
44 | | -import java.util.StringJoiner; |
45 | 41 | import java.util.UUID; |
46 | 42 | import java.util.concurrent.ConcurrentHashMap; |
47 | 43 | import java.util.concurrent.CopyOnWriteArrayList; |
48 | 44 | import java.util.function.Function; |
49 | 45 | import java.util.function.Supplier; |
50 | 46 | import java.util.function.UnaryOperator; |
51 | 47 | import java.util.stream.Collectors; |
52 | | -import javax.management.MBeanServer; |
53 | | -import javax.management.ObjectName; |
54 | | -import javax.management.StandardMBean; |
55 | 48 | import org.slf4j.Logger; |
56 | 49 | import org.slf4j.LoggerFactory; |
57 | 50 | import reactor.core.Disposable; |
@@ -227,7 +220,6 @@ private Mono<Microservices> start() { |
227 | 220 | this, new ServiceDiscoveryOptions().serviceEndpoint(serviceEndpoint)) |
228 | 221 | .then(startGateway(new GatewayOptions().call(call))) |
229 | 222 | .then(Mono.fromCallable(() -> Injector.inject(this, serviceInstances))) |
230 | | - .then(Mono.fromCallable(() -> JmxMonitorMBean.start(this))) |
231 | 223 | .then(compositeDiscovery.startListen()) |
232 | 224 | .thenReturn(this); |
233 | 225 | }) |
@@ -847,91 +839,4 @@ private Mono<Void> shutdown() { |
847 | 839 | .then()); |
848 | 840 | } |
849 | 841 | } |
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 | | - } |
937 | 842 | } |
0 commit comments