@Test public void testGetHostNameBasedOnConfig() { LogStream logStream = new LogStream(new SingerLog(new SingerLogConfig(), "pod-11"), "test"); SingerConfig config = new SingerConfig(); config.setKubernetesEnabled(true); String hostNameBasedOnConfig = SingerUtils.getHostNameBasedOnConfig(logStream, config); assertEquals("pod-11", hostNameBasedOnConfig); logStream = new LogStream(new SingerLog(new SingerLogConfig(), null), "test"); hostNameBasedOnConfig = SingerUtils.getHostNameBasedOnConfig(logStream, config); assertEquals(SingerUtils.getHostname(), hostNameBasedOnConfig); logStream = new LogStream(new SingerLog(new SingerLogConfig(), LogStreamManager.NON_KUBERNETES_POD_ID), "test"); hostNameBasedOnConfig = SingerUtils.getHostNameBasedOnConfig(logStream, config); assertEquals(SingerUtils.getHostname(), hostNameBasedOnConfig); config.setKubernetesEnabled(false); logStream = new LogStream(new SingerLog(new SingerLogConfig(), "pod-11"), "test"); hostNameBasedOnConfig = SingerUtils.getHostNameBasedOnConfig(logStream, config); assertEquals(SingerUtils.getHostname(), hostNameBasedOnConfig); }
public static String getHostNameBasedOnConfig(LogStream logStream, SingerConfig singerConfig) { if (singerConfig.isKubernetesEnabled()) { if (logStream.getSingerLog().getPodUid() !=null && logStream.getSingerLog().getPodUid() != LogStreamManager.NON_KUBERNETES_POD_ID) { return logStream.getSingerLog().getPodUid(); } } return HOSTNAME; }
SingerUtils { public static String getHostNameBasedOnConfig(LogStream logStream, SingerConfig singerConfig) { if (singerConfig.isKubernetesEnabled()) { if (logStream.getSingerLog().getPodUid() !=null && logStream.getSingerLog().getPodUid() != LogStreamManager.NON_KUBERNETES_POD_ID) { return logStream.getSingerLog().getPodUid(); } } return HOSTNAME; } }
SingerUtils { public static String getHostNameBasedOnConfig(LogStream logStream, SingerConfig singerConfig) { if (singerConfig.isKubernetesEnabled()) { if (logStream.getSingerLog().getPodUid() !=null && logStream.getSingerLog().getPodUid() != LogStreamManager.NON_KUBERNETES_POD_ID) { return logStream.getSingerLog().getPodUid(); } } return HOSTNAME; }  }
SingerUtils { public static String getHostNameBasedOnConfig(LogStream logStream, SingerConfig singerConfig) { if (singerConfig.isKubernetesEnabled()) { if (logStream.getSingerLog().getPodUid() !=null && logStream.getSingerLog().getPodUid() != LogStreamManager.NON_KUBERNETES_POD_ID) { return logStream.getSingerLog().getPodUid(); } } return HOSTNAME; }  static String getHostname(); static Path getPath(String filePathStr); static Date convertToDate(String timeString); static void printStackTrace(); static byte[] readFromByteBuffer(ByteBuffer buf); static long getFileInode(Path filePath); static long getFileInode(String filePathStr); static long getFileLastModifiedTime(String  filePathStr); static long getFileLastModifiedTime(File file); static long getFileLastModifiedTime(Path path); @SuppressWarnings("restriction") static WatchKey registerWatchKey(WatchService watchService, Path logDir); static SingerConfig loadSingerConfig(String singerConfigDir,
            String singerPropertiesFile, boolean startDirectoryWatcher); static void exit(String msg, int statusCode); static CloseableHttpResponse makeRequest(HttpRequestBase request); static CloseableHttpResponse makeRequestAuthenticated(HttpRequestBase request, CredentialsProvider provider); static CloseableHttpClient buildClient(String baseURL, int connectTimeout, int requestTimeout,
	CredentialsProvider provider); static boolean isMac(); static boolean createEmptyDotFile(String path); static String makeGetRequest(String uri); static String getHostNameBasedOnConfig(LogStream logStream,
                                                     SingerConfig singerConfig); static void deleteRecursively(File baseDir); }
SingerUtils { public static String getHostNameBasedOnConfig(LogStream logStream, SingerConfig singerConfig) { if (singerConfig.isKubernetesEnabled()) { if (logStream.getSingerLog().getPodUid() !=null && logStream.getSingerLog().getPodUid() != LogStreamManager.NON_KUBERNETES_POD_ID) { return logStream.getSingerLog().getPodUid(); } } return HOSTNAME; }  static String getHostname(); static Path getPath(String filePathStr); static Date convertToDate(String timeString); static void printStackTrace(); static byte[] readFromByteBuffer(ByteBuffer buf); static long getFileInode(Path filePath); static long getFileInode(String filePathStr); static long getFileLastModifiedTime(String  filePathStr); static long getFileLastModifiedTime(File file); static long getFileLastModifiedTime(Path path); @SuppressWarnings("restriction") static WatchKey registerWatchKey(WatchService watchService, Path logDir); static SingerConfig loadSingerConfig(String singerConfigDir,
            String singerPropertiesFile, boolean startDirectoryWatcher); static void exit(String msg, int statusCode); static CloseableHttpResponse makeRequest(HttpRequestBase request); static CloseableHttpResponse makeRequestAuthenticated(HttpRequestBase request, CredentialsProvider provider); static CloseableHttpClient buildClient(String baseURL, int connectTimeout, int requestTimeout,
	CredentialsProvider provider); static boolean isMac(); static boolean createEmptyDotFile(String path); static String makeGetRequest(String uri); static String getHostNameBasedOnConfig(LogStream logStream,
                                                     SingerConfig singerConfig); static void deleteRecursively(File baseDir); static final FileSystem defaultFileSystem; static String HOSTNAME; }