Skip to content

Commit

Permalink
fix: minor semplification of database install logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Jan 24, 2024
1 parent 45d2c6b commit fdd18ad
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,32 @@
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.enterprise.server.OEnterpriseServer;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.exception.OConfigurationException;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.server.OServer;
import com.orientechnologies.orient.server.distributed.*;
import com.orientechnologies.orient.server.distributed.ODistributedConfiguration;
import com.orientechnologies.orient.server.distributed.ODistributedRequest;
import com.orientechnologies.orient.server.distributed.ODistributedResponse;
import com.orientechnologies.orient.server.distributed.ODistributedServerManager;
import com.orientechnologies.orient.server.distributed.OModifiableDistributedConfiguration;
import com.orientechnologies.orient.server.distributed.impl.task.OEnterpriseStatsTask;
import com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin;
import com.orientechnologies.orient.server.network.OServerNetworkListener;
import com.orientechnologies.orient.server.network.protocol.http.OHttpRequest;
import com.orientechnologies.orient.server.network.protocol.http.OHttpResponse;
import com.orientechnologies.orient.server.network.protocol.http.OHttpUtils;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class OServerCommandDistributedManager extends OServerCommandDistributedScope {

Expand Down Expand Up @@ -150,9 +159,8 @@ private void synchCluster(final OHttpResponse iResponse, final String[] parts)

ODatabaseDocumentInternal db = server.openDatabase(database);
try {
Object result =
db.command(new OCommandSQL(String.format("ha sync cluster %s ", cluster))).execute();
final ODocument document = new ODocument().field("result", result);
OResult result = db.command(String.format("ha sync cluster %s ", cluster)).next();
final ODocument document = new ODocument().field("result", result.toElement());
iResponse.send(
OHttpUtils.STATUS_OK_CODE, "OK", OHttpUtils.CONTENT_JSON, document.toJSON(""), null);
} finally {
Expand All @@ -174,12 +182,7 @@ private void syncDatabase(final OHttpResponse iResponse, final String[] parts)
if (dManager == null || !dManager.isEnabled())
throw new OCommandExecutionException("OrientDB is not started in distributed mode");

boolean installDatabase =
dManager.installDatabase(
true,
database,
false,
OGlobalConfiguration.DISTRIBUTED_BACKUP_TRY_INCREMENTAL_FIRST.getValueAsBoolean());
boolean installDatabase = dManager.installDatabase(true, database, false, true);

ODocument document = new ODocument().field("result", installDatabase);
iResponse.send(
Expand Down

0 comments on commit fdd18ad

Please sign in to comment.