Search in sources :

Example 1 with OracleNetConnectionDescriptorParser

use of com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser in project pinpoint by naver.

the class OracleNetConnectionDescriptorParserTest method parse4.

@Test
public void parse4() {
    String rac = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE = off )" + "(ADDRESS  =  ( PROTOCOL = TCP)(HOST = 1.2.3.4 ) (PORT = 1521 ))" + " ( CONNECT_DATA = ( SID = sid ) ) )";
    OracleNetConnectionDescriptorParser parser = new OracleNetConnectionDescriptorParser(rac);
    KeyValue keyValue = parser.parse();
    Description description = new Description(keyValue);
    Description value = new Description();
    value.setSid("sid");
    value.addAddress("tcp", "1.2.3.4", "1521");
    Assert.assertEquals(description, value);
}
Also used : KeyValue(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.KeyValue) Description(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.Description) OracleNetConnectionDescriptorParser(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser) Test(org.junit.Test)

Example 2 with OracleNetConnectionDescriptorParser

use of com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser in project pinpoint by naver.

the class OracleNetConnectionDescriptorParserTest method emptyValue.

@Test
public void emptyValue() {
    String rac = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=)" + "(CONNECT_DATA=(SERVICE_NAME=)))";
    OracleNetConnectionDescriptorParser parser = new OracleNetConnectionDescriptorParser(rac);
    KeyValue keyValue = parser.parse();
    logger.info(keyValue.toString());
    Description des = new Description(keyValue);
    Assert.assertEquals(des.getServiceName(), null);
}
Also used : KeyValue(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.KeyValue) Description(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.Description) OracleNetConnectionDescriptorParser(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser) Test(org.junit.Test)

Example 3 with OracleNetConnectionDescriptorParser

use of com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser in project pinpoint by naver.

the class OracleNetConnectionDescriptorParserTest method parseEofError.

@Test
public void parseEofError() {
    String rac = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE = off )" + "(ADDRESS  =  ( PROTOCOL = TCP)(HOST = 1.2.3.4 ) (PORT = 1521 ))" + //                " ( CONNECT_DATA = ( SID = sid ) ) )";
    " ( CONNECT_DATA = ( SID = sid ) ) ";
    OracleNetConnectionDescriptorParser parser = new OracleNetConnectionDescriptorParser(rac);
    try {
        KeyValue keyValue = parser.parse();
        Assert.fail();
    } catch (OracleConnectionStringException e) {
        logger.info("Expected error", e);
    }
}
Also used : KeyValue(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.KeyValue) OracleConnectionStringException(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleConnectionStringException) OracleNetConnectionDescriptorParser(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser) Test(org.junit.Test)

Example 4 with OracleNetConnectionDescriptorParser

use of com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser in project pinpoint by naver.

the class OracleNetConnectionDescriptorParserTest method parse2.

@Test
public void parse2() {
    String rac = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE = off )" + "(ADDRESS  =  ( PROTOCOL = TCP)(HOST = 1.2.3.4 ) (PORT = 1521 ))" + "(ADDRESS = (PROTOCOL = TCP ) (HOST = 1.2.3.5) ( PORT = 1522 ))" + " ( CONNECT_DATA = ( SERVICE_NAME = service ) ) )";
    OracleNetConnectionDescriptorParser parser = new OracleNetConnectionDescriptorParser(rac);
    KeyValue keyValue = parser.parse();
    Description description = new Description(keyValue);
    Description value = new Description();
    value.setServiceName("service");
    value.addAddress("tcp", "1.2.3.4", "1521");
    value.addAddress("tcp", "1.2.3.5", "1522");
    Assert.assertEquals(description, value);
}
Also used : KeyValue(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.KeyValue) Description(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.Description) OracleNetConnectionDescriptorParser(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser) Test(org.junit.Test)

Example 5 with OracleNetConnectionDescriptorParser

use of com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser in project pinpoint by naver.

the class OracleJdbcUrlParser method parseNetConnectionUrl.

//    rac url.
//    jdbc:oracle:thin:@(Description=(LOAD_BALANCE=on)" +
//    "(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.4) (PORT=1521))" +
//            "(ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.5) (PORT=1521))" +
//            "(CONNECT_DATA=(SERVICE_NAME=service)))"
//
//    thin driver url
//    jdbc:oracle:thin:@hostname:port:SID
//    "jdbc:oracle:thin:MYWORKSPACE/qwerty@localhost:1521:XE";
//    With proper indentation and line break, 
//    jdbc:oracle:thin:
//    @(
//         Description=(LOAD_BALANCE=on)
//         (
//             ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.4) (PORT=1521)
//         )
//         (
//             ADDRESS=(PROTOCOL=TCP)(HOST=1.2.3.5) (PORT=1521)
//         )
//         (
//             CONNECT_DATA=(SERVICE_NAME=service)
//         )
//    )
private DatabaseInfo parseNetConnectionUrl(String url) {
    // oracle new URL : for rac
    OracleNetConnectionDescriptorParser parser = new OracleNetConnectionDescriptorParser(url);
    KeyValue keyValue = parser.parse();
    //                parser.getDriverType();
    return createOracleDatabaseInfo(keyValue, url);
}
Also used : KeyValue(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.KeyValue) OracleNetConnectionDescriptorParser(com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser)

Aggregations

KeyValue (com.navercorp.pinpoint.plugin.jdbc.oracle.parser.KeyValue)10 OracleNetConnectionDescriptorParser (com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleNetConnectionDescriptorParser)10 Test (org.junit.Test)9 Description (com.navercorp.pinpoint.plugin.jdbc.oracle.parser.Description)6 OracleConnectionStringException (com.navercorp.pinpoint.plugin.jdbc.oracle.parser.OracleConnectionStringException)3