2026-08-20 00:18:33 +08:00
|
|
|
package com.haobang.wal;
|
|
|
|
|
|
|
|
|
|
import com.haobang.dispatch.DeviceContextResolver;
|
|
|
|
|
import com.haobang.dispatch.SyslogWalDispatcher;
|
|
|
|
|
import com.netty.SyslogMessageHandler;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/** 运维只读状态接口;不提供跳过、清空或人工推进游标等危险操作。 */
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/syslog/wal")
|
|
|
|
|
public class SyslogWalStatusController {
|
|
|
|
|
private final SyslogWalService wal;
|
|
|
|
|
private final SyslogWalDispatcher dispatcher;
|
|
|
|
|
private final DeviceContextResolver resolver;
|
|
|
|
|
|
|
|
|
|
public SyslogWalStatusController(SyslogWalService wal, SyslogWalDispatcher dispatcher,
|
|
|
|
|
DeviceContextResolver resolver) {
|
|
|
|
|
this.wal = wal;
|
|
|
|
|
this.dispatcher = dispatcher;
|
|
|
|
|
this.resolver = resolver;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/status")
|
|
|
|
|
public Map<String, Object> status() {
|
|
|
|
|
Map<String, Object> value = new LinkedHashMap<>();
|
|
|
|
|
value.put("network_received", SyslogMessageHandler.getNetworkReceivedCount());
|
2026-09-12 19:22:52 +08:00
|
|
|
value.put("network_oversized_dropped", SyslogMessageHandler.getOversizedDroppedCount());
|
2026-08-20 00:18:33 +08:00
|
|
|
value.put("wal_appended", wal.getAppendedCount());
|
|
|
|
|
value.put("wal_queue_size", wal.getQueueSize());
|
|
|
|
|
value.put("wal_queue_capacity", wal.getQueueCapacity());
|
2026-09-12 19:22:52 +08:00
|
|
|
value.put("wal_pending_bytes", wal.getPendingAppendBytes());
|
2026-08-20 00:18:33 +08:00
|
|
|
value.put("wal_durable_sequence", wal.getDurableSequence());
|
|
|
|
|
value.put("wal_checkpoint_sequence", wal.getCheckpointSequence());
|
|
|
|
|
value.put("wal_pending_approx", wal.getPendingRecordsApprox());
|
|
|
|
|
value.put("wal_admission_backpressure", wal.getBackpressureCount());
|
2026-09-12 19:22:52 +08:00
|
|
|
value.put("wal_admission_oversized", wal.getOversizedCount());
|
2026-08-20 00:18:33 +08:00
|
|
|
value.put("wal_terminal_recorded", wal.getTerminalRecordedCount());
|
|
|
|
|
value.put("wal_quarantined", wal.getQuarantinedCount());
|
|
|
|
|
Map<String, Long> pointTimeAssigned = new LinkedHashMap<>();
|
|
|
|
|
pointTimeAssigned.put("ingress", wal.getIngressPointTimeAssignedCount());
|
|
|
|
|
value.put("point_time_assigned_total", pointTimeAssigned);
|
|
|
|
|
value.put("wal_disk_critical", wal.isDiskCritical());
|
2026-09-06 16:46:21 +08:00
|
|
|
value.put("wal_disk_state", wal.getDiskState());
|
|
|
|
|
value.put("wal_disk_total_bytes", wal.getDiskTotalBytes());
|
|
|
|
|
value.put("wal_disk_usable_bytes", wal.getDiskUsableBytes());
|
|
|
|
|
value.put("wal_disk_stop_threshold_bytes", wal.getDiskStopThresholdBytes());
|
2026-08-20 00:18:33 +08:00
|
|
|
value.put("wal_fatal_error", wal.getFatalFailure() == null
|
|
|
|
|
? null : wal.getFatalFailure().toString());
|
|
|
|
|
value.put("dispatch_inflight", dispatcher.getInflight());
|
2026-09-12 19:22:52 +08:00
|
|
|
value.put("dispatch_inflight_bytes", dispatcher.getInflightBytes());
|
2026-08-20 00:18:33 +08:00
|
|
|
value.put("kafka_acked", dispatcher.getKafkaAcked());
|
2026-09-12 19:22:52 +08:00
|
|
|
value.put("kafka_large_dispatched", dispatcher.getLargeDispatched());
|
2026-08-20 00:18:33 +08:00
|
|
|
value.put("dispatch_terminal_filtered", dispatcher.getTerminalFiltered());
|
|
|
|
|
value.put("dispatch_retry", dispatcher.getRetryCount());
|
|
|
|
|
value.put("tcp_pause_total", SyslogMessageHandler.getTcpPauseCount());
|
|
|
|
|
value.put("udp_dropped_total", SyslogMessageHandler.getUdpDroppedCount());
|
|
|
|
|
value.put("device_cache_size", resolver.getCacheSize());
|
|
|
|
|
value.put("device_cache_hits", resolver.getHitCount());
|
|
|
|
|
value.put("device_cache_misses", resolver.getMissCount());
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|