Commit 5a79f2a4 authored by amir.yosef's avatar amir.yosef

Updating where sending to replica invoked

parent aa94992a
......@@ -4,7 +4,7 @@ import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class CommandInvoker {
public final class CommandInvoker {
private static final Logger logger = Logger.getLogger(CommandInvoker.class.getName());
public static byte[] invoke(CommandExecutable<byte[]> command) throws IOException {
......
......@@ -29,7 +29,7 @@ public final class ClientCommandHandler {
this.os = outputStream;
this.commandParser = new CommandParser();
this.sendToReplica = SendToReplica.getInstance();
sendToReplica.start();
}
public void execute() {
......
......@@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
public class SendToReplica implements Closeable {
public final class SendToReplica implements Closeable {
private static final Logger logger = Logger.getLogger(SendToReplica.class.getName());
private final Queue<ConnectedReplica> connectedReplicas;
private final Queue<String> commands;
......@@ -24,7 +24,7 @@ public class SendToReplica implements Closeable {
private SendToReplica() {
this.connectedReplicas = new ConcurrentLinkedQueue<>();
this.commands = new ConcurrentLinkedQueue<>();
this.executorService = Executors.newVirtualThreadPerTaskExecutor();
this.executorService = Executors.newSingleThreadExecutor();
this.countCommands = new AtomicInteger(0);
}
......
......@@ -27,6 +27,8 @@ public final class Server implements AutoCloseable {
this.executor = Executors.newVirtualThreadPerTaskExecutor();
this.manager = new StorageManager();
this.replicaConnectionService = replicaConnectionService;
SendToReplica sendToReplica = SendToReplica.getInstance();
sendToReplica.start();
}
public void start() {
......
......@@ -7,7 +7,7 @@ import java.io.IOException;
import java.util.Map;
import java.util.logging.Logger;
public class ServerBuilder {
public final class ServerBuilder {
private static final Logger logger = Logger.getLogger(ServerBuilder.class.getName());
private int port = 6379;
private String role = "master";
......
......@@ -4,7 +4,7 @@ package server;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ServerInfo {
public final class ServerInfo {
private static ServerInfo serverInfo;
private final Map<String, String> info = new ConcurrentHashMap<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment