Skip to content

Commit

Permalink
Improved storage performance by optimising fucntions for tasks
Browse files Browse the repository at this point in the history
+ Improved storage performance by optimising fucntions and the way data is stored for specific tasks
+ Reduced probability for data-loss
+ Fixed date messages being doubled in time.
  • Loading branch information
noahbclarkson committed Dec 22, 2020
1 parent 8839718 commit 43818ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
23 changes: 13 additions & 10 deletions Auto-Tune/src/unprotesting/com/github/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,32 +432,35 @@ public static FileConfiguration saveGUIShopFiles(){
public static void setupDataFiles() {
if (Config.isChecksumHeaderBypass()) {
Main.debugLog("Enabling checksum-header-bypass");
db = DBMaker.fileDB("data.db").checksumHeaderBypass().closeOnJvmShutdown().make();
db = DBMaker.fileDB("data.db").checksumHeaderBypass().fileChannelEnable().allocateStartSize(10240).transactionEnable().closeOnJvmShutdown().make();
map = (ConcurrentMap<String, ConcurrentHashMap<Integer, Double[]>>) db.hashMap("map").createOrOpen();
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
memDB = DBMaker.memoryDB().checksumHeaderBypass().closeOnJvmShutdown().make();
memDB = DBMaker.heapDB().checksumHeaderBypass().transactionEnable().closeOnJvmShutdown().make();
memMap = memDB.hashMap("memMap", Serializer.INTEGER, Serializer.STRING).createOrOpen();
enchDB = DBMaker.fileDB("enchantment-data.db").checksumHeaderBypass().closeOnJvmShutdown().make();
enchDB = DBMaker.fileDB("enchantment-data.db").checksumHeaderBypass().fileChannelEnable().transactionEnable().closeOnJvmShutdown().make();
enchMap = (ConcurrentMap<String, ConcurrentHashMap<String, EnchantmentSetting>>) enchDB.hashMap("enchMap", Serializer.STRING, Serializer.JAVA).createOrOpen();
} else {
db = DBMaker.fileDB("data.db").checksumHeaderBypass().closeOnJvmShutdown().make();
db = DBMaker.fileDB("data.db").checksumHeaderBypass().fileChannelEnable().allocateStartSize(10240).transactionEnable().closeOnJvmShutdown().make();
map = (ConcurrentMap<String, ConcurrentHashMap<Integer, Double[]>>) db.hashMap("map").createOrOpen();
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
memDB = DBMaker.memoryDB().closeOnJvmShutdown().make();
memDB = DBMaker.heapDB().closeOnJvmShutdown().transactionEnable().make();
memMap = memDB.hashMap("memMap", Serializer.INTEGER, Serializer.STRING).createOrOpen();
enchDB = DBMaker.fileDB("enchantment-data.db").closeOnJvmShutdown().make();
enchDB = DBMaker.fileDB("enchantment-data.db").closeOnJvmShutdown().fileChannelEnable().transactionEnable().make();
enchMap = (ConcurrentMap<String, ConcurrentHashMap<String, EnchantmentSetting>>) enchDB.hashMap("enchMap", Serializer.STRING, Serializer.JAVA).createOrOpen();
}
tempDB = DBMaker.fileDB("plugins/Auto-Tune/temp/tempdata.db").checksumHeaderBypass().closeOnJvmShutdown().make();
playerDataConfig = YamlConfiguration.loadConfiguration(playerdata);
tempDB = DBMaker.fileDB("plugins/Auto-Tune/temp/tempdata.db").checksumHeaderBypass().fileMmapEnableIfSupported().fileMmapPreclearDisable().cleanerHackEnable().closeOnJvmShutdown().transactionEnable().make();
tempdatadata = tempDB.hashMap("tempdatadata", Serializer.STRING, Serializer.DOUBLE).createOrOpen();
loanDB = DBMaker.fileDB("plugins/Auto-Tune/temp/loandata.db").checksumHeaderBypass().closeOnJvmShutdown().make();
loanDB = DBMaker.fileDB("plugins/Auto-Tune/temp/loandata.db").checksumHeaderBypass().fileMmapEnableIfSupported().fileMmapPreclearDisable().cleanerHackEnable().transactionEnable().closeOnJvmShutdown().make();
loanMap = loanDB.hashMap("loanMap", Serializer.JAVA, Serializer.JAVA).createOrOpen();
if (tempdatadata.get("GDP")==null){
tempdatadata.put("GDP", 0.0);
}
}

public static void closeDataFiles(){
db.commit();
enchDB.commit();
tempDB.commit();
loanDB.commit();
db.close();
memDB.close();
enchDB.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public static boolean ghostCheckAPIKey() throws ClientProtocolException, IOExcep
}
else{
Main.debugLog("Api-Key has been changed in config");
Main.log("Sending API key to database..");
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("https://safe-refuge-09383.herokuapp.com");
httpPost.setHeader("content-type", "application/json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void loadItemPricesAndCalculate() throws ParseException, ClientPro
obj.put("minVolatility", Config.getBasicMinVariableVolatility());
HttpPostRequestor.updatePricesforItems(obj);
Date date = Calendar.getInstance().getTime();
Date newDate = MathHandler.addMinutesToJavaUtilDate(date, Config.getTimePeriod()*2);
Date newDate = MathHandler.addMinutesToJavaUtilDate(date, Config.getTimePeriod());
String strDate = Main.dateFormat.format(newDate);
Main.log("Done running item price Algorithim, a new check will occur at: " + strDate);
try {
Expand Down

0 comments on commit 43818ce

Please sign in to comment.