// Path: thirdparty/src/main/java/org/opendaylight/atrium/util/AtriumGroupedThreadFactory.java
// public static AtriumGroupedThreadFactory groupedThreadFactory(String groupName) {
//     AtriumGroupedThreadFactory factory = FACTORIES.get(groupName);
//     if (factory != null) {
//         return factory;
//     }
// 
//     // Find the parent group or root the group hierarchy under default group.
//     int i = groupName.lastIndexOf(DELIMITER);
//     if (i > 0) {
//         String name = groupName.substring(0, i);
//         ThreadGroup parentGroup = groupedThreadFactory(name).threadGroup();
//         factory = new AtriumGroupedThreadFactory(new ThreadGroup(parentGroup, groupName));
//     } else {
//         factory = new AtriumGroupedThreadFactory(new ThreadGroup(groupName));
//     }
// 
//     return ConcurrentUtils.putIfAbsent(FACTORIES, groupName, factory);
// }


import static java.nio.file.Files.delete;
import static java.nio.file.Files.walkFileTree;
import static org.opendaylight.atrium.util.AtriumGroupedThreadFactory.groupedThreadFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
import com.google.common.primitives.UnsignedLongs;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
/*
 * Copyright 2014 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.opendaylight.atrium.util;





/**
 * Miscellaneous utility methods.
 */
public abstract class AtriumTools {

	private AtriumTools() {
	}

	private static final Logger log = LoggerFactory.getLogger(AtriumTools.class);

	private static Random random = new Random();

	/**
	 * Returns a thread factory that produces threads named according to the
	 * supplied name pattern.
	 *
	 * @param pattern
	 *            name pattern
	 * @return thread factory
	 */
	public static ThreadFactory namedThreads(String pattern) {
		return new ThreadFactoryBuilder().setNameFormat(pattern)
				.setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception on " + t.getName(), e)).build();
	}

	/**
	 * Returns a thread factory that produces threads named according to the
	 * supplied name pattern and from the specified thread-group. The thread
	 * group name is expected to be specified in slash-delimited format, The
	 * thread names will be produced by converting the thread group name into
	 * dash-delimited format and pre-pended to the specified pattern.
	 *
	 * @param groupName
	 *            group name in slash-delimited format to indicate hierarchy
	 * @param pattern
	 *            name pattern
	 * @return thread factory
	 */
	public static ThreadFactory groupedThreads(String groupName, String pattern) {
// Path: thirdparty/src/main/java/org/opendaylight/atrium/util/AtriumGroupedThreadFactory.java
// public static AtriumGroupedThreadFactory groupedThreadFactory(String groupName) {
//     AtriumGroupedThreadFactory factory = FACTORIES.get(groupName);
//     if (factory != null) {
//         return factory;
//     }
// 
//     // Find the parent group or root the group hierarchy under default group.
//     int i = groupName.lastIndexOf(DELIMITER);
//     if (i > 0) {
//         String name = groupName.substring(0, i);
//         ThreadGroup parentGroup = groupedThreadFactory(name).threadGroup();
//         factory = new AtriumGroupedThreadFactory(new ThreadGroup(parentGroup, groupName));
//     } else {
//         factory = new AtriumGroupedThreadFactory(new ThreadGroup(groupName));
//     }
// 
//     return ConcurrentUtils.putIfAbsent(FACTORIES, groupName, factory);
// }


// Path: thirdparty/src/main/java/org/opendaylight/atrium/util/AtriumTools.java
import static java.nio.file.Files.delete;
import static java.nio.file.Files.walkFileTree;
import static org.opendaylight.atrium.util.AtriumGroupedThreadFactory.groupedThreadFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
import com.google.common.primitives.UnsignedLongs;
import com.google.common.util.concurrent.ThreadFactoryBuilder;

/*
 * Copyright 2014 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.opendaylight.atrium.util;





/**
 * Miscellaneous utility methods.
 */
public abstract class AtriumTools {

	private AtriumTools() {
	}

	private static final Logger log = LoggerFactory.getLogger(AtriumTools.class);

	private static Random random = new Random();

	/**
	 * Returns a thread factory that produces threads named according to the
	 * supplied name pattern.
	 *
	 * @param pattern
	 *            name pattern
	 * @return thread factory
	 */
	public static ThreadFactory namedThreads(String pattern) {
		return new ThreadFactoryBuilder().setNameFormat(pattern)
				.setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception on " + t.getName(), e)).build();
	}

	/**
	 * Returns a thread factory that produces threads named according to the
	 * supplied name pattern and from the specified thread-group. The thread
	 * group name is expected to be specified in slash-delimited format, The
	 * thread names will be produced by converting the thread group name into
	 * dash-delimited format and pre-pended to the specified pattern.
	 *
	 * @param groupName
	 *            group name in slash-delimited format to indicate hierarchy
	 * @param pattern
	 *            name pattern
	 * @return thread factory
	 */
	public static ThreadFactory groupedThreads(String groupName, String pattern) {
		return new ThreadFactoryBuilder().setThreadFactory(groupedThreadFactory(groupName))