Search in sources :

Example 6 with DefaultDatabaseInfo

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo 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 DefaultDatabaseInfo

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

the class OracleJdbcUrlParser method createOracleDatabaseInfo.

private DatabaseInfo createOracleDatabaseInfo(KeyValue keyValue, String url) {
    Description description = new Description(keyValue);
    List<String> jdbcHost = description.getJdbcHost();
    return new DefaultDatabaseInfo(OracleConstants.ORACLE, OracleConstants.ORACLE_EXECUTE_QUERY, url, url, jdbcHost, description.getDatabaseId());
}
Also used : Description(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.Description) DefaultDatabaseInfo(com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo)

Example 8 with DefaultDatabaseInfo

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo 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 DefaultDatabaseInfo

use of com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo 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

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