@Test(dataProvider = "datePrefixProvider") public void testParseStringDatePrefix(String input, Long expected) { Assert.assertEquals(retryableKubernetesClient.parseDatePrefix(input), expected); }
protected Long parseDatePrefix(String message) { String reducedMessage = message; if(message != null) { int startIdx = message.length() - (message.endsWith(System.lineSeparator()) ? 1 + System.lineSeparator().length() : 1); int subStringIndex = StringUtils.lastIndexOf(message, System.lineSeparator(), startIdx); if (subStringIndex > -1) reducedMessage = StringUtils.substring(message, subStringIndex + 1); } String[] messageParts = StringUtils.split(reducedMessage, ' '); if(messageParts != null && messageParts.length > 0) { try { return Instant.parse(messageParts[0]).toEpochMilli(); } catch(DateTimeParseException e) { logger.error(String.format("Unable to parse timestamp: %1$s", messageParts[0]), e); } } return null; }
RetryableKubernetesClient extends RetryableBase implements KubernetesClientFacade { protected Long parseDatePrefix(String message) { String reducedMessage = message; if(message != null) { int startIdx = message.length() - (message.endsWith(System.lineSeparator()) ? 1 + System.lineSeparator().length() : 1); int subStringIndex = StringUtils.lastIndexOf(message, System.lineSeparator(), startIdx); if (subStringIndex > -1) reducedMessage = StringUtils.substring(message, subStringIndex + 1); } String[] messageParts = StringUtils.split(reducedMessage, ' '); if(messageParts != null && messageParts.length > 0) { try { return Instant.parse(messageParts[0]).toEpochMilli(); } catch(DateTimeParseException e) { logger.error(String.format("Unable to parse timestamp: %1$s", messageParts[0]), e); } } return null; } }
RetryableKubernetesClient extends RetryableBase implements KubernetesClientFacade { protected Long parseDatePrefix(String message) { String reducedMessage = message; if(message != null) { int startIdx = message.length() - (message.endsWith(System.lineSeparator()) ? 1 + System.lineSeparator().length() : 1); int subStringIndex = StringUtils.lastIndexOf(message, System.lineSeparator(), startIdx); if (subStringIndex > -1) reducedMessage = StringUtils.substring(message, subStringIndex + 1); } String[] messageParts = StringUtils.split(reducedMessage, ' '); if(messageParts != null && messageParts.length > 0) { try { return Instant.parse(messageParts[0]).toEpochMilli(); } catch(DateTimeParseException e) { logger.error(String.format("Unable to parse timestamp: %1$s", messageParts[0]), e); } } return null; } RetryableKubernetesClient(DefaultKubernetesClient kubernetesClient);  RetryableKubernetesClient(DefaultKubernetesClient kubernetesClient, ConnectionTracker connectionTracker); }
RetryableKubernetesClient extends RetryableBase implements KubernetesClientFacade { protected Long parseDatePrefix(String message) { String reducedMessage = message; if(message != null) { int startIdx = message.length() - (message.endsWith(System.lineSeparator()) ? 1 + System.lineSeparator().length() : 1); int subStringIndex = StringUtils.lastIndexOf(message, System.lineSeparator(), startIdx); if (subStringIndex > -1) reducedMessage = StringUtils.substring(message, subStringIndex + 1); } String[] messageParts = StringUtils.split(reducedMessage, ' '); if(messageParts != null && messageParts.length > 0) { try { return Instant.parse(messageParts[0]).toEpochMilli(); } catch(DateTimeParseException e) { logger.error(String.format("Unable to parse timestamp: %1$s", messageParts[0]), e); } } return null; } RetryableKubernetesClient(DefaultKubernetesClient kubernetesClient);  RetryableKubernetesClient(DefaultKubernetesClient kubernetesClient, ConnectionTracker connectionTracker); @Override Pod startPod(Pod podToCreate); @Override void updatePodAnnotations(String podName, Map<String, String> annotations); @Override Map<String, String> getPodAnnotations(String podName); @Override PodResource<Pod, DoneablePod> getPodResource(String nameSpace, String podName); @Override Long getLastLogLineTimestamp(String namespace, String podName); @Override void close(); @Override KubernetesClient getInternalClient(); @Override ConnectionTracker getConnectionTracker(); @Override String getName(); @Override void setName(String name); }
RetryableKubernetesClient extends RetryableBase implements KubernetesClientFacade { protected Long parseDatePrefix(String message) { String reducedMessage = message; if(message != null) { int startIdx = message.length() - (message.endsWith(System.lineSeparator()) ? 1 + System.lineSeparator().length() : 1); int subStringIndex = StringUtils.lastIndexOf(message, System.lineSeparator(), startIdx); if (subStringIndex > -1) reducedMessage = StringUtils.substring(message, subStringIndex + 1); } String[] messageParts = StringUtils.split(reducedMessage, ' '); if(messageParts != null && messageParts.length > 0) { try { return Instant.parse(messageParts[0]).toEpochMilli(); } catch(DateTimeParseException e) { logger.error(String.format("Unable to parse timestamp: %1$s", messageParts[0]), e); } } return null; } RetryableKubernetesClient(DefaultKubernetesClient kubernetesClient);  RetryableKubernetesClient(DefaultKubernetesClient kubernetesClient, ConnectionTracker connectionTracker); @Override Pod startPod(Pod podToCreate); @Override void updatePodAnnotations(String podName, Map<String, String> annotations); @Override Map<String, String> getPodAnnotations(String podName); @Override PodResource<Pod, DoneablePod> getPodResource(String nameSpace, String podName); @Override Long getLastLogLineTimestamp(String namespace, String podName); @Override void close(); @Override KubernetesClient getInternalClient(); @Override ConnectionTracker getConnectionTracker(); @Override String getName(); @Override void setName(String name);  }