@Test @Ignore public void readTest() { String podName = "dbtest1-2-3nvf3"; String integration = "DBTest1"; String integrationId = "-L5ApZneYNfmLWG-PKQt"; String version = "1"; PodMetricsReader reader = new PodMetricsReader( new DefaultKubernetesClient(), podName, integration, integrationId, version, new LogRawMetrics()); reader.run(); }
@Override public void run() { try { LOGGER.debug("Collecting stats from integrationId: {}", integrationId); List<Map<String, String>> routeStats = getRoutes(integration, "[a-zA-z0-9_-]+"); routeStats.forEach( m -> { long messages = toLong(m.getOrDefault(EXCHANGES_TOTAL, "0")); long errors = toLong(m.getOrDefault(EXCHANGES_FAILED, "0")); Instant lastCompleted = toInstant(m.get(LAST_COMPLETED_TIMESTAMP)); Instant lastFailed = toInstant(m.get(LAST_FAILED_TIMESTAMP)); Instant lastMessage = (lastCompleted == null && lastFailed != null) || (lastCompleted != null && lastFailed != null && lastFailed.isAfter(lastCompleted)) ? lastFailed : lastCompleted; Instant resetDate = toInstant(m.get(RESET_TIMESTAMP)); Instant startDate = toInstant(m.get(START_TIMESTAMP)); handler.persist(new RawMetrics.Builder() .pod(pod) .integrationId(integrationId) .version(version) .messages(messages) .errors(errors) .startDate(startDate) .lastProcessed(Optional.ofNullable(lastMessage)) .resetDate(resetDate) .build()); } ); } catch (MalformedObjectNameException | J4pException e) { LOGGER.error("Collecting stats from integrationId: {}", integrationId); LOGGER.debug("Collecting stats from integrationId: {}", integrationId, e); } }
PodMetricsReader implements Runnable { @Override public void run() { try { LOGGER.debug("Collecting stats from integrationId: {}", integrationId); List<Map<String, String>> routeStats = getRoutes(integration, "[a-zA-z0-9_-]+"); routeStats.forEach( m -> { long messages = toLong(m.getOrDefault(EXCHANGES_TOTAL, "0")); long errors = toLong(m.getOrDefault(EXCHANGES_FAILED, "0")); Instant lastCompleted = toInstant(m.get(LAST_COMPLETED_TIMESTAMP)); Instant lastFailed = toInstant(m.get(LAST_FAILED_TIMESTAMP)); Instant lastMessage = (lastCompleted == null && lastFailed != null) || (lastCompleted != null && lastFailed != null && lastFailed.isAfter(lastCompleted)) ? lastFailed : lastCompleted; Instant resetDate = toInstant(m.get(RESET_TIMESTAMP)); Instant startDate = toInstant(m.get(START_TIMESTAMP)); handler.persist(new RawMetrics.Builder() .pod(pod) .integrationId(integrationId) .version(version) .messages(messages) .errors(errors) .startDate(startDate) .lastProcessed(Optional.ofNullable(lastMessage)) .resetDate(resetDate) .build()); } ); } catch (MalformedObjectNameException | J4pException e) { LOGGER.error("Collecting stats from integrationId: {}", integrationId); LOGGER.debug("Collecting stats from integrationId: {}", integrationId, e); } } }
PodMetricsReader implements Runnable { @Override public void run() { try { LOGGER.debug("Collecting stats from integrationId: {}", integrationId); List<Map<String, String>> routeStats = getRoutes(integration, "[a-zA-z0-9_-]+"); routeStats.forEach( m -> { long messages = toLong(m.getOrDefault(EXCHANGES_TOTAL, "0")); long errors = toLong(m.getOrDefault(EXCHANGES_FAILED, "0")); Instant lastCompleted = toInstant(m.get(LAST_COMPLETED_TIMESTAMP)); Instant lastFailed = toInstant(m.get(LAST_FAILED_TIMESTAMP)); Instant lastMessage = (lastCompleted == null && lastFailed != null) || (lastCompleted != null && lastFailed != null && lastFailed.isAfter(lastCompleted)) ? lastFailed : lastCompleted; Instant resetDate = toInstant(m.get(RESET_TIMESTAMP)); Instant startDate = toInstant(m.get(START_TIMESTAMP)); handler.persist(new RawMetrics.Builder() .pod(pod) .integrationId(integrationId) .version(version) .messages(messages) .errors(errors) .startDate(startDate) .lastProcessed(Optional.ofNullable(lastMessage)) .resetDate(resetDate) .build()); } ); } catch (MalformedObjectNameException | J4pException e) { LOGGER.error("Collecting stats from integrationId: {}", integrationId); LOGGER.debug("Collecting stats from integrationId: {}", integrationId, e); } } PodMetricsReader(KubernetesClient kubernetes, String pod, String integration, String integrationId, String version,
            RawMetricsHandler handler); }
PodMetricsReader implements Runnable { @Override public void run() { try { LOGGER.debug("Collecting stats from integrationId: {}", integrationId); List<Map<String, String>> routeStats = getRoutes(integration, "[a-zA-z0-9_-]+"); routeStats.forEach( m -> { long messages = toLong(m.getOrDefault(EXCHANGES_TOTAL, "0")); long errors = toLong(m.getOrDefault(EXCHANGES_FAILED, "0")); Instant lastCompleted = toInstant(m.get(LAST_COMPLETED_TIMESTAMP)); Instant lastFailed = toInstant(m.get(LAST_FAILED_TIMESTAMP)); Instant lastMessage = (lastCompleted == null && lastFailed != null) || (lastCompleted != null && lastFailed != null && lastFailed.isAfter(lastCompleted)) ? lastFailed : lastCompleted; Instant resetDate = toInstant(m.get(RESET_TIMESTAMP)); Instant startDate = toInstant(m.get(START_TIMESTAMP)); handler.persist(new RawMetrics.Builder() .pod(pod) .integrationId(integrationId) .version(version) .messages(messages) .errors(errors) .startDate(startDate) .lastProcessed(Optional.ofNullable(lastMessage)) .resetDate(resetDate) .build()); } ); } catch (MalformedObjectNameException | J4pException e) { LOGGER.error("Collecting stats from integrationId: {}", integrationId); LOGGER.debug("Collecting stats from integrationId: {}", integrationId, e); } } PodMetricsReader(KubernetesClient kubernetes, String pod, String integration, String integrationId, String version,
            RawMetricsHandler handler); @Override void run(); List<Map<String, String>> getRoutes(String camelContextName, String filter); static String removeLeadingAndEndingQuotes(String s); static boolean isEmpty(Object value); @SuppressWarnings("unchecked") static boolean isNotEmpty(Object value); }
PodMetricsReader implements Runnable { @Override public void run() { try { LOGGER.debug("Collecting stats from integrationId: {}", integrationId); List<Map<String, String>> routeStats = getRoutes(integration, "[a-zA-z0-9_-]+"); routeStats.forEach( m -> { long messages = toLong(m.getOrDefault(EXCHANGES_TOTAL, "0")); long errors = toLong(m.getOrDefault(EXCHANGES_FAILED, "0")); Instant lastCompleted = toInstant(m.get(LAST_COMPLETED_TIMESTAMP)); Instant lastFailed = toInstant(m.get(LAST_FAILED_TIMESTAMP)); Instant lastMessage = (lastCompleted == null && lastFailed != null) || (lastCompleted != null && lastFailed != null && lastFailed.isAfter(lastCompleted)) ? lastFailed : lastCompleted; Instant resetDate = toInstant(m.get(RESET_TIMESTAMP)); Instant startDate = toInstant(m.get(START_TIMESTAMP)); handler.persist(new RawMetrics.Builder() .pod(pod) .integrationId(integrationId) .version(version) .messages(messages) .errors(errors) .startDate(startDate) .lastProcessed(Optional.ofNullable(lastMessage)) .resetDate(resetDate) .build()); } ); } catch (MalformedObjectNameException | J4pException e) { LOGGER.error("Collecting stats from integrationId: {}", integrationId); LOGGER.debug("Collecting stats from integrationId: {}", integrationId, e); } } PodMetricsReader(KubernetesClient kubernetes, String pod, String integration, String integrationId, String version,
            RawMetricsHandler handler); @Override void run(); List<Map<String, String>> getRoutes(String camelContextName, String filter); static String removeLeadingAndEndingQuotes(String s); static boolean isEmpty(Object value); @SuppressWarnings("unchecked") static boolean isNotEmpty(Object value);  }