1717 *
1818 */
1919
20- use std:: {
21- collections:: HashMap ,
22- fs,
23- path:: { Path , PathBuf } ,
24- process,
25- sync:: Arc ,
26- } ;
27-
2820use crate :: {
2921 event:: DEFAULT_TIMESTAMP_KEY ,
3022 handlers:: http:: modal:: { ingest_server:: INGESTOR_META , IngestorMetadata , DEFAULT_VERSION } ,
@@ -36,6 +28,7 @@ use crate::{
3628 hostname_unchecked,
3729 } ,
3830} ;
31+ use anyhow:: anyhow;
3932use arrow_schema:: { ArrowError , Schema } ;
4033use base64:: Engine ;
4134use chrono:: { NaiveDateTime , Timelike , Utc } ;
@@ -47,6 +40,14 @@ use parquet::{
4740 format:: SortingColumn ,
4841 schema:: types:: ColumnPath ,
4942} ;
43+ use serde_json:: Value as JsonValue ;
44+ use std:: {
45+ collections:: HashMap ,
46+ fs,
47+ path:: { Path , PathBuf } ,
48+ process,
49+ sync:: Arc ,
50+ } ;
5051
5152const ARROW_FILE_EXTENSION : & str = "data.arrows" ;
5253const PARQUET_FILE_EXTENSION : & str = "data.parquet" ;
@@ -318,7 +319,21 @@ pub fn get_ingestor_info() -> anyhow::Result<IngestorMetadata> {
318319
319320 if flag {
320321 // get the ingestor metadata from staging
321- let mut meta: IngestorMetadata = serde_json:: from_slice ( & std:: fs:: read ( path) ?) ?;
322+ let mut meta: JsonValue = serde_json:: from_slice ( & std:: fs:: read ( path) ?) ?;
323+
324+ // migrate the staging meta
325+ let obj = meta
326+ . as_object_mut ( )
327+ . ok_or_else ( || anyhow ! ( "Could Not parse Ingestor Metadata Json" ) ) ?;
328+
329+ if obj. get ( "flight_port" ) . is_none ( ) {
330+ obj. insert (
331+ "flight_port" . to_owned ( ) ,
332+ JsonValue :: String ( CONFIG . parseable . flight_port . to_string ( ) ) ,
333+ ) ;
334+ }
335+
336+ let mut meta: IngestorMetadata = serde_json:: from_value ( meta) ?;
322337
323338 // compare url endpoint and port
324339 if meta. domain_name != url {
@@ -379,7 +394,7 @@ pub fn get_ingestor_info() -> anyhow::Result<IngestorMetadata> {
379394/// # Parameters
380395///
381396/// * `ingestor_info`: The ingestor info to be stored.
382- fn put_ingestor_info ( info : IngestorMetadata ) -> anyhow:: Result < ( ) > {
397+ pub fn put_ingestor_info ( info : IngestorMetadata ) -> anyhow:: Result < ( ) > {
383398 let path = PathBuf :: from ( & CONFIG . parseable . local_staging_path ) ;
384399 let file_name = format ! ( "ingestor.{}.json" , info. ingestor_id) ;
385400 let file_path = path. join ( file_name) ;
0 commit comments