-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.x' into pb-dependency
- Loading branch information
Showing
19 changed files
with
711 additions
and
132 deletions.
There are no files selected for viewing
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
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
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
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
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
53 changes: 53 additions & 0 deletions
53
integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/fence/hook/TccHook.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,53 @@ | ||
/* | ||
* 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 org.apache.seata.rm.tcc.api.BusinessActionContext; | ||
|
||
public interface TccHook { | ||
|
||
/** | ||
* before tcc prepare | ||
*/ | ||
void beforeTccPrepare(String xid, Long branchId, String actionName, BusinessActionContext context); | ||
|
||
/** | ||
* after tcc prepare | ||
*/ | ||
void afterTccPrepare(String xid, Long branchId, String actionName, BusinessActionContext context); | ||
|
||
/** | ||
* before tcc commit | ||
*/ | ||
void beforeTccCommit(String xid, Long branchId, String actionName, BusinessActionContext context); | ||
|
||
/** | ||
* after tcc commit | ||
*/ | ||
void afterTccCommit(String xid, Long branchId, String actionName, BusinessActionContext context); | ||
|
||
/** | ||
* before tcc rollback | ||
*/ | ||
void beforeTccRollback(String xid, Long branchId, String actionName, BusinessActionContext context); | ||
|
||
/** | ||
* after tcc rollback | ||
*/ | ||
void afterTccRollback(String xid, Long branchId, String actionName, BusinessActionContext context); | ||
} |
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 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."); | ||
} | ||
} |
Oops, something went wrong.