dev.net.cn Technical Blog
website·Indexed 31 days ago
https://dev.net.cnA collection of technical guides and tutorials covering a wide range of development topics, including Java 11 LTS, MyBatis, Linux administration (Crontab, RHEL, yum), Node.js process management with PM2, database configuration for Oracle, MySQL, and HBase, and various DevOps tips for Git, Nginx, and Nexus3.
What's inside dev.net.cn
- PM2 is a production process manager for Node.js applications that provides built-in load balancing (via the Node cluster module), background execution, and zero-downtime reloads. It ensures processes stay alive, utilizes all available CPUs, and can manage multiple Node projects simultaneously. Key features include startup scripts for Ubuntu and CentOS, unstable process termination to prevent infinite loops, a console monitor, and a remote control HTTP API.
Overview of OpenClaw
OpenClaw is an open-source, locally deployed AI Agent gateway. Unlike standard LLM interfaces that only answer questions, OpenClaw is designed to give AI the ability to perform actions, such as visiting webpages, running commands, scheduling tasks, connecting to chat channels, and managing sessions.Overview of Spring AI Advisors API
The Advisors API provides a mechanism to intercept, modify, and enhance AI-driven interactions in Spring applications. Advisors act similarly to interceptors, allowing developers to supplement user text with contextual data (such as RAG results) before the request is sent to the AI model.Overview of default Docker network modes
When Docker is installed, it automatically creates three default network types:bridge,host, andnone. You can list all available networks using thedocker network lscommand.docker network lsOverview of LangChain Core Concepts
LangChain is an open-source framework designed to connect Large Language Models (LLMs) like DeepSeek, OpenAI, and Claude with external programs, databases, documents, and APIs to build AI applications and Agents. Key concepts include:
- Model: The LLM being called (e.g.,
gpt-4,deepseek-v4). - Prompt: Instructions provided to the model to guide its output.
- Chain: A sequence of steps (e.g., organize question -> retrieve data -> generate answer).
- Tool: External capabilities the model can invoke, such as web search, API calls, or code execution.
- Agent: An AI assistant that autonomously decides which tools to use and which steps to take to complete a task.
- Retriever: A mechanism to fetch relevant content from documents or vector databases.
- Model: The LLM being called (e.g.,
Understand Gin middleware execution flow
Gin middleware operates on a 'chain of responsibility' or 'onion model'. Middlewares and business handlers are stored as a slice of functions (HandlersChain) in thegin.Context. They are executed sequentially based on an internal index. If a middleware does not callc.Next(), the framework automatically proceeds to the next handler after the current function finishes. Ifc.Next()is called, the framework executes all subsequent handlers first, then returns to execute the remaining code in the current middleware after the stack unwinds.JVM Container Awareness and G1 GC Improvements
Java 10 introduced critical JVM updates for containerized environments:
- Container Awareness: The JVM now correctly recognizes CGroup CPU and memory limits in Docker containers, preventing unexpected OutOfMemoryErrors caused by the JVM seeing the host's physical memory instead of the container's limit.
- Parallel Full GC for G1: The G1 garbage collector (default since Java 9) was optimized in Java 10 to allow Full GC to execute in parallel, significantly reducing pause times for servers with large memory (e.g., 8GB+).
Understand Red-Black Tree properties and constraints
A Red-Black Tree is a self-balancing binary search tree (BST) where each node is colored either red or black. It ensures $O(\log n)$ time complexity by adhering to five strict rules:
- Node Color: Every node is either red or black.
- Root Property: The root node must always be black.
- Leaf Property: All leaf nodes (null pointers) are considered black.
- Red Property: Red nodes cannot be adjacent; a red node cannot have a red child (no consecutive red nodes).
- Black Height Property: Every path from a given node to any of its descendant leaf nodes must contain the same number of black nodes.
Define the boundary between Handler and Service layers
In a layered Go web architecture:
- Handler Layer: Handles protocol-specific tasks (JSON binding, path parameters, response formatting). It depends on the Service layer.
- Service Layer: Handles business rules (creating users, role validation, permission checks). Crucially, the Service layer must not depend on the Gin framework to remain decoupled from the transport layer.
Compare Arrays vs Slices in Go
Understanding the fundamental differences between arrays and slices is critical for performance and correctness in Go.| Feature | Array | Slice | |---------------|----------------------------|----------------------------| | Length | Fixed, part of the type | Variable | | Type | Value type | Reference type (header) | | Pass-by-param | Copies entire array | Copies header (24 bytes) | | Dynamic Exp. | Not supported | Supported via append() | | Comparison | Supports == | Only comparable to nil |Inspect a specific corrupt HDFS file
To get detailed information about a specific corrupt file, including its block locations and file status, usehdfs fsckwith the-locations,-blocks, and-filesflags.hdfs fsck /path/to/corrupt/file -locations -blocks -filesImplement Reactive Streams with java.util.concurrent.Flow
Java 9 introduced thejava.util.concurrent.Flowclass to standardize reactive programming. It defines a Publisher-Subscriber model that supports 'backpressure', allowing subscribers to signal the publisher to slow down data transmission. This serves as the foundation for interoperability between libraries like Project Reactor (Spring WebFlux) and RxJava.