Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make saving single threaded again #168

Open
wants to merge 4 commits into
base: 2.6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 33 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@
<build/> <!-- default value for jenkins build number -->

<!-- Changeable variables -->
<outputDir>target/output-files
</outputDir> <!-- Set to relative directory output of PreShade and JavaDoc files -->

<outputDir>target</outputDir>
</properties>

<profiles>
Expand Down Expand Up @@ -146,6 +144,8 @@
<defaultGoal>${doClean} install</defaultGoal>
<finalName>${project.name}-${project.version}${branch}${commit}${fileTimeStamp}${build}</finalName>

<directory>${outputDir}/PreShade/</directory>

<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
Expand All @@ -168,7 +168,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.12.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -181,15 +181,14 @@
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<outputDirectory>${outputDir}/shade</outputDirectory>
<outputFile>target/server/plugins/${build.finalName}.jar
</outputFile>
<outputFile>${outputDir}/server/plugins/${project.build.finalName}.jar</outputFile>
<artifactSet>
<includes>
<include>org.bstats:*</include>
<include>de.themoep:*</include>
<include>com.bergerkiller.bukkit:*</include>
<include>com.github.simplix-softworks:*</include>
<include>de.leonhart:*</include>
</includes>
</artifactSet>
<relocations>
Expand All @@ -206,28 +205,51 @@
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<fileSets>
<fileSet>
<sourceFile>${outputDir}/server/plugins/${project.build.finalName}.jar</sourceFile>
<destinationFile>${outputDir}/${project.build.finalName}.jar</destinationFile>
</fileSet>
</fileSets>
</configuration>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<name>${project.build.finalName}</name>
<failOnError>false</failOnError>
<jarOutputDirectory>${outputDir}/JavaDocs</jarOutputDirectory>
<jarOutputDirectory>${outputDir}</jarOutputDirectory>
<!--suppress UnresolvedMavenProperty -->
<skip>${skipDocs}</skip>
<sourceFileExcludes>
Expand Down Expand Up @@ -287,7 +309,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -334,7 +356,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/shanerx/tradeshop/TradeShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ private boolean loadChecks() {
getSettingManager().reload();
getMessageManager().reload();

String lockout = "§a§3§c§2§f§6";
if (Setting.MESSAGE_PREFIX.getString().startsWith(lockout)) { //TODO remove for release if old data will not be lost
getLogger().log(Level.SEVERE, "This version will most likely break existing data. To continue, please add `" + lockout + "` before the message prefix in the config and restart the server.");
return false;
}

return getVarManager().getDataStorage() != null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,12 @@ protected LinkageConfiguration getLinkageData(World w) {

public void ensureFinalSave() {
// for onDisable !!!
/* WILL BE ADDED BACK IN LATER
if (dataType == DataType.FLATFILE) {
JsonShopData.SaveThreadMaster.getInstance().saveEverythingNow();
}
// SQLITE will have an analogous branch
*/
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.shanerx.tradeshop.TradeShop;
import org.shanerx.tradeshop.data.config.Setting;
import org.shanerx.tradeshop.data.storage.ShopConfiguration;
import org.shanerx.tradeshop.shop.Shop;
import org.shanerx.tradeshop.shoplocation.ShopChunk;
Expand All @@ -45,6 +44,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import org.shanerx.tradeshop.data.config.Setting;

public class JsonShopData extends JsonConfiguration implements ShopConfiguration {

Expand Down Expand Up @@ -105,7 +105,23 @@ public int size() {

@Override
protected void saveFile() {
SaveThreadMaster.getInstance().enqueue(this);
if (super.keySet().isEmpty()) {
super.file.delete();
} else {
super.saveFile();
}

/*
//SaveThreadMaster.getInstance().enqueue(this);

File file = op.jsonConfig.getFile();
if (op.jsonConfig.keySet().isEmpty()) {
file.delete();
} else {
op.jsonConfig.saveFile();
}
*/

}

@Override
Expand All @@ -131,6 +147,7 @@ protected void loadFile() {
}
}

/*
public static class SaveOperation implements Comparable<SaveOperation> {

@Getter
Expand Down Expand Up @@ -259,4 +276,5 @@ public int hashCode() {
return master.maxThreads == 0 ? 0 : super.getTaskId();
}
}
*/
}