From 7038f14662a6dd799b0e4dcc59de7d19eae79675 Mon Sep 17 00:00:00 2001 From: Tglman Date: Fri, 8 Nov 2024 19:36:12 +0000 Subject: [PATCH] refactor: removed code not use enymore for command replication --- .../core/command/OCommandRequestAbstract.java | 53 +------------------ .../command/OCommandRequestTextAbstract.java | 4 -- .../core/command/ODistributedCommand.java | 39 -------------- .../orient/core/db/OExecutionThreadLocal.java | 7 +-- .../replication/OAsyncReplicationError.java | 41 -------------- .../core/replication/OAsyncReplicationOk.java | 29 ---------- .../orient/core/sql/OCommandSQL.java | 14 ----- 7 files changed, 2 insertions(+), 185 deletions(-) delete mode 100644 core/src/main/java/com/orientechnologies/orient/core/command/ODistributedCommand.java delete mode 100644 core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationError.java delete mode 100644 core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationOk.java diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestAbstract.java index 017478a0071..1c71f74133c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestAbstract.java @@ -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; @@ -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; @@ -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 nodesToExclude = new HashSet(); private boolean recordResultSet = true; @@ -102,38 +96,6 @@ protected Map 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; } @@ -207,11 +169,6 @@ public TIMEOUT_STRATEGY getTimeoutStrategy() { return timeoutStrategy; } - @Override - public Set nodesToExclude() { - return Collections.unmodifiableSet(nodesToExclude); - } - public void addExcludedNode(String node) { nodesToExclude.add(node); } @@ -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; diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java index 49f5a9af116..bcbb9cec53c 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java @@ -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; @@ -57,9 +56,6 @@ protected OCommandRequestTextAbstract(final String iText) { public 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); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/ODistributedCommand.java b/core/src/main/java/com/orientechnologies/orient/core/command/ODistributedCommand.java deleted file mode 100644 index ec9e1b419ef..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/command/ODistributedCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ - -package com.orientechnologies.orient.core.command; - -import com.orientechnologies.orient.core.replication.OAsyncReplicationError; -import com.orientechnologies.orient.core.replication.OAsyncReplicationOk; -import java.util.Set; - -/** - * @author Andrey Lomakin (a.lomakin-at-orientdb.com) - * @since 7/2/14 - */ -public interface ODistributedCommand { - Set nodesToExclude(); - - /** Defines a callback to call in case of the asynchronous replication succeed. */ - ODistributedCommand onAsyncReplicationOk(OAsyncReplicationOk iCallback); - - /** Defines a callback to call in case of error during the asynchronous replication. */ - ODistributedCommand onAsyncReplicationError(OAsyncReplicationError iCallback); -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/OExecutionThreadLocal.java b/core/src/main/java/com/orientechnologies/orient/core/db/OExecutionThreadLocal.java index 412a8ce5c6b..c94e3cc7f51 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/db/OExecutionThreadLocal.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/OExecutionThreadLocal.java @@ -22,8 +22,6 @@ 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. @@ -31,10 +29,7 @@ * @author Luca Garulli (l.garulli--(at)--orientdb.com) */ public class OExecutionThreadLocal extends ThreadLocal { - public class OExecutionThreadData { - public volatile OAsyncReplicationOk onAsyncReplicationOk; - public volatile OAsyncReplicationError onAsyncReplicationError; - } + public class OExecutionThreadData {} @Override protected OExecutionThreadData initialValue() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationError.java b/core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationError.java deleted file mode 100644 index 27eb924ffd7..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationError.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ -package com.orientechnologies.orient.core.replication; - -/** - * Interface to catch errors on asynchronous replication. - * - * @author Luca Garulli (l.garulli--(at)--orientdb.com) - */ -public interface OAsyncReplicationError { - enum ACTION { - IGNORE, - RETRY - } - - /** - * Callback called in case of error during asynchronous replication. - * - * @param iException The exception caught - * @param iRetry The number of retries so far. At every retry, this number is incremented. - * @return RETRY to retry the operation, otherwise IGNORE - */ - ACTION onAsyncReplicationError(Throwable iException, int iRetry); -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationOk.java b/core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationOk.java deleted file mode 100644 index e3b28726dea..00000000000 --- a/core/src/main/java/com/orientechnologies/orient/core/replication/OAsyncReplicationOk.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2010-2016 OrientDB LTD (http://orientdb.com) - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. - * * - * * For more information: http://orientdb.com - * - */ -package com.orientechnologies.orient.core.replication; - -/** - * Interface to catch asynchronous replication operation successfully completed. - * - * @author Luca Garulli (l.garulli--(at)--orientdb.com) - */ -public interface OAsyncReplicationOk { - void onAsyncReplicationOk(); -} diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandSQL.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandSQL.java index 250a9648b32..bc4b181b6c1 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandSQL.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OCommandSQL.java @@ -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 @@ -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); - } }