Check value meta length before writing to Vertica
If value meta length is larger than the size of the Vertica column, the write will fail and cause the persister to die. Check the length and drop the value meta if too large. This should not occur as the value meta is validated by the API before being written to Kafka, but this is a cheap check and ensures the persister will stay up if some application starts writing directly to the Kafka queue Change-Id: I893d02751217beb6ba5a88625f20448c45a1b376
This commit is contained in:
parent
a3acd792da
commit
0529f0ca3a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
* (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -57,6 +57,8 @@ public class VerticaMetricRepo extends VerticaRepo implements Repo<MetricEnvelop
|
||||
|
||||
public static final int MAX_COLUMN_LENGTH = 255;
|
||||
|
||||
public static final int MAX_VALUE_META_LENGTH = 2048;
|
||||
|
||||
private final SimpleDateFormat simpleDateFormat;
|
||||
|
||||
private static final String TENANT_ID = "tenantId";
|
||||
@ -367,6 +369,12 @@ public class VerticaMetricRepo extends VerticaRepo implements Repo<MetricEnvelop
|
||||
try {
|
||||
|
||||
valueMetaString = this.objectMapper.writeValueAsString(valueMeta);
|
||||
if (valueMetaString.length() > MAX_VALUE_META_LENGTH) {
|
||||
logger
|
||||
.error("[{}]: Value meta length {} longer than maximum {}, dropping value meta",
|
||||
id, valueMetaString.length(), MAX_VALUE_META_LENGTH);
|
||||
return "";
|
||||
}
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user