Skip to content

Commit 8be0f24

Browse files
authored
Merge pull request #29 from codingapi/pom
Pom
2 parents 10efdce + af06347 commit 8be0f24

17 files changed

Lines changed: 195 additions & 179 deletions

File tree

pom.xml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
<groupId>com.codingapi</groupId>
77
<artifactId>tx-lcn</artifactId>
8-
<version>4.0.0</version>
8+
<version>4.0.3.M1</version>
99
<packaging>pom</packaging>
1010

1111
<name>tx-lcn</name>
12+
<url>https://github.com/codingapi/tx-lcn</url>
13+
<description>tx-lcn project for LCN</description>
1214

1315
<modules>
1416
<module>tx-client</module>
@@ -77,14 +79,6 @@
7779

7880
<build>
7981
<plugins>
80-
<plugin>
81-
<groupId>org.apache.maven.plugins</groupId>
82-
<artifactId>maven-compiler-plugin</artifactId>
83-
<configuration>
84-
<source>${java.version}</source>
85-
<target>${java.version}</target>
86-
</configuration>
87-
</plugin>
8882
<plugin>
8983
<groupId>org.apache.maven.plugins</groupId>
9084
<artifactId>maven-compiler-plugin</artifactId>
@@ -108,6 +102,8 @@
108102
</execution>
109103
</executions>
110104
</plugin>
105+
106+
111107
<plugin>
112108
<groupId>org.sonatype.plugins</groupId>
113109
<artifactId>nexus-staging-maven-plugin</artifactId>
@@ -132,21 +128,24 @@
132128
</execution>
133129
</executions>
134130
</plugin>
135-
<!-- 手动打包时,将下面的plugin注释掉 -->
136-
<plugin>
137-
<groupId>org.apache.maven.plugins</groupId>
138-
<artifactId>maven-gpg-plugin</artifactId>
139-
<version>1.6</version>
140-
<executions>
141-
<execution>
142-
<id>sign-artifacts</id>
143-
<phase>verify</phase>
144-
<goals>
145-
<goal>sign</goal>
146-
</goals>
147-
</execution>
148-
</executions>
149-
</plugin>
131+
132+
<!--手动打包时,将下面的plugin注释掉-->
133+
134+
<!--<plugin>-->
135+
<!--<groupId>org.apache.maven.plugins</groupId>-->
136+
<!--<artifactId>maven-gpg-plugin</artifactId>-->
137+
<!--<version>1.6</version>-->
138+
<!--<executions>-->
139+
<!--<execution>-->
140+
<!--<id>sign-artifacts</id>-->
141+
<!--<phase>verify</phase>-->
142+
<!--<goals>-->
143+
<!--<goal>sign</goal>-->
144+
<!--</goals>-->
145+
<!--</execution>-->
146+
<!--</executions>-->
147+
<!--</plugin>-->
148+
150149
</plugins>
151150
</build>
152151

transaction-dubbo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.codingapi</groupId>
1010
<artifactId>tx-lcn</artifactId>
11-
<version>4.0.0</version>
11+
<version>4.0.3.M1</version>
1212
</parent>
1313

1414
<groupId>com.codingapi</groupId>

transaction-motan/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>com.codingapi</groupId>
1010
<artifactId>tx-lcn</artifactId>
11-
<version>4.0.0</version>
11+
<version>4.0.3.M1</version>
1212
</parent>
1313

1414
<groupId>com.codingapi</groupId>

transaction-springcloud/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi</groupId>
88
<artifactId>tx-lcn</artifactId>
9-
<version>4.0.0</version>
9+
<version>4.0.3.M1</version>
1010
</parent>
1111

1212
<groupId>com.codingapi</groupId>

tx-client/pom.xml

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi</groupId>
88
<artifactId>tx-lcn</artifactId>
9-
<version>4.0.0</version>
9+
<version>4.0.3.M1</version>
1010
</parent>
1111

1212
<groupId>com.codingapi</groupId>
@@ -123,78 +123,4 @@
123123
</dependencies>
124124

125125

126-
<build>
127-
<plugins>
128-
<plugin>
129-
<groupId>org.apache.maven.plugins</groupId>
130-
<artifactId>maven-compiler-plugin</artifactId>
131-
<configuration>
132-
<source>1.7</source>
133-
<target>1.7</target>
134-
</configuration>
135-
</plugin>
136-
<plugin>
137-
<groupId>org.apache.maven.plugins</groupId>
138-
<artifactId>maven-compiler-plugin</artifactId>
139-
<version>${maven-compiler-plugin.version}</version>
140-
<configuration>
141-
<source>${maven.compile.source}</source>
142-
<target>${maven.compile.target}</target>
143-
<encoding>${project.build.sourceEncoding}</encoding>
144-
</configuration>
145-
</plugin>
146-
<plugin>
147-
<groupId>org.apache.maven.plugins</groupId>
148-
<artifactId>maven-source-plugin</artifactId>
149-
<version>2.4</version>
150-
<executions>
151-
<execution>
152-
<id>attach-sources</id>
153-
<goals>
154-
<goal>jar-no-fork</goal>
155-
</goals>
156-
</execution>
157-
</executions>
158-
</plugin>
159-
<plugin>
160-
<groupId>org.sonatype.plugins</groupId>
161-
<artifactId>nexus-staging-maven-plugin</artifactId>
162-
<version>1.6.3</version>
163-
<extensions>true</extensions>
164-
<configuration>
165-
<serverId>ossrh</serverId>
166-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
167-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
168-
</configuration>
169-
</plugin>
170-
<plugin>
171-
<groupId>org.apache.maven.plugins</groupId>
172-
<artifactId>maven-javadoc-plugin</artifactId>
173-
<version>2.10.3</version>
174-
<executions>
175-
<execution>
176-
<id>attach-javadocs</id>
177-
<goals>
178-
<goal>jar</goal>
179-
</goals>
180-
</execution>
181-
</executions>
182-
</plugin>
183-
<plugin>
184-
<groupId>org.apache.maven.plugins</groupId>
185-
<artifactId>maven-gpg-plugin</artifactId>
186-
<version>1.6</version>
187-
<executions>
188-
<execution>
189-
<id>sign-artifacts</id>
190-
<phase>verify</phase>
191-
<goals>
192-
<goal>sign</goal>
193-
</goals>
194-
</execution>
195-
</executions>
196-
</plugin>
197-
</plugins>
198-
</build>
199-
200126
</project>

tx-client/src/main/java/com/codingapi/tx/aop/service/impl/TxStartTransactionServerImpl.java

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,50 +83,56 @@ public Object execute(ProceedingJoinPoint point,final TxTransactionInfo info) th
8383
new Thread(new HookRunnable() {
8484
@Override
8585
public void run0() {
86-
if(task.isAwait()) {
8786

88-
int rs = txManagerService.closeTransactionGroup(groupId, resState);
87+
while (!task.isAwait() && !Thread.currentThread().interrupted()) {
88+
try {
89+
Thread.sleep(1);
90+
} catch (InterruptedException e) {
91+
e.printStackTrace();
92+
}
93+
}
8994

90-
int lastState = rs==-1?0:resState;
95+
int rs = txManagerService.closeTransactionGroup(groupId, resState);
9196

92-
int executeConnectionError = 0;
97+
int lastState = rs==-1?0:resState;
9398

94-
//控制本地事务的数据提交
95-
final TxTask waitTask = TaskGroupManager.getInstance().getTask(groupId, type);
96-
if(waitTask!=null){
97-
waitTask.setState(lastState);
98-
waitTask.signalTask();
99+
int executeConnectionError = 0;
99100

100-
while (!waitTask.isRemove()){
101-
try {
102-
Thread.sleep(1);
103-
} catch (InterruptedException e) {
104-
e.printStackTrace();
105-
}
106-
}
101+
//控制本地事务的数据提交
102+
final TxTask waitTask = TaskGroupManager.getInstance().getTask(groupId, type);
103+
if(waitTask!=null){
104+
waitTask.setState(lastState);
105+
waitTask.signalTask();
107106

108-
if(waitTask.getState()== TaskState.connectionError.getCode()){
109-
//本地执行失败.
110-
executeConnectionError = 1;
111-
112-
lastState = 0;
107+
while (!waitTask.isRemove()){
108+
try {
109+
Thread.sleep(1);
110+
} catch (InterruptedException e) {
111+
e.printStackTrace();
113112
}
114113
}
115114

115+
if(waitTask.getState()== TaskState.connectionError.getCode()){
116+
//本地执行失败.
117+
executeConnectionError = 1;
116118

117-
if (compensateLocal == null) {
118-
long end = System.currentTimeMillis();
119-
long time = end - start;
120-
if (executeConnectionError == 1||(lastState == 1 && rs == 0)) {
121-
//记录补偿日志
122-
txManagerService.sendCompensateMsg(groupId, time, info,executeConnectionError);
123-
}
119+
lastState = 0;
124120
}
121+
}
125122

126-
task.setState(lastState);
127-
task.signalTask();
123+
if (compensateLocal == null) {
124+
long end = System.currentTimeMillis();
125+
long time = end - start;
126+
if (executeConnectionError == 1||(lastState == 1 && rs == 0)) {
127+
//记录补偿日志
128+
txManagerService.sendCompensateMsg(groupId, time, info,executeConnectionError);
129+
}
128130
}
131+
132+
task.setState(lastState);
133+
task.signalTask();
129134
}
135+
130136
}).start();
131137

132138
task.awaitTask();
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
3+
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
4+
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
5+
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
6+
* Vestibulum commodo. Ut rhoncus gravida arcu.
7+
*/
8+
9+
package com.codingapi.tx.framework.utils;
10+
11+
import java.net.InetAddress;
12+
import java.net.UnknownHostException;
13+
import java.util.regex.Matcher;
14+
import java.util.regex.Pattern;
15+
16+
/**
17+
* create by lorne on 2017/12/12
18+
*/
19+
public class IpAddressUtils {
20+
21+
22+
public static boolean isIpAddress(String ipAddress){
23+
String ipAddressRegex = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}:([0-9]|[1-9]\\d{1,3}|[1-5]\\d{4}|6[0-5][0-9][0-3][0-5])";
24+
Pattern ipAddressPattern = Pattern.compile(ipAddressRegex);
25+
Matcher matcher = ipAddressPattern.matcher(ipAddress);
26+
return matcher.matches();
27+
}
28+
29+
public static boolean isIpFormat(String ipAddress){
30+
return ipAddress.contains(":");
31+
}
32+
33+
public static String getIpByDomain(String domain){
34+
InetAddress ip= null;
35+
try {
36+
ip = InetAddress.getByName(domain);
37+
} catch (UnknownHostException e) {
38+
return null;
39+
}
40+
return ip.getHostAddress();
41+
}
42+
43+
44+
public static boolean isIp(String ipString) {
45+
String ipRegex = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}";
46+
Pattern pattern = Pattern.compile(ipRegex);
47+
Matcher matcher = pattern.matcher(ipString);
48+
return matcher.matches();
49+
}
50+
51+
52+
}

tx-client/src/main/java/com/codingapi/tx/netty/service/impl/NettyControlServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.codingapi.tx.netty.service.MQTxManagerService;
88
import com.codingapi.tx.netty.service.NettyControlService;
99
import com.codingapi.tx.netty.service.NettyService;
10-
import com.codingapi.tx.netty.utils.IpAddressUtils;
10+
import com.codingapi.tx.framework.utils.IpAddressUtils;
1111
import com.lorne.core.framework.utils.task.ConditionUtils;
1212
import com.lorne.core.framework.utils.task.IBack;
1313
import com.lorne.core.framework.utils.task.Task;

tx-client/src/main/java/com/codingapi/tx/netty/service/impl/NettyServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public void initChannel(SocketChannel ch) throws Exception {
7979
ch.pipeline().addLast(new LengthFieldPrepender(4, false));
8080
ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4));
8181

82+
8283
ch.pipeline().addLast(transactionHandler);
8384
}
8485
});

tx-client/src/main/java/com/codingapi/tx/netty/utils/IpAddressUtils.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)