Search in sources :

Example 6 with StringMaker

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

the class JtdsJdbcUrlParser method parse0.

private DatabaseInfo parse0(String url) {
    //        jdbc:jtds:sqlserver://10.xx.xx.xx:1433;DatabaseName=CAFECHAT;sendStringParametersAsUnicode=false;useLOBs=false;loginTimeout=3
    //        jdbc:jtds:sqlserver://server[:port][/database][;property=value[;...]]
    //        jdbc:jtds:sqlserver://server/db;user=userName;password=password
    StringMaker maker = new StringMaker(url);
    maker.lower().after(URL_PREFIX);
    StringMaker before = maker.after("//").before(';');
    final String hostAndPortAndDataBaseString = before.value();
    String databaseId = "";
    String hostAndPortString = "";
    final int databaseIdIndex = hostAndPortAndDataBaseString.indexOf('/');
    if (databaseIdIndex != -1) {
        hostAndPortString = hostAndPortAndDataBaseString.substring(0, databaseIdIndex);
        databaseId = hostAndPortAndDataBaseString.substring(databaseIdIndex + 1, hostAndPortAndDataBaseString.length());
    } else {
        hostAndPortString = hostAndPortAndDataBaseString;
    }
    List<String> hostList = new ArrayList<String>(1);
    hostList.add(hostAndPortString);
    // option properties search
    if (databaseId.isEmpty()) {
        databaseId = maker.next().after("databasename=").before(';').value();
    }
    String normalizedUrl = maker.clear().before(";").value();
    return new DefaultDatabaseInfo(JtdsConstants.MSSQL, JtdsConstants.MSSQL_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 7 with StringMaker

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

the class OracleJdbcUrlParser method parse0.

private DatabaseInfo parse0(String jdbcUrl) {
    StringMaker maker = new StringMaker(jdbcUrl);
    maker.after(URL_PREFIX).after(":");
    String description = maker.after('@').value().trim();
    if (description.startsWith("(")) {
        return parseNetConnectionUrl(jdbcUrl);
    } else {
        return parseSimpleUrl(jdbcUrl, maker);
    }
}
Also used : StringMaker(com.navercorp.pinpoint.bootstrap.plugin.jdbc.StringMaker)

Example 8 with StringMaker

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

the class PostgreSqlJdbcUrlParser method parseNormal.

private DatabaseInfo parseNormal(String url) {
    // jdbc:postgresql://1.2.3.4:5678/test_db
    StringMaker maker = new StringMaker(url);
    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(PostgreSqlConstants.POSTGRESQL, PostgreSqlConstants.POSTGRESQL_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 9 with StringMaker

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

the class PostgreSqlJdbcUrlParser method parseLoadbalancedUrl.

private DatabaseInfo parseLoadbalancedUrl(String url) {
    // jdbc:postgresql://1.2.3.4:5678/test_db
    StringMaker maker = new StringMaker(url);
    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(PostgreSqlConstants.POSTGRESQL, PostgreSqlConstants.POSTGRESQL_EXECUTE_QUERY, url, normalizedUrl, hostList, databaseId);
}
Also used : 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