-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Subclassing of ConnectionManager into JDBCConnectionManager and SparkConnectionManager. - Fix for logging dependency in pom.xml. - Moving configuration input parsing methods into their own utility class. - TelemetryRegistry can rely on any ConnectionManager. - Move to Java11. Closes #17
- Loading branch information
Showing
36 changed files
with
1,102 additions
and
476 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
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
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/microsoft/lst_bench/client/ClientException.java
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,28 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.microsoft.lst_bench.client; | ||
|
||
/** A client exception. */ | ||
public class ClientException extends Exception { | ||
|
||
public ClientException(Exception cause) { | ||
super(cause); | ||
} | ||
|
||
public ClientException(String message) { | ||
super(message); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/microsoft/lst_bench/client/Connection.java
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,24 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.microsoft.lst_bench.client; | ||
|
||
/** A connection. */ | ||
public interface Connection extends AutoCloseable { | ||
|
||
void execute(String sqlText) throws ClientException; | ||
|
||
void close() throws ClientException; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/microsoft/lst_bench/client/ConnectionManager.java
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,22 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.microsoft.lst_bench.client; | ||
|
||
/** A connection manager. */ | ||
public interface ConnectionManager { | ||
|
||
Connection createConnection() throws ClientException; | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/microsoft/lst_bench/client/JDBCConnection.java
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,54 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.microsoft.lst_bench.client; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
/** A JDBC connection. */ | ||
public class JDBCConnection implements Connection { | ||
|
||
private final java.sql.Connection connection; | ||
|
||
public JDBCConnection(java.sql.Connection connection) { | ||
this.connection = connection; | ||
} | ||
|
||
@Override | ||
public void execute(String sqlText) throws ClientException { | ||
try (Statement s = connection.createStatement()) { | ||
boolean hasResults = s.execute(sqlText); | ||
if (hasResults) { | ||
ResultSet rs = s.getResultSet(); | ||
while (rs.next()) { | ||
// do nothing | ||
} | ||
} | ||
} catch (Exception e) { | ||
throw new ClientException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void close() throws ClientException { | ||
try { | ||
connection.close(); | ||
} catch (SQLException e) { | ||
throw new ClientException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.