fix: stabilize raw frame history queries
This commit is contained in:
@@ -8,6 +8,8 @@ import com.lingniu.ingest.eventfilestore.EventFileStore;
|
||||
import com.lingniu.ingest.sink.mq.proto.VehicleEnvelope;
|
||||
import com.lingniu.ingest.tdenginehistory.TdengineEnvelopeRows;
|
||||
import com.lingniu.ingest.tdenginehistory.TdengineHistoryWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -22,6 +24,8 @@ import java.util.List;
|
||||
*/
|
||||
public final class EventHistoryEnvelopeIngestor implements EnvelopeBatchIngestor {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EventHistoryEnvelopeIngestor.class);
|
||||
|
||||
private final EventFileStore store;
|
||||
private final TelemetryEnvelopeRecordMapper mapper;
|
||||
private final TdengineHistoryWriter tdengineWriter;
|
||||
@@ -122,6 +126,12 @@ public final class EventHistoryEnvelopeIngestor implements EnvelopeBatchIngestor
|
||||
entry.vin()));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
log.error("event history TDengine/file-store ingest failed batchSize={} validSize={} firstEventId={} firstVin={}",
|
||||
kafkaValues.size(),
|
||||
valid.size(),
|
||||
valid.getFirst().envelope().getEventId(),
|
||||
valid.getFirst().envelope().getVin(),
|
||||
ex);
|
||||
for (BatchEntry entry : valid) {
|
||||
results.set(entry.index(), EnvelopeIngestResult.failed(
|
||||
entry.envelope().getEventId(),
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -252,7 +253,7 @@ public final class RawFrameHistoryController {
|
||||
out.putAll(parsed);
|
||||
}
|
||||
if (!includeParsedFields) {
|
||||
return Map.copyOf(out);
|
||||
return immutableMap(out);
|
||||
}
|
||||
for (TdengineLocationRow location : reader.queryLocationsByRawUri(
|
||||
row.protocol(), row.rawUri(), LOCATION_ENRICH_LIMIT)) {
|
||||
@@ -266,7 +267,7 @@ public final class RawFrameHistoryController {
|
||||
out.put(field.fieldKey() + "._unit", field.unit());
|
||||
}
|
||||
}
|
||||
return Map.copyOf(out);
|
||||
return immutableMap(out);
|
||||
}
|
||||
|
||||
private static Map<String, Object> parsed(String parsedJson) {
|
||||
@@ -302,6 +303,10 @@ public final class RawFrameHistoryController {
|
||||
}
|
||||
return field.valueText();
|
||||
}
|
||||
|
||||
private static Map<String, Object> immutableMap(Map<String, Object> values) {
|
||||
return Collections.unmodifiableMap(new LinkedHashMap<>(values));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user