Firefly v3.0.4 is released

14 Dec 2014, Alvin Qiu

Firefly v3.0.4 optimized the asynchronous log performance and added some new JSON APIs, AIO network frameworks, and ALPN (Application Layer Protocol Negotiation) support. Now, firefly changed the JDK dependency to JDK7. Firefly v3.0.4 takes advantage of JDK7 provides brand new asynchronous I/O and j.u.c APIs to enhance the performance.

Firefly v3.0.4 provides the unified abstract layer for NIO and AIO. You don’t need modify your program when you change NIO to AIO. Below picture is the architecture diagram of firefly network framework:

network framework

In addition, the network framework adds ALPN (Application Layer Protocol Negotiation) support of SSL. The examples of server and client which enable SSL with ALPN are in test.net.ssl.SSLClientDemo and test.net.ssl.SSLServerDemo. Before you run these examples, you must enable ALPN support, start the JVM as follows:

java -Xbootclasspath/p:<path_to_alpn_boot_jar> ...

where path_to_alpn_boot_jar is the path on the file system for the ALPN Boot Jar file, for example, one at the Maven coordinates org.mortbay.jetty.alpn:alpn-boot.

The ALPN implementation, relying on modifications of OpenJDK classes, updates every time there are updates to the modified OpenJDK classes.

OpenJDK versionALPN version
1.7.0u407.1.0.v20141016
1.7.0u457.1.0.v20141016
1.7.0u517.1.0.v20141016
1.7.0u557.1.0.v20141016
1.7.0u607.1.0.v20141016
1.7.0u657.1.0.v20141016
1.7.0u677.1.0.v20141016
1.7.0u717.1.2.v20141202
1.7.0u727.1.2.v20141202
1.8.08.1.0.v20141016
1.8.0u058.1.0.v20141016
1.8.0u118.1.0.v20141016
1.8.0u208.1.0.v20141016
1.8.0u208.1.0.v20141016
1.8.0u258.1.2.v20141202

More ALPN details, please see the the eclipse ALPN document.

Another important update of Firefly v3.0.4 is some new JSON parsing APIs that can parse a JSON string and return a JsonObject or JsonArray instance without object binding. Such as:

String json = "[333,444,{\"key\" : \"hello\", \"keyObject\" : [\"object0\",\"object1\"  ]},666]";
JsonArray array = Json.toJsonArray(json);

Assert.assertThat(array.getJsonObject(2).getJsonArray("keyObject").getString(0), is("object0"));
Assert.assertThat(array.getJsonObject(2).getJsonArray("keyObject").getString(1), is("object1"));

json = "{\"key1\":333, \"arrayKey\":[444, \"array\"], \"key2\" : {\"key3\" : \"hello\", \"key4\":\"world\" }, \"booleanKey\" : true } ";
JsonObject jsonObject = Json.toJsonObject(json);
Assert.assertThat(jsonObject.getJsonArray("arrayKey").getString(1), is("array"));

These methods are more convenient than the toObject(String json, Class<T> clazz) method, although the object binding API has the higher performance.

Update log:

  1. Improve the asynchronous log performance.
  2. Add AIO network framework.
  3. Add ALPN support of SSL.
  4. Add some new JSON APIs.
  5. use the new j.u.c APIs of JDK7 to enhance the performance of Firefly.