This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 9bb919af048 Remove useless InstanceAwareRule (#18801)
9bb919af048 is described below
commit 9bb919af04825a373528d34a7bb714504e022d02
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jul 3 12:02:20 2022 +0800
Remove useless InstanceAwareRule (#18801)
---
.../rule/identifier/type/InstanceAwareRule.java | 34 ----------------------
.../mode/manager/ContextManager.java | 11 -------
2 files changed, 45 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/InstanceAwareRule.java
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/InstanceAwareRule.java
deleted file mode 100644
index cbef4fbda71..00000000000
---
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/identifier/type/InstanceAwareRule.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.shardingsphere.infra.rule.identifier.type;
-
-import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-
-/**
- * Instance aware rule.
- */
-public interface InstanceAwareRule extends ShardingSphereRule {
-
- /**
- * Set instance context.
- *
- * @param instanceContext instance context
- */
- void setInstanceContext(InstanceContext instanceContext);
-}
diff --git
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index 7ac481b5a57..25212e4f38a 100644
---
a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++
b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -44,7 +44,6 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSc
import
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
-import org.apache.shardingsphere.infra.rule.identifier.type.InstanceAwareRule;
import
org.apache.shardingsphere.infra.rule.identifier.type.MutableDataNodeRule;
import org.apache.shardingsphere.infra.rule.identifier.type.ResourceHeldRule;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -80,12 +79,6 @@ public final class ContextManager implements AutoCloseable {
this.metaDataContexts = metaDataContexts;
this.instanceContext = instanceContext;
executorEngine =
ExecutorEngine.createExecutorEngineWithSize(metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE));
- setInstanceContext();
- }
-
- private void setInstanceContext() {
-
metaDataContexts.getMetaData().getGlobalRuleMetaData().findRules(InstanceAwareRule.class).forEach(each
-> each.setInstanceContext(instanceContext));
- metaDataContexts.getMetaData().getDatabases().forEach((key, value) ->
value.getRuleMetaData().findRules(InstanceAwareRule.class).forEach(each ->
each.setInstanceContext(instanceContext)));
}
/**
@@ -251,7 +244,6 @@ public final class ContextManager implements AutoCloseable {
metaDataContexts.getOptimizerContext().getFederationMetaData().getDatabases().putAll(changedMetaDataContexts.getOptimizerContext().getFederationMetaData().getDatabases());
metaDataContexts.getMetaData().getDatabases().get(databaseName).getRuleMetaData().findRules(ResourceHeldRule.class).forEach(ResourceHeldRule::closeStaleResources);
metaDataContexts.getMetaData().getDatabases().putAll(changedMetaDataContexts.getMetaData().getDatabases());
- setInstanceContext();
} catch (final SQLException ex) {
log.error("Alter database:{} rule configuration failed",
databaseName, ex);
}
@@ -267,7 +259,6 @@ public final class ContextManager implements AutoCloseable {
try {
MetaDataContexts changedMetaDataContext =
buildChangedMetaDataContextWithChangedDataSource(metaDataContexts.getMetaData().getDatabases().get(databaseName),
dataSourcePropsMap);
refreshMetaDataContext(databaseName, changedMetaDataContext,
dataSourcePropsMap);
- setInstanceContext();
} catch (final SQLException ex) {
log.error("Alter database:{} data source configuration failed",
databaseName, ex);
}
@@ -285,7 +276,6 @@ public final class ContextManager implements AutoCloseable {
MetaDataContexts changedMetaDataContext =
buildChangedMetaDataContextWithChangedDataSourceAndRule(
metaDataContexts.getMetaData().getDatabases().get(databaseName),
dataSourcePropsMap, ruleConfigs);
refreshMetaDataContext(databaseName, changedMetaDataContext,
dataSourcePropsMap);
- setInstanceContext();
} catch (SQLException ex) {
log.error("Alter database:{} data source and rule configuration
failed", databaseName, ex);
}
@@ -304,7 +294,6 @@ public final class ContextManager implements AutoCloseable {
new
ShardingSphereRuleMetaData(GlobalRulesBuilder.buildRules(ruleConfigs,
metaDataContexts.getMetaData().getDatabases(), instanceContext)));
metaDataContexts.getMetaData().getGlobalRuleMetaData().findRules(ResourceHeldRule.class).forEach(ResourceHeldRule::closeStaleResources);
renewMetaDataContexts(newMetaDataContexts);
- setInstanceContext();
}
/**