/** * Retrieves a Thread from this Thread store.<p> * * @param key the key of the Thread to retrieve * @return the Thread form this Thread store that matches the given key */ public A_CmsReportThread retrieveThread(CmsUUID key) { if (LOG.isDebugEnabled()) { dumpThreads(); } return m_threads.get(key); }
/** * Shut down this thread store.<p> */ protected synchronized void shutDown() { m_alive = false; interrupt(); }
/** * Hides the public constructor.<p> * * @param securityManager needed for scheduling "undercover-jobs" * that increase stability and fault tolerance */ protected CmsThreadStore(CmsSecurityManager securityManager) { super(new ThreadGroup("OpenCms Thread Store"), "OpenCms: Grim Reaper"); setDaemon(true); // Hashtable is still the most efficient form of a synchronized HashMap m_threads = new Hashtable<CmsUUID, A_CmsReportThread>(); m_alive = true; m_securityManager = securityManager; start(); }
sleep(ONE_MINUTE_IN_MILLIS); } catch (InterruptedException e) { handleDoomedThreads(); validateSessions(); persistData(); if (checkPublishQueue) { checkPublishQueue();
/** * Constructs a new report Thread with the given name.<p> * * @param cms the current OpenCms context object * @param name the name of the Thread */ protected A_CmsReportThread(CmsObject cms, String name) { super(OpenCms.getThreadStore().getThreadGroup(), name); // report Threads are never daemon Threads setDaemon(false); // the session in the cms context must not be updated when it is used in a report m_cms = cms; m_cms.getRequestContext().setUpdateSessionEnabled(false); // generate the report Thread id m_id = new CmsUUID(); setName(name + " [" + m_id + "]"); // new Threads are not doomed m_doomed = false; // set start time m_starttime = System.currentTimeMillis(); // add this Thread to the main Thread store OpenCms.getThreadStore().addThread(this); }
/** * Returns true if the report Thread is still alive (i.e. running), false otherwise.<p> * * @return true if the report Thread is still alive */ public boolean isAlive() { A_CmsReportThread thread = OpenCms.getThreadStore().retrieveThread(m_paramThread); if (thread != null) { return thread.isAlive(); } else { return false; } }
sleep(60000); } catch (InterruptedException e) { dumpThreads();
m_threadStore.shutDown();
m_threadStore = new CmsThreadStore(m_securityManager);
/** * Constructs a new report Thread with the given name.<p> * * @param cms the current OpenCms context object * @param name the name of the Thread */ protected A_CmsReportThread(CmsObject cms, String name) { super(OpenCms.getThreadStore().getThreadGroup(), name); // report Threads are never daemon Threads setDaemon(false); // the session in the cms context must not be updated when it is used in a report m_cms = cms; m_cms.getRequestContext().setUpdateSessionEnabled(false); // generate the report Thread id m_id = new CmsUUID(); setName(name + " [" + m_id + "]"); // new Threads are not doomed m_doomed = false; // set start time m_starttime = System.currentTimeMillis(); // add this Thread to the main Thread store OpenCms.getThreadStore().addThread(this); }
/** * Returns the part of the report that is ready for output.<p> * * @return the part of the report that is ready for output */ public String getReportUpdate() { A_CmsReportThread thread = OpenCms.getThreadStore().retrieveThread(m_paramThread); if (thread != null) { return thread.getReportUpdate(); } else { return ""; } }
m_threadStore.shutDown();
m_threadStore = new CmsThreadStore(m_securityManager);
/** * Hides the public constructor.<p> * * @param securityManager needed for scheduling "undercover-jobs" * that increase stability and fault tolerance */ protected CmsThreadStore(CmsSecurityManager securityManager) { super(new ThreadGroup("OpenCms Thread Store"), "OpenCms: Grim Reaper"); setDaemon(true); // Hashtable is still the most efficient form of a synchronized HashMap m_threads = new Hashtable(); m_alive = true; m_securityManager = securityManager; start(); }
/** * Returns if the report generated an error output.<p> * * @return true if the report generated an error, otherwise false */ public boolean hasError() { A_CmsReportThread thread = OpenCms.getThreadStore().retrieveThread(m_paramThread); if (thread != null) { return thread.hasError(); } else { return false; } }
/** * Retrieves a Thread from this Thread store.<p> * * @param key the key of the Thread to retrieve * @return the Thread form this Thread store that matches the given key */ public A_CmsReportThread retrieveThread(CmsUUID key) { if (LOG.isDebugEnabled()) { dumpThreads(); } return (A_CmsReportThread)m_threads.get(key); }
/** * Shut down this thread store.<p> */ protected synchronized void shutDown() { m_alive = false; interrupt(); }
/** * Returns if the report generated an error output.<p> * * @return true if the report generated an error, otherwise false */ public boolean hasError() { A_CmsReportThread thread = OpenCms.getThreadStore().retrieveThread(m_paramThread); if (thread != null) { return thread.hasError(); } else { return false; } }
/** * Adds a Thread to this Thread store.<p> * * @param thread the Thread to add */ public void addThread(A_CmsReportThread thread) { m_threads.put(thread.getUUID(), thread); if (LOG.isDebugEnabled()) { dumpThreads(); } }
/** * Returns true if the report Thread is still alive (i.e. running), false otherwise.<p> * * @return true if the report Thread is still alive */ public boolean isAlive() { A_CmsReportThread thread = OpenCms.getThreadStore().retrieveThread(m_paramThread); if (thread != null) { return thread.isAlive(); } else { return false; } }