Java Distributed Lock Practice for Beginners
This article covers usage only, no theory. Simple and straightforward. A distributed lock is, as the name suggests, a lock for distributed systems, used in scenarios where multiple instances need coordination. For example, if a service is deployed on multiple machines and may operate on the same record in a database, a distributed lock becomes necessary. There are many ways to implement distributed locks. Generally, a lock requires an entity to represent it — when acquiring the lock, this ent...
LeetCode Problem 3: Longest Substring Without Repeating Characters
ProblemGiven a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “b”, with the length of 1. Given “pwwkew”, the answer is “wke”, with the length of 3. Note that the answer must be a substring, “pwke” is a subsequence and not a substring. In other words, given a string, output the length of the longest substring without repeating characters. ApproachThe problem can ...
Investigating a Kafka Disk Usage Spike: Data Compression, Batch Sending, and More
The ProblemOur company needs to receive a large amount of external data from various sources, including IBM MQ, ActiveMQ, Redis pub/sub, and more. To funnel all this data into our internal AMQ/Kafka, we previously ran a large number of separate processes, which were quite complex to manage. Recently, we consolidated these processes using Apache Camel. A few hours after deployment, Kafka disk space alerts started firing. We initially determined that this was caused by the new deploym...
The Magic of 128 in Java: Understanding Integer Caching
The Integer class is essentially just an ordinary Java class — even if the values are the same, they are different objects. For example: Integer a = <span class="hljs-number">148</span>; Integer b = <span class="hljs-number">148</span>; System.out.println(a==b);` The output here is false. Easy to understand. However, if you change the value to a number below 128, such as 48: <pre class="prettyprint">` ...
Storm/JStorm Ecosystem and Peripheral Tools: Connecting Storm to ActiveMQ, Kafka, HDFS and More
Storm has a very rich surrounding ecosystem. There are ready-made toolkits available for interacting with Kafka, ActiveMQ, HDFS, HBase, and others. Most of these tools, including those introduced today, can also be used normally in JStorm. storm-jmsImplements interaction with JMS implementations such as ActiveMQ. Here we mainly introduce JmsSpout. Since sending queue data in Storm is no different from regular Java programs, wrapping it in a dedicated bolt seems unnecessary. https://github.com...
JStorm UI Introduction
UI OverviewCompared to Storm, JStorm’s UI provides more detailed monitoring items. The UI itself is a WAR package running in Tomcat, making secondary development relatively easy. Cluster PageCluster Summary, Cluster Stats, Topology SummaryOverall cluster information. The conf section contains the configuration of the nimbus node. Topology SummaryA list of all currently running topologies along with summary information. The conf section corresponds to topology-specific configuration items. Sup...
Five Minutes to Learn Storm Coding: JStorm/Storm Coding Principles and Differences from Regular Java Programs
Runtime MechanismThe overall structure of spout/bolt in a topology won’t be discussed in detail here. The focus is on the potential differences between Storm/JStorm topology runtime and traditional Java programs. In fact, there are very few differences, mainly体现在 initialization. The purpose of this article is to help developers troubleshoot potential topology program issues without needing to understand Storm’s internal principles. A topology contains multiple spout threads and bolt...
ActiveMQ Web Console Security Configuration
ActiveMQ’s web console is built on Jetty, and its permission management is also based on Jetty. Based on requirements, different permissions can be assigned to different users. Jetty’s permission management is fairly flexible, though it can be a bit cumbersome to configure. You can specify whether a particular role (role) has access to a specific page. Below is a brief introduction to the configuration method. You only need to modify the following files under /conf: jetty.xml and jetty-realm....
Understanding Key Properties in Storm UI
Storm UI is very helpful for troubleshooting issues encountered during Storm usage, but some properties have unclear meanings. Although they are all simple concepts, not knowing them can be quite frustrating. One thing to note: when you hover over the title bar in the UI, you can see the specific details of that property. Several highly-ranked Google articles are essentially just organizing this information. Most properties are straightforward — you know what they mean just by seeing the name...
ActiveMQ 5.6 Connection Pool Memory Leak Issue
Recently, while using ActiveMQ’s connection pool, I discovered a very serious memory leak issue. Through jmap monitoring, it can be seen that java.util.concurrent.locks.ReentrantLock and org.apache.activemq.pool.PooledConnection occupy a very large amount of memory, and the growth rate is also very fast. After searching online, I found exactly the corresponding ActiveMQ bug report: https://issues.apache.org/jira/browse/AMQ-3997 This bug has been fixed in version 5.7, so it can be resolved by ...