コード例 #1
2
ファイル: MBeanClientFactory.cs プロジェクト: tableau/TabMon
        /// <summary>
        /// Creates instances of MBeanClient objects for all open JMX ports on a host within a given port range.
        /// This is accomplished by scanning the range starting from the bottom and stopping when a closed port is encountered, to maintain parity with how Tableau exposes JMX ports.
        /// </summary>
        /// <param name="hostname">The hostname of the remote host to generate clients for.</param>
        /// <param name="startPort">The start of the port range to scan.</param>
        /// <param name="endPort">The end of the port range to scan.</param>
        /// <returns>Collection of MBeanClients for open ports within the given range.</returns>
        public static ICollection<IMBeanClient> CreateClients(string hostname, int startPort, int endPort)
        {
            // Validate port range.
            if (!IsValidPortRange(startPort, endPort))
            {
                throw new ArgumentException("Invalid port range");
            }

            Log.Debug(String.Format("Scanning JMX ports {0}-{1} on {2}..", startPort, endPort, hostname));
            ICollection<IMBeanClient> validClients = new List<IMBeanClient>();

            for (var currentPort = startPort; currentPort <= endPort; currentPort++)
            {
                var connectionInfo = new JmxConnectionInfo(hostname, currentPort);
                var connector = new JmxConnectorProxy(connectionInfo);

                try
                {
                    connector.OpenConnection();
                    IMBeanClient client = new MBeanClient(connector);
                    validClients.Add(client);
                    Log.Debug(String.Format("Created JMX client for {0}", connectionInfo));
                }
                catch (Exception)
                {
                    Log.Debug(String.Format("Encountered closed JMX port ({0}), stopping scan.", currentPort));
                    break;
                }
            }

            return validClients;
        }
コード例 #2
0
        /// <summary>
        /// Creates instances of MBeanClient objects for all open JMX ports on a host within a given port range.
        /// This is accomplished by scanning the range starting from the bottom and stopping when a closed port is encountered, to maintain parity with how Tableau exposes JMX ports.
        /// </summary>
        /// <param name="hostname">The hostname of the remote host to generate clients for.</param>
        /// <param name="startPort">The start of the port range to scan.</param>
        /// <param name="endPort">The end of the port range to scan.</param>
        /// <returns>Collection of MBeanClients for open ports within the given range.</returns>
        public static ICollection <IMBeanClient> CreateClients(string hostname, int startPort, int endPort)
        {
            // Validate port range.
            if (!IsValidPortRange(startPort, endPort))
            {
                throw new ArgumentException("Invalid port range");
            }

            Log.Debug(String.Format("Scanning JMX ports {0}-{1} on {2}..", startPort, endPort, hostname));
            ICollection <IMBeanClient> validClients = new List <IMBeanClient>();

            for (var currentPort = startPort; currentPort <= endPort; currentPort++)
            {
                var connectionInfo = new JmxConnectionInfo(hostname, currentPort);
                var connector      = new JmxConnectorProxy(connectionInfo);

                try
                {
                    connector.OpenConnection();
                    IMBeanClient client = new MBeanClient(connector);
                    validClients.Add(client);
                    Log.Debug(String.Format("Created JMX client for {0}", connectionInfo));
                }
                catch (Exception)
                {
                    Log.Debug(String.Format("Encountered closed JMX port ({0}), stopping scan.", currentPort));
                    break;
                }
            }

            return(validClients);
        }
コード例 #3
0
        private static IMBeanClient CreateMBeanClient(string hostname, int port, int instanceNumber)
        {
            var connectionInfo = new JmxConnectionInfo(hostname, port);
            var connector      = new JmxConnectorProxy(connectionInfo);

            connector.OpenConnection();
            return(new MBeanClient(connector, instanceNumber));
        }
コード例 #4
0
 public MBeanClient(JmxConnectorProxy connector, int instanceNumber)
 {
     Connector      = connector;
     InstanceNumber = instanceNumber;
 }
コード例 #5
0
 public MBeanClient(JmxConnectorProxy connector)
 {
     Connector = connector;
 }
コード例 #6
0
ファイル: MBeanClient.cs プロジェクト: yaswanth369/TabMon
 public MBeanClient(JmxConnectorProxy connector)
 {
     Connector = connector;
 }