Rename "update task" --> "sync task"
This commit is contained in:
parent
3a123f9fa1
commit
8d79ec6b07
@ -113,7 +113,7 @@ public class LuckPermsApiProvider implements LuckPermsApi {
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompletableFuture<Void> runUpdateTask() {
|
||||
return this.plugin.getUpdateTaskBuffer().request();
|
||||
return this.plugin.getSyncTaskBuffer().request();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -87,7 +87,7 @@ public class Importer implements Runnable {
|
||||
this.notify.forEach(s -> Message.IMPORT_START.send(s));
|
||||
|
||||
// start an update task in the background - we'll #join this later
|
||||
CompletableFuture<Void> updateTask = CompletableFuture.runAsync(() -> this.commandManager.getPlugin().getUpdateTaskBuffer().requestDirectly());
|
||||
CompletableFuture<Void> updateTask = CompletableFuture.runAsync(() -> this.commandManager.getPlugin().getSyncTaskBuffer().requestDirectly());
|
||||
|
||||
this.notify.forEach(s -> Message.IMPORT_INFO.send(s, "Processing commands..."));
|
||||
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* This file is part of LuckPerms, licensed under the MIT License.
|
||||
*
|
||||
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.buffers;
|
||||
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.tasks.UpdateTask;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class UpdateTaskBuffer extends BufferedRequest<Void> {
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
public UpdateTaskBuffer(LuckPermsPlugin plugin) {
|
||||
super(500L, TimeUnit.MILLISECONDS, plugin.getBootstrap().getScheduler());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void perform() {
|
||||
new UpdateTask(this.plugin, false).run();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ public class DeleteGroup extends SingleCommand {
|
||||
.action("delete")
|
||||
.build().submit(plugin, sender);
|
||||
|
||||
plugin.getUpdateTaskBuffer().request();
|
||||
plugin.getSyncTaskBuffer().request();
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class BulkUpdateCommand extends SingleCommand {
|
||||
Message.BULK_UPDATE_STARTING.send(sender);
|
||||
plugin.getStorage().applyBulkUpdate(operation).whenCompleteAsync((v, ex) -> {
|
||||
if (ex == null) {
|
||||
plugin.getUpdateTaskBuffer().requestDirectly();
|
||||
plugin.getSyncTaskBuffer().requestDirectly();
|
||||
Message.BULK_UPDATE_SUCCESS.send(sender);
|
||||
} else {
|
||||
ex.printStackTrace();
|
||||
|
@ -47,7 +47,7 @@ public class NetworkSyncCommand extends SingleCommand {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
Message.UPDATE_TASK_REQUEST.send(sender);
|
||||
plugin.getUpdateTaskBuffer().request().join();
|
||||
plugin.getSyncTaskBuffer().request().join();
|
||||
Message.UPDATE_TASK_COMPLETE_NETWORK.send(sender);
|
||||
|
||||
Optional<InternalMessagingService> messagingService = plugin.getMessagingService();
|
||||
|
@ -45,7 +45,7 @@ public class SyncCommand extends SingleCommand {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
Message.UPDATE_TASK_REQUEST.send(sender);
|
||||
plugin.getUpdateTaskBuffer().request().join();
|
||||
plugin.getSyncTaskBuffer().request().join();
|
||||
Message.UPDATE_TASK_COMPLETE.send(sender);
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ public class LuckPermsMessagingService implements InternalMessagingService, Inco
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.getUpdateTaskBuffer().request();
|
||||
this.plugin.getSyncTaskBuffer().request();
|
||||
} else if (message instanceof UserUpdateMessage) {
|
||||
UserUpdateMessage msg = (UserUpdateMessage) message;
|
||||
|
||||
|
@ -29,8 +29,6 @@ import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||
import me.lucko.luckperms.common.api.ApiRegistrationUtil;
|
||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||
import me.lucko.luckperms.common.buffers.UpdateTaskBuffer;
|
||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
import me.lucko.luckperms.common.config.AbstractConfiguration;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
@ -52,7 +50,7 @@ import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.storage.StorageFactory;
|
||||
import me.lucko.luckperms.common.storage.StorageType;
|
||||
import me.lucko.luckperms.common.storage.dao.file.FileWatcher;
|
||||
import me.lucko.luckperms.common.tasks.UpdateTask;
|
||||
import me.lucko.luckperms.common.tasks.SyncTask;
|
||||
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||
|
||||
@ -75,7 +73,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
private FileWatcher fileWatcher = null;
|
||||
private Storage storage;
|
||||
private InternalMessagingService messagingService = null;
|
||||
private BufferedRequest<Void> updateTaskBuffer;
|
||||
private SyncTask.Buffer syncTaskBuffer;
|
||||
private InheritanceHandler inheritanceHandler;
|
||||
private CalculatorFactory calculatorFactory;
|
||||
private LuckPermsApiProvider apiProvider;
|
||||
@ -133,7 +131,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
this.messagingService = provideMessagingFactory().getInstance();
|
||||
|
||||
// setup the update task buffer
|
||||
this.updateTaskBuffer = new UpdateTaskBuffer(this);
|
||||
this.syncTaskBuffer = new SyncTask.Buffer(this);
|
||||
|
||||
// register commands
|
||||
registerCommands();
|
||||
@ -164,13 +162,13 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
// schedule update tasks
|
||||
int mins = getConfiguration().get(ConfigKeys.SYNC_TIME);
|
||||
if (mins > 0) {
|
||||
getBootstrap().getScheduler().asyncRepeating(() -> this.updateTaskBuffer.request(), mins, TimeUnit.MINUTES);
|
||||
getBootstrap().getScheduler().asyncRepeating(() -> this.syncTaskBuffer.request(), mins, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
// run an update instantly.
|
||||
getLogger().info("Performing initial data load...");
|
||||
try {
|
||||
new UpdateTask(this, true).run();
|
||||
new SyncTask(this, true).run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -292,8 +290,8 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedRequest<Void> getUpdateTaskBuffer() {
|
||||
return this.updateTaskBuffer;
|
||||
public SyncTask.Buffer getSyncTaskBuffer() {
|
||||
return this.syncTaskBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,6 @@ package me.lucko.luckperms.common.plugin;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.common.actionlog.LogDispatcher;
|
||||
import me.lucko.luckperms.common.api.LuckPermsApiProvider;
|
||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
import me.lucko.luckperms.common.command.CommandManager;
|
||||
import me.lucko.luckperms.common.command.abstraction.Command;
|
||||
@ -51,6 +50,7 @@ import me.lucko.luckperms.common.plugin.util.AbstractConnectionListener;
|
||||
import me.lucko.luckperms.common.sender.Sender;
|
||||
import me.lucko.luckperms.common.storage.Storage;
|
||||
import me.lucko.luckperms.common.storage.dao.file.FileWatcher;
|
||||
import me.lucko.luckperms.common.tasks.SyncTask;
|
||||
import me.lucko.luckperms.common.treeview.PermissionRegistry;
|
||||
import me.lucko.luckperms.common.verbose.VerboseHandler;
|
||||
|
||||
@ -249,16 +249,16 @@ public interface LuckPermsPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the update task buffer of the platform, used for scheduling and running update tasks.
|
||||
* Gets the sync task buffer of the platform, used for scheduling and running sync tasks.
|
||||
*
|
||||
* @return the update task buffer instance
|
||||
* @return the sync task buffer instance
|
||||
*/
|
||||
BufferedRequest<Void> getUpdateTaskBuffer();
|
||||
SyncTask.Buffer getSyncTaskBuffer();
|
||||
|
||||
/**
|
||||
* Called at the end of the sync task.
|
||||
*/
|
||||
default void onPostUpdate() {
|
||||
default void performPlatformDataSync() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -201,11 +201,11 @@ public class CombinedConfigurateDao extends AbstractConfigurateDao {
|
||||
if (path.getFileName().equals(this.usersFile.getFileName())) {
|
||||
this.plugin.getLogger().info("[FileWatcher] Detected change in users file - reloading...");
|
||||
this.usersLoader.reload();
|
||||
this.plugin.getUpdateTaskBuffer().request();
|
||||
this.plugin.getSyncTaskBuffer().request();
|
||||
} else if (path.getFileName().equals(this.groupsFile.getFileName())) {
|
||||
this.plugin.getLogger().info("[FileWatcher] Detected change in groups file - reloading...");
|
||||
this.groupsLoader.reload();
|
||||
this.plugin.getUpdateTaskBuffer().request();
|
||||
this.plugin.getSyncTaskBuffer().request();
|
||||
} else if (path.getFileName().equals(this.tracksFile.getFileName())) {
|
||||
this.plugin.getLogger().info("[FileWatcher] Detected change in tracks file - reloading...");
|
||||
this.tracksLoader.reload();
|
||||
|
@ -187,7 +187,7 @@ public class SeparatedConfigurateDao extends AbstractConfigurateDao {
|
||||
|
||||
String groupName = s.substring(0, s.length() - this.fileExtension.length());
|
||||
this.plugin.getLogger().info("[FileWatcher] Detected change in group file for " + groupName + " - reloading...");
|
||||
this.plugin.getUpdateTaskBuffer().request();
|
||||
this.plugin.getSyncTaskBuffer().request();
|
||||
});
|
||||
|
||||
this.trackWatcher = watcher.getWatcher(this.tracksDirectory);
|
||||
|
@ -26,17 +26,19 @@
|
||||
package me.lucko.luckperms.common.tasks;
|
||||
|
||||
import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.buffers.BufferedRequest;
|
||||
import me.lucko.luckperms.common.node.factory.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* System wide update task for LuckPerms.
|
||||
* System wide sync task for LuckPerms.
|
||||
*
|
||||
* <p>Ensures that all local data is consistent with the storage.</p>
|
||||
*/
|
||||
public class UpdateTask implements Runnable {
|
||||
public class SyncTask implements Runnable {
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
/**
|
||||
@ -44,7 +46,7 @@ public class UpdateTask implements Runnable {
|
||||
*/
|
||||
private final boolean initialUpdate;
|
||||
|
||||
public UpdateTask(LuckPermsPlugin plugin, boolean initialUpdate) {
|
||||
public SyncTask(LuckPermsPlugin plugin, boolean initialUpdate) {
|
||||
this.plugin = plugin;
|
||||
this.initialUpdate = initialUpdate;
|
||||
}
|
||||
@ -76,8 +78,23 @@ public class UpdateTask implements Runnable {
|
||||
userUpdateFut.join();
|
||||
}
|
||||
|
||||
this.plugin.onPostUpdate();
|
||||
this.plugin.performPlatformDataSync();
|
||||
|
||||
this.plugin.getEventFactory().handlePostSync();
|
||||
}
|
||||
|
||||
public static class Buffer extends BufferedRequest<Void> {
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
public Buffer(LuckPermsPlugin plugin) {
|
||||
super(500L, TimeUnit.MILLISECONDS, plugin.getBootstrap().getScheduler());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void perform() {
|
||||
new SyncTask(this.plugin, false).run();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -212,7 +212,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostUpdate() {
|
||||
public void performPlatformDataSync() {
|
||||
for (LPSubjectCollection collection : this.service.getLoadedCollections().values()) {
|
||||
if (collection instanceof PersistedCollection) {
|
||||
((PersistedCollection) collection).loadAll();
|
||||
|
Loading…
Reference in New Issue
Block a user