Embedding Hawtio Monitoring in a Standalone Java Application
Hawtio (hawt.io) is an open-source monitoring system that provides multiple startup methods. It can run as a standalone JAR or WAR package and remotely connect to other applications for monitoring, or it can be directly embedded into our own applications. This article introduces how to embed Hawtio in a standalone Java application, corresponding to the official documentation (http://hawt.io/getstarted/index.html) section “Using hawtio inside a stand alone Java application”. However, that se...
Java Serialization Performance Comparison: kryo/protobuf/protostuff vs Json
Why Compare Serialization SolutionsFor serializing a Java object, I wanted to test the differences in time and space performance between using JSON and using general-purpose serialization tools. For JSON, I chose fastjson. For serialization tools, I used protostuff and kryo. Why not protobuf? Because for an existing Java class with hundreds of properties, creating a matching proto file feels somewhat inhumane. Protostuff is an improved version of protobuf — it can directly serialize a Java ...
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
Java’s Integer caching mechanism is a frequently asked interview topic and a common source of pitfalls in daily development. To understand it, let’s start with a counterintuitive experiment. The Curious Case of 1281234567Integer a = 148;Integer b = 148;System.out.println(a == b); // false — as expected, two different objectsInteger c = 48;Integer d = 48;System.out.println(c == d); // true — wait, why? The same == comparison returns false for 148 but true for 48. The reason lies in Intege...
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
Storm (and Alibaba’s open-source fork JStorm) is a distributed real-time computation framework. Its programming model has some key differences from traditional Java programs. If you don’t understand these differences, it’s easy to write code that runs fine locally but produces all sorts of bizarre bugs when deployed to a cluster. This article doesn’t dive deep into Storm’s internals. Instead, it focuses on the few critical differences that developers most need to know — helping you get up to ...
ActiveMQ Web Console Security Configuration
Security Risks of Web ConsoleActiveMQ’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. JAAS Authentication ConfigurationBelow is a brief introduction to the configuration method. You only need to modi...













