From 0529f0ca3ac7f9d6d7f6934973ee97b30435006d Mon Sep 17 00:00:00 2001 From: Craig Bryant Date: Thu, 18 Aug 2016 17:17:09 -0600 Subject: [PATCH] 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 --- .../repository/vertica/VerticaMetricRepo.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/src/main/java/monasca/persister/repository/vertica/VerticaMetricRepo.java b/java/src/main/java/monasca/persister/repository/vertica/VerticaMetricRepo.java index 7ad4e289..52baf7ee 100644 --- a/java/src/main/java/monasca/persister/repository/vertica/VerticaMetricRepo.java +++ b/java/src/main/java/monasca/persister/repository/vertica/VerticaMetricRepo.java @@ -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 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) {