/** * Returns a <code>ThreadGroup</code> whose {@link * ThreadGroup#uncaughtException} method logs to both {#link * System#err} and the given <code>LogWriterI18n</code>. * * @param name * The name of the <code>ThreadGroup</code> * @param logger * A <code>LogWriterI18n</code> to log uncaught exceptions to. It * is okay for this argument to be <code>null</code>. * * author David Whitlock * @since 3.0 */ public static LoggingThreadGroup createThreadGroup(String name, final LogWriterI18n logger) { return createThreadGroup(name, logger, null); }
private ExecutorService getShutdownAllExecutorService(LogWriterI18n logger, int size) { final ThreadGroup thrGrp = LogWriterImpl.createThreadGroup("ShutdownAllGroup", logger); ThreadFactory thrFactory = new ThreadFactory() { private final AtomicInteger threadCount = new AtomicInteger(1); public Thread newThread(Runnable r) { Thread t = new Thread(thrGrp, r, "ShutdownAll-" + threadCount.getAndIncrement()); t.setDaemon(true); return t; } }; ExecutorService es = Executors.newFixedThreadPool(shutdownAllPoolSize == -1 ? size : shutdownAllPoolSize, thrFactory); return es; }
/** * Initialize the thread pool, setting the number of threads that is equal * to the number of processors available to the JVM. */ private void initializeConflationThreadPool() { final LogWriterImpl.LoggingThreadGroup loggingThreadGroup = LogWriterImpl .createThreadGroup("WAN Queue Conflation Logger Group", this.logger); final ThreadFactory threadFactory = new ThreadFactory() { public Thread newThread(final Runnable task) { final Thread thread = new Thread(loggingThreadGroup, task, "WAN Queue Conflation Thread"); thread.setDaemon(true); return thread; } }; conflationExecutor = Executors.newFixedThreadPool(Runtime.getRuntime() .availableProcessors(), threadFactory); }
public Thread newThread(final Runnable r) { LogWriterI18n logger = InternalDistributedSystem.getLoggerI18n(); Thread result = new Thread(LogWriterImpl.createThreadGroup( "FunctionExecutionThreadGroup", logger), r, "Function Execution Thread-" + threadNum.incrementAndGet()); result.setDaemon(true); return result; } });
/** * Constructs a new TransactionManagerImpl */ private TransactionManagerImpl() { cleaner = this.new TransactionTimeOutThread(); ThreadGroup group = LogWriterImpl.createThreadGroup(LocalizedStrings.TransactionManagerImpl_CLEAN_UP_THREADS.toLocalizedString(), (LogWriterI18n) null); cleanUpThread = new Thread(group, cleaner, "GlobalTXTimeoutMonitor"); cleanUpThread.setDaemon(true); cleanUpThread.start(); }
private void startSweeper(TombstoneSweeper tombstoneSweeper) { synchronized(tombstoneSweeper) { if (tombstoneSweeper.sweeperThread == null) { tombstoneSweeper.sweeperThread = new Thread(LogWriterImpl.createThreadGroup("Destroyed Entries Processors", cache.getLoggerI18n()), tombstoneSweeper); tombstoneSweeper.sweeperThread.setDaemon(true); String product = GemFireVersion.getProductName(); if (tombstoneSweeper == this.replicatedTombstoneSweeper) { tombstoneSweeper.sweeperThread.setName(product + " Garbage Collection Thread 1"); } else { tombstoneSweeper.sweeperThread.setName(product + " Garbage Collection Thread 2"); } tombstoneSweeper.sweeperThread.start(); } } }
public Thread newThread(final Runnable command) { final Runnable r = new Runnable() { public void run() { command.run(); } }; final ThreadGroup group = LogWriterImpl.createThreadGroup(ManagementStrings.MANAGEMENT_TASK_THREAD_GROUP .toLocalizedString(), logger); Thread thread = new Thread(group, r, ManagementStrings.MANAGEMENT_TASK.toLocalizedString()); thread.setDaemon(true); return thread; } };
/** * Creates a new <code>ManagedEntityController</code> for entities * in the given distributed system. */ EnabledManagedEntityController(AdminDistributedSystem system) { this.system = system; this.threadGroup = LogWriterImpl.createThreadGroup("ManagedEntityController threads", system.getLogWriter().convertToLogWriterI18n()); }
/** * Start monitoring off-heap memory usage by adding this as a listener to the * off-heap memory allocator. */ private void startMonitoring() { synchronized (this) { if (this.started) { return; } this.offHeapMemoryUsageListener = new OffHeapMemoryUsageListener(getBytesUsed()); ThreadGroup group = LogWriterImpl.createThreadGroup("OffHeapMemoryMonitor Threads", (LogWriterI18n) null); Thread memoryListenerThread = new Thread(group, this.offHeapMemoryUsageListener); memoryListenerThread.setName(memoryListenerThread.getName() + " OffHeapMemoryListener"); memoryListenerThread.setPriority(Thread.MAX_PRIORITY); memoryListenerThread.setDaemon(true); memoryListenerThread.start(); this.memoryAllocator.addMemoryUsageListener(this); this.started = true; } }
protected SerialGatewaySenderEventProcessor(SerialGatewaySenderImpl sender, String id) { super(LogWriterImpl.createThreadGroup( "Event Processor for GatewaySender_" + id, sender.getLogger()), "Event Processor for GatewaySender_" + id, sender); this.unprocessedEvents = new LinkedHashMap<EventID, EventWrapper>(); this.unprocessedTokens = new LinkedHashMap<EventID, Long>(); initializeMessageQueue(id); setDaemon(true); }
/** * Creates a health monitor given its owner, configuration, and its dm */ public HealthMonitorImpl(InternalDistributedMember owner, GemFireHealthConfig config, DistributionManager dm) { this.owner = owner; this.id = getNewId(); this.dm = dm; this.eval = new GemFireHealthEvaluator(config, dm); this.currentStatus = GemFireHealth.GOOD_HEALTH; ThreadGroup tg = LogWriterImpl.createThreadGroup("HealthMonitor Threads", dm.getLoggerI18n()); this.t = new Thread(tg, this, LocalizedStrings.HealthMonitorImpl_HEALTH_MONITOR_OWNED_BY_0.toLocalizedString(owner)); this.t.setDaemon(true); }
/** * Default constructor for this singleton class. Private -- use * {@link #getInstance()} to get the singleton instance. */ private ConnectionSignaller() { super(LogWriterImpl.createThreadGroup( LocalizedStrings.CONNECTION_DISTRIBUTOR_THREAD.toLocalizedString(), (LogWriterI18n)null), LocalizedStrings.CONNECTION_DISTRIBUTOR_THREAD .toLocalizedString()); this.shouldContinue = true; this.connectionList = new TreeSet<ConnectionStateKey>(); this.setDaemon(true); this.start(); }
/** * Default constructor for this singleton class. Private -- use * {@link #getInstance()} to get the singleton instance. */ private ConnectionSignaller() { super(LogWriterImpl.createThreadGroup( LocalizedStrings.CONNECTION_DISTRIBUTOR_THREAD.toLocalizedString(), (LogWriterI18n)null), LocalizedStrings.CONNECTION_DISTRIBUTOR_THREAD .toLocalizedString()); this.shouldContinue = true; this.connectionList = new TreeSet<ConnectionStateKey>(); this.setDaemon(true); this.start(); }
/** * Default constructor for this singleton class. Private -- use * {@link #getInstance()} to get the singleton instance. */ private ConnectionSignaller() { super(LogWriterImpl.createThreadGroup( LocalizedStrings.CONNECTION_DISTRIBUTOR_THREAD.toLocalizedString(), (LogWriterI18n)null), LocalizedStrings.CONNECTION_DISTRIBUTOR_THREAD .toLocalizedString()); this.shouldContinue = true; this.connectionList = new TreeSet<ConnectionStateKey>(); this.setDaemon(true); this.start(); }
private void startAsyncFlusher() { final String thName = LocalizedStrings.DiskRegion_ASYNCHRONOUS_DISK_WRITER_0 .toLocalizedString(new Object[] { getName() }); this.flusherThread = new Thread(LogWriterImpl.createThreadGroup( LocalizedStrings.DiskRegion_DISK_WRITERS.toLocalizedString(), getCache().getDistributedSystem().getLogWriter() .convertToLogWriterI18n()), new FlusherThread(), thName); this.flusherThread.setDaemon(true); this.flusherThread.start(); }
/** * @param sender */ public ConcurrentSerialGatewaySenderEventProcessor( SerialGatewaySenderImpl sender) { super(LogWriterImpl.createThreadGroup("Event Processor for GatewaySender_" + sender.getId(), sender.getLogger()), "Event Processor for GatewaySender_" + sender.getId(), sender); this.sender = sender; initializeMessageQueue(sender.getId()); queues = new HashSet<RegionQueue>(); for (SerialGatewaySenderEventProcessor processor : processors) { queues.add(processor.getQueue()); } setDaemon(true); }
protected static synchronized void readyThreadGroup() { if (threadGroup == null) { InternalDistributedSystem ds = InternalDistributedSystem.getAnyInstance(); Assert.assertTrue(ds != null, "Cannot find any instance of InternalDistributedSystem"); LogWriterI18n logger = ds.getLogWriter().convertToLogWriterI18n(); String threadGroupName = LocalizedStrings.DLockService_DISTRIBUTED_LOCKING_THREADS.toLocalizedString(); final ThreadGroup group = LogWriterImpl.createThreadGroup( threadGroupName, logger); threadGroup = group; } }
private void initializeEvictorThreadPool() { final ThreadGroup evictorThreadGroup = LogWriterImpl.createThreadGroup( getEvictorThreadGroupName(), getLoggerI18n()); ThreadFactory evictorThreadFactory = new ThreadFactory() { private int next = 0; public Thread newThread(Runnable command) { Thread t = new Thread(evictorThreadGroup, command, getEvictorThreadName() + next++); t.setDaemon(true); return t; } }; if (!DISABLE_HEAP_EVICTIOR_THREAD_POOL) { this.poolQueue = new OverflowQueueWithDMStats(getGemFireCache().getCachePerfStats().getEvictionQueueStatHelper()); this.evictorThreadPool = new ThreadPoolExecutor(MAX_EVICTOR_THREADS, MAX_EVICTOR_THREADS, 15, TimeUnit.SECONDS, this.poolQueue, evictorThreadFactory); } }
protected ParallelGatewaySenderEventProcessor( ParallelGatewaySenderImpl sender) { super(LogWriterImpl.createThreadGroup("Event Processor for GatewaySender_" + sender.getId(), sender.getLogger()), "Event Processor for GatewaySender_" + sender.getId(), sender); this.index = 0; this.nDispatcher = 1; initializeMessageQueue(sender.getId()); setDaemon(true); }
/** * use in concurrent scenario where queue is to be shared among all the processors. */ protected ParallelGatewaySenderEventProcessor(ParallelGatewaySenderImpl sender, Set<Region> userRegions, int id, int nDispatcher) { super(LogWriterImpl.createThreadGroup("Event Processor for GatewaySender_" + sender.getId(), sender.getLogger()), "Event Processor for GatewaySender_" + sender.getId()+"_"+ id, sender); this.index = id; this.nDispatcher = nDispatcher; //this.queue = new ParallelGatewaySenderQueue(sender, userRegions, id, nDispatcher); initializeMessageQueue(sender.getId()); setDaemon(true); }