-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use DataChangedEventHandler to instead of DispatchEventBuilder
- Loading branch information
Showing
7 changed files
with
158 additions
and
31 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...e/shardingsphere/mode/manager/cluster/event/dispatch/handler/DataChangedEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.mode.manager.cluster.event.dispatch.handler; | ||
|
||
import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI; | ||
import org.apache.shardingsphere.mode.event.DataChangedEvent; | ||
import org.apache.shardingsphere.mode.event.DataChangedEvent.Type; | ||
import org.apache.shardingsphere.mode.manager.ContextManager; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Data changed event handler. | ||
*/ | ||
@SingletonSPI | ||
public interface DataChangedEventHandler { | ||
|
||
/** | ||
* Get subscribed key. | ||
* | ||
* @return subscribed key | ||
*/ | ||
String getSubscribedKey(); | ||
|
||
/** | ||
* Get subscribed types. | ||
* | ||
* @return subscribed types | ||
*/ | ||
Collection<Type> getSubscribedTypes(); | ||
|
||
|
||
/** | ||
* Handle data changed event. | ||
* | ||
* @param contextManager context manager | ||
* @param event data changed event | ||
*/ | ||
void handle(ContextManager contextManager, DataChangedEvent event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...phere/mode/manager/cluster/event/dispatch/listener/type/GlobalMetaDataChangedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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.mode.manager.cluster.event.dispatch.listener.type; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.apache.shardingsphere.mode.event.DataChangedEvent; | ||
import org.apache.shardingsphere.mode.manager.ContextManager; | ||
import org.apache.shardingsphere.mode.manager.cluster.event.dispatch.handler.DataChangedEventHandler; | ||
import org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEventListener; | ||
|
||
/** | ||
* Global meta data changed handler. | ||
*/ | ||
@RequiredArgsConstructor | ||
public final class GlobalMetaDataChangedHandler implements DataChangedEventListener { | ||
|
||
private final ContextManager contextManager; | ||
|
||
private final DataChangedEventHandler handler; | ||
|
||
@Override | ||
public void onChange(final DataChangedEvent event) { | ||
if (handler.getSubscribedTypes().contains(event.getType())) { | ||
handler.handle(contextManager, event); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...apache.shardingsphere.mode.manager.cluster.event.dispatch.handler.DataChangedEventHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
org.apache.shardingsphere.mode.manager.cluster.event.dispatch.handler.type.ClusterStateChangedHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters