Skip to content

Commit

Permalink
fix: if the quorum settings are not valid, set it to MAJORITY and log…
Browse files Browse the repository at this point in the history
… a SEVERE error
  • Loading branch information
lvca committed Nov 21, 2024
1 parent 0a26baf commit 421e4f5
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.arcadedb.database.DatabaseInternal;
import com.arcadedb.database.DocumentCallback;
import com.arcadedb.database.DocumentIndexer;
import com.arcadedb.database.LocalDatabase;
import com.arcadedb.database.EmbeddedModifier;
import com.arcadedb.database.LocalDatabase;
import com.arcadedb.database.MutableDocument;
import com.arcadedb.database.MutableEmbeddedDocument;
import com.arcadedb.database.RID;
Expand All @@ -54,6 +54,7 @@
import com.arcadedb.graph.MutableVertex;
import com.arcadedb.graph.Vertex;
import com.arcadedb.index.IndexCursor;
import com.arcadedb.log.LogManager;
import com.arcadedb.network.binary.ServerIsNotTheLeaderException;
import com.arcadedb.query.QueryEngine;
import com.arcadedb.query.select.Select;
Expand All @@ -77,6 +78,7 @@
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.logging.*;

public class ReplicatedDatabase implements DatabaseInternal {
private final ArcadeDBServer server;
Expand All @@ -90,10 +92,21 @@ public ReplicatedDatabase(final ArcadeDBServer server, final LocalDatabase proxi

this.server = server;
this.proxied = proxied;
this.quorum = HAServer.QUORUM.valueOf(
proxied.getConfiguration().getValueAsString(GlobalConfiguration.HA_QUORUM).toUpperCase(Locale.ENGLISH));
this.timeout = proxied.getConfiguration().getValueAsLong(GlobalConfiguration.HA_QUORUM_TIMEOUT);
this.proxied.setWrappedDatabaseInstance(this);

HAServer.QUORUM quorum;
final String quorumValue = proxied.getConfiguration().getValueAsString(GlobalConfiguration.HA_QUORUM)
.toUpperCase(Locale.ENGLISH);
try {
quorum = HAServer.QUORUM.valueOf(quorumValue);
} catch (Exception e) {
LogManager.instance()
.log(this, Level.SEVERE, "Error on setting quorum to '%s' for database '%s'. Setting it to MAJORITY", e, quorumValue,
getName());
quorum = HAServer.QUORUM.MAJORITY;
}
this.quorum = quorum;
}

@Override
Expand Down

0 comments on commit 421e4f5

Please sign in to comment.