Phase 2b: 11개 모듈 전량 실동작 (333 서비스, 전서버 부팅)
- 10개 모듈 추가/확장(au py rc st lg cl mm vl mg cm), 각 30 서비스 = 330 + tmsrv - build.sh 자동발견으로 11 모듈서버 + dbio 라이브러리 23 + 배치 22 빌드 - schema.d 11파일 → 75 테이블, 모듈별 disjoint - 부팅 리소스 규명: fs.mqueue.queues_max=8192(330큐>256), NDRX_MSGSIZEMAX 16000· MSGMAX 50(큐당 5.6MB→0.8MB), msgqueue ulimit 2GB → 전 12서버 runok - 검증: xadmin psc 333 AVAIL, 매입체인 XA 커밋, prepared_xacts=0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8219b85f14
commit
bec83c721e
73 changed files with 10705 additions and 35 deletions
62
app/src/vl/batch/vl_anomaly_batch.pgc
Normal file
62
app/src/vl/batch/vl_anomaly_batch.pgc
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* vl_anomaly_batch.pgc - 이상거래(고액/0원) 탐지 배치 (커서 + XA).
|
||||
*
|
||||
* Cursors over a biz_date's 매입 whose amount exceeds the AMT_MAX rule threshold
|
||||
* or is non-positive, and that is not already flagged; each is written to
|
||||
* vl_suspect (via dbio) under ONE global XA transaction.
|
||||
* Usage: vl_anomaly_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "vl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long flagged = 0;
|
||||
char sev[8] = "ERROR";
|
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_pid, h_amt, thr = 50000000;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
/* 규칙 임계 로드 (dbio) - 없으면 기본값 유지 */
|
||||
if (vldb_get_rule("AMT_MAX", &thr, sev) < 0) { thr = 50000000; strcpy(sev, "ERROR"); }
|
||||
|
||||
EXEC SQL DECLARE vac CURSOR FOR
|
||||
SELECT p.purchase_id, p.amount FROM purchase p
|
||||
WHERE p.biz_date = :h_bizdate
|
||||
AND (p.amount > :thr OR p.amount <= 0)
|
||||
AND NOT EXISTS (SELECT 1 FROM vl_suspect s
|
||||
WHERE s.purchase_id = p.purchase_id AND s.rule_code = 'AMT_MAX')
|
||||
ORDER BY p.purchase_id;
|
||||
EXEC SQL OPEN vac;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH vac INTO :h_pid, :h_amt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "FETCH FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); EXEC SQL CLOSE vac; tpabort(0); return 1; }
|
||||
if (vldb_insert_suspect(h_pid, "AMT_MAX", sev,
|
||||
(h_amt <= 0) ? "0원/음수 금액" : "고액 이상거래", bizdate) < 0) {
|
||||
EXEC SQL CLOSE vac; tpabort(0); return 1;
|
||||
}
|
||||
flagged++;
|
||||
}
|
||||
EXEC SQL CLOSE vac;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> vl_anomaly_batch COMMIT: bizdate=%s 임계=%ld 적출=%ld\n", bizdate, thr, flagged);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
64
app/src/vl/batch/vl_sales_batch.pgc
Normal file
64
app/src/vl/batch/vl_sales_batch.pgc
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* vl_sales_batch.pgc - 매입-정산 대사검증 배치 (커서 JOIN + XA).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction, an EXEC SQL cursor JOINs 정산완료(status='S') 매입 against its
|
||||
* settlement rows for a biz_date; any purchase whose settled net != sum of its
|
||||
* settlement net (or with no settlement) is written to vl_suspect (via the
|
||||
* linked dbio lib), then tpcommit drives XA 2PC.
|
||||
* Usage: vl_sales_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "vl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long scanned = 0, flagged = 0;
|
||||
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_pid, h_pnet, h_snet;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
/* 매입(정산완료) LEFT JOIN 정산합계 - 불일치/누락 추출 */
|
||||
EXEC SQL DECLARE vsc CURSOR FOR
|
||||
SELECT p.purchase_id, p.net, coalesce(s.snet, 0)
|
||||
FROM purchase p
|
||||
LEFT JOIN (SELECT purchase_id, sum(net) AS snet FROM settlement
|
||||
GROUP BY purchase_id) s ON s.purchase_id = p.purchase_id
|
||||
WHERE p.biz_date = :h_bizdate AND p.status = 'S'
|
||||
ORDER BY p.purchase_id;
|
||||
EXEC SQL OPEN vsc;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH vsc INTO :h_pid, :h_pnet, :h_snet;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "FETCH FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); EXEC SQL CLOSE vsc; tpabort(0); return 1; }
|
||||
scanned++;
|
||||
if (h_snet != h_pnet) {
|
||||
if (vldb_insert_suspect(h_pid, "LEDGER_MIS", "CRIT",
|
||||
"매입-정산 대사 불일치", bizdate) < 0) {
|
||||
EXEC SQL CLOSE vsc; tpabort(0); return 1;
|
||||
}
|
||||
flagged++;
|
||||
}
|
||||
}
|
||||
EXEC SQL CLOSE vsc;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> vl_sales_batch COMMIT: bizdate=%s 검사=%ld 적출=%ld\n", bizdate, scanned, flagged);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue