This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sun.jvm.hotspot.oops.*; | |
import sun.jvm.hotspot.runtime.*; | |
import sun.jvm.hotspot.tools.Tool; | |
/** | |
* @author duqi | |
* @createTime 2018/9/1 下午11:55 | |
**/ | |
public class PermTool extends Tool { | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class List2MapExample { | |
public static void main(String[] args) { | |
List<ClassRecordDTO> list = new ArrayList<>(); | |
list.add(new ClassRecordDTO(1, 2, "xxx", 0.0, 0.0)); | |
list.add(new ClassRecordDTO(1, 2, "yyy", 0.0, 0.0)); | |
list.add(new ClassRecordDTO(2, 3, "zzz", 0.0, 0.0)); | |
Map<String, ClassRecordDTO> result = list.stream().collect(Collectors.toMap(ClassRecordDTO::getClassName, classRecordDTO -> classRecordDTO)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.collect.ImmutableMap; | |
import java.util.Map; | |
/** | |
* @author duqi | |
* @createTime 2018/8/14 下午3:18 | |
**/ | |
public class ClassNameUtil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
WatchMonitor watchMonitor = WatchMonitor.create("/Users/duqi/", WatchMonitor.ENTRY_CREATE, WatchMonitor.ENTRY_DELETE); | |
watchMonitor.setWatcher(new Watcher() { | |
@Override | |
public void onCreate(WatchEvent<?> event, Path currentPath) { | |
System.out.println("create1 current time:" + System.currentTimeMillis()); | |
System.out.println("文件创建:" + currentPath); | |
System.out.println("create2 current time:" + System.currentTimeMillis()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by IntelliJ IDEA. | |
* User: duqi | |
* Date: 2017/2/9 | |
* Time: 15:06 | |
*/ | |
public class AsyncHttpClientFactoryBean implements FactoryBean<CloseableHttpAsyncClient> { | |
private static final int DEFAULT_MAX_TOTAL = 512; | |
private static final int DEFAULT_MAX_PER_ROUTE = 64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by IntelliJ IDEA. | |
* User: duqi | |
* Date: 2017/2/9 | |
* Time: 13:54 | |
*/ | |
public class HttpClientFactoryBean implements FactoryBean<HttpClient> { | |
// 知识点1:路由(MAX_PER_ROUTE)是对最大连接数(MAX_TOTAL)的细分,整个连接池的限制数量实际使用DefaultMaxPerRoute并非MaxTotal。 | |
// 设置过小无法支持大并发(ConnectionPoolTimeoutException: Timeout waiting for connection from pool), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncThreadExecutor implements AutoCloseable { | |
private static final int DEFAULT_QUEUE_SIZE = 1000; | |
private static final int DEFAULT_POOL_SIZE = 10; | |
@Setter | |
private int queueSize = DEFAULT_QUEUE_SIZE; | |
@Setter |