sun.management.Agent Java Examples
The following examples show how to use
sun.management.Agent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AgentCMETest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #2
Source File: AgentCMETest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #3
Source File: AgentCMETest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #4
Source File: AgentCMETest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #5
Source File: AgentCMETest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #6
Source File: AgentCMETest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #7
Source File: AgentCMETest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #8
Source File: AgentCMETest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #9
Source File: AgentCMETest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #10
Source File: AgentCMETest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #11
Source File: JmxUtils.java From Kafdrop with Apache License 2.0 | 6 votes |
public static int getJmxPort(final Environment environment) { Optional<Integer> jmxPort = Optional.empty(); final Properties managementProperties = Agent.getManagementProperties(); if (managementProperties != null) { final String portProperty = managementProperties.getProperty(JMX_PORT_PROPERTY); if (portProperty != null) { final Optional<Integer> port = Optional.ofNullable(Ints.tryParse(portProperty)); jmxPort = port; } } return jmxPort.orElse(0); }
Example #12
Source File: AgentCMETest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #13
Source File: AgentCMETest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * In sun.management.Agent.loadManagementProperties(), call * properties.putAll API may fail with ConcurrentModifcationException if the * system properties are modified simultaneously by another thread * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println("Start..."); final Properties properties = System.getProperties(); Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 100; i++) { properties.put(String.valueOf(i), ""); try { Thread.sleep(1); } catch (InterruptedException e) { // do nothing } } } }); t1.start(); for (int i = 0; i < 10000; i++) { Agent.loadManagementProperties(); } System.out.println("Finished..."); }
Example #14
Source File: ConnectorBootstrap.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void checkPasswordFile(String passwordFileName) { if (passwordFileName == null || passwordFileName.length() == 0) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET); } File file = new File(passwordFileName); if (!file.exists()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND, passwordFileName); } if (!file.canRead()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_READABLE, passwordFileName); } FileSystem fs = FileSystem.open(); try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly", passwordFileName); log.config("startRemoteConnectorServer", msg); throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED, passwordFileName); } } } catch (IOException e) { throw new AgentConfigurationError(PASSWORD_FILE_READ_FAILED, e, passwordFileName); } }
Example #15
Source File: ConnectorBootstrap.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Initializes and starts the JMX Connector Server. * If the com.sun.management.jmxremote.port property is not defined, * simply return. Otherwise, attempts to load the config file, and * then calls {@link #startRemoteConnectorServer * (java.lang.String, java.util.Properties)}. * * This method is used by some jtreg tests. **/ public static synchronized JMXConnectorServer initialize() { // Load a new management properties final Properties props = Agent.loadManagementProperties(); if (props == null) { return null; } final String portStr = props.getProperty(PropertyNames.PORT); return startRemoteConnectorServer(portStr, props); }
Example #16
Source File: AdaptorBootstrap.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes and starts the SNMP Adaptor Server. * If the com.sun.management.snmp.port property is not defined, * simply return. Otherwise, attempts to load the config file, and * then calls {@link #initialize(java.lang.String, java.util.Properties)}. * **/ public static synchronized AdaptorBootstrap initialize() { // Load a new properties final Properties props = Agent.loadManagementProperties(); if (props == null) return null; final String portStr = props.getProperty(PropertyNames.PORT); return initialize(portStr,props); }
Example #17
Source File: ConnectorBootstrap.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkPasswordFile(String passwordFileName) { if (passwordFileName == null || passwordFileName.length() == 0) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET); } File file = new File(passwordFileName); if (!file.exists()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND, passwordFileName); } if (!file.canRead()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_READABLE, passwordFileName); } FileSystem fs = FileSystem.open(); try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly", passwordFileName); log.config("startRemoteConnectorServer", msg); throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED, passwordFileName); } } } catch (IOException e) { throw new AgentConfigurationError(PASSWORD_FILE_READ_FAILED, e, passwordFileName); } }
Example #18
Source File: AdaptorBootstrap.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Trap Target List from the ACL file. **/ @SuppressWarnings("unchecked") private static List<NotificationTarget> getTargetList(InetAddressAcl acl, int defaultTrapPort) { final ArrayList<NotificationTarget> result = new ArrayList<>(); if (acl != null) { if (log.isDebugOn()) log.debug("getTargetList",Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.processing")); final Enumeration<InetAddress> td = acl.getTrapDestinations(); for (; td.hasMoreElements() ;) { final InetAddress targetAddr = td.nextElement(); final Enumeration<String> tc = acl.getTrapCommunities(targetAddr); for (;tc.hasMoreElements() ;) { final String community = tc.nextElement(); final NotificationTarget target = new NotificationTargetImpl(targetAddr, defaultTrapPort, community); if (log.isDebugOn()) log.debug("getTargetList", Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.adding", target.toString())); result.add(target); } } } return result; }
Example #19
Source File: ConnectorBootstrap.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkRestrictedFile(String restrictedFileName) { if (restrictedFileName == null || restrictedFileName.length() == 0) { throw new AgentConfigurationError(FILE_NOT_SET); } File file = new File(restrictedFileName); if (!file.exists()) { throw new AgentConfigurationError(FILE_NOT_FOUND, restrictedFileName); } if (!file.canRead()) { throw new AgentConfigurationError(FILE_NOT_READABLE, restrictedFileName); } FileSystem fs = FileSystem.open(); try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { final String msg = Agent.getText( "jmxremote.ConnectorBootstrap.file.readonly", restrictedFileName); log.config("startRemoteConnectorServer", msg); throw new AgentConfigurationError( FILE_ACCESS_NOT_RESTRICTED, restrictedFileName); } } } catch (IOException e) { throw new AgentConfigurationError( FILE_READ_FAILED, e, restrictedFileName); } }
Example #20
Source File: AdaptorBootstrap.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Initializes and starts the SNMP Adaptor Server. * If the com.sun.management.snmp.port property is not defined, * simply return. Otherwise, attempts to load the config file, and * then calls {@link #initialize(java.lang.String, java.util.Properties)}. * **/ public static synchronized AdaptorBootstrap initialize() { // Load a new properties final Properties props = Agent.loadManagementProperties(); if (props == null) return null; final String portStr = props.getProperty(PropertyNames.PORT); return initialize(portStr,props); }
Example #21
Source File: AgentCheckTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args){ String [][] testStrings = { {"agent.err.error", "", ""}, {"jmxremote.ConnectorBootstrap.starting", "", ""}, {"jmxremote.ConnectorBootstrap.noAuthentication", "", ""}, {"jmxremote.ConnectorBootstrap.ready", "Phony JMXServiceURL", ""}, {"jmxremote.ConnectorBootstrap.password.readonly", "Phony passwordFileName", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.processing", "", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.adding", "Phony target", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.starting", "", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.initialize1", "", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Phony hostname", "Phony port"}, {"jmxremote.AdaptorBootstrap.getTargetList.terminate", "Phony exception", ""}, }; boolean pass = true; System.out.println("Start..."); for (int ii = 0; ii < testStrings.length; ii++) { String key = testStrings[ii][0]; String p1 = testStrings[ii][1]; String p2 = testStrings[ii][2]; String ss = Agent.getText(key, p1, p2); if (ss.startsWith("missing resource key")) { pass = false; System.out.println(" lookup failed for key = " + key); } } if (!pass) { throw new Error ("Resource lookup(s) failed; Test failed"); } System.out.println("...Finished."); }
Example #22
Source File: AdaptorBootstrap.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Initializes and starts the SNMP Adaptor Server. * If the com.sun.management.snmp.port property is not defined, * simply return. Otherwise, attempts to load the config file, and * then calls {@link #initialize(java.lang.String, java.util.Properties)}. * **/ public static synchronized AdaptorBootstrap initialize() { // Load a new properties final Properties props = Agent.loadManagementProperties(); if (props == null) return null; final String portStr = props.getProperty(PropertyNames.PORT); return initialize(portStr,props); }
Example #23
Source File: AdaptorBootstrap.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Trap Target List from the ACL file. **/ @SuppressWarnings("unchecked") private static List<NotificationTarget> getTargetList(InetAddressAcl acl, int defaultTrapPort) { final ArrayList<NotificationTarget> result = new ArrayList<>(); if (acl != null) { if (log.isDebugOn()) log.debug("getTargetList",Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.processing")); final Enumeration<InetAddress> td = acl.getTrapDestinations(); for (; td.hasMoreElements() ;) { final InetAddress targetAddr = td.nextElement(); final Enumeration<String> tc = acl.getTrapCommunities(targetAddr); for (;tc.hasMoreElements() ;) { final String community = tc.nextElement(); final NotificationTarget target = new NotificationTargetImpl(targetAddr, defaultTrapPort, community); if (log.isDebugOn()) log.debug("getTargetList", Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.adding", target.toString())); result.add(target); } } } return result; }
Example #24
Source File: ConnectorBootstrap.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkRestrictedFile(String restrictedFileName) { if (restrictedFileName == null || restrictedFileName.length() == 0) { throw new AgentConfigurationError(FILE_NOT_SET); } File file = new File(restrictedFileName); if (!file.exists()) { throw new AgentConfigurationError(FILE_NOT_FOUND, restrictedFileName); } if (!file.canRead()) { throw new AgentConfigurationError(FILE_NOT_READABLE, restrictedFileName); } FileSystem fs = FileSystem.open(); try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { final String msg = Agent.getText( "jmxremote.ConnectorBootstrap.file.readonly", restrictedFileName); log.config("startRemoteConnectorServer", msg); throw new AgentConfigurationError( FILE_ACCESS_NOT_RESTRICTED, restrictedFileName); } } } catch (IOException e) { throw new AgentConfigurationError( FILE_READ_FAILED, e, restrictedFileName); } }
Example #25
Source File: ConnectorBootstrap.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void checkPasswordFile(String passwordFileName) { if (passwordFileName == null || passwordFileName.length() == 0) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET); } File file = new File(passwordFileName); if (!file.exists()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND, passwordFileName); } if (!file.canRead()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_READABLE, passwordFileName); } FileSystem fs = FileSystem.open(); try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly", passwordFileName); log.config("startRemoteConnectorServer", msg); throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED, passwordFileName); } } } catch (IOException e) { throw new AgentConfigurationError(PASSWORD_FILE_READ_FAILED, e, passwordFileName); } }
Example #26
Source File: ConnectorBootstrap.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Initializes and starts the JMX Connector Server. * If the com.sun.management.jmxremote.port property is not defined, * simply return. Otherwise, attempts to load the config file, and * then calls {@link #startRemoteConnectorServer * (java.lang.String, java.util.Properties)}. * * This method is used by some jtreg tests. **/ public static synchronized JMXConnectorServer initialize() { // Load a new management properties final Properties props = Agent.loadManagementProperties(); if (props == null) { return null; } final String portStr = props.getProperty(PropertyNames.PORT); return startRemoteConnectorServer(portStr, props); }
Example #27
Source File: AgentCheckTest.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args){ String [][] testStrings = { {"agent.err.error", "", ""}, {"jmxremote.ConnectorBootstrap.starting", "", ""}, {"jmxremote.ConnectorBootstrap.noAuthentication", "", ""}, {"jmxremote.ConnectorBootstrap.ready", "Phony JMXServiceURL", ""}, {"jmxremote.ConnectorBootstrap.password.readonly", "Phony passwordFileName", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.processing", "", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.adding", "Phony target", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.starting", "", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.initialize1", "", ""}, {"jmxremote.AdaptorBootstrap.getTargetList.initialize2", "Phony hostname", "Phony port"}, {"jmxremote.AdaptorBootstrap.getTargetList.terminate", "Phony exception", ""}, }; boolean pass = true; System.out.println("Start..."); for (int ii = 0; ii < testStrings.length; ii++) { String key = testStrings[ii][0]; String p1 = testStrings[ii][1]; String p2 = testStrings[ii][2]; String ss = Agent.getText(key, p1, p2); if (ss.startsWith("missing resource key")) { pass = false; System.out.println(" lookup failed for key = " + key); } } if (!pass) { throw new Error ("Resource lookup(s) failed; Test failed"); } System.out.println("...Finished."); }
Example #28
Source File: AdaptorBootstrap.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Initializes and starts the SNMP Adaptor Server. * If the com.sun.management.snmp.port property is not defined, * simply return. Otherwise, attempts to load the config file, and * then calls {@link #initialize(java.lang.String, java.util.Properties)}. * **/ public static synchronized AdaptorBootstrap initialize() { // Load a new properties final Properties props = Agent.loadManagementProperties(); if (props == null) return null; final String portStr = props.getProperty(PropertyNames.PORT); return initialize(portStr,props); }
Example #29
Source File: AdaptorBootstrap.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Trap Target List from the ACL file. **/ @SuppressWarnings("unchecked") private static List<NotificationTarget> getTargetList(InetAddressAcl acl, int defaultTrapPort) { final ArrayList<NotificationTarget> result = new ArrayList<>(); if (acl != null) { if (log.isDebugOn()) log.debug("getTargetList",Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.processing")); final Enumeration<InetAddress> td = acl.getTrapDestinations(); for (; td.hasMoreElements() ;) { final InetAddress targetAddr = td.nextElement(); final Enumeration<String> tc = acl.getTrapCommunities(targetAddr); for (;tc.hasMoreElements() ;) { final String community = tc.nextElement(); final NotificationTarget target = new NotificationTargetImpl(targetAddr, defaultTrapPort, community); if (log.isDebugOn()) log.debug("getTargetList", Agent.getText("jmxremote.AdaptorBootstrap.getTargetList.adding", target.toString())); result.add(target); } } } return result; }
Example #30
Source File: ConnectorBootstrap.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static void checkPasswordFile(String passwordFileName) { if (passwordFileName == null || passwordFileName.length() == 0) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_SET); } File file = new File(passwordFileName); if (!file.exists()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_FOUND, passwordFileName); } if (!file.canRead()) { throw new AgentConfigurationError(PASSWORD_FILE_NOT_READABLE, passwordFileName); } FileSystem fs = FileSystem.open(); try { if (fs.supportsFileSecurity(file)) { if (!fs.isAccessUserOnly(file)) { final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly", passwordFileName); log.config("startRemoteConnectorServer", msg); throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED, passwordFileName); } } } catch (IOException e) { throw new AgentConfigurationError(PASSWORD_FILE_READ_FAILED, e, passwordFileName); } }