Skip to content

Commit

Permalink
Rename ReadwriteSplittingQualifiedDataSourceDeletedSubscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Dec 13, 2024
1 parent a2de706 commit 22d9821
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDataSource;
import org.apache.shardingsphere.infra.rule.attribute.datasource.StaticDataSourceRuleAttribute;
import org.apache.shardingsphere.infra.state.datasource.DataSourceState;
import org.apache.shardingsphere.readwritesplitting.subscriber.QualifiedDataSourceDeletedEvent;
import org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingQualifiedDataSourceDeletedEvent;
import org.apache.shardingsphere.readwritesplitting.exception.logic.ReadwriteSplittingDataSourceRuleNotFoundException;
import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingDataSourceGroupRule;

Expand Down Expand Up @@ -69,6 +69,6 @@ public void cleanStorageNodeDataSources() {

private void deleteStorageNodeDataSources(final ReadwriteSplittingDataSourceGroupRule rule) {
rule.getReadwriteSplittingGroup().getReadDataSources()
.forEach(each -> computeNodeInstanceContext.getEventBusContext().post(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource(databaseName, rule.getName(), each))));
.forEach(each -> computeNodeInstanceContext.getEventBusContext().post(new ReadwriteSplittingQualifiedDataSourceDeletedEvent(new QualifiedDataSource(databaseName, rule.getName(), each))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.apache.shardingsphere.infra.util.event.DeliverEvent;

/**
* Qualified data source deleted event.
* Readwrite-splitting qualified data source deleted event.
*/
@RequiredArgsConstructor
@Getter
public final class QualifiedDataSourceDeletedEvent implements DeliverEvent {
public final class ReadwriteSplittingQualifiedDataSourceDeletedEvent implements DeliverEvent {

private final QualifiedDataSource qualifiedDataSource;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import org.apache.shardingsphere.mode.spi.PersistRepository;

/**
* Qualified data source deleted subscriber.
* Readwrite-splitting qualified data source deleted subscriber.
*/
@RequiredArgsConstructor
public final class QualifiedDataSourceDeletedSubscriber implements EventSubscriber {
public final class ReadwriteSplittingQualifiedDataSourceDeletedSubscriber implements EventSubscriber {

private final PersistRepository repository;

Expand All @@ -37,7 +37,7 @@ public final class QualifiedDataSourceDeletedSubscriber implements EventSubscrib
* @param event qualified data source deleted event
*/
@Subscribe
public void delete(final QualifiedDataSourceDeletedEvent event) {
public void delete(final ReadwriteSplittingQualifiedDataSourceDeletedEvent event) {
repository.delete(QualifiedDataSourceNode.getQualifiedDataSourceNodePath(event.getQualifiedDataSource()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import org.apache.shardingsphere.mode.spi.PersistRepository;

/**
* Qualified data source deleted subscriber factory.
* Readwrite-splitting qualified data source deleted subscriber factory.
*/
public final class QualifiedDataSourceDeletedSubscriberFactory implements DeliverEventSubscriberFactory {
public final class ReadwriteSplittingQualifiedDataSourceDeletedSubscriberFactory implements DeliverEventSubscriberFactory {

@Override
public EventSubscriber create(final PersistRepository repository, final EventBusContext eventBusContext) {
return new QualifiedDataSourceDeletedSubscriber(repository);
return new ReadwriteSplittingQualifiedDataSourceDeletedSubscriber(repository);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.readwritesplitting.subscriber.QualifiedDataSourceDeletedSubscriberFactory
org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingQualifiedDataSourceDeletedSubscriberFactory
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext;
import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedDataSource;
import org.apache.shardingsphere.infra.state.datasource.DataSourceState;
import org.apache.shardingsphere.readwritesplitting.subscriber.QualifiedDataSourceDeletedEvent;
import org.apache.shardingsphere.readwritesplitting.subscriber.ReadwriteSplittingQualifiedDataSourceDeletedEvent;
import org.apache.shardingsphere.readwritesplitting.exception.logic.ReadwriteSplittingDataSourceRuleNotFoundException;
import org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingDataSourceGroupRule;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -75,7 +75,7 @@ void assertCleanStorageNodeDataSource() {
ReadwriteSplittingStaticDataSourceRuleAttribute ruleAttribute = new ReadwriteSplittingStaticDataSourceRuleAttribute(
"foo_db", Collections.singletonMap("foo_group", dataSourceGroupRule), computeNodeInstanceContext);
ruleAttribute.cleanStorageNodeDataSource("foo_group");
verify(computeNodeInstanceContext.getEventBusContext()).post(deepEq(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
verify(computeNodeInstanceContext.getEventBusContext()).post(deepEq(new ReadwriteSplittingQualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
}

@Test
Expand All @@ -87,6 +87,6 @@ void assertCleanStorageNodeDataSources() {
ReadwriteSplittingStaticDataSourceRuleAttribute ruleAttribute = new ReadwriteSplittingStaticDataSourceRuleAttribute(
"foo_db", Collections.singletonMap("foo_group", dataSourceGroupRule), computeNodeInstanceContext);
ruleAttribute.cleanStorageNodeDataSources();
verify(computeNodeInstanceContext.getEventBusContext()).post(deepEq(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
verify(computeNodeInstanceContext.getEventBusContext()).post(deepEq(new ReadwriteSplittingQualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db.foo_group.read_ds"))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@
import static org.mockito.Mockito.verify;

@ExtendWith(MockitoExtension.class)
class QualifiedDataSourceDeletedSubscriberTest {
class ReadwriteSplittingQualifiedDataSourceDeletedSubscriberTest {

private QualifiedDataSourceDeletedSubscriber subscriber;
private ReadwriteSplittingQualifiedDataSourceDeletedSubscriber subscriber;

@Mock
private PersistRepository repository;

@BeforeEach
void setUp() {
subscriber = new QualifiedDataSourceDeletedSubscriber(repository);
subscriber = new ReadwriteSplittingQualifiedDataSourceDeletedSubscriber(repository);
}

@Test
void assertDeleteStorageNodeDataSourceDataSourceState() {
subscriber.delete(new QualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db", "foo_group", "foo_ds")));
subscriber.delete(new ReadwriteSplittingQualifiedDataSourceDeletedEvent(new QualifiedDataSource("foo_db", "foo_group", "foo_ds")));
verify(repository).delete("/nodes/qualified_data_sources/foo_db.foo_group.foo_ds");
}
}

0 comments on commit 22d9821

Please sign in to comment.