static void gatherNames(Set<String> set, boolean resolve) { set.add(OSUtils.getHostName()); if(resolve) { try { resolveNames(set); } catch (Exception e) { log.error("Can not resolve names.", e); } } }
public static boolean isOurContainer(ContainerBaseIface cont) { if (!ContainerDetector.isContainer()) { // haven was not started in container, skipping protection return false; } // depend of some options container can have hostname equal with name or part of container id String hostName = OSUtils.getHostName(); String id = ContainerDetector.getId(); String pcid = cont.getId(); boolean sameName = hostName.equals(cont.getName()); boolean sameId = id == null ? pcid.startsWith(hostName) : pcid.equals(id); return sameName || sameId; }
@Autowired public DataProvider(NotifierProps config, AbstractConfigurableEmbeddedServletContainer container) { this.collector = new InfoCollector(config.getRootPath()); this.address = getAddress(config.getAddress(), container); this.hostName = OSUtils.getHostName(); }
/** * create default ApplicationInfo * @return */ public static ApplicationInfoImpl createDefault() { return ApplicationInfoImpl.builder() .host(OSUtils.getHostName()) .application(AppInfo.getApplicationName()) .applicationVersion(AppInfo.getApplicationVersion()) .build(); } }
private void processMessageProperties(MessageProperties messageProperties) { messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setContentEncoding("UTF-8"); messageProperties.setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT); messageProperties.setHeader(MessageHeaders.HOST, OSUtils.getHostName()); messageProperties.setAppId(AppInfo.getApplicationName()); if(this.messagePropertiesCallback != null) { this.messagePropertiesCallback.call(messageProperties); } } }