本文整理汇总了Java中org.apache.curator.utils.ThreadUtils.newThreadFactory方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadUtils.newThreadFactory方法的具体用法?Java ThreadUtils.newThreadFactory怎么用?Java ThreadUtils.newThreadFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.utils.ThreadUtils
的用法示例。
在下文中一共展示了ThreadUtils.newThreadFactory方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalListen
import org.apache.curator.utils.ThreadUtils; //导入方法依赖的package包/类
protected void internalListen(ServiceDescription description) throws Exception {
ServiceCache serviceCache = null;
synchronized (serviceCacheMap) {
serviceCache = serviceCacheMap.get(description.getName());
if (serviceCache == null) {
String providerPath = pathForProviders(description.getName());
ThreadFactory threadFactory = ThreadUtils.newThreadFactory("ServiceDiscovery");
serviceCache = new ServiceCache(client, providerPath, threadFactory).build();
serviceCacheMap.put(description.getName(), serviceCache);
}
}
serviceCache.addConsumer(description);
}
示例2: ZKConsumerLeader
import org.apache.curator.utils.ThreadUtils; //导入方法依赖的package包/类
ZKConsumerLeader(final ZKHolder zkHolder, final String consumerName, final ZKMember member) {
this.zkHolder = requireNonNull(zkHolder, "zkHolder must not be null");
this.consumerName = requireNonNull(consumerName, "consumerName must not be null");
this.member = requireNonNull(member, "member must not be null");
this.leaderSelectorThreadFactory = ThreadUtils.newThreadFactory("LeaderSelector-" + consumerName);
}
示例3: ConnectionStateManager
import org.apache.curator.utils.ThreadUtils; //导入方法依赖的package包/类
/**
* @param client the client
* @param threadFactory thread factory to use or null for a default
* @param sessionTimeoutMs the ZK session timeout in milliseconds
* @param sessionExpirationPercent percentage of negotiated session timeout to use when simulating a session timeout. 0 means don't simulate at all
*/
public ConnectionStateManager(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent)
{
this.client = client;
this.sessionTimeoutMs = sessionTimeoutMs;
this.sessionExpirationPercent = sessionExpirationPercent;
if ( threadFactory == null )
{
threadFactory = ThreadUtils.newThreadFactory("ConnectionStateManager");
}
service = Executors.newSingleThreadExecutor(threadFactory);
}
示例4: getThreadFactory
import org.apache.curator.utils.ThreadUtils; //导入方法依赖的package包/类
private ThreadFactory getThreadFactory(CuratorFrameworkFactory.Builder builder)
{
ThreadFactory threadFactory = builder.getThreadFactory();
if ( threadFactory == null )
{
threadFactory = ThreadUtils.newThreadFactory("Framework");
}
return threadFactory;
}
示例5: CustomServiceProvider
import org.apache.curator.utils.ThreadUtils; //导入方法依赖的package包/类
public CustomServiceProvider(ServiceDiscoveryImpl<T> discovery, String basePath, String serviceName,
ProviderStrategy<T> providerStrategy, IDiscoveryBackupManager discoveryStacksBackupManager, IInstanceWeigher<T> weighter) {
this(discovery, basePath, serviceName, providerStrategy, ThreadUtils.newThreadFactory("CustomServiceProvider: " + basePath + serviceName),
new ArrayList<InstanceFilter<T>>(), discoveryStacksBackupManager, weighter);
}