[ server ] [ scheduler ]- script scheduler fix bugs - 1

This commit is contained in:
zeaslity
2023-01-18 16:07:32 +08:00
parent 96e805916b
commit f6045783a2
5 changed files with 41 additions and 24 deletions

View File

@@ -21,12 +21,14 @@ import java.util.List;
public class LogToArrayListCache {
// concurrent command execute logs
public static List<ArrayList<String>> CachedCommandLog = List.of(
new ArrayList<>(256),
new ArrayList<>(256),
new ArrayList<>(256),
new ArrayList<>(256),
new ArrayList<>(256)
public static List<ArrayList<String>> CachedCommandLog = new ArrayList<>(
List.of(
new ArrayList<>(256),
new ArrayList<>(256),
new ArrayList<>(256),
new ArrayList<>(256),
new ArrayList<>(256)
)
);
public void cacheLog(String streamKey, Process process) {
@@ -69,7 +71,14 @@ public class LogToArrayListCache {
return CachedCommandLog.get(keyToIndex);
}
private int hashStreamKeyToCachedArrayListIndex(String streamKey) {
int size = CachedCommandLog.size();
return Math.abs(streamKey.hashCode() % size);
}
private int hashStreamKeyToCachedArrayListIndexWithProblem(String streamKey) {
int size = CachedCommandLog.size();
int result = Math.abs(streamKey.hashCode() % size);