Skip to content

Commit

Permalink
Refactor RuleChangedSubscriber (apache#26747)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Jul 3, 2023
1 parent 437c447 commit 1945d85
Show file tree
Hide file tree
Showing 30 changed files with 721 additions and 577 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class BroadcastTableSubscriber implements RuleChangedSubscriber {
public final class BroadcastTableSubscriber implements RuleChangedSubscriber<AlterBroadcastTableEvent, DropBroadcastTableEvent> {

private ContextManager contextManager;

/**
* Renew with alter broadcast table.
*
* @param event alter broadcast table event
*/
@Subscribe
@Override
public synchronized void renew(final AlterBroadcastTableEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -66,12 +62,8 @@ public synchronized void renew(final AlterBroadcastTableEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with delete broadcast table.
*
* @param event delete broadcast table event
*/
@Subscribe
@Override
public synchronized void renew(final DropBroadcastTableEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class EncryptTableSubscriber implements RuleChangedSubscriber {
public final class EncryptTableSubscriber implements RuleChangedSubscriber<AlterEncryptTableEvent, DropEncryptTableEvent> {

private ContextManager contextManager;

/**
* Renew with alter encrypt table.
*
* @param event alter encrypt table event
*/
@Subscribe
@Override
public synchronized void renew(final AlterEncryptTableEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -61,12 +57,8 @@ public synchronized void renew(final AlterEncryptTableEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), changedConfig));
}

/**
* Renew with drop encrypt table.
*
* @param event drop encrypt table event
*/
@Subscribe
@Override
public synchronized void renew(final DropEncryptTableEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class EncryptorSubscriber implements RuleChangedSubscriber {
public final class EncryptorSubscriber implements RuleChangedSubscriber<AlterEncryptorEvent, DropEncryptorEvent> {

private ContextManager contextManager;

/**
* Renew with alter encryptor.
*
* @param event alter encryptor event
*/
@Subscribe
@Override
public synchronized void renew(final AlterEncryptorEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -64,12 +60,8 @@ public synchronized void renew(final AlterEncryptorEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with drop encryptor.
*
* @param event drop encryptor event
*/
@Subscribe
@Override
public synchronized void renew(final DropEncryptorEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@
@Deprecated
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class CompatibleEncryptTableSubscriber implements RuleChangedSubscriber {
public final class CompatibleEncryptTableSubscriber implements RuleChangedSubscriber<AlterCompatibleEncryptTableEvent, DropCompatibleEncryptTableEvent> {

private ContextManager contextManager;

/**
* Renew with alter encrypt table.
*
* @param event alter encrypt table event
*/
@Subscribe
@Override
public synchronized void renew(final AlterCompatibleEncryptTableEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -68,12 +64,8 @@ public synchronized void renew(final AlterCompatibleEncryptTableEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with drop encrypt table.
*
* @param event drop encrypt table event
*/
@Subscribe
@Override
public synchronized void renew(final DropCompatibleEncryptTableEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@
@Deprecated
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class CompatibleEncryptorSubscriber implements RuleChangedSubscriber {
public final class CompatibleEncryptorSubscriber implements RuleChangedSubscriber<AlterCompatibleEncryptorEvent, DropCompatibleEncryptorEvent> {

private ContextManager contextManager;

/**
* Renew with alter encryptor.
*
* @param event alter encryptor event
*/
@Subscribe
@Override
public synchronized void renew(final AlterCompatibleEncryptorEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -66,12 +62,8 @@ public synchronized void renew(final AlterCompatibleEncryptorEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with drop encryptor.
*
* @param event drop encryptor event
*/
@Subscribe
@Override
public synchronized void renew(final DropCompatibleEncryptorEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class MaskAlgorithmSubscriber implements RuleChangedSubscriber {
public final class MaskAlgorithmSubscriber implements RuleChangedSubscriber<AlterMaskAlgorithmEvent, DropMaskAlgorithmEvent> {

private ContextManager contextManager;

/**
* Renew with alter mask algorithm.
*
* @param event alter mask algorithm event
*/
@Subscribe
@Override
public synchronized void renew(final AlterMaskAlgorithmEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -63,12 +59,8 @@ public synchronized void renew(final AlterMaskAlgorithmEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with drop mask algorithm.
*
* @param event drop mask algorithm event
*/
@Subscribe
@Override
public synchronized void renew(final DropMaskAlgorithmEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class MaskTableSubscriber implements RuleChangedSubscriber {
public final class MaskTableSubscriber implements RuleChangedSubscriber<AlterMaskTableEvent, DropMaskTableEvent> {

private ContextManager contextManager;

/**
* Renew with alter mask table.
*
* @param event alter mask table event
*/
@Subscribe
@Override
public synchronized void renew(final AlterMaskTableEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -61,12 +57,8 @@ public synchronized void renew(final AlterMaskTableEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with drop mask table.
*
* @param event drop mask table event
*/
@Subscribe
@Override
public synchronized void renew(final DropMaskTableEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class ReadwriteSplittingDataSourceSubscriber implements RuleChangedSubscriber {
public final class ReadwriteSplittingDataSourceSubscriber implements RuleChangedSubscriber<AlterReadwriteSplittingDataSourceEvent, DropReadwriteSplittingDataSourceEvent> {

private ContextManager contextManager;

/**
* Renew with alter readwrite-splitting configuration.
*
* @param event alter readwrite-splitting configuration event
*/
@Subscribe
@Override
public synchronized void renew(final AlterReadwriteSplittingDataSourceEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -64,12 +60,8 @@ public synchronized void renew(final AlterReadwriteSplittingDataSourceEvent even
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with drop readwrite-splitting configuration.
*
* @param event drop readwrite-splitting configuration event
*/
@Subscribe
@Override
public synchronized void renew(final DropReadwriteSplittingDataSourceEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class ReadwriteSplittingLoadBalanceSubscriber implements RuleChangedSubscriber {
public final class ReadwriteSplittingLoadBalanceSubscriber implements RuleChangedSubscriber<AlterReadwriteSplittingLoadBalancerEvent, DropReadwriteSplittingLoadBalancerEvent> {

private ContextManager contextManager;

/**
* Renew with alter load-balancer.
*
* @param event alter load-balancer event
*/
@Subscribe
@Override
public synchronized void renew(final AlterReadwriteSplittingLoadBalancerEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -62,12 +58,8 @@ public synchronized void renew(final AlterReadwriteSplittingLoadBalancerEvent ev
getConfiguration(contextManager.getMetaDataContexts().getMetaData().getDatabases().get(event.getDatabaseName()), event.getItemName(), toBeChangedConfig)));
}

/**
* Renew with drop load-balancer.
*
* @param event drop load-balancer event
*/
@Subscribe
@Override
public synchronized void renew(final DropReadwriteSplittingLoadBalancerEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class DefaultShadowAlgorithmNameSubscriber implements RuleChangedSubscriber {
public final class DefaultShadowAlgorithmNameSubscriber implements RuleChangedSubscriber<AlterDefaultShadowAlgorithmEvent, DropDefaultShadowAlgorithmEvent> {

private ContextManager contextManager;

/**
* Renew with alter default algorithm name.
*
* @param event alter default algorithm name event
*/
@Subscribe
@Override
public synchronized void renew(final AlterDefaultShadowAlgorithmEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -60,12 +56,8 @@ public synchronized void renew(final AlterDefaultShadowAlgorithmEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with delete default algorithm name.
*
* @param event delete default algorithm name event
*/
@Subscribe
@Override
public synchronized void renew(final DropDefaultShadowAlgorithmEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class ShadowAlgorithmSubscriber implements RuleChangedSubscriber {
public final class ShadowAlgorithmSubscriber implements RuleChangedSubscriber<AlterShadowAlgorithmEvent, DropShadowAlgorithmEvent> {

private ContextManager contextManager;

/**
* Renew with alter algorithm.
*
* @param event alter algorithm event
*/
@Subscribe
@Override
public synchronized void renew(final AlterShadowAlgorithmEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -66,12 +62,8 @@ public synchronized void renew(final AlterShadowAlgorithmEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with delete algorithm.
*
* @param event delete algorithm event
*/
@Subscribe
@Override
public synchronized void renew(final DropShadowAlgorithmEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,12 @@
*/
@SuppressWarnings("UnstableApiUsage")
@Setter
public final class ShadowDataSourceSubscriber implements RuleChangedSubscriber {
public final class ShadowDataSourceSubscriber implements RuleChangedSubscriber<AlterShadowDataSourceEvent, DropShadowDataSourceEvent> {

private ContextManager contextManager;

/**
* Renew with alter shadow data source.
*
* @param event alter shadow data source event
*/
@Subscribe
@Override
public synchronized void renew(final AlterShadowDataSourceEvent event) {
if (!event.getActiveVersion().equals(contextManager.getInstanceContext().getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
return;
Expand All @@ -61,12 +57,8 @@ public synchronized void renew(final AlterShadowDataSourceEvent event) {
contextManager.getInstanceContext().getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}

/**
* Renew with delete shadow data source.
*
* @param event delete shadow data source event
*/
@Subscribe
@Override
public synchronized void renew(final DropShadowDataSourceEvent event) {
if (!contextManager.getMetaDataContexts().getMetaData().containsDatabase(event.getDatabaseName())) {
return;
Expand Down
Loading

0 comments on commit 1945d85

Please sign in to comment.