-
Notifications
You must be signed in to change notification settings - Fork 8.8k
feature: add TCC three-phase hooks #6766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
funky-eyes
merged 16 commits into
apache:2.x
from
iAmClever:clever_tcc_fence_hook_function
Sep 2, 2024
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
135f273
feature: add TCC three-phase hooks (#6731)
b358e22
feature: add TCC three-phase hooks (#6731)
a2ebc11
feature: add TCC three-phase hooks (#6731)
6b2c5c6
feature: add TCC three-phase hooks (#6731)
e4b4bab
Merge branch '2.x' into clever_tcc_fence_hook_function
funky-eyes 01cd836
Merge branch '2.x' into clever_tcc_fence_hook_function
funky-eyes 9a15907
feature: add TCC three-phase hooks (#6731)
59e82ce
Merge branch 'clever_tcc_fence_hook_function' of https://github.com/i…
381c3c3
feature: add TCC three-phase hooks (#6731)
21e7fdd
Update integration-tx-api/src/test/java/org/apache/seata/integration/…
funky-eyes 2186ceb
Merge branch '2.x' into clever_tcc_fence_hook_function
funky-eyes 2637ac3
feature: add TCC three-phase hooks (#6731)
2d920e2
feature: add TCC three-phase hooks (#6731)
db4ac70
feature: add TCC three-phase hooks (#6731)
2280597
feature: add TCC three-phase hooks (#6731)
dfa0d27
feature: add TCC three-phase hooks (#6731)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
51 changes: 51 additions & 0 deletions
51
integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/fence/hook/TccHook.java
This file contains hidden or 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,51 @@ | ||
/* | ||
* 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.seata.integration.tx.api.fence.hook; | ||
|
||
|
||
public interface TccHook { | ||
|
||
/** | ||
* before tcc prepare | ||
*/ | ||
void beforeTccPrepare(String xid, Long branchId, String actionName); | ||
|
||
/** | ||
* after tcc prepare | ||
*/ | ||
void afterTccPrepare(String xid, Long branchId, String actionName); | ||
|
||
/** | ||
* before tcc commit | ||
*/ | ||
void beforeTccCommit(String xid, Long branchId, String actionName); | ||
|
||
/** | ||
* after tcc commit | ||
*/ | ||
void afterTccCommit(String xid, Long branchId, String actionName); | ||
|
||
/** | ||
* before tcc rollback | ||
*/ | ||
void beforeTccRollback(String xid, Long branchId, String actionName); | ||
|
||
/** | ||
* after tcc rollback | ||
*/ | ||
void afterTccRollback(String xid, Long branchId, String actionName); | ||
} |
73 changes: 73 additions & 0 deletions
73
...n-tx-api/src/main/java/org/apache/seata/integration/tx/api/fence/hook/TccHookManager.java
This file contains hidden or 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,73 @@ | ||
/* | ||
* 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.seata.integration.tx.api.fence.hook; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class TccHookManager { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(TccHookManager.class); | ||
|
||
private TccHookManager() { | ||
|
||
} | ||
|
||
private static final List<TccHook> TCC_HOOKS = new CopyOnWriteArrayList<>(); | ||
// Cache unmodifiable lists | ||
private volatile static List<TccHook> CACHED_UNMODIFIABLE_HOOKS = null; | ||
|
||
/** | ||
* get the hooks | ||
* @return tccHook list | ||
*/ | ||
public static List<TccHook> getHooks() { | ||
if (CACHED_UNMODIFIABLE_HOOKS == null) { | ||
synchronized (TccHookManager.class) { | ||
if (CACHED_UNMODIFIABLE_HOOKS == null) { | ||
CACHED_UNMODIFIABLE_HOOKS = Collections.unmodifiableList(TCC_HOOKS); | ||
} | ||
} | ||
} | ||
return CACHED_UNMODIFIABLE_HOOKS; | ||
} | ||
|
||
/** | ||
* add new hook | ||
* @param tccHook tccHook | ||
*/ | ||
public static void registerHook(TccHook tccHook) { | ||
if (tccHook == null) { | ||
throw new NullPointerException("tccHook must not be null"); | ||
} | ||
TCC_HOOKS.add(tccHook); | ||
CACHED_UNMODIFIABLE_HOOKS = null; | ||
LOGGER.info("TccHook registered succeeded! TccHooks size: {}", TCC_HOOKS.size()); | ||
} | ||
|
||
/** | ||
* clear hooks | ||
*/ | ||
public static void clear() { | ||
TCC_HOOKS.clear(); | ||
CACHED_UNMODIFIABLE_HOOKS = null; | ||
LOGGER.info("All TccHooks have been cleared."); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.