Search in sources :

Example 6 with SearchServiceStatus

use of org.olat.search.SearchServiceStatus in project OpenOLAT by OpenOLAT.

the class ProcSamplerJob method writeProcFile.

public void writeProcFile(File xmlFile) {
    try {
        Statistics statistics = CoreSpringFactory.getImpl(MonitoringService.class).getStatistics();
        Document doc = loadDocument(xmlFile);
        if (doc == null)
            return;
        Element rootEl = doc.getDocumentElement();
        // sessions
        SessionsVO sessionsVo = statistics.getSessionsVo();
        addValue("secureAuthenticatedCount", sessionsVo.getSecureAuthenticatedCount(), rootEl, doc);
        addValue("secureRestCount", sessionsVo.getSecureRestCount(), rootEl, doc);
        addValue("secureWebdavCount", sessionsVo.getSecureWebdavCount(), rootEl, doc);
        // clicks
        addValue("authenticatedClickCountLastFiveMinutes", sessionsVo.getAuthenticatedClickCountLastFiveMinutes(), rootEl, doc);
        addValue("concurrentDispatchThreads", sessionsVo.getConcurrentDispatchThreads(), rootEl, doc);
        addValue("requestLastFiveMinutes", sessionsVo.getRequestLastFiveMinutes(), rootEl, doc);
        addValue("requestLastMinute", sessionsVo.getRequestLastMinute(), rootEl, doc);
        // openolat
        addValue("activeUserCount", statistics.getActiveUserCount(), rootEl, doc);
        addValue("totalGroupCount", statistics.getTotalGroupCount(), rootEl, doc);
        addValue("publishedCourses", statistics.getPublishedCourses(), rootEl, doc);
        // indexer
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        format.setTimeZone(TimeZones.getUtcTimeZone());
        SearchServiceStatus status = SearchServiceFactory.getService().getStatus();
        if (status instanceof SearchServiceStatusImpl) {
            SearchServiceStatusImpl statusImpl = (SearchServiceStatusImpl) status;
            FullIndexerStatus fStatus = statusImpl.getFullIndexerStatus();
            String date = format.format(new Date(fStatus.getLastFullIndexTime()));
            addValue("lastFullIndexTime", date, rootEl, doc);
        }
        // marker
        addValue("lastOpenOLATSampling", format.format(new Date()), rootEl, doc);
        // Use a Transformer for output
        try (OutputStream out = new FileOutputStream(xmlFile)) {
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.transform(new DOMSource(doc), new StreamResult(out));
        } catch (IOException e) {
            log.error("", e);
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) FullIndexerStatus(org.olat.search.service.indexer.FullIndexerStatus) Element(org.w3c.dom.Element) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) SearchServiceStatusImpl(org.olat.search.service.SearchServiceStatusImpl) IOException(java.io.IOException) Document(org.w3c.dom.Document) Statistics(org.olat.restapi.system.MonitoringService.Statistics) Date(java.util.Date) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) SessionsVO(org.olat.restapi.system.vo.SessionsVO) FileOutputStream(java.io.FileOutputStream) SimpleDateFormat(java.text.SimpleDateFormat) SearchServiceStatus(org.olat.search.SearchServiceStatus)

Example 7 with SearchServiceStatus

use of org.olat.search.SearchServiceStatus in project OpenOLAT by OpenOLAT.

the class IndexerWebService method getIndexerStatistics.

protected IndexerStatisticsVO getIndexerStatistics() {
    IndexerStatisticsVO stats = new IndexerStatisticsVO();
    SearchServiceStatus status = SearchServiceFactory.getService().getStatus();
    if (status instanceof SearchServiceStatusImpl) {
        SearchServiceStatusImpl statusImpl = (SearchServiceStatusImpl) status;
        FullIndexerStatus fStatus = statusImpl.getFullIndexerStatus();
        stats.setIndexedDocumentCount(fStatus.getDocumentCount());
        stats.setExcludedDocumentCount(fStatus.getExcludedDocumentCount());
        stats.setIndexSize(fStatus.getIndexSize());
        stats.setIndexingTime(fStatus.getIndexingTime());
        stats.setFullIndexStartedAt(fStatus.getFullIndexStartedAt());
        stats.setDocumentQueueSize(fStatus.getDocumentQueueSize());
        stats.setRunningFolderIndexerCount(fStatus.getNumberRunningFolderIndexer());
        stats.setAvailableFolderIndexerCount(fStatus.getNumberAvailableFolderIndexer());
        stats.setLastFullIndexTime(fStatus.getLastFullIndexDateString());
        stats.setStatus(status.getStatus());
    } else {
        stats.setStatus("disabled");
    }
    return stats;
}
Also used : IndexerStatisticsVO(org.olat.restapi.system.vo.IndexerStatisticsVO) FullIndexerStatus(org.olat.search.service.indexer.FullIndexerStatus) SearchServiceStatusImpl(org.olat.search.service.SearchServiceStatusImpl) SearchServiceStatus(org.olat.search.SearchServiceStatus)

Example 8 with SearchServiceStatus

use of org.olat.search.SearchServiceStatus in project OpenOLAT by OpenOLAT.

the class SearchServiceImpl method stop.

@Override
public void stop() {
    SearchServiceStatus status = getStatus();
    String statusStr = status.getStatus();
    if (statusStr.equals(FullIndexerStatus.STATUS_RUNNING)) {
        stopIndexing();
    }
    try {
        if (indexSearcherRefMgr != null) {
            indexSearcherRefMgr.close();
            indexSearcherRefMgr = null;
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : SearchServiceStatus(org.olat.search.SearchServiceStatus) QueryException(org.olat.search.QueryException) AssertException(org.olat.core.logging.AssertException) TimeoutException(java.util.concurrent.TimeoutException) ServiceNotAvailableException(org.olat.search.ServiceNotAvailableException) ParseException(org.apache.lucene.queryparser.classic.ParseException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 9 with SearchServiceStatus

use of org.olat.search.SearchServiceStatus in project openolat by klemens.

the class MonitoringService method getStatistics.

public Statistics getStatistics() {
    Statistics statistics = new Statistics();
    SessionsVO sessionsVo = new OpenOLATStatisticsWebService().getSessionsVO();
    statistics.setSessionsVo(sessionsVo);
    SearchServiceStatus status = SearchServiceFactory.getService().getStatus();
    if (status instanceof SearchServiceStatusImpl) {
        SearchServiceStatusImpl statusImpl = (SearchServiceStatusImpl) status;
        FullIndexerStatus fStatus = statusImpl.getFullIndexerStatus();
        statistics.setLastFullIndexTime(fStatus.getLastFullIndexDateString());
    }
    // activeUserCount="88" // registered and activated identities, same as in GUI
    if (start < 1 || (System.currentTimeMillis() - start) > RENEW_RATE) {
        start = System.currentTimeMillis();
        activeUserCount = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, null, Constants.USERSTATUS_ACTIVE);
        totalGroupCount = businessGroupService.countBusinessGroups(null, null);
        publishedCourses = repositoryManager.countPublished(CourseModule.ORES_TYPE_COURSE);
    }
    statistics.setActiveUserCount(activeUserCount);
    statistics.setTotalGroupCount(totalGroupCount);
    statistics.setPublishedCourses(publishedCourses);
    DatabaseConnectionVO connections = databaseStatsManager.getConnectionInfos();
    if (connections != null) {
        statistics.setActiveConnectionCount(connections.getActiveConnectionCount());
        statistics.setCurrentConnectionCount(connections.getCurrentConnectionCount());
    }
    return statistics;
}
Also used : SessionsVO(org.olat.restapi.system.vo.SessionsVO) FullIndexerStatus(org.olat.search.service.indexer.FullIndexerStatus) SearchServiceStatusImpl(org.olat.search.service.SearchServiceStatusImpl) SearchServiceStatus(org.olat.search.SearchServiceStatus) DatabaseConnectionVO(org.olat.admin.sysinfo.model.DatabaseConnectionVO)

Example 10 with SearchServiceStatus

use of org.olat.search.SearchServiceStatus in project openolat by klemens.

the class ProcSamplerJob method writeProcFile.

public void writeProcFile(File xmlFile) {
    try {
        Statistics statistics = CoreSpringFactory.getImpl(MonitoringService.class).getStatistics();
        Document doc = loadDocument(xmlFile);
        if (doc == null)
            return;
        Element rootEl = doc.getDocumentElement();
        // sessions
        SessionsVO sessionsVo = statistics.getSessionsVo();
        addValue("secureAuthenticatedCount", sessionsVo.getSecureAuthenticatedCount(), rootEl, doc);
        addValue("secureRestCount", sessionsVo.getSecureRestCount(), rootEl, doc);
        addValue("secureWebdavCount", sessionsVo.getSecureWebdavCount(), rootEl, doc);
        // clicks
        addValue("authenticatedClickCountLastFiveMinutes", sessionsVo.getAuthenticatedClickCountLastFiveMinutes(), rootEl, doc);
        addValue("concurrentDispatchThreads", sessionsVo.getConcurrentDispatchThreads(), rootEl, doc);
        addValue("requestLastFiveMinutes", sessionsVo.getRequestLastFiveMinutes(), rootEl, doc);
        addValue("requestLastMinute", sessionsVo.getRequestLastMinute(), rootEl, doc);
        // openolat
        addValue("activeUserCount", statistics.getActiveUserCount(), rootEl, doc);
        addValue("totalGroupCount", statistics.getTotalGroupCount(), rootEl, doc);
        addValue("publishedCourses", statistics.getPublishedCourses(), rootEl, doc);
        // indexer
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        format.setTimeZone(TimeZones.getUtcTimeZone());
        SearchServiceStatus status = SearchServiceFactory.getService().getStatus();
        if (status instanceof SearchServiceStatusImpl) {
            SearchServiceStatusImpl statusImpl = (SearchServiceStatusImpl) status;
            FullIndexerStatus fStatus = statusImpl.getFullIndexerStatus();
            String date = format.format(new Date(fStatus.getLastFullIndexTime()));
            addValue("lastFullIndexTime", date, rootEl, doc);
        }
        // marker
        addValue("lastOpenOLATSampling", format.format(new Date()), rootEl, doc);
        // Use a Transformer for output
        try (OutputStream out = new FileOutputStream(xmlFile)) {
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.transform(new DOMSource(doc), new StreamResult(out));
        } catch (IOException e) {
            log.error("", e);
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) FullIndexerStatus(org.olat.search.service.indexer.FullIndexerStatus) Element(org.w3c.dom.Element) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) SearchServiceStatusImpl(org.olat.search.service.SearchServiceStatusImpl) IOException(java.io.IOException) Document(org.w3c.dom.Document) Statistics(org.olat.restapi.system.MonitoringService.Statistics) Date(java.util.Date) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) SessionsVO(org.olat.restapi.system.vo.SessionsVO) FileOutputStream(java.io.FileOutputStream) SimpleDateFormat(java.text.SimpleDateFormat) SearchServiceStatus(org.olat.search.SearchServiceStatus)

Aggregations

SearchServiceStatus (org.olat.search.SearchServiceStatus)12 SearchServiceStatusImpl (org.olat.search.service.SearchServiceStatusImpl)10 FullIndexerStatus (org.olat.search.service.indexer.FullIndexerStatus)8 IOException (java.io.IOException)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 SessionsVO (org.olat.restapi.system.vo.SessionsVO)4 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 Transformer (javax.xml.transform.Transformer)2 TransformerFactory (javax.xml.transform.TransformerFactory)2 DOMSource (javax.xml.transform.dom.DOMSource)2 StreamResult (javax.xml.transform.stream.StreamResult)2 ParseException (org.apache.lucene.queryparser.classic.ParseException)2 DatabaseConnectionVO (org.olat.admin.sysinfo.model.DatabaseConnectionVO)2