protected void renameThreads() { for(Iterator<WeakReference<Thread>> it=threads.iterator(); it.hasNext();) { WeakReference<Thread> ref=it.next(); Thread thread=ref.get(); if(thread == null || thread.getState() == Thread.State.TERMINATED) { it.remove(); continue; } String name=thread.getName(); name=changeName(name); thread.setName(name); if(!name.contains(ADDR) && !name.contains(CLUSTER)) it.remove(); } }
/** * Stops the timer, cancelling all tasks */ public void stop() { stopRunner(); // we may need to do multiple iterations as the iterator works on a copy and tasks might have been added just // after the iterator() call returned while(!queue.isEmpty()) for(Task entry: queue) { entry.cancel(true); queue.remove(entry); } queue.clear(); if(pool instanceof ThreadPoolExecutor) { ThreadPoolExecutor p=(ThreadPoolExecutor)pool; List<Runnable> remaining_tasks=p.shutdownNow(); remaining_tasks.stream().filter(task -> task instanceof Future).forEach(task -> ((Future)task).cancel(true)); p.getQueue().clear(); try { p.awaitTermination(Global.THREADPOOL_SHUTDOWN_WAIT_TIME, TimeUnit.MILLISECONDS); } catch(InterruptedException e) { } } // clears the threads list (https://issues.jboss.org/browse/JGRP-1971) if(timer_thread_factory instanceof LazyThreadFactory) ((LazyThreadFactory)timer_thread_factory).destroy(); }
public Thread newThread(Runnable r) { return newThread(r, baseName); }
@Override public void init() throws Exception { global_thread_factory = new DefaultThreadFactory("Geode ", true); timer_thread_factory = new LazyThreadFactory(THREAD_POOL_NAME_PREFIX + " Timer", true, true); default_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " Incoming", true, true); oob_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " OOB", true, true); internal_thread_factory = new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " INT", true, true); super.init(); }
public void setAddress(String address) { boolean changed=false; if(!Util.match(this.address, address)) changed=true; super.setAddress(address); if(changed) renameThreads(); }
public Thread newThread(Runnable r, String name) { Thread retval=null; String addr=address; if(addr == null) addr=ADDR; String cluster_name=clusterName; if(cluster_name == null) cluster_name=CLUSTER; retval=super.newThread(r, name, addr, cluster_name); int size=threads.size(); threads.add(new WeakReference<>(retval)); if(size > 0) removeTerminatedThreads(); return retval; }
thread_factory=new LazyThreadFactory("jgroups", false, true); internal_thread_factory=new LazyThreadFactory("jgroups-int", false, true);
public void setClusterName(String cluster_name) { boolean changed=false; if(!Util.match(this.clusterName, cluster_name)) changed=true; super.setClusterName(cluster_name); if(changed) renameThreads(); }
@Override public void init() throws Exception { global_thread_factory=new DefaultThreadFactory("Geode ", true); timer_thread_factory=new LazyThreadFactory(THREAD_POOL_NAME_PREFIX + " Timer", true, true); default_thread_factory=new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " Incoming", true, true); oob_thread_factory=new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " OOB", true, true); internal_thread_factory=new DefaultThreadFactory(THREAD_POOL_NAME_PREFIX + " INT", true, true); super.init(); }
public void setClusterName(String cluster_name) { boolean changed=false; if(!Util.match(this.clusterName, cluster_name)) changed=true; super.setClusterName(cluster_name); if(changed) renameThreads(); }
public Thread newThread(Runnable r) { return newThread(r, baseName); }
protected void renameThreads() { for(Iterator<WeakReference<Thread>> it=threads.iterator(); it.hasNext();) { WeakReference<Thread> ref=it.next(); Thread thread=ref.get(); if(thread == null || thread.getState() == Thread.State.TERMINATED) { it.remove(); continue; } String name=thread.getName(); name=changeName(name); thread.setName(name); } }
/** * Stops the timer, cancelling all tasks */ public void stop() { stopRunner(); // we may need to do multiple iterations as the iterator works on a copy and tasks might have been added just // after the iterator() call returned while(!queue.isEmpty()) for(Task entry: queue) { entry.cancel(true); queue.remove(entry); } queue.clear(); if(pool instanceof ThreadPoolExecutor) { ThreadPoolExecutor p=(ThreadPoolExecutor)pool; List<Runnable> remaining_tasks=p.shutdownNow(); remaining_tasks.stream().filter(task -> task instanceof Future).forEach(task -> ((Future)task).cancel(true)); p.getQueue().clear(); try { p.awaitTermination(Global.THREADPOOL_SHUTDOWN_WAIT_TIME, TimeUnit.MILLISECONDS); } catch(InterruptedException e) { } } // clears the threads list (https://issues.jboss.org/browse/JGRP-1971) if(timer_thread_factory instanceof LazyThreadFactory) ((LazyThreadFactory)timer_thread_factory).destroy(); }
thread_factory=new LazyThreadFactory("jgroups", false, true); internal_thread_factory=new LazyThreadFactory("jgroups-int", false, true);
public void setAddress(String address) { boolean changed=false; if(!Util.match(this.address, address)) changed=true; super.setAddress(address); if(changed) renameThreads(); }
if (timerFactory == null) timerFactory = new LazyThreadFactory(Util.getGlobalThreadGroup(), "Timer", true, true); tp.setTimerThreadFactory(timerFactory);