Search in sources :

Example 1 with StringMaker

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker in project pinpoint by naver.

the class MySqlJdbcUrlParser method parseLoadbalancedUrl.

private DatabaseInfo parseLoadbalancedUrl(String jdbcUrl) {
    // jdbc:mysql://1.2.3.4:5678/test_db
    StringMaker maker = new StringMaker(jdbcUrl);
    maker.after(URL_PREFIX);
    // 1.2.3.4:5678 In case of replication driver could have multiple values
    // We have to consider mm db too.
    String host = maker.after("//").before('/').value();
    // Decided not to cache regex. This is not invoked often so don't waste memory.
    String[] parsedHost = host.split(",");
    List<String> hostList = Arrays.asList(parsedHost);
    String databaseId = maker.next().afterLast('/').before('?').value();
    String normalizedUrl = maker.clear().before('?').value();
    return new DefaultDatabaseInfo(MySqlConstants.MYSQL, MySqlConstants.MYSQL_EXECUTE_QUERY, jdbcUrl, normalizedUrl, hostList, databaseId);
}
Also used : DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) StringMaker(com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)

Example 2 with StringMaker

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker in project pinpoint by naver.

the class MySqlJdbcUrlParser method parseNormal.

private DatabaseInfo parseNormal(String jdbcUrl) {
    // jdbc:mysql://1.2.3.4:5678/test_db
    StringMaker maker = new StringMaker(jdbcUrl);
    maker.after(URL_PREFIX);
    // 1.2.3.4:5678 In case of replication driver could have multiple values
    // We have to consider mm db too.
    String host = maker.after("//").before('/').value();
    List<String> hostList = new ArrayList<String>(1);
    hostList.add(host);
    // String port = maker.next().after(':').before('/').value();
    String databaseId = maker.next().afterLast('/').before('?').value();
    String normalizedUrl = maker.clear().before('?').value();
    return new DefaultDatabaseInfo(MySqlConstants.MYSQL, MySqlConstants.MYSQL_EXECUTE_QUERY, jdbcUrl, normalizedUrl, hostList, databaseId);
}
Also used : ArrayList(java.util.ArrayList) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) StringMaker(com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)

Example 3 with StringMaker

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker in project pinpoint by naver.

the class MariaDBJdbcUrlParser method parseNormal.

private DatabaseInfo parseNormal(String url, Type type) {
    // jdbc:mariadb://1.2.3.4:5678/test_db
    StringMaker maker = new StringMaker(url);
    maker.after(type.getUrlPrefix());
    // 1.2.3.4:5678 In case of replication driver could have multiple values
    // We have to consider mm db too.
    String host = maker.after("//").before('/').value();
    List<String> hostList = new ArrayList<String>(1);
    hostList.add(host);
    // String port = maker.next().after(':').before('/').value();
    String databaseId = maker.next().afterLast('/').before('?').value();
    String normalizedUrl = maker.clear().before('?').value();
    return new DefaultDatabaseInfo(MariaDBConstants.MARIADB, MariaDBConstants.MARIADB_EXECUTE_QUERY, url, normalizedUrl, hostList, databaseId);
}
Also used : ArrayList(java.util.ArrayList) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) StringMaker(com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)

Example 4 with StringMaker

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker in project pinpoint by naver.

the class MariaDBJdbcUrlParser method parseLoadbalancedUrl.

private DatabaseInfo parseLoadbalancedUrl(String url, Type type) {
    // jdbc:mariadb://1.2.3.4:5678/test_db
    StringMaker maker = new StringMaker(url);
    maker.after(type.getUrlPrefix());
    // 1.2.3.4:5678 In case of replication driver could have multiple values
    // We have to consider mm db too.
    String host = maker.after("//").before('/').value();
    // Decided not to cache regex. This is not invoked often so don't waste
    // memory.
    String[] parsedHost = host.split(",");
    List<String> hostList = Arrays.asList(parsedHost);
    String databaseId = maker.next().afterLast('/').before('?').value();
    String normalizedUrl = maker.clear().before('?').value();
    return new DefaultDatabaseInfo(MariaDBConstants.MARIADB, MariaDBConstants.MARIADB_EXECUTE_QUERY, url, normalizedUrl, hostList, databaseId);
}
Also used : DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) StringMaker(com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)

Example 5 with StringMaker

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker in project pinpoint by naver.

the class CubridJdbcUrlParser method parse0.

private DatabaseInfo parse0(String jdbcUrl) {
    final Matcher matcher = PATTERN.matcher(jdbcUrl);
    if (!matcher.find()) {
        throw new IllegalArgumentException();
    }
    String host = matcher.group(2);
    String portString = matcher.group(3);
    String db = matcher.group(4);
    String user = matcher.group(5);
    if (host == null || host.length() == 0) {
        host = DEFAULT_HOSTNAME;
    }
    if (user == null) {
        user = DEFAULT_USER;
    }
    //        if (pass == null) {
    //            pass = DEFAULT_PASSWORD;
    //        }
    //        resolvedUrl = "jdbc:cubrid:" + host + ":" + port + ":" + db + ":" + user + ":********:";
    StringMaker maker = new StringMaker(jdbcUrl);
    String normalizedUrl = maker.clear().before('?').value();
    List<String> hostList = new ArrayList<String>(1);
    final String hostAndPort = host + ":" + portString;
    hostList.add(hostAndPort);
    return new DefaultDatabaseInfo(CubridConstants.CUBRID, CubridConstants.CUBRID_EXECUTE_QUERY, jdbcUrl, normalizedUrl, hostList, db);
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo) StringMaker(com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)

Aggregations

StringMaker (com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)9 DefaultDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo)8 ArrayList (java.util.ArrayList)5 Matcher (java.util.regex.Matcher)1