public NetworkManager(AbstractNodesGroup<?> group) { this.group = group; this.networksCache = SingleValueCache.builder(this::loadNetworks) .timeAfterWrite(TimeUnit.MINUTES, 5L) .build(); }
/** * Invoke callback if it is not a null. * @param callback * @param value */ public static <T> void call(Callback<T> callback, T value) { if(callback == null) { return; } callback.call(value); }
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); } } }
/** * Close specified object if it is instance of AutoCloseable * @param mayBeCloseable */ public static void closeIfCloseable(Object mayBeCloseable) { if(mayBeCloseable instanceof AutoCloseable) { close((AutoCloseable) mayBeCloseable); } }
/** * Variant of {@link #schedule(long, TimeUnit)} with {@link Builder#getMaxDelay()} as argument. */ public void schedule() { schedule(maxDelay, TimeUnit.MILLISECONDS); }
/** * Is a <code>match(str, StringUtils::isAz09);</code>. * @param str string * @return true if string match [A-Za-z0-9]* */ public static boolean matchAz09(String str) { return match(str, StringUtils::isAz09); }
/** * Flag which set order of empty or absent suffix. Default true. * @param emptySuffixLast * @return */ public Builder emptySuffixLast(boolean emptySuffixLast) { setEmptySuffixLast(emptySuffixLast); return this; }
/** * Holder for consumed value. It threadsafe. * @param <T> * @return */ public static <T> HolderConsumer<T> holder() { return new HolderConsumer<>(); }
/** * Predicate which must return true for passed entries, and false for skipped. <p/> * @see Predicates#truePredicate() * @return never null, default value {@link Predicates#TRUE} */ default Predicate<T> historyFilter() { return Predicates.truePredicate(); } }
/** * Parse literals like KiB or KB to its number representation 1024 (for KB & KiB) * @param mult str * @return long value */ public static long parseMultiplier(String mult) { return parseMult(mult, 0); }
/** * Retain chars which is acceptable as file name or part of url on most operation systems. <p/> * It: <code>'A'-'z', '0'-'9', '_', '-', '.'</code> * @param src source string, may be null * @return string, null when incoming string is null */ public static String retainForFileName(String src) { return retain(src, StringUtils::isAz09); }
/** * Test that specified codePoint is an ASCII letter, digit or hyphen '-'. * @param cp codePoint * @return true for specified chars */ public static boolean isAz09Hyp(int cp) { return isAz09(cp) || cp == '-'; }
/** * extract '$version' from manifest (Implementation-Version) or other places. * * @return */ public static String getApplicationVersion() { return getValue("dm-cluman-info-version"); }
/** * @see DeferredExecutor * @return new instance of {@link DeferredExecutor } */ public static DeferredExecutor deferred() { return new DeferredExecutor(); }
/** * Name of thread, without thread number pattern. * @param name name * @return this */ public ExecutorBuilder name(String name) { setName(name); return this; }
/** * Uncaught exception handler. * @param exceptionHandler handler, default {@link Throwables#uncaughtHandler()} * @return this */ public ExecutorBuilder exceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler) { setExceptionHandler(exceptionHandler); return this; }
@Override public int compareTo(ApplicationSource o) { return Comparables.compare(name, o.name); } }
/** * Is a <code>match(str, StringUtils::isAz09Hyp);</code>. * @param str string * @return true if string match [A-Za-z0-9-]* */ public static boolean matchAz09Hyp(String str) { return match(str, StringUtils::isAz09Hyp); }
/** * Is a <code>match(str, StringUtils::isId);</code>. * @param str string * @return true if string match [A-Za-z0-9-_:.]* */ public static boolean matchId(String str) { return match(str, StringUtils::isId); }