forked from Qortal/qortal
Merge pull request #211 from crowetic/master
PR for combined changes from kenny+alpha+crowetic for release candidate
This commit is contained in:
commit
50d6e388f0
@ -43,4 +43,3 @@ https://qortal.dev - secondary and development focused website with links to man
|
|||||||
https://wiki.qortal.org - community built and managed wiki with detailed information regarding the project
|
https://wiki.qortal.org - community built and managed wiki with detailed information regarding the project
|
||||||
|
|
||||||
links to telegram and discord communities are at the top of https://qortal.org as well.
|
links to telegram and discord communities are at the top of https://qortal.org as well.
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class ApplyRestart {
|
|||||||
private static final String JAVA_TOOL_OPTIONS_NAME = "JAVA_TOOL_OPTIONS";
|
private static final String JAVA_TOOL_OPTIONS_NAME = "JAVA_TOOL_OPTIONS";
|
||||||
private static final String JAVA_TOOL_OPTIONS_VALUE = "";
|
private static final String JAVA_TOOL_OPTIONS_VALUE = "";
|
||||||
|
|
||||||
private static final long CHECK_INTERVAL = 10 * 1000L; // ms
|
private static final long CHECK_INTERVAL = 30 * 1000L; // ms
|
||||||
private static final int MAX_ATTEMPTS = 12;
|
private static final int MAX_ATTEMPTS = 12;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -56,7 +56,7 @@ public class ApplyRestart {
|
|||||||
else
|
else
|
||||||
Settings.getInstance();
|
Settings.getInstance();
|
||||||
|
|
||||||
LOGGER.info("Applying restart...");
|
LOGGER.info("Applying restart this can take up to 5 minutes...");
|
||||||
|
|
||||||
// Shutdown node using API
|
// Shutdown node using API
|
||||||
if (!shutdownNode())
|
if (!shutdownNode())
|
||||||
@ -64,19 +64,19 @@ public class ApplyRestart {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Give some time for shutdown
|
// Give some time for shutdown
|
||||||
TimeUnit.SECONDS.sleep(30);
|
TimeUnit.SECONDS.sleep(60);
|
||||||
|
|
||||||
// Remove blockchain lock if exist
|
// Remove blockchain lock if exist
|
||||||
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
|
ReentrantLock blockchainLock = Controller.getInstance().getBlockchainLock();
|
||||||
if (blockchainLock.isLocked())
|
if (blockchainLock.isLocked())
|
||||||
blockchainLock.unlock();
|
blockchainLock.unlock();
|
||||||
|
|
||||||
// Remove blockchain lock file if exist
|
// Remove blockchain lock file if still exist
|
||||||
TimeUnit.SECONDS.sleep(60);
|
TimeUnit.SECONDS.sleep(60);
|
||||||
deleteLock();
|
deleteLock();
|
||||||
|
|
||||||
// Restart node
|
// Restart node
|
||||||
TimeUnit.SECONDS.sleep(30);
|
TimeUnit.SECONDS.sleep(15);
|
||||||
restartNode(args);
|
restartNode(args);
|
||||||
|
|
||||||
LOGGER.info("Restarting...");
|
LOGGER.info("Restarting...");
|
||||||
@ -117,10 +117,17 @@ public class ApplyRestart {
|
|||||||
String response = ApiRequest.perform(baseUri + "admin/stop", params);
|
String response = ApiRequest.perform(baseUri + "admin/stop", params);
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
// No response - consider node shut down
|
// No response - consider node shut down
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(30);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (apiKeyNewlyGenerated) {
|
if (apiKeyNewlyGenerated) {
|
||||||
// API key was newly generated for restarting node, so we need to remove it
|
// API key was newly generated for restarting node, so we need to remove it
|
||||||
ApplyRestart.removeGeneratedApiKey();
|
ApplyRestart.removeGeneratedApiKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +178,7 @@ public class ApplyRestart {
|
|||||||
LOGGER.debug("Lockfile is: {}", lockFile);
|
LOGGER.debug("Lockfile is: {}", lockFile);
|
||||||
FileUtils.forceDelete(FileUtils.getFile(lockFile));
|
FileUtils.forceDelete(FileUtils.getFile(lockFile));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Error deleting blockchain lock file: {}", e.getMessage());
|
LOGGER.debug("Error deleting blockchain lock file: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,26 +579,28 @@ public class Controller extends Thread {
|
|||||||
// If GUI is enabled, we're no longer starting up but actually running now
|
// If GUI is enabled, we're no longer starting up but actually running now
|
||||||
Gui.getInstance().notifyRunning();
|
Gui.getInstance().notifyRunning();
|
||||||
|
|
||||||
// Check every 10 minutes if we have enough connected peers
|
if (Settings.getInstance().isAutoRestartEnabled()) {
|
||||||
Timer checkConnectedPeers = new Timer();
|
// Check every 10 minutes if we have enough connected peers
|
||||||
|
Timer checkConnectedPeers = new Timer();
|
||||||
|
|
||||||
checkConnectedPeers.schedule(new TimerTask() {
|
checkConnectedPeers.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Get the connected peers
|
// Get the connected peers
|
||||||
int myConnectedPeers = Network.getInstance().getImmutableHandshakedPeers().size();
|
int myConnectedPeers = Network.getInstance().getImmutableHandshakedPeers().size();
|
||||||
LOGGER.debug("Node have {} connected peers", myConnectedPeers);
|
LOGGER.debug("Node have {} connected peers", myConnectedPeers);
|
||||||
if (myConnectedPeers == 0) {
|
if (myConnectedPeers == 0) {
|
||||||
// Restart node if we have 0 peers
|
// Restart node if we have 0 peers
|
||||||
LOGGER.info("Node have no connected peers, restarting node");
|
LOGGER.info("Node have no connected peers, restarting node");
|
||||||
try {
|
try {
|
||||||
RestartNode.attemptToRestart();
|
RestartNode.attemptToRestart();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Unable to restart the node", e);
|
LOGGER.error("Unable to restart the node", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 10*60*1000, 10*60*1000);
|
||||||
}, 10*60*1000, 10*60*1000);
|
}
|
||||||
|
|
||||||
// Check every 10 minutes to see if the block minter is running
|
// Check every 10 minutes to see if the block minter is running
|
||||||
Timer checkBlockMinter = new Timer();
|
Timer checkBlockMinter = new Timer();
|
||||||
|
@ -12,6 +12,7 @@ import org.qortal.data.arbitrary.ArbitraryResourceStatus;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLNonTransientConnectionException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
@ -355,9 +356,7 @@ public class HSQLDBCacheUtils {
|
|||||||
*
|
*
|
||||||
* @return the data cache
|
* @return the data cache
|
||||||
*/
|
*/
|
||||||
public static ArbitraryResourceCache startCaching(int priorityRequested, int frequency, HSQLDBRepository respository) {
|
public static void startCaching(int priorityRequested, int frequency, HSQLDBRepository respository) {
|
||||||
|
|
||||||
final ArbitraryResourceCache cache = ArbitraryResourceCache.getInstance();
|
|
||||||
|
|
||||||
// ensure priority is in between 1-10
|
// ensure priority is in between 1-10
|
||||||
final int priority = Math.max(0, Math.min(10, priorityRequested));
|
final int priority = Math.max(0, Math.min(10, priorityRequested));
|
||||||
@ -388,8 +387,6 @@ public class HSQLDBCacheUtils {
|
|||||||
|
|
||||||
// delay 1 second
|
// delay 1 second
|
||||||
timer.scheduleAtFixedRate(task, 1000, frequency * 1000);
|
timer.scheduleAtFixedRate(task, 1000, frequency * 1000);
|
||||||
|
|
||||||
return cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -418,6 +415,9 @@ public class HSQLDBCacheUtils {
|
|||||||
|
|
||||||
fillNamepMap(cache.getLevelByName(), repository);
|
fillNamepMap(cache.getLevelByName(), repository);
|
||||||
}
|
}
|
||||||
|
catch (SQLNonTransientConnectionException e ) {
|
||||||
|
LOGGER.warn("Connection problems. Retry later.");
|
||||||
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
LOGGER.error(e.getMessage(), e);
|
LOGGER.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,8 @@ public class Settings {
|
|||||||
|
|
||||||
/** Whether we check, fetch and install auto-updates */
|
/** Whether we check, fetch and install auto-updates */
|
||||||
private boolean autoUpdateEnabled = true;
|
private boolean autoUpdateEnabled = true;
|
||||||
|
/** Whether we check, restart node without connected peers */
|
||||||
|
private boolean autoRestartEnabled = false;
|
||||||
/** How long between repository backups (ms), or 0 if disabled. */
|
/** How long between repository backups (ms), or 0 if disabled. */
|
||||||
private long repositoryBackupInterval = 0; // ms
|
private long repositoryBackupInterval = 0; // ms
|
||||||
/** Whether to show a notification when we backup repository. */
|
/** Whether to show a notification when we backup repository. */
|
||||||
@ -406,7 +408,7 @@ public class Settings {
|
|||||||
* The thread priority (1 is lowest, 10 is highest) of the threads used for network peer connections. This is the
|
* The thread priority (1 is lowest, 10 is highest) of the threads used for network peer connections. This is the
|
||||||
* main thread connecting to a peer in the network.
|
* main thread connecting to a peer in the network.
|
||||||
*/
|
*/
|
||||||
private int networkThreadPriority = 5;
|
private int networkThreadPriority = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Handshake Thread Priority
|
* The Handshake Thread Priority
|
||||||
@ -414,14 +416,14 @@ public class Settings {
|
|||||||
* The thread priority (1 i slowest, 10 is highest) of the threads used for peer handshake messaging. This is a
|
* The thread priority (1 i slowest, 10 is highest) of the threads used for peer handshake messaging. This is a
|
||||||
* secondary thread to exchange status messaging to a peer in the network.
|
* secondary thread to exchange status messaging to a peer in the network.
|
||||||
*/
|
*/
|
||||||
private int handshakeThreadPriority = 5;
|
private int handshakeThreadPriority = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pruning Thread Priority
|
* Pruning Thread Priority
|
||||||
*
|
*
|
||||||
* The thread priority (1 is lowest, 10 is highest) of the threads used for database pruning and trimming.
|
* The thread priority (1 is lowest, 10 is highest) of the threads used for database pruning and trimming.
|
||||||
*/
|
*/
|
||||||
private int pruningThreadPriority = 1;
|
private int pruningThreadPriority = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sychronizer Thread Priority
|
* Sychronizer Thread Priority
|
||||||
@ -973,6 +975,10 @@ public class Settings {
|
|||||||
return this.autoUpdateEnabled;
|
return this.autoUpdateEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAutoRestartEnabled() {
|
||||||
|
return this.autoRestartEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getAutoUpdateRepos() {
|
public String[] getAutoUpdateRepos() {
|
||||||
return this.autoUpdateRepos;
|
return this.autoUpdateRepos;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user