forked from Qortal-Forker/qortal
		
	the bootstrapper was resetting the database configuration that the db cache was dependent on, so that dependency was changed
This commit is contained in:
		@@ -1092,25 +1092,4 @@ public class AdminResource {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		return info;
 | 
							return info;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	@GET
 | 
					 | 
				
			||||||
	@Path("/dbstates")
 | 
					 | 
				
			||||||
	@Operation(
 | 
					 | 
				
			||||||
			summary = "Get DB States",
 | 
					 | 
				
			||||||
			description = "Get DB States",
 | 
					 | 
				
			||||||
			responses = {
 | 
					 | 
				
			||||||
					@ApiResponse(
 | 
					 | 
				
			||||||
							content = @Content(mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = DbConnectionInfo.class)))
 | 
					 | 
				
			||||||
					)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
	)
 | 
					 | 
				
			||||||
	public List<DbConnectionInfo> getDbConnectionsStates() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		try {
 | 
					 | 
				
			||||||
			return Controller.REPOSITORY_FACTORY.getDbConnectionsStates();
 | 
					 | 
				
			||||||
		} catch (Exception e) {
 | 
					 | 
				
			||||||
			LOGGER.error(e.getMessage(), e);
 | 
					 | 
				
			||||||
			return new ArrayList<>(0);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -73,8 +73,6 @@ import java.util.stream.Collectors;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public class Controller extends Thread {
 | 
					public class Controller extends Thread {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static HSQLDBRepositoryFactory REPOSITORY_FACTORY;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	static {
 | 
						static {
 | 
				
			||||||
		// This must go before any calls to LogManager/Logger
 | 
							// This must go before any calls to LogManager/Logger
 | 
				
			||||||
		System.setProperty("log4j2.formatMsgNoLookups", "true");
 | 
							System.setProperty("log4j2.formatMsgNoLookups", "true");
 | 
				
			||||||
@@ -405,8 +403,8 @@ public class Controller extends Thread {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		LOGGER.info("Starting repository");
 | 
							LOGGER.info("Starting repository");
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			REPOSITORY_FACTORY = new HSQLDBRepositoryFactory(getRepositoryUrl());
 | 
								HSQLDBRepositoryFactory repositoryFactory = new HSQLDBRepositoryFactory(getRepositoryUrl());
 | 
				
			||||||
			RepositoryManager.setRepositoryFactory(REPOSITORY_FACTORY);
 | 
								RepositoryManager.setRepositoryFactory(repositoryFactory);
 | 
				
			||||||
			RepositoryManager.setRequestedCheckpoint(Boolean.TRUE);
 | 
								RepositoryManager.setRequestedCheckpoint(Boolean.TRUE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			try (final Repository repository = RepositoryManager.getRepository()) {
 | 
								try (final Repository repository = RepositoryManager.getRepository()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
package org.qortal.repository;
 | 
					package org.qortal.repository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.sql.Connection;
 | 
				
			||||||
import java.util.concurrent.TimeoutException;
 | 
					import java.util.concurrent.TimeoutException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public interface Repository extends AutoCloseable {
 | 
					public interface Repository extends AutoCloseable {
 | 
				
			||||||
@@ -62,4 +63,5 @@ public interface Repository extends AutoCloseable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public static void attemptRecovery(String connectionUrl, String name) throws DataException {}
 | 
						public static void attemptRecovery(String connectionUrl, String name) throws DataException {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Connection getConnection();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -468,7 +468,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                Thread.currentThread().setName(DB_CACHE_TIMER_TASK);
 | 
					                Thread.currentThread().setName(DB_CACHE_TIMER_TASK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                try (final HSQLDBRepository respository = (HSQLDBRepository) Controller.REPOSITORY_FACTORY.getRepository()) {
 | 
					                try (final Repository respository = RepositoryManager.getRepository()) {
 | 
				
			||||||
                    fillCache(ArbitraryResourceCache.getInstance(), respository);
 | 
					                    fillCache(ArbitraryResourceCache.getInstance(), respository);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch( DataException e ) {
 | 
					                catch( DataException e ) {
 | 
				
			||||||
@@ -611,7 +611,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
    private static int recordCurrentBalances(ConcurrentHashMap<Integer, List<AccountBalanceData>> balancesByHeight) {
 | 
					    private static int recordCurrentBalances(ConcurrentHashMap<Integer, List<AccountBalanceData>> balancesByHeight) {
 | 
				
			||||||
        int currentHeight;
 | 
					        int currentHeight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try (final HSQLDBRepository repository = (HSQLDBRepository) Controller.REPOSITORY_FACTORY.getRepository()) {
 | 
					        try (final Repository repository = RepositoryManager.getRepository()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // get current balances
 | 
					            // get current balances
 | 
				
			||||||
            List<AccountBalanceData> accountBalances = getAccountBalances(repository);
 | 
					            List<AccountBalanceData> accountBalances = getAccountBalances(repository);
 | 
				
			||||||
@@ -675,7 +675,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
     * @param cache the cache to fill
 | 
					     * @param cache the cache to fill
 | 
				
			||||||
     * @param repository the data source to fill the cache with
 | 
					     * @param repository the data source to fill the cache with
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void fillCache(ArbitraryResourceCache cache, HSQLDBRepository repository) {
 | 
					    public static void fillCache(ArbitraryResourceCache cache, Repository repository) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            // ensure all data is committed in, before we query it
 | 
					            // ensure all data is committed in, before we query it
 | 
				
			||||||
@@ -713,7 +713,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private static void fillNamepMap(ConcurrentHashMap<String, Integer> levelByName, HSQLDBRepository repository ) throws SQLException {
 | 
					    private static void fillNamepMap(ConcurrentHashMap<String, Integer> levelByName, Repository repository ) throws SQLException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        StringBuilder sql = new StringBuilder(512);
 | 
					        StringBuilder sql = new StringBuilder(512);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -721,7 +721,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
        sql.append("FROM NAMES ");
 | 
					        sql.append("FROM NAMES ");
 | 
				
			||||||
        sql.append("INNER JOIN ACCOUNTS on owner = account ");
 | 
					        sql.append("INNER JOIN ACCOUNTS on owner = account ");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Statement statement = repository.connection.createStatement();
 | 
					        Statement statement = repository.getConnection().createStatement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ResultSet resultSet = statement.executeQuery(sql.toString());
 | 
					        ResultSet resultSet = statement.executeQuery(sql.toString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -744,7 +744,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
     * @return the resources
 | 
					     * @return the resources
 | 
				
			||||||
     * @throws SQLException
 | 
					     * @throws SQLException
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private static List<ArbitraryResourceData> getResources( HSQLDBRepository repository) throws SQLException {
 | 
					    private static List<ArbitraryResourceData> getResources( Repository repository) throws SQLException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<ArbitraryResourceData> resources = new ArrayList<>();
 | 
					        List<ArbitraryResourceData> resources = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -756,7 +756,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
        sql.append("LEFT JOIN ArbitraryMetadataCache USING (service, name, identifier) WHERE name IS NOT NULL");
 | 
					        sql.append("LEFT JOIN ArbitraryMetadataCache USING (service, name, identifier) WHERE name IS NOT NULL");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<ArbitraryResourceData> arbitraryResources = new ArrayList<>();
 | 
					        List<ArbitraryResourceData> arbitraryResources = new ArrayList<>();
 | 
				
			||||||
        Statement statement = repository.connection.createStatement();
 | 
					        Statement statement = repository.getConnection().createStatement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ResultSet resultSet = statement.executeQuery(sql.toString());
 | 
					        ResultSet resultSet = statement.executeQuery(sql.toString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -822,7 +822,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
        return resources;
 | 
					        return resources;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static List<AccountBalanceData> getAccountBalances(HSQLDBRepository repository) {
 | 
					    public static List<AccountBalanceData> getAccountBalances(Repository repository) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        StringBuilder sql = new StringBuilder();
 | 
					        StringBuilder sql = new StringBuilder();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -836,7 +836,7 @@ public class HSQLDBCacheUtils {
 | 
				
			|||||||
        LOGGER.info( "Getting account balances ...");
 | 
					        LOGGER.info( "Getting account balances ...");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            Statement statement = repository.connection.createStatement();
 | 
					            Statement statement = repository.getConnection().createStatement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            ResultSet resultSet = statement.executeQuery(sql.toString());
 | 
					            ResultSet resultSet = statement.executeQuery(sql.toString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -174,6 +174,11 @@ public class HSQLDBRepository implements Repository {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Transaction COMMIT / ROLLBACK / savepoints
 | 
						// Transaction COMMIT / ROLLBACK / savepoints
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public Connection getConnection() {
 | 
				
			||||||
 | 
							return this.connection;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void saveChanges() throws DataException {
 | 
						public void saveChanges() throws DataException {
 | 
				
			||||||
		long beforeQuery = this.slowQueryThreshold == null ? 0 : System.currentTimeMillis();
 | 
							long beforeQuery = this.slowQueryThreshold == null ? 0 : System.currentTimeMillis();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user