Skip to content

Commit 48f7ca0

Browse files
authored
[WIP] Implement certificate refreshes asynchronously (#137)
* Add new CloudSqlInstance Class for managing instance info. * Add updateInstanceMetadata for fetching InstanceMetadata. * Added updateEphemeralCerificate. * Add createSocket and updateSslContext. * Update CloudSQLInstance methods to use async. * Fix checkstyle errors. * Added getPrefferedIpType. * Use callbacks over in method future updates. * Add RateLimiting for immediateSslContextUpdate(). * Correct 'connect' to be static. * Use new class in createSSLSocket. * Remove older code. * Add generic whenComplete function. * Refactor 3 seperate tasks into a single operation. * Fixed scheduling for next refresh. * Update to Futures.getDone instead of .get * Clean up some error handling. * Clean up commenting. * Update from blocked call to nested ListenableFutures. * Improve future handling of scheduleRefresh. * Remove blocking from forcedRefresh. * Fix error propegation to cause. * Fix miscellanous Javadoc comments. * Fix miscellaneous style and best practice issues. * Inline blockInstanceDataOnNext into forceRefresh. * Move listener to performRefresh. * Misc updates. * Move the rest of scheduledRefresh into performRefresh. * Update tests. * Style fix in fetchMetadata. * Switch whenAllComplete to whenAllSucceed. * Updates based on review feedback. * Additional feedback updates. * Remove unncessary annotation. * Remove nullcheck for nextInstanceData. * Update tests to use error.hasMessageThat.
1 parent eaa61ed commit 48f7ca0

File tree

6 files changed

+578
-557
lines changed

6 files changed

+578
-557
lines changed

connector-j-5/src/main/java/com/google/cloud/sql/mysql/SocketFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public class SocketFactory implements com.mysql.jdbc.SocketFactory {
3333

3434
@Override
3535
public Socket connect(String hostname, int portNumber, Properties props) throws IOException {
36-
socket =
37-
CoreSocketFactory.getInstance().connect(props, CoreSocketFactory.MYSQL_SOCKET_FILE_FORMAT);
36+
socket = CoreSocketFactory.connect(props, CoreSocketFactory.MYSQL_SOCKET_FILE_FORMAT);
3837
return socket;
3938
}
4039

connector-j-6/src/main/java/com/google/cloud/sql/mysql/SocketFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public class SocketFactory implements com.mysql.cj.api.io.SocketFactory {
3434
@Override
3535
public Socket connect(String host, int portNumber, Properties props, int loginTimeout)
3636
throws IOException {
37-
socket =
38-
CoreSocketFactory.getInstance().connect(props, CoreSocketFactory.MYSQL_SOCKET_FILE_FORMAT);
37+
socket = CoreSocketFactory.connect(props, CoreSocketFactory.MYSQL_SOCKET_FILE_FORMAT);
3938
return socket;
4039
}
4140

connector-j-8/src/main/java/com/google/cloud/sql/mysql/SocketFactory.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ public <T extends Closeable> T connect(
4545
public <T extends Closeable> T connect(
4646
String host, int portNumber, Properties props, int loginTimeout) throws IOException {
4747
@SuppressWarnings("unchecked")
48-
T socket =
49-
(T)
50-
CoreSocketFactory.getInstance()
51-
.connect(props, CoreSocketFactory.MYSQL_SOCKET_FILE_FORMAT);
48+
T socket = (T) CoreSocketFactory.connect(props, CoreSocketFactory.MYSQL_SOCKET_FILE_FORMAT);
5249
return socket;
5350
}
5451

@@ -67,5 +64,4 @@ public <T extends Closeable> T performTlsHandshake(
6764

6865
@Override
6966
public void afterHandshake() {}
70-
7167
}

0 commit comments

Comments
 (0)