Skip to content

Commit e2ac2c8

Browse files
authored
Tick tock fix (#5)
Fix tick-tock handler
1 parent 91c3bc1 commit e2ac2c8

File tree

19 files changed

+311
-33
lines changed

19 files changed

+311
-33
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
- Add tests.
1717
- Rething caches in terms and modules.
1818
- Add lazy deserialization for terms.
19+
- Add `UDP`/`SCTP` protocols support.
20+
- Rethink handshake implementation design.
21+
- Add handshake error handling (exceptions? error logs?).
22+
- Turn on checkstyle JavaDocs module.
23+
- Add updates to the protocol, like new `ControlMessage`.
24+
25+
## [1.3.1](https://github.com/appulse-projects/encon-java/releases/tag/1.3.1) - 2018-06-28
26+
27+
Fix short node name host detection.
1928

2029
## [1.3.0](https://github.com/appulse-projects/encon-java/releases/tag/1.3.0) - 2018-06-28
2130

encon-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525
<parent>
2626
<groupId>io.appulse.encon</groupId>
2727
<artifactId>encon-parent</artifactId>
28-
<version>1.3.0</version>
28+
<version>1.3.1</version>
2929
</parent>
3030

3131
<artifactId>encon-common</artifactId>

encon-common/src/main/java/io/appulse/encon/common/NodeDescriptor.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public class NodeDescriptor implements Serializable {
6565

6666
private static final InetAddress LOOPBACK;
6767

68-
private static final String HOST_NAME;
68+
private static final String LONG_HOST_NAME;
69+
70+
private static final String SHORT_HOST_NAME;
6971

7072
static {
7173
try {
@@ -74,7 +76,11 @@ public class NodeDescriptor implements Serializable {
7476
throw new RuntimeException(ex);
7577
}
7678
LOOPBACK = InetAddress.getLoopbackAddress();
77-
HOST_NAME = LOCALHOST.getHostName();
79+
LONG_HOST_NAME = LOCALHOST.getHostName();
80+
val dotIndex = LONG_HOST_NAME.indexOf('.');
81+
SHORT_HOST_NAME = dotIndex > 0
82+
? LONG_HOST_NAME.substring(dotIndex)
83+
: LONG_HOST_NAME;
7884
NODE_DESCRIPTOR_CACHE = new ConcurrentHashMap<>();
7985
}
8086

@@ -216,16 +222,14 @@ private static NodeDescriptor parse (@NonNull String node, boolean isShortName)
216222
hostName);
217223
throw new IllegalArgumentException(message);
218224
}
219-
address = InetAddress.getByName(hostName);
225+
address = isShortName
226+
? LOOPBACK
227+
: InetAddress.getByName(hostName);
220228
} else if (isShortName) {
221-
val dotIndex = HOST_NAME.indexOf('.');
222-
hostName = dotIndex > 0
223-
? HOST_NAME.substring(dotIndex)
224-
: HOST_NAME;
225-
229+
hostName = SHORT_HOST_NAME;
226230
address = LOOPBACK;
227231
} else {
228-
hostName = HOST_NAME;
232+
hostName = LONG_HOST_NAME;
229233
address = LOCALHOST;
230234
}
231235

encon-config/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ First of all, add config's dependency:
1414
<dependency>
1515
<groupId>io.appulse.encon</groupId>
1616
<artifactId>encon-config</artifactId>
17-
<version>1.3.0</version>
17+
<version>1.3.1</version>
1818
</dependency>
1919
...
2020
</dependencies>
@@ -23,7 +23,7 @@ First of all, add config's dependency:
2323
**Gradle**:
2424

2525
```groovy
26-
compile 'io.appulse.encon.java:encon-config:1.3.0'
26+
compile 'io.appulse.encon.java:encon-config:1.3.1'
2727
```
2828

2929
### File based configuration

encon-config/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525
<parent>
2626
<groupId>io.appulse.encon</groupId>
2727
<artifactId>encon-parent</artifactId>
28-
<version>1.3.0</version>
28+
<version>1.3.1</version>
2929
</parent>
3030

3131
<artifactId>encon-config</artifactId>

encon-databind/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ First of all, add databind's dependency:
1414
<dependency>
1515
<groupId>io.appulse.encon</groupId>
1616
<artifactId>encon-databind</artifactId>
17-
<version>1.3.0</version>
17+
<version>1.3.1</version>
1818
</dependency>
1919
...
2020
</dependencies>
@@ -23,7 +23,7 @@ First of all, add databind's dependency:
2323
**Gradle**:
2424

2525
```groovy
26-
compile 'io.appulse.encon.java:encon-databind:1.3.0'
26+
compile 'io.appulse.encon.java:encon-databind:1.3.1'
2727
```
2828

2929
Let's imagine, you have POJO like this:

encon-databind/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525
<parent>
2626
<groupId>io.appulse.encon</groupId>
2727
<artifactId>encon-parent</artifactId>
28-
<version>1.3.0</version>
28+
<version>1.3.1</version>
2929
</parent>
3030

3131
<artifactId>encon-databind</artifactId>

encon-spring/pom.xml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Copyright 2018 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>io.appulse.encon</groupId>
27+
<artifactId>encon-parent</artifactId>
28+
<version>1.1.0</version>
29+
</parent>
30+
31+
<artifactId>encon-spring</artifactId>
32+
<packaging>jar</packaging>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.projectlombok</groupId>
37+
<artifactId>lombok</artifactId>
38+
<scope>provided</scope>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>${project.groupId}</groupId>
43+
<artifactId>encon</artifactId>
44+
<version>${project.version}</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.google.code.findbugs</groupId>
49+
<artifactId>annotations</artifactId>
50+
<scope>provided</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>com.google.code.findbugs</groupId>
54+
<artifactId>jsr305</artifactId>
55+
<scope>provided</scope>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>io.netty</groupId>
60+
<artifactId>netty-all</artifactId>
61+
<scope>provided</scope>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>junit</groupId>
66+
<artifactId>junit</artifactId>
67+
<scope>test</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.assertj</groupId>
71+
<artifactId>assertj-core</artifactId>
72+
<scope>test</scope>
73+
</dependency>
74+
</dependencies>
75+
76+
<build>
77+
<plugins>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-source-plugin</artifactId>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-javadoc-plugin</artifactId>
85+
</plugin>
86+
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-surefire-plugin</artifactId>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-failsafe-plugin</artifactId>
94+
</plugin>
95+
96+
<plugin>
97+
<groupId>org.codehaus.mojo</groupId>
98+
<artifactId>findbugs-maven-plugin</artifactId>
99+
</plugin>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-pmd-plugin</artifactId>
103+
</plugin>
104+
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-checkstyle-plugin</artifactId>
108+
</plugin>
109+
</plugins>
110+
</build>
111+
</project>
112+
113+
</project>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appulse.encon.spring;
18+
19+
import static java.lang.annotation.ElementType.FIELD;
20+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
21+
22+
import java.lang.annotation.Documented;
23+
import java.lang.annotation.Retention;
24+
import java.lang.annotation.Target;
25+
26+
/**
27+
* Indicates that an annotated class is a "Controller" (e.g. a web controller).
28+
*
29+
* <p>This annotation serves as a specialization of {@link Component @Component},
30+
* allowing for implementation classes to be autodetected through classpath scanning.
31+
* It is typically used in combination with annotated handler methods based on the
32+
* {@link org.springframework.web.bind.annotation.RequestMapping} annotation.
33+
*
34+
* @since 1.2.0
35+
* @author Artem Labazin
36+
*
37+
* @see Component
38+
* @see org.springframework.web.bind.annotation.RequestMapping
39+
* @see org.springframework.context.annotation.ClassPathBeanDefinitionScanner
40+
*/
41+
@Component
42+
@Documented
43+
@Target(FIELD)
44+
@Retention(RUNTIME)
45+
public @interface ErlangController {
46+
47+
/**
48+
* The value may indicate a suggestion for a logical component name,
49+
* to be turned into a Spring bean in case of an autodetected component.
50+
* @return the suggested component name, if any
51+
*/
52+
String value() default "";
53+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
3+
@ErlangController
4+
public class MyController {
5+
6+
/**
7+
* Default listener parameters with:
8+
* - default mailbox (primary one)
9+
* - default node (primary bean)
10+
* - no wrapper
11+
*/
12+
@MailboxListener
13+
public void doSome1 (ErlangTerm term) {
14+
// ...
15+
}
16+
17+
/**
18+
* The same as previous, but with custom user POJO
19+
*/
20+
@MailboxListener
21+
public void doSome2 (MyPojo pojo) {
22+
// ...
23+
}
24+
25+
@MailboxListener(
26+
node = "my-node-name", // not default node
27+
mailbox = "the-first-one", // specify mailbox, not default one
28+
wrapper = TUPLE // request wrapper tupe, all args below wraped in this
29+
)
30+
public void doSome3 (@AsEralngAtom String myAtom, Integer age) {
31+
// ...
32+
}
33+
}
34+
35+
@ErlangController
36+
public class MyController {
37+
38+
@MailboxListener
39+
public void doSome1 (@AsErlangAtom String atom) {
40+
System.out.println("hello!");
41+
42+
43+
builder
44+
.case(service).myHandler1(42, anyInt(), anyString())
45+
.case(service).myHandler2(3, anyInt(), anyString())
46+
.case(service).myHandler3(anyInt(), anyInt(), anyString());
47+
48+
builder
49+
.case()
50+
.tuple(int(3), any(), any())
51+
.handler(...)
52+
.case()
53+
.tuple(any(), any(), any())
54+
.handler(...)
55+
.case()
56+
.tuple(int(42), any(), any())
57+
.handler(...);
58+
59+
}
60+
61+
@MailboxListener
62+
public void doSome2 (@Expected("42") Integer age) {
63+
System.out.println("world!");
64+
}
65+
66+
@MailboxListener
67+
public void doSome3 (@Expected("3") Integer age) {
68+
System.out.println("popa");
69+
}
70+
}

0 commit comments

Comments
 (0)