Skip to content

Commit

Permalink
Merge pull request apache#5 from slievrly/master
Browse files Browse the repository at this point in the history
add copyright and javadoc
  • Loading branch information
slievrly authored Jan 9, 2019
2 parents bfac40f + 77d9177 commit fff4d20
Show file tree
Hide file tree
Showing 18 changed files with 288 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package com.alibaba.fescar.core.service;
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/

import java.util.List;
package com.alibaba.fescar.core.service;

/**
* Watch for server address list change
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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 com.alibaba.fescar.core.service;

public class ConfigurationKeys {
Expand All @@ -9,7 +25,6 @@ public class ConfigurationKeys {

public static final String ENABLE_DEGRADE_POSTFIX = "enableDegrade";


public static final String CLIENT_PREFIX = "client.";

public static final String CLIENT_ASYNC_COMMIT_BUFFER_LIMIT = CLIENT_PREFIX + "async.commit.buffer.limit";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package com.alibaba.fescar.core.service;
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/

import java.util.List;
package com.alibaba.fescar.core.service;

/**
* Service Registry and Discovery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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 com.alibaba.fescar.core.service;

import com.alibaba.fescar.common.exception.FrameworkException;
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#
#
# Copyright 1999-2018 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
#

log4j.rootCategory=info,R

Expand Down
2 changes: 0 additions & 2 deletions core/src/main/logback.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~
~ Copyright 1999-2018 Alibaba Group Holding Ltd.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,7 +14,6 @@
~ 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.
~
-->
<configuration debug="false">

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed 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 com.alibaba.fescar.dubbo;

import com.alibaba.dubbo.common.Constants;
import com.alibaba.dubbo.common.extension.Activate;
import com.alibaba.dubbo.rpc.*;
import com.alibaba.dubbo.rpc.Filter;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Result;
import com.alibaba.dubbo.rpc.RpcContext;
import com.alibaba.dubbo.rpc.RpcException;
import com.alibaba.fescar.core.context.RootContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,26 @@
import com.alibaba.fescar.core.model.ResourceManagerInbound;
import com.alibaba.fescar.core.protocol.AbstractMessage;
import com.alibaba.fescar.core.protocol.AbstractResultMessage;
import com.alibaba.fescar.core.protocol.transaction.*;
import com.alibaba.fescar.core.protocol.transaction.AbstractTransactionRequestToTC;
import com.alibaba.fescar.core.protocol.transaction.AbstractTransactionResponse;
import com.alibaba.fescar.core.protocol.transaction.BranchCommitRequest;
import com.alibaba.fescar.core.protocol.transaction.BranchCommitResponse;
import com.alibaba.fescar.core.protocol.transaction.BranchRegisterRequest;
import com.alibaba.fescar.core.protocol.transaction.BranchRegisterResponse;
import com.alibaba.fescar.core.protocol.transaction.BranchReportRequest;
import com.alibaba.fescar.core.protocol.transaction.BranchReportResponse;
import com.alibaba.fescar.core.protocol.transaction.BranchRollbackRequest;
import com.alibaba.fescar.core.protocol.transaction.BranchRollbackResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalBeginRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalBeginResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalCommitRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalCommitResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalLockQueryRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalLockQueryResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalRollbackRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalRollbackResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalStatusRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalStatusResponse;
import com.alibaba.fescar.core.rpc.RpcContext;
import com.alibaba.fescar.core.rpc.ServerMessageSender;
import com.alibaba.fescar.core.rpc.TransactionMessageHandler;
Expand Down Expand Up @@ -209,16 +227,16 @@ private void handleAsyncCommitting() throws TransactionException {
}

private ScheduledThreadPoolExecutor retryRollbacking = new ScheduledThreadPoolExecutor(1,
new NamedThreadFactory("RetryRollbacking", 1, true));
new NamedThreadFactory("RetryRollbacking", 1));

private ScheduledThreadPoolExecutor retryCommitting = new ScheduledThreadPoolExecutor(1,
new NamedThreadFactory("RetryCommitting", 1, true));
new NamedThreadFactory("RetryCommitting", 1));

private ScheduledThreadPoolExecutor asyncCommitting = new ScheduledThreadPoolExecutor(1,
new NamedThreadFactory("AsyncCommitting", 1, true));
new NamedThreadFactory("AsyncCommitting", 1));

private ScheduledThreadPoolExecutor timeoutCheck = new ScheduledThreadPoolExecutor(1,
new NamedThreadFactory("TimeoutCheck", 1, true));
new NamedThreadFactory("TxTimeoutCheck", 1));

public void init() {
retryRollbacking.scheduleAtFixedRate(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,32 @@
import com.alibaba.fescar.core.exception.TransactionExceptionCode;
import com.alibaba.fescar.core.model.GlobalStatus;
import com.alibaba.fescar.core.model.TransactionManager;
import com.alibaba.fescar.core.protocol.transaction.*;
import com.alibaba.fescar.core.protocol.transaction.AbstractTransactionRequest;
import com.alibaba.fescar.core.protocol.transaction.AbstractTransactionResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalBeginRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalBeginResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalCommitRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalCommitResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalRollbackRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalRollbackResponse;
import com.alibaba.fescar.core.protocol.transaction.GlobalStatusRequest;
import com.alibaba.fescar.core.protocol.transaction.GlobalStatusResponse;
import com.alibaba.fescar.core.rpc.netty.TmRpcClient;

/**
* The type Default transaction manager.
*/
public class DefaultTransactionManager implements TransactionManager {

private static class SingletonHolder {
private static final TransactionManager INSTANCE = new DefaultTransactionManager();
}

/**
* Get transaction manager.
*
* @return the transaction manager
*/
public static TransactionManager get() {
return SingletonHolder.INSTANCE;
}
Expand Down
10 changes: 9 additions & 1 deletion tm/src/main/java/com/alibaba/fescar/tm/TMClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@

import com.alibaba.fescar.core.rpc.netty.TmRpcClient;

/**
* The type Tm client.
*/
public class TMClient {

/**
* Init.
*
* @param applicationId the application id
* @param transactionServiceGroup the transaction service group
*/
public static void init(String applicationId, String transactionServiceGroup) {
TmRpcClient tmRpcClient = TmRpcClient.getInstance(applicationId, transactionServiceGroup);
tmRpcClient.init();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import org.slf4j.LoggerFactory;

/**
* @Author: [email protected]
* @Project: feats-all
* @DateTime: 2019/1/8 7:27 PM
* The type Default failure handler.
*
* @Author: jimin.jm @alibaba-inc.com
* @Project: feats -all
* @DateTime: 2019 /1/8 7:27 PM
* @FileName: DefaultFailureHandlerImpl
* @Description:
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import com.alibaba.fescar.core.model.GlobalStatus;
import com.alibaba.fescar.core.model.TransactionManager;
import com.alibaba.fescar.tm.DefaultTransactionManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The type Default global transaction.
*/
public class DefaultGlobalTransaction implements GlobalTransaction {

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultGlobalTransaction.class);
Expand All @@ -41,10 +45,18 @@ public class DefaultGlobalTransaction implements GlobalTransaction {

private GlobalTransactionRole role = GlobalTransactionRole.Launcher;

/**
* Instantiates a new Default global transaction.
*/
DefaultGlobalTransaction() {
this(null);
}

/**
* Instantiates a new Default global transaction.
*
* @param xid the xid
*/
DefaultGlobalTransaction(String xid) {
this.transactionManager = DefaultTransactionManager.get();
this.xid = xid;
Expand Down
18 changes: 18 additions & 0 deletions tm/src/main/java/com/alibaba/fescar/tm/api/FailureHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,27 @@
*/
public interface FailureHandler {

/**
* On begin failure.
*
* @param tx the tx
* @param cause the cause
*/
void onBeginFailure(GlobalTransaction tx, Throwable cause);

/**
* On commit failure.
*
* @param tx the tx
* @param cause the cause
*/
void onCommitFailure(GlobalTransaction tx, Throwable cause);

/**
* On rollback failure.
*
* @param tx the tx
* @param cause the cause
*/
void onRollbackFailure(GlobalTransaction tx, Throwable cause);
}
Loading

0 comments on commit fff4d20

Please sign in to comment.