Class MergeLogsCLI
java.lang.Object
com.scivicslab.actoriac.cli.MergeLogsCLI
CLI subcommand to merge scattered log databases into a single database.
Before the log-server feature, each workflow run would create its own separate database file. This command consolidates them into one database.
Usage Examples
# Scan a directory for .mv.db files and merge them actor-iac merge-logs --scan ./workflows --target ./logs/merged # Merge specific database files actor-iac merge-logs --target ./logs/merged ./db1 ./db2 ./db3 # Dry-run to see what would be merged actor-iac merge-logs --scan ./workflows --target ./logs/merged --dry-run
- Since:
- 2.10.0
- Author:
- devteam@scivics-lab.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()Collects all source database files from scan directory and explicit parameters.private intcopyLogs(Connection source, Connection target, long oldSessionId, long newSessionId) Copies logs from source to target with new session ID.private intcopyNodeResults(Connection source, Connection target, long oldSessionId, long newSessionId) Copies node_results from source to target with new session ID.private intcountRows(Connection conn, String table) Counts rows in a table.private intdryRunAnalysis(List<File> sources) Performs dry-run analysis showing what would be merged.private voidinitializeSchema(Connection conn) Initializes the target database schema.private longinsertSession(Connection target, ResultSet rs, String sourceName) Inserts a session into the target database.Loads existing session keys for duplicate detection.private StringmakeSessionKey(String workflowName, Timestamp startedAt) Creates a unique key for duplicate detection.private voidmergeDatabase(Connection source, Connection target, Set<String> existingSessions, String sourceName) Merges one source database into the target.private ConnectionopenDatabase(File dbPath) Opens a database connection.private intperformMerge(List<File> sources) Performs the actual merge operation.private booleantableExists(Connection conn, String tableName) Checks if a table exists in the database.private static StringTruncates a string to max length with ellipsis.
-
Field Details
-
targetDb
-
scanDir
-
sourceDbs
-
dryRun
-
verbose
-
skipDuplicates
-
totalSessions
Statistics for reporting -
totalLogs
-
totalNodeResults
-
skippedSessions
-
-
Constructor Details
-
MergeLogsCLI
public MergeLogsCLI()
-
-
Method Details
-
call
-
collectSourceDatabases
Collects all source database files from scan directory and explicit parameters. -
dryRunAnalysis
Performs dry-run analysis showing what would be merged. -
performMerge
Performs the actual merge operation.- Throws:
SQLException
-
openDatabase
Opens a database connection.- Throws:
SQLException
-
initializeSchema
Initializes the target database schema.- Throws:
SQLException
-
loadExistingSessions
Loads existing session keys for duplicate detection.- Throws:
SQLException
-
makeSessionKey
Creates a unique key for duplicate detection. -
tableExists
Checks if a table exists in the database. -
mergeDatabase
private void mergeDatabase(Connection source, Connection target, Set<String> existingSessions, String sourceName) throws SQLException Merges one source database into the target.- Throws:
SQLException
-
insertSession
Inserts a session into the target database.- Throws:
SQLException
-
copyLogs
private int copyLogs(Connection source, Connection target, long oldSessionId, long newSessionId) throws SQLException Copies logs from source to target with new session ID.- Throws:
SQLException
-
copyNodeResults
private int copyNodeResults(Connection source, Connection target, long oldSessionId, long newSessionId) throws SQLException Copies node_results from source to target with new session ID.- Throws:
SQLException
-
countRows
Counts rows in a table.- Throws:
SQLException
-
truncate
-