forked from hugegraph/hugegraph-sync
add api for setting thread pool name
Change-Id: I93aeddc6783e6b03d2aa31aa8ca42059e253ba81
This commit is contained in:
parent
904f4260b9
commit
146e4bc362
4
pom.xml
4
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>com.baidu.hugegraph</groupId>
|
||||
<artifactId>hugegraph-common</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<version>1.5.3</version>
|
||||
|
||||
<name>hugegraph-common</name>
|
||||
<url>https://github.com/hugegraph/hugegraph-common</url>
|
||||
|
|
@ -192,7 +192,7 @@
|
|||
<manifestEntries>
|
||||
<!-- Must be on one line, otherwise the automatic
|
||||
upgrade script cannot replace the version number -->
|
||||
<Implementation-Version>1.5.2.0</Implementation-Version>
|
||||
<Implementation-Version>1.5.3.0</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.concurrent.CompletableFuture;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -36,6 +35,7 @@ import org.slf4j.Logger;
|
|||
|
||||
import com.baidu.hugegraph.iterator.ExtendableIterator;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.ExecutorUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
|
|
@ -43,6 +43,7 @@ public class EventHub {
|
|||
|
||||
private static final Logger LOG = Log.logger(EventHub.class);
|
||||
|
||||
public static final String EVENT_WORKER = "event-worker-%d";
|
||||
public static final String ANY_EVENT = "*";
|
||||
|
||||
private static final List<EventListener> EMPTY = ImmutableList.of();
|
||||
|
|
@ -70,7 +71,7 @@ public class EventHub {
|
|||
return;
|
||||
}
|
||||
LOG.debug("Init pool(size {}) for EventHub", poolSize);
|
||||
executor = Executors.newFixedThreadPool(poolSize);
|
||||
executor = ExecutorUtil.newFixedThreadPool(poolSize, EVENT_WORKER);
|
||||
}
|
||||
|
||||
public static synchronized boolean destroy(long timeout)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You 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 com.baidu.hugegraph.util;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
|
||||
public final class ExecutorUtil {
|
||||
|
||||
public static ExecutorService newFixedThreadPool(int size, String name) {
|
||||
ThreadFactory factory = new BasicThreadFactory.Builder()
|
||||
.namingPattern(name)
|
||||
.build();
|
||||
return Executors.newFixedThreadPool(size, factory);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue