@Override public Serde<MetricsSnapshot> getSerde(String name, Config config) { return new MetricsSnapshotSerdeV2(); } }
/** Metrics returns an UnmodifiableMap. * Unmodifiable maps should not be serialized with type, because UnmodifiableMap cannot be deserialized. * So we convert to HashMap. */ private HashMap convertMap(Map<String, Object> map) { HashMap retVal = new HashMap(map); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getValue() instanceof Map) { retVal.put(entry.getKey(), convertMap((Map<String, Object>) entry.getValue())); } } return retVal; } }
MetricsSnapshotSerdeV2 metricsSnapshotSerde = new MetricsSnapshotSerdeV2(); byte[] serializedBytes = metricsSnapshotSerde.toBytes(metricsSnapshot); MetricsSnapshot deserializedMetricsSnapshot = metricsSnapshotSerde.fromBytes(serializedBytes);
/** Metrics returns an UnmodifiableMap. * Unmodifiable maps should not be serialized with type, because UnmodifiableMap cannot be deserialized. * So we convert to HashMap. */ private HashMap convertMap(Map<String, Object> map) { HashMap retVal = new HashMap(map); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getValue() instanceof Map) { retVal.put(entry.getKey(), convertMap((Map<String, Object>) entry.getValue())); } } return retVal; } }
/** Metrics returns an UnmodifiableMap. * Unmodifiable maps should not be serialized with type, because UnmodifiableMap cannot be deserialized. * So we convert to HashMap. */ private HashMap convertMap(Map<String, Object> map) { HashMap retVal = new HashMap(map); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getValue() instanceof Map) { retVal.put(entry.getKey(), convertMap((Map<String, Object>) entry.getValue())); } } return retVal; } }
@Override public Serde<MetricsSnapshot> getSerde(String name, Config config) { return new MetricsSnapshotSerdeV2(); } }
/** Metrics returns an UnmodifiableMap. * Unmodifiable maps should not be serialized with type, because UnmodifiableMap cannot be deserialized. * So we convert to HashMap. */ private HashMap convertMap(Map<String, Object> map) { HashMap retVal = new HashMap(map); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getValue() instanceof Map) { retVal.put(entry.getKey(), convertMap((Map<String, Object>) entry.getValue())); } } return retVal; } }
@Override public Serde<MetricsSnapshot> getSerde(String name, Config config) { return new MetricsSnapshotSerdeV2(); } }
@Override public byte[] toBytes(MetricsSnapshot metricsSnapshot) { try { return objectMapper.writeValueAsString(convertMap(metricsSnapshot.getAsMap())).getBytes("UTF-8"); } catch (IOException e) { LOG.info("Exception while serializing", e); } return null; }
@Override public Serde<MetricsSnapshot> getSerde(String name, Config config) { return new MetricsSnapshotSerdeV2(); } }
@Override public byte[] toBytes(MetricsSnapshot metricsSnapshot) { try { return objectMapper.writeValueAsString(convertMap(metricsSnapshot.getAsMap())).getBytes("UTF-8"); } catch (IOException e) { LOG.info("Exception while serializing", e); } return null; }
@Override public Serde<MetricsSnapshot> getSerde(String name, Config config) { return new MetricsSnapshotSerdeV2(); } }
@Override public byte[] toBytes(MetricsSnapshot metricsSnapshot) { try { return objectMapper.writeValueAsString(convertMap(metricsSnapshot.getAsMap())).getBytes("UTF-8"); } catch (IOException e) { LOG.info("Exception while serializing", e); } return null; }
private MetricsSnapshotReporter getMetricsSnapshotReporter(String blacklist) { return new MetricsSnapshotReporter(new InMemorySystemProducer("test system", null), new SystemStream("test system", "test stream"), 60000, "test job", "test jobID", "samza-container-0", "test version", "test samza version", "test host", new MetricsSnapshotSerdeV2(), new Some<>(blacklist), new AbstractFunction0<Object>() { @Override public Object apply() { return System.currentTimeMillis(); } }); } }
/** Metrics returns an UnmodifiableMap. * Unmodifiable maps should not be serialized with type, because UnmodifiableMap cannot be deserialized. * So we convert to HashMap. */ private HashMap convertMap(Map<String, Object> map) { HashMap retVal = new HashMap(map); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getValue() instanceof Map) { retVal.put(entry.getKey(), convertMap((Map<String, Object>) entry.getValue())); } } return retVal; } }
@Override public byte[] toBytes(MetricsSnapshot metricsSnapshot) { try { return objectMapper.writeValueAsString(convertMap(metricsSnapshot.getAsMap())).getBytes("UTF-8"); } catch (IOException e) { LOG.info("Exception while serializing", e); } return null; }
@Override public byte[] toBytes(MetricsSnapshot metricsSnapshot) { try { return objectMapper.writeValueAsString(convertMap(metricsSnapshot.getAsMap())).getBytes("UTF-8"); } catch (IOException e) { LOG.info("Exception while serializing", e); } return null; }