Skip to content

Commit

Permalink
refactor: removed code not use enymore for command replication
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Nov 8, 2024
1 parent c044df7 commit 7038f14
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.replication.OAsyncReplicationError;
import com.orientechnologies.orient.core.replication.OAsyncReplicationOk;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -38,8 +35,7 @@
* @author Luca Garulli (l.garulli--(at)--orientdb.com)
*/
@SuppressWarnings("serial")
public abstract class OCommandRequestAbstract
implements OCommandRequestInternal, ODistributedCommand {
public abstract class OCommandRequestAbstract implements OCommandRequestInternal {
protected OCommandResultListener resultListener;
protected OProgressListener progressListener;
protected int limit = -1;
Expand All @@ -50,8 +46,6 @@ public abstract class OCommandRequestAbstract
protected boolean useCache = false;
protected boolean cacheableResult = false;
protected OCommandContext context;
protected OAsyncReplicationOk onAsyncReplicationOk;
protected OAsyncReplicationError onAsyncReplicationError;

private final Set<String> nodesToExclude = new HashSet<String>();
private boolean recordResultSet = true;
Expand Down Expand Up @@ -102,38 +96,6 @@ protected Map<Object, Object> convertToParameters(Object... iArgs) {
return params;
}

/** Defines a callback to call in case of the asynchronous replication succeed. */
@Override
public OCommandRequestAbstract onAsyncReplicationOk(final OAsyncReplicationOk iCallback) {
onAsyncReplicationOk = iCallback;
return this;
}

/** Defines a callback to call in case of error during the asynchronous replication. */
@Override
public OCommandRequestAbstract onAsyncReplicationError(final OAsyncReplicationError iCallback) {
if (iCallback != null) {
onAsyncReplicationError =
new OAsyncReplicationError() {
private int retry = 0;

@Override
public ACTION onAsyncReplicationError(Throwable iException, final int iRetry) {
switch (iCallback.onAsyncReplicationError(iException, ++retry)) {
case RETRY:
execute();
break;

case IGNORE:
}

return ACTION.IGNORE;
}
};
} else onAsyncReplicationError = null;
return this;
}

public OProgressListener getProgressListener() {
return progressListener;
}
Expand Down Expand Up @@ -207,11 +169,6 @@ public TIMEOUT_STRATEGY getTimeoutStrategy() {
return timeoutStrategy;
}

@Override
public Set<String> nodesToExclude() {
return Collections.unmodifiableSet(nodesToExclude);
}

public void addExcludedNode(String node) {
nodesToExclude.add(node);
}
Expand All @@ -220,14 +177,6 @@ public void removeExcludedNode(String node) {
nodesToExclude.remove(node);
}

public OAsyncReplicationOk getOnAsyncReplicationOk() {
return onAsyncReplicationOk;
}

public OAsyncReplicationError getOnAsyncReplicationError() {
return onAsyncReplicationError;
}

@Override
public void setRecordResultSet(boolean recordResultSet) {
this.recordResultSet = recordResultSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package com.orientechnologies.orient.core.command;

import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.OExecutionThreadLocal;
import com.orientechnologies.orient.core.exception.OSerializationException;
import com.orientechnologies.orient.core.index.OCompositeKey;
import com.orientechnologies.orient.core.record.impl.ODocument;
Expand Down Expand Up @@ -57,9 +56,6 @@ protected OCommandRequestTextAbstract(final String iText) {
public <RET> RET execute(final Object... iArgs) {
setParameters(iArgs);

OExecutionThreadLocal.INSTANCE.get().onAsyncReplicationOk = onAsyncReplicationOk;
OExecutionThreadLocal.INSTANCE.get().onAsyncReplicationError = onAsyncReplicationError;

return (RET) ODatabaseRecordThreadLocal.instance().get().getStorage().command(this);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@
import com.orientechnologies.common.thread.OSoftThread;
import com.orientechnologies.orient.core.OOrientListenerAbstract;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.replication.OAsyncReplicationError;
import com.orientechnologies.orient.core.replication.OAsyncReplicationOk;

/**
* Thread Local to store execution setting.
*
* @author Luca Garulli (l.garulli--(at)--orientdb.com)
*/
public class OExecutionThreadLocal extends ThreadLocal<OExecutionThreadLocal.OExecutionThreadData> {
public class OExecutionThreadData {
public volatile OAsyncReplicationOk onAsyncReplicationOk;
public volatile OAsyncReplicationError onAsyncReplicationError;
}
public class OExecutionThreadData {}

@Override
protected OExecutionThreadData initialValue() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
package com.orientechnologies.orient.core.sql;

import com.orientechnologies.orient.core.command.OCommandRequestTextAbstract;
import com.orientechnologies.orient.core.replication.OAsyncReplicationError;
import com.orientechnologies.orient.core.replication.OAsyncReplicationOk;

/**
* SQL command request implementation. It just stores the request and delegated the execution to the
Expand All @@ -45,16 +43,4 @@ public boolean isIdempotent() {
public String toString() {
return "sql." + text; // OIOUtils.getStringMaxLength(text, 50, "...");
}

/** Defines a callback to call in case of the asynchronous replication succeed. */
@Override
public OCommandSQL onAsyncReplicationOk(final OAsyncReplicationOk iCallback) {
return (OCommandSQL) super.onAsyncReplicationOk(iCallback);
}

/** Defines a callback to call in case of error during the asynchronous replication. */
@Override
public OCommandSQL onAsyncReplicationError(final OAsyncReplicationError iCallback) {
return (OCommandSQL) super.onAsyncReplicationError(iCallback);
}
}

0 comments on commit 7038f14

Please sign in to comment.