|
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; |
@@ -233,7 +226,6 @@ this, new ServiceDiscoveryOptions().serviceEndpoint(serviceEndpoint)) |
233 | 226 | .then(startGateway(new GatewayOptions().call(call))) |
234 | 227 | .publishOn(scheduler) |
235 | 228 | .then(Mono.fromCallable(() -> Injector.inject(this, serviceInstances))) |
236 | | - .then(Mono.fromCallable(() -> JmxMonitorMBean.start(this))) |
237 | 229 | .then(compositeDiscovery.startListen()) |
238 | 230 | .publishOn(scheduler) |
239 | 231 | .thenReturn(this); |
@@ -834,91 +826,4 @@ private Mono<Void> shutdown() { |
834 | 826 | .then()); |
835 | 827 | } |
836 | 828 | } |
837 | | - |
838 | | - @SuppressWarnings("unused") |
839 | | - public interface MonitorMBean { |
840 | | - |
841 | | - String getServiceEndpoint(); |
842 | | - |
843 | | - String getAllServiceEndpoints(); |
844 | | - |
845 | | - String getServiceMethodInvokers(); |
846 | | - |
847 | | - String getServiceInfos(); |
848 | | - } |
849 | | - |
850 | | - private static class JmxMonitorMBean implements MonitorMBean { |
851 | | - |
852 | | - private static final String OBJECT_NAME_FORMAT = "io.scalecube.services:name=%s@%s"; |
853 | | - |
854 | | - private final Microservices microservices; |
855 | | - |
856 | | - private static JmxMonitorMBean start(Microservices instance) throws Exception { |
857 | | - MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); |
858 | | - JmxMonitorMBean jmxMBean = new JmxMonitorMBean(instance); |
859 | | - ObjectName objectName = |
860 | | - new ObjectName(String.format(OBJECT_NAME_FORMAT, instance.id(), System.nanoTime())); |
861 | | - StandardMBean standardMBean = new StandardMBean(jmxMBean, MonitorMBean.class); |
862 | | - mbeanServer.registerMBean(standardMBean, objectName); |
863 | | - return jmxMBean; |
864 | | - } |
865 | | - |
866 | | - private JmxMonitorMBean(Microservices microservices) { |
867 | | - this.microservices = microservices; |
868 | | - } |
869 | | - |
870 | | - @Override |
871 | | - public String getServiceEndpoint() { |
872 | | - return String.valueOf(microservices.serviceEndpoint); |
873 | | - } |
874 | | - |
875 | | - @Override |
876 | | - public String getAllServiceEndpoints() { |
877 | | - return microservices.serviceRegistry.listServiceEndpoints().stream() |
878 | | - .map(ServiceEndpoint::toString) |
879 | | - .collect(Collectors.joining(",", "[", "]")); |
880 | | - } |
881 | | - |
882 | | - @Override |
883 | | - public String getServiceMethodInvokers() { |
884 | | - return microservices.methodRegistry.listInvokers().stream() |
885 | | - .map(JmxMonitorMBean::asString) |
886 | | - .collect(Collectors.joining(",", "[", "]")); |
887 | | - } |
888 | | - |
889 | | - @Override |
890 | | - public String getServiceInfos() { |
891 | | - return microservices.methodRegistry.listServices().stream() |
892 | | - .map(JmxMonitorMBean::asString) |
893 | | - .collect(Collectors.joining(",", "[", "]")); |
894 | | - } |
895 | | - |
896 | | - private static String asString(ServiceMethodInvoker invoker) { |
897 | | - return new StringJoiner(", ", ServiceMethodInvoker.class.getSimpleName() + "[", "]") |
898 | | - .add("methodInfo=" + asString(invoker.methodInfo())) |
899 | | - .add( |
900 | | - "serviceMethod=" |
901 | | - + invoker.service().getClass().getCanonicalName() |
902 | | - + "." |
903 | | - + invoker.methodInfo().methodName() |
904 | | - + "(" |
905 | | - + invoker.methodInfo().parameterCount() |
906 | | - + ")") |
907 | | - .toString(); |
908 | | - } |
909 | | - |
910 | | - private static String asString(MethodInfo methodInfo) { |
911 | | - return new StringJoiner(", ", MethodInfo.class.getSimpleName() + "[", "]") |
912 | | - .add("qualifier=" + methodInfo.qualifier()) |
913 | | - .add("auth=" + methodInfo.isSecured()) |
914 | | - .toString(); |
915 | | - } |
916 | | - |
917 | | - private static String asString(ServiceInfo serviceInfo) { |
918 | | - return new StringJoiner(", ", ServiceMethodInvoker.class.getSimpleName() + "[", "]") |
919 | | - .add("serviceInstance=" + serviceInfo.serviceInstance()) |
920 | | - .add("tags=" + serviceInfo.tags()) |
921 | | - .toString(); |
922 | | - } |
923 | | - } |
924 | 829 | } |
0 commit comments