Skip to content

Commit

Permalink
rename to remove millis
Browse files Browse the repository at this point in the history
  • Loading branch information
bbeaudreault committed Aug 23, 2017
1 parent 2eb0871 commit a14aa65
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
36 changes: 18 additions & 18 deletions java/jdbc/src/main/java/io/vitess/jdbc/ConnectionProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,20 @@ public class ConnectionProperties {
"Should the driver treat java.util.Date as a TIMESTAMP for the purposes of PreparedStatement.setObject()",
true);

private LongConnectionProperty queryTimeoutMillis = new LongConnectionProperty(
"queryTimeoutMillis",
private LongConnectionProperty queryTimeout = new LongConnectionProperty(
"queryTimeout",
"The default query timeout, in millis, to use for queries which do not explicitly setQueryTimeout",
Constants.DEFAULT_TIMEOUT
);

private LongConnectionProperty connectionTimeoutMillis = new LongConnectionProperty(
"connectionTimeoutMillis",
private LongConnectionProperty connectionTimeout = new LongConnectionProperty(
"connectionTimeout",
"The timeout, in millis, to use when creating new gRPC connections",
Constants.CONNECTION_TIMEOUT
);

private LongConnectionProperty transactionTimeoutMillis = new LongConnectionProperty(
"transactionTimeoutMillis",
private LongConnectionProperty transactionTimeout = new LongConnectionProperty(
"transactionTimeout",
"The timeout, in millis, to use when committing or rolling back transactions",
Constants.DEFAULT_TIMEOUT
);
Expand Down Expand Up @@ -480,28 +480,28 @@ public void setTreatUtilDateAsTimestamp(boolean treatUtilDateAsTimestamp) {
this.treatUtilDateAsTimestamp.setValue(treatUtilDateAsTimestamp);
}

public long getQueryTimeoutMillis() {
return queryTimeoutMillis.getValueAsLong();
public long getQueryTimeout() {
return queryTimeout.getValueAsLong();
}

public void setQueryTimeoutMillis(long queryTimeoutMillis) {
this.queryTimeoutMillis.setValue(queryTimeoutMillis);
public void setQueryTimeout(long queryTimeout) {
this.queryTimeout.setValue(queryTimeout);
}

public long getConnectionTimeoutMillis() {
return connectionTimeoutMillis.getValueAsLong();
public long getConnectionTimeout() {
return connectionTimeout.getValueAsLong();
}

public void setConnectionTimeoutMillis(long connectionTimeoutMillis) {
this.connectionTimeoutMillis.setValue(connectionTimeoutMillis);
public void setConnectionTimeout(long connectionTimeout) {
this.connectionTimeout.setValue(connectionTimeout);
}

public long getTransactionTimeoutMillis() {
return transactionTimeoutMillis.getValueAsLong();
public long getTransactionTimeout() {
return transactionTimeout.getValueAsLong();
}

public void setTransactionTimeoutMillis(long transactionTimeoutMillis) {
this.transactionTimeoutMillis.setValue(transactionTimeoutMillis);
public void setTransactionTimeout(long transactionTimeout) {
this.transactionTimeout.setValue(transactionTimeout);
}

public String getTarget() {
Expand Down
4 changes: 2 additions & 2 deletions java/jdbc/src/main/java/io/vitess/jdbc/VitessConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void commit() throws SQLException {
checkAutoCommit(Constants.SQLExceptionMessages.COMMIT_WHEN_AUTO_COMMIT_TRUE);
try {
if (isInTransaction()) {
Context context = createContext(getTransactionTimeoutMillis());
Context context = createContext(getTransactionTimeout());
this.vtGateTx.commit(context, getTwopcEnabled()).checkedGet();
}
} finally {
Expand All @@ -191,7 +191,7 @@ public void rollback() throws SQLException {
checkAutoCommit(Constants.SQLExceptionMessages.ROLLBACK_WHEN_AUTO_COMMIT_TRUE);
try {
if (isInTransaction()) {
Context context = createContext(getTransactionTimeoutMillis());
Context context = createContext(getTransactionTimeout());
this.vtGateTx.rollback(context).checkedGet();
}
} finally {
Expand Down
4 changes: 2 additions & 2 deletions java/jdbc/src/main/java/io/vitess/jdbc/VitessStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public VitessStatement(VitessConnection vitessConnection) {
public VitessStatement(VitessConnection vitessConnection, int resultSetType,
int resultSetConcurrency) {
this.vitessConnection = vitessConnection;
this.queryTimeoutInMillis = vitessConnection.getQueryTimeoutMillis();
this.queryTimeoutInMillis = vitessConnection.getQueryTimeout();
this.vitessResultSet = null;
this.resultSetType = resultSetType;
this.resultSetConcurrency = resultSetConcurrency;
Expand Down Expand Up @@ -268,7 +268,7 @@ public void setQueryTimeout(int seconds) throws SQLException {
Constants.SQLExceptionMessages.ILLEGAL_VALUE_FOR + "query timeout");
}
this.queryTimeoutInMillis =
(0 == seconds) ? vitessConnection.getQueryTimeoutMillis() : (long) seconds * 1000;
(0 == seconds) ? vitessConnection.getQueryTimeout() : (long) seconds * 1000;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static void updateVtGateConnHashMap(String identifier, VitessJDBCUrl.Hos
private static VTGateConn getVtGateConn(VitessJDBCUrl.HostInfo hostInfo, VitessConnection connection) {
final String username = connection.getUsername();
final String keyspace = connection.getKeyspace();
final Context context = CommonUtils.createContext(username,connection.getConnectionTimeoutMillis());
final Context context = CommonUtils.createContext(username,connection.getConnectionTimeout());
RetryingInterceptorConfig retryingConfig = getRetryingInterceptorConfig(connection);
RpcClient client;
if (connection.getUseSSL()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,23 +530,23 @@ private void testExecute(int fetchSize, boolean simpleExecute, boolean shouldRun

@Test public void testGetQueryTimeout() throws SQLException {
VitessConnection mockConn = PowerMockito.mock(VitessConnection.class);
Mockito.when(mockConn.getQueryTimeoutMillis()).thenReturn((long)Constants.DEFAULT_TIMEOUT);
Mockito.when(mockConn.getQueryTimeout()).thenReturn((long)Constants.DEFAULT_TIMEOUT);

VitessStatement statement = new VitessStatement(mockConn);
Assert.assertEquals(30, statement.getQueryTimeout());
}

@Test public void testGetQueryTimeoutZeroDefault() throws SQLException {
VitessConnection mockConn = PowerMockito.mock(VitessConnection.class);
Mockito.when(mockConn.getQueryTimeoutMillis()).thenReturn(0L);
Mockito.when(mockConn.getQueryTimeout()).thenReturn(0L);

VitessStatement statement = new VitessStatement(mockConn);
Assert.assertEquals(0, statement.getQueryTimeout());
}

@Test public void testSetQueryTimeout() throws SQLException {
VitessConnection mockConn = PowerMockito.mock(VitessConnection.class);
Mockito.when(mockConn.getQueryTimeoutMillis()).thenReturn((long)Constants.DEFAULT_TIMEOUT);
Mockito.when(mockConn.getQueryTimeout()).thenReturn((long)Constants.DEFAULT_TIMEOUT);

VitessStatement statement = new VitessStatement(mockConn);

Expand Down

0 comments on commit a14aa65

Please sign in to comment.