Apache/InLong InLong Manager 支援配置 Flink 任務併發度/Adjust sort resources according to data scale心得

peterzh6發表於2024-07-07

audit已經實現了對於InLong系統的Agent、DataProxy、Sort模組的入流量、出流量進行實時審計對賬。 對賬的粒度有分鐘、小時、天三種粒度。

  1. audit的資料快取在org.apache.inlong.audit.cache的各個類中,有DayCache HalfHourCache等等
  2. 請求audit資料的api在org.apache.inlong.audit.config.OpenApiConstants中,透過org.apache.inlong.audit.service.ApiService來呼叫。呼叫的時候注意引數的合法性,有合法性檢查,以免請求不到資料。居然沒有用controller,挺神奇的,貼一段程式碼上來,便於以後研究

private void initHttpServer() {

點選檢視程式碼
 private void initHttpServer() {
        int bindPort = Configuration.getInstance().get(KEY_HTTP_SERVER_BIND_PORT, DEFAULT_HTTP_SERVER_BIND_PORT);
        try {
            HttpServer server = HttpServer.create(new InetSocketAddress(bindPort),
                    Configuration.getInstance().get(KEY_API_BACKLOG_SIZE, DEFAULT_API_BACKLOG_SIZE));
            server.setExecutor(Executors.newFixedThreadPool(
                    Configuration.getInstance().get(KEY_API_THREAD_POOL_SIZE, DEFAULT_API_THREAD_POOL_SIZE)));
            server.createContext(Configuration.getInstance().get(KEY_API_DAY_PATH, DEFAULT_API_DAY_PATH),
                    new AuditHandler(DAY));
            server.createContext(Configuration.getInstance().get(KEY_API_HOUR_PATH, DEFAULT_API_HOUR_PATH),
                    new AuditHandler(HOUR));
            server.createContext(Configuration.getInstance().get(KEY_API_MINUTES_PATH, DEFAULT_API_MINUTES_PATH),
........省略類似的方法.........
            server.start();
            LOGGER.info("Init http server success. Bind port is: {}", bindPort);
        } catch (Exception e) {
            LOGGER.error("Init http server has exception!", e);
        }
    }
    int bindPort = Configuration.getInstance().get(KEY_HTTP_SERVER_BIND_PORT, DEFAULT_HTTP_SERVER_BIND_PORT);
    try {
        HttpServer server = HttpServer.create(new InetSocketAddress(bindPort),
                Configuration.getInstance().get(KEY_API_BACKLOG_SIZE, DEFAULT_API_BACKLOG_SIZE));
        server.setExecutor(Executors.newFixedThreadPool(
                Configuration.getInstance().get(KEY_API_THREAD_POOL_SIZE, DEFAULT_API_THREAD_POOL_SIZE)));
        server.createContext(Configuration.getInstance().get(KEY_API_DAY_PATH, DEFAULT_API_DAY_PATH),
                new AuditHandler(DAY));
        server.createContext(Configuration.getInstance().get(KEY_API_HOUR_PATH, DEFAULT_API_HOUR_PATH),
                new AuditHandler(HOUR));
        server.createContext(Configuration.getInstance().get(KEY_API_MINUTES_PATH, DEFAULT_API_MINUTES_PATH),

........省略類似的方法.........
server.start();
LOGGER.info("Init http server success. Bind port is: {}", bindPort);
} catch (Exception e) {
LOGGER.error("Init http server has exception!", e);
}
}

  1. 請求方法樣例,查詢小時資料curl localhost:10080/audit/hour?startTime=2024-07-01T00:00:00&endTime=2024-07-07T23:59:59&inlongGroupId=testGroup&inlongStreamId=testStream&auditId=testAudit

相關文章