Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@
} finally {
txn.close();
}
if (upgrade.refreshPoolConnectionsAfterUpgrade()) {
TransactionLegacy.refreshConnections(TransactionLegacy.CLOUD_DB);

Check warning on line 383 in engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java#L383

Added line #L383 was not covered by tests
}
return version;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@
void performDataMigration(Connection conn);

InputStream[] getCleanupScripts();

default boolean refreshPoolConnectionsAfterUpgrade() { return false; }

Check warning on line 42 in engine/schema/src/main/java/com/cloud/upgrade/dao/DbUpgrade.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/upgrade/dao/DbUpgrade.java#L42

Added line #L42 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
// under the License.
package com.cloud.upgrade.dao;

import com.cloud.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
Expand All @@ -28,6 +24,10 @@

import org.apache.cloudstack.framework.config.ConfigKey;

import com.cloud.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;

public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
private SystemVmTemplateRegistration systemVmTemplateRegistration;

Expand Down Expand Up @@ -118,4 +118,9 @@
throw new CloudRuntimeException(String.format("Failed to migrate existing configuration scope values to bitmask due to: %s", e.getMessage()));
}
}

@Override
public boolean refreshPoolConnectionsAfterUpgrade() {
return true;
}

Check warning on line 125 in engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42010to42100.java#L123-L125

Added lines #L123 - L125 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ private void runTestGetConfigStringValueExpiry(long wait, int configDBRetrieval)
String result = configDepotImpl.getConfigStringValue(key, ConfigKey.Scope.Global, null);
Assert.assertEquals(value, result);
Mockito.verify(_configDao, Mockito.times(configDBRetrieval)).findById(key);

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@
return _conn;
}

public static void refreshConnections(final short dbId) {

Check warning on line 608 in framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java

View check run for this annotation

Codecov / codecov/patch

framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java#L608

Added line #L608 was not covered by tests
if (dbId != CLOUD_DB) {
return;

Check warning on line 610 in framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java

View check run for this annotation

Codecov / codecov/patch

framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java#L610

Added line #L610 was not covered by tests
}
if (s_ds instanceof HikariDataSource) {
((HikariDataSource)s_ds).getHikariPoolMXBean().softEvictConnections();

Check warning on line 613 in framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java

View check run for this annotation

Codecov / codecov/patch

framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java#L613

Added line #L613 was not covered by tests
}
}

Check warning on line 615 in framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java

View check run for this annotation

Codecov / codecov/patch

framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java#L615

Added line #L615 was not covered by tests

protected boolean takeOver(final String name, final boolean create) {
if (_stack.size() != 0) {
if (!create) {
Expand Down
Loading