kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 8ed9f031ec202d9b3493d86d4ebbd3e0d4e4abbe633d225d3e9ead3b7e018b38 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2016-09-12 13:57 -07:00 |
| Committer | GitHub <noreply@github.com> · 2016-09-12 13:57 -07:00 |
| Parents | 06afebc26b36 |
3 files changed
modified changelog/README.md +1 −0
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | - [bug] JAVA-1258: Regression: Mapper cannot map a materialized view after JAVA-1126. |
| 8 | 8 | - [bug] JAVA-1101: Batch and BatchStatement should consider inner statements to determine query idempotence |
| 9 | 9 | - [improvement] JAVA-1262: Use ParseUtils for quoting & unquoting. |
| 10 | +- [improvement] JAVA-1275: Use Netty's default thread factory | |
| 10 | 11 | |
| 11 | 12 | |
| 12 | 13 | ### 3.0.3 |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +9 −1
| @@ -25,6 +25,7 @@ | ||
| 25 | 25 | import com.google.common.base.Throwables; |
| 26 | 26 | import com.google.common.collect.*; |
| 27 | 27 | import com.google.common.util.concurrent.*; |
| 28 | +import io.netty.util.concurrent.DefaultThreadFactory; | |
| 28 | 29 | import org.slf4j.Logger; |
| 29 | 30 | import org.slf4j.LoggerFactory; |
| 30 | 31 | |
| @@ -1515,7 +1516,14 @@ | ||
| 1515 | 1516 | } |
| 1516 | 1517 | |
| 1517 | 1518 | ThreadFactory threadFactory(String name) { |
| 1518 | - return new ThreadFactoryBuilder().setNameFormat(clusterName + "-" + name + "-%d").build(); | |
| 1519 | + return new ThreadFactoryBuilder() | |
| 1520 | + .setNameFormat(clusterName + "-" + name + "-%d") | |
| 1521 | + // Back with Netty's thread factory in order to create FastThreadLocalThread instances. This allows | |
| 1522 | + // an optimization around ThreadLocals (we could use DefaultThreadFactory directly but it creates | |
| 1523 | + // slightly different thread names, so keep we keep a ThreadFactoryBuilder wrapper for backward | |
| 1524 | + // compatibility). | |
| 1525 | + .setThreadFactory(new DefaultThreadFactory("ignored name")) | |
| 1526 | + .build(); | |
| 1519 | 1527 | } |
| 1520 | 1528 | |
| 1521 | 1529 | private ListeningExecutorService makeExecutor(int threads, String name, LinkedBlockingQueue<Runnable> workQueue) { |
modified driver-core/src/main/java/com/datastax/driver/core/NettyOptions.java +8 −2
| @@ -89,7 +89,10 @@ | ||
| 89 | 89 | * |
| 90 | 90 | * @param threadFactory The {@link ThreadFactory} to use when creating a new {@code EventLoopGroup} instance; |
| 91 | 91 | * The driver will provide its own internal thread factory here. |
| 92 | - * It is safe to ignore it and use another thread factory. | |
| 92 | + * It is safe to ignore it and use another thread factory. Note however that for optimal | |
| 93 | + * performance it is recommended to use a factory that returns | |
| 94 | + * {@link io.netty.util.concurrent.FastThreadLocalThread} instances (such as Netty's | |
| 95 | + * {@link java.util.concurrent.Executors.DefaultThreadFactory}). | |
| 93 | 96 | * @return the {@code EventLoopGroup} instance to use. |
| 94 | 97 | */ |
| 95 | 98 | public EventLoopGroup eventLoopGroup(ThreadFactory threadFactory) { |
| @@ -205,7 +208,10 @@ | ||
| 205 | 208 | * |
| 206 | 209 | * @param threadFactory The {@link ThreadFactory} to use when creating a new {@link HashedWheelTimer} instance; |
| 207 | 210 | * The driver will provide its own internal thread factory here. |
| 208 | - * It is safe to ignore it and use another thread factory. | |
| 211 | + * It is safe to ignore it and use another thread factory. Note however that for optimal | |
| 212 | + * performance it is recommended to use a factory that returns | |
| 213 | + * {@link io.netty.util.concurrent.FastThreadLocalThread} instances (such as Netty's | |
| 214 | + * {@link java.util.concurrent.Executors.DefaultThreadFactory}). | |
| 209 | 215 | * @return the {@link Timer} instance to use. |
| 210 | 216 | */ |
| 211 | 217 | public Timer timer(ThreadFactory threadFactory) { |