-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix JMXFetch issue when several instances on the same host (#124)
* Remove storage of connections in the connection manager The connection will now be stored by the instance. No more shared connections * Change ConnectionManager into ConnectionFactory
- Loading branch information
Showing
3 changed files
with
46 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.datadog.jmxfetch; | ||
|
||
import java.io.IOException; | ||
import java.util.LinkedHashMap; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
|
||
/** | ||
* Singleton used to create connections to the MBeanServer | ||
*/ | ||
public class ConnectionFactory { | ||
private final static Logger LOGGER = Logger.getLogger(ConnectionFactory.class.getName()); | ||
public static final String PROCESS_NAME_REGEX = "process_name_regex"; | ||
private static ConnectionFactory connectionFactory = null; | ||
|
||
public static Connection createConnection(LinkedHashMap<String, Object> connectionParams) throws IOException { | ||
if (connectionParams.get(PROCESS_NAME_REGEX) != null) { | ||
try { | ||
Class.forName( "com.sun.tools.attach.AttachNotSupportedException" ); | ||
} catch (ClassNotFoundException e) { | ||
throw new IOException("Unable to find tools.jar. Are you using a JDK and did you set the pass to tools.jar ?"); | ||
} | ||
LOGGER.info("Connecting using Attach API"); | ||
return new AttachApiConnection(connectionParams); | ||
|
||
} | ||
LOGGER.info("Connecting using JMX Remote"); | ||
return new RemoteConnection(connectionParams); | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters