Skip to content

Commit 803f45f

Browse files
committed
NTA-89: Add a keyword filter
https://issues.jboss.org/browse/NTA-89
1 parent 82d8e76 commit 803f45f

38 files changed

+615
-242
lines changed

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ To build the `Transaction Analyser` from source you need Maven 3.0.0+ installed
2323

2424
## Download and Configure WildFly
2525

26-
Currently the `Transaction Analyser` can work with the WildFly 8.0.0.Final:
26+
Currently the `Transaction Analyser` can work with the WildFly 10.0.0.Final:
2727

28-
wget http://download.jboss.org/wildfly/8.0.0.Final/wildfly-8.0.0.Final.zip
29-
unzip wildfly-8.0.0.Final.zip
30-
export WILDFLY_HOME=/path/to/wildfly-8.0.0.Final
28+
wget http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.zip
29+
unzip wildfly-10.0.0.Final.zip
30+
export WILDFLY_HOME=/path/to/wildfly-10.0.0.Final.zip
3131

32+
## Run Wildfly
3233

34+
cd $WILDFLY_HOME/bin
35+
./standalone.sh -c standalone-full.xml
3336

34-
## Deploy to WildFLy
37+
## Deploy to WildFly
3538
To run the `Transaction Analyzer` you just need to deploy the ear file to WildFly and visit the console. To do this:
3639

37-
cp nta-dist/target/nta-1.0.0.Alpha2-SNAPSHOT.ear $WILDFLY_HOME/standalone/deployments
40+
cp nta-dist/target/nta-1.0.0.Alpha3-SNAPSHOT.ear $WILDFLY_HOME/standalone/deployments
3841

3942
Then visit: http://localhost:8080/nta/. By default the `Transaction Analyser` is disabled. To enable it click on the 'start' button at the top-right
4043
of the console's home page. Similarly, you can stop it by clicking the 'stop' button.
@@ -43,7 +46,7 @@ of the console's home page. Similarly, you can stop it by clicking the 'stop' bu
4346
## Running the Demo Application
4447
The demo application provides a simple way to play with this tool if you don't have an application with failing transactions to hand. To deploy it:
4548

46-
cp demo/target/nta-demo-1.0.0.Alpha2-SNAPSHOT.war $WILDFLY_HOME/standalone/deployments
49+
cp demo/target/nta-demo-1.0.0.Alpha3-SNAPSHOT.war $WILDFLY_HOME/standalone/deployments
4750

4851
The demo is now available at http://localhost:8080/txdemo. To use the demo, simply click on the button for the scenario you want to run. When the scenario
4952
completes you will be notified of the outcome from the transaction. For most scenarios you will get an error message returned. This is to be expected

core/pom.xml

+6-33
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<parent>
3030
<artifactId>nta-all</artifactId>
3131
<groupId>io.narayana.nta</groupId>
32-
<version>1.0.0.Alpha2-SNAPSHOT</version>
32+
<version>1.0.0.Alpha3-SNAPSHOT</version>
3333
</parent>
3434

3535
<artifactId>core</artifactId>
@@ -50,31 +50,10 @@
5050
</snapshotRepository>
5151
</distributionManagement>
5252

53-
<dependencyManagement>
54-
<dependencies>
55-
<dependency>
56-
<groupId>org.jboss.shrinkwrap.resolver</groupId>
57-
<artifactId>shrinkwrap-resolver-bom</artifactId>
58-
<version>2.0.0-beta-1</version>
59-
<scope>import</scope>
60-
<type>pom</type>
61-
</dependency>
62-
63-
<dependency>
64-
<groupId>org.jboss.bom</groupId>
65-
<artifactId>jboss-javaee-6.0-with-tools</artifactId>
66-
<version>1.0.0.Final</version>
67-
<type>pom</type>
68-
<scope>import</scope>
69-
</dependency>
70-
</dependencies>
71-
</dependencyManagement>
72-
7353
<dependencies>
7454
<dependency>
7555
<groupId>org.jboss.shrinkwrap.resolver</groupId>
7656
<artifactId>shrinkwrap-resolver-api</artifactId>
77-
<version>2.0.0-beta-1</version>
7857
<scope>test</scope>
7958
</dependency>
8059

@@ -93,34 +72,31 @@
9372
<dependency>
9473
<groupId>org.jboss.shrinkwrap.resolver</groupId>
9574
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
96-
<version>2.0.0-beta-1</version>
9775
<scope>test</scope>
9876
</dependency>
9977

10078
<dependency>
10179
<groupId>org.jboss.shrinkwrap.resolver</groupId>
10280
<artifactId>shrinkwrap-resolver-api-maven</artifactId>
103-
<version>2.0.0-beta-1</version>
10481
<scope>test</scope>
10582
</dependency>
10683

10784
<dependency>
10885
<groupId>org.hibernate</groupId>
10986
<artifactId>hibernate-annotations</artifactId>
110-
<version>3.5.6-Final</version>
11187
<scope>provided</scope>
11288
</dependency>
89+
11390
<dependency>
11491
<groupId>org.jboss.narayana.jta</groupId>
11592
<artifactId>narayana-jta</artifactId>
116-
<version>5.0.0.M2</version>
11793
<scope>provided</scope>
11894
</dependency>
95+
11996
<dependency>
12097
<groupId>org.jboss.spec.javax.transaction</groupId>
12198
<artifactId>jboss-transaction-api_1.1_spec</artifactId>
12299
<scope>provided</scope>
123-
<version>1.0.1.Final</version>
124100
</dependency>
125101

126102
<dependency>
@@ -145,22 +121,19 @@
145121
<dependency>
146122
<groupId>commons-io</groupId>
147123
<artifactId>commons-io</artifactId>
148-
<version>2.5-SNAPSHOT</version>
149124
<scope>system</scope>
150125
<systemPath>${basedir}/../etc/lib/commons-io-2.5-SNAPSHOT.jar</systemPath>
151126
</dependency>
152127

153128
<dependency>
154129
<groupId>log4j</groupId>
155130
<artifactId>log4j</artifactId>
156-
<version>1.2.17</version>
157131
<scope>provided</scope>
158132
</dependency>
159133

160134
<dependency>
161135
<groupId>org.jboss.arquillian.junit</groupId>
162136
<artifactId>arquillian-junit-container</artifactId>
163-
<version>1.0.3.Final</version>
164137
<scope>test</scope>
165138
</dependency>
166139
</dependencies>
@@ -179,7 +152,7 @@
179152
<plugin>
180153
<groupId>org.apache.maven.plugins</groupId>
181154
<artifactId>maven-jar-plugin</artifactId>
182-
<version>2.3.1</version>
155+
<version>${maven.plugins}</version>
183156
<configuration>
184157
<archive>
185158
<manifestEntries>
@@ -210,7 +183,7 @@
210183
<dependency>
211184
<groupId>org.wildfly</groupId>
212185
<artifactId>wildfly-arquillian-container-remote</artifactId>
213-
<version>8.0.0.Final</version>
186+
<version>${version.wildfly}</version>
214187
<scope>test</scope>
215188
</dependency>
216189
</dependencies>
@@ -233,7 +206,7 @@
233206
<dependency>
234207
<groupId>org.jboss.as</groupId>
235208
<artifactId>jboss-as-arquillian-container-remote</artifactId>
236-
<version>7.3.0.Final-redhat-SNAPSHOT</version>
209+
<version>${jboos.as}</version>
237210
<scope>test</scope>
238211
</dependency>
239212
</dependencies>

core/src/main/java/io/narayana/nta/Configuration.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
package io.narayana.nta;
2424

25+
import io.narayana.nta.logparsing.as8.filters.KeywordFilter;
2526
import io.narayana.nta.logparsing.as8.filters.PackageFilter;
27+
import io.narayana.nta.logparsing.as8.filters.KeywordFilter;
2628
import io.narayana.nta.logparsing.as8.handlers.*;
2729

2830
import java.io.File;
@@ -54,7 +56,7 @@ public final class Configuration {
5456
/**
5557
*
5658
*/
57-
public static final int DEFAULT_ITEMS_PER_PAGE = 7;
59+
public static final int DEFAULT_ITEMS_PER_PAGE = 50;
5860
/**
5961
*
6062
*/
@@ -64,6 +66,7 @@ public final class Configuration {
6466
*/
6567
public static final Class[] LOG_HANDLERS = new Class[]{
6668
BasicActionHandler.class,
69+
JCAEnlistResourceHandler.class,
6770
JTACreateResourceRecordHandler.class,
6871
JTAResourceExceptionHandler.class,
6972
JTAResourceRecordHandler.class,
@@ -79,6 +82,7 @@ public final class Configuration {
7982

8083
public static final Class[] LOG_FILTERS = new Class[]{
8184
PackageFilter.class,
85+
KeywordFilter.class,
8286
};
8387

8488
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package io.narayana.nta.logparsing.as8.filters;
2+
3+
import org.apache.log4j.Logger;
4+
5+
import java.io.FileNotFoundException;
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
import java.util.Properties;
11+
12+
public class GetFilterKeywords {
13+
private List<String> filterKeywords;
14+
private static final Logger logger = Logger.getLogger(GetFilterKeywords.class.getName());
15+
16+
private static class GetFilterKeywordsHolder {
17+
private static final GetFilterKeywords INSTANCE = new GetFilterKeywords();
18+
}
19+
20+
public static final GetFilterKeywords getInstance() {
21+
return GetFilterKeywordsHolder.INSTANCE;
22+
}
23+
24+
private GetFilterKeywords() {
25+
InputStream inputStream = null;
26+
try {
27+
Properties prop = new Properties();
28+
filterKeywords = new ArrayList<>();
29+
30+
String propFileName = "filter.properties";
31+
logger.warn(getClass().getClassLoader().getResource());
32+
inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
33+
if (inputStream != null) {
34+
prop.load(inputStream);
35+
} else {
36+
throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
37+
}
38+
39+
for (String name : prop.stringPropertyNames()) {
40+
if (name.contains("keywords"))
41+
filterKeywords.add(prop.getProperty(name));
42+
}
43+
} catch (Exception e) {
44+
e.printStackTrace();
45+
} finally {
46+
try {
47+
inputStream.close();
48+
} catch (IOException ignored) {
49+
}
50+
}
51+
}
52+
53+
public List<String> getFilterKeywords() {
54+
return filterKeywords;
55+
}
56+
}
57+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* JBoss, Home of Professional Open Source.
3+
* Copyright 2016, Red Hat, Inc., and individual contributors
4+
* as indicated by the @author tags. See the copyright.txt file in the
5+
* distribution for a full listing of individual contributors.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
*/
22+
23+
package io.narayana.nta.logparsing.as8.filters;
24+
25+
import io.narayana.nta.logparsing.common.Filter;
26+
27+
import java.util.List;
28+
29+
/**
30+
* @author huyuan
31+
*/
32+
public class KeywordFilter implements Filter {
33+
34+
35+
@Override
36+
public boolean matches(String line) throws IndexOutOfBoundsException {
37+
38+
List<String> keywordList = GetFilterKeywords.getInstance().getFilterKeywords();
39+
40+
try {
41+
for (String s : keywordList) {
42+
if (line.contains(s)) { // if black list use !line.contains(s)
43+
return true;
44+
}
45+
}
46+
return false;
47+
} catch (IndexOutOfBoundsException e) {
48+
return false;
49+
}
50+
}
51+
}

core/src/main/java/io/narayana/nta/logparsing/as8/filters/PackageFilter.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@
3232
public class PackageFilter implements Filter {
3333

3434
public static final String PACKAGE_ARJUNA = "com.arjuna";
35+
public static final String PACKAGE_JCA = "org.jboss.jca";
3536

3637

3738
@Override
3839
public boolean matches(String line) {
3940

4041
try {
4142
final int startPos = line.indexOf('[') + 1;
42-
return !PACKAGE_ARJUNA.equals(line.substring(startPos, startPos + 10));
43+
if(startPos == 0) {
44+
return false;
45+
}
46+
return !PACKAGE_ARJUNA.equals(line.substring(startPos, startPos + PACKAGE_ARJUNA.length())) &&
47+
!PACKAGE_JCA.equals(line.substring(startPos, startPos + PACKAGE_JCA.length()));
4348
} catch (IndexOutOfBoundsException e) {
4449
return false;
4550
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* JBoss, Home of Professional Open Source.
3+
* Copyright (c) 2011, Red Hat, Inc., and individual contributors
4+
* as indicated by the @author tags. See the copyright.txt file in the
5+
* distribution for a full listing of individual contributors.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
*/
22+
package io.narayana.nta.logparsing.as8.handlers;
23+
24+
import java.util.regex.Matcher;
25+
26+
/**
27+
* @author <a href="mailto:[email protected]">Amos Feng</a>
28+
*/
29+
public class JCAEnlistResourceHandler extends JbossAS8AbstractHandler {
30+
public static final String REGEX = "Enlisted resource.*?xaResource=LocalXAResourceImpl.*?" + "tx_uid=" + PATTERN_TXUID +
31+
".*?branch_uid=" + PATTERN_BRANCHUID + ".*?eis_name=" + PATTERN_EISNAME +
32+
".*?productName=(?<" + RM_PRODUCT_NAME + ">.*?)\\sproductVersion=(?<" + RM_PRODUCT_VERSION + ">.*?)" +
33+
"\\sjndiName=(?<" + RM_JNDI_NAME + ">java:[\\w/]+)\\].*";
34+
35+
public JCAEnlistResourceHandler() {
36+
super(REGEX);
37+
}
38+
39+
40+
@Override
41+
public void handle(Matcher matcher, String line) {
42+
43+
service.enlistResourceManagerJTA(matcher.group(TXUID), matcher.group(BRANCHUID), matcher.group(RM_JNDI_NAME), matcher.group(RM_PRODUCT_NAME),
44+
matcher.group(RM_PRODUCT_VERSION), matcher.group(EISNAME), parseTimestamp(matcher.group(TIMESTAMP)), matcher.group(TXUID) + ":" + LAST_RESOURCE_ID);
45+
}
46+
}

core/src/main/java/io/narayana/nta/logparsing/as8/handlers/JTACreateResourceRecordHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class JTACreateResourceRecordHandler extends JbossAS8AbstractHandler {
3535
/**
3636
*
3737
*/
38-
public static final String REGEX = "XAResourceRecord\\.XAResourceRecord.*?" + "tx_uid=" + PATTERN_TXUID + ".*?" + PATTERN_XARESOURCEWRAPPERIMPL + "\\] \\), record id=" + PATTERN_RESOURCE_UID;
38+
public static final String REGEX = "XAResourceRecord\\.XAResourceRecord.*?" + "tx_uid=" + PATTERN_TXUID + ".*?branch_uid=" + PATTERN_BRANCHUID + ".*?eis_name=" + PATTERN_EISNAME + ".*?(" + PATTERN_XARESOURCEWRAPPERIMPL + ")?\\] \\), record id=" + PATTERN_RESOURCE_UID + "$";
3939

4040
public static final String LINE = "XAResourceRecord.XAResourceRecord ( < formatId=131077, gtrid_length=29, " +
4141
"bqual_length=36, tx_uid=0:ffff7f000001:-3713c968:5243fb29:25, node_name=1, branch_uid=0:ffff7f000001:-3713c968:5243fb29:2c, " +
@@ -57,8 +57,8 @@ public JTACreateResourceRecordHandler() {
5757
@Override
5858
public void handle(Matcher matcher, String line) {
5959

60-
service.enlistResourceManagerJTA(matcher.group(TXUID), matcher.group(RM_JNDI_NAME), matcher.group(RM_PRODUCT_NAME),
61-
matcher.group(RM_PRODUCT_VERSION), parseTimestamp(matcher.group(TIMESTAMP)), matcher.group(RESUID));
60+
service.enlistResourceManagerJTA(matcher.group(TXUID), matcher.group(BRANCHUID), matcher.group(RM_JNDI_NAME), matcher.group(RM_PRODUCT_NAME),
61+
matcher.group(RM_PRODUCT_VERSION), matcher.group(EISNAME), parseTimestamp(matcher.group(TIMESTAMP)), matcher.group(RESUID));
6262
}
6363

6464
public static void main(String[] args) {

0 commit comments

Comments
 (0)