10
10
from celery .app .task import Task
11
11
from celery .utils .log import get_task_logger
12
12
from clp_py_utils .clp_config import (
13
+ ARCHIVES_TABLE_SUFFIX ,
13
14
COMPRESSION_JOBS_TABLE_NAME ,
14
15
COMPRESSION_TASKS_TABLE_NAME ,
15
16
Database ,
@@ -82,6 +83,23 @@ def update_job_metadata_and_tags(db_cursor, job_id, table_prefix, tag_ids, archi
82
83
)
83
84
84
85
86
+ def update_archive_metadata (db_cursor , table_prefix , archive_stats ):
87
+ archive_stats_defaults = {
88
+ "begin_timestamp" : 0 ,
89
+ "end_timestamp" : 0 ,
90
+ "creator_id" : "" ,
91
+ "creation_ix" : 0 ,
92
+ }
93
+ for k , v in archive_stats_defaults .items ():
94
+ archive_stats .setdefault (k , v )
95
+ keys = ", " .join (archive_stats .keys ())
96
+ value_placeholders = ", " .join (["%s" ] * len (archive_stats ))
97
+ query = (
98
+ f"INSERT INTO { table_prefix } { ARCHIVES_TABLE_SUFFIX } ({ keys } ) VALUES ({ value_placeholders } )"
99
+ )
100
+ db_cursor .execute (query , list (archive_stats .values ()))
101
+
102
+
85
103
def _generate_fs_logs_list (
86
104
output_file_path : pathlib .Path ,
87
105
paths_to_compress : PathsToCompress ,
@@ -161,15 +179,13 @@ def make_clp_s_command_and_env(
161
179
clp_home : pathlib .Path ,
162
180
archive_output_dir : pathlib .Path ,
163
181
clp_config : ClpIoConfig ,
164
- db_config_file_path : pathlib .Path ,
165
182
use_single_file_archive : bool ,
166
183
) -> Tuple [List [str ], Optional [Dict [str , str ]]]:
167
184
"""
168
185
Generates the command and environment variables for a clp_s compression job.
169
186
:param clp_home:
170
187
:param archive_output_dir:
171
188
:param clp_config:
172
- :param db_config_file_path:
173
189
:param use_single_file_archive:
174
190
:return: Tuple of (compression_command, compression_env_vars)
175
191
"""
@@ -182,7 +198,6 @@ def make_clp_s_command_and_env(
182
198
"--target-encoded-size" ,
183
199
str (clp_config .output .target_segment_size + clp_config .output .target_dictionaries_size ),
184
200
"--compression-level" , str (clp_config .output .compression_level ),
185
- "--db-config-file" , str (db_config_file_path ),
186
201
]
187
202
# fmt: on
188
203
@@ -271,7 +286,6 @@ def run_clp(
271
286
clp_home = clp_home ,
272
287
archive_output_dir = archive_output_dir ,
273
288
clp_config = clp_config ,
274
- db_config_file_path = db_config_file_path ,
275
289
use_single_file_archive = enable_s3_write ,
276
290
)
277
291
else :
@@ -347,10 +361,13 @@ def run_clp(
347
361
with closing (sql_adapter .create_connection (True )) as db_conn , closing (
348
362
db_conn .cursor (dictionary = True )
349
363
) as db_cursor :
364
+ table_prefix = clp_metadata_db_connection_config ["table_prefix" ]
365
+ if StorageEngine .CLP_S == clp_storage_engine :
366
+ update_archive_metadata (db_cursor , table_prefix , last_archive_stats )
350
367
update_job_metadata_and_tags (
351
368
db_cursor ,
352
369
job_id ,
353
- clp_metadata_db_connection_config [ " table_prefix" ] ,
370
+ table_prefix ,
354
371
tag_ids ,
355
372
last_archive_stats ,
356
373
)
0 commit comments