use of org.jgroups.util.ThreadFactory in project JGroups by belaban.
the class FD_SOCK method startPingerThread.
/**
* Does *not* need to be synchronized on pinger_mutex because the caller (down()) already has the mutex acquired
*/
protected synchronized boolean startPingerThread() {
if (!isPingerThreadRunning()) {
ThreadFactory factory = getThreadFactory();
pinger_thread = factory.newThread(this, "FD_SOCK pinger");
pinger_thread.setDaemon(true);
pinger_thread.start();
return true;
}
return false;
}
use of org.jgroups.util.ThreadFactory in project wildfly by wildfly.
the class ThreadPoolFactoryBuilder method build.
@Override
public ServiceBuilder<ThreadPoolFactory> build(ServiceTarget target) {
int queueLength = this.getQueueLength();
BlockingQueue<Runnable> queue = (queueLength > 0) ? new ArrayBlockingQueue<>(queueLength) : new SynchronousQueue<>();
ClassLoader loader = JChannelFactory.class.getClassLoader();
ThreadFactory threadFactory = new ClassLoaderThreadFactory(new DefaultThreadFactory(this.getThreadGroupPrefix(), false, true), loader);
RejectedExecutionHandler handler = new ShutdownRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
ThreadPoolFactory factory = () -> new ThreadPoolExecutor(this.getMinThreads(), this.getMaxThreads(), this.getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, threadFactory, handler);
return target.addService(this.getServiceName(), new ValueService<>(new ImmediateValue<>(factory)));
}
use of org.jgroups.util.ThreadFactory in project wildfly by wildfly.
the class TimerFactoryBuilder method build.
@Override
public ServiceBuilder<TimerFactory> build(ServiceTarget target) {
ThreadFactory threadFactory = new ClassLoaderThreadFactory(new LazyThreadFactory(this.getThreadGroupPrefix(), true, true), JChannelFactory.class.getClassLoader());
TimerFactory factory = () -> new TimeScheduler3(threadFactory, this.getMinThreads(), this.getMaxThreads(), this.getKeepAliveTime(), this.getQueueLength(), "abort");
return target.addService(this.getServiceName(), new ValueService<>(new ImmediateValue<>(factory)));
}
use of org.jgroups.util.ThreadFactory in project JGroups by belaban.
the class ViewHandlerTest method configureGMS.
protected static void configureGMS(GMS gms) {
Address local_addr = Util.createRandomAddress("A");
ThreadFactory fac = new DefaultThreadFactory("test", true);
set(gms, "local_addr", local_addr);
set(gms, "timer", new TimeScheduler3(fac, 1, 3, 5000, 100, "run"));
gms.setDownProtocol(new Protocol() {
public ThreadFactory getThreadFactory() {
return fac;
}
});
}
use of org.jgroups.util.ThreadFactory in project JGroups by belaban.
the class VERIFY_SUSPECT_Test method testUnsuspect.
public void testUnsuspect() throws TimeoutException {
VERIFY_SUSPECT ver = new VERIFY_SUSPECT().setTimeout(1000);
ProtImpl impl = new ProtImpl();
ver.setUpProtocol(impl);
ver.setDownProtocol(new Protocol() {
public Object down(Event evt) {
return null;
}
public Object down(Message msg) {
return null;
}
public ThreadFactory getThreadFactory() {
return new DefaultThreadFactory("foo", false, true);
}
});
Map<Address, Long> map = impl.getMap();
start = System.currentTimeMillis();
ver.up(new Event(Event.SUSPECT, Collections.singletonList(a)));
ver.up(new Event(Event.SUSPECT, Collections.singletonList(b)));
Util.waitUntil(10000, 500, () -> map.size() == 2);
ver.up(new Event(Event.SUSPECT, Collections.singletonList(a)));
ver.up(new Event(Event.SUSPECT, Collections.singletonList(b)));
ver.unsuspect(a);
Util.waitUntilTrue(10000, 500, () -> map.size() == 1);
assert map.size() == 1 && map.containsKey(b);
}
Aggregations