Run operations for closed folders as batch / low priority

This commit is contained in:
M66B 2020-01-27 08:43:50 +01:00
parent 3c995ec3d8
commit a7acf34321
2 changed files with 11 additions and 6 deletions

View File

@ -1150,8 +1150,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
});
boolean offline = (mapFolders.get(folder) == null);
for (TupleOperationEx op : submit) {
TupleOperationEx.PartitionKey key = op.getPartitionKey();
TupleOperationEx.PartitionKey key = op.getPartitionKey(offline);
if (!partitions.containsKey(key))
partitions.put(key, new ArrayList<>());
partitions.get(key).add(op);

View File

@ -43,11 +43,15 @@ public class TupleOperationEx extends EntityOperation {
return false;
}
PartitionKey getPartitionKey() {
PartitionKey getPartitionKey(boolean offline) {
PartitionKey key = new PartitionKey();
key.id = (MOVE.equals(name) || FETCH.equals(name) ? 0 : this.id);
key.priority = this.priority;
key.operation = this.name;
if (offline)
key.priority = this.priority + 10;
else {
key.id = (MOVE.equals(name) || FETCH.equals(name) ? 0 : this.id);
key.priority = this.priority;
key.operation = this.name;
}
return key;
}
@ -72,7 +76,7 @@ public class TupleOperationEx extends EntityOperation {
PartitionKey other = (PartitionKey) obj;
return (this.id == other.id &&
this.priority == other.priority &&
this.operation.equals(other.operation));
Objects.equals(this.operation, other.operation));
} else
return false;
}