Search in sources :

Example 1 with IIndexerWorkItem

use of com.helger.pd.indexer.index.IIndexerWorkItem in project phoss-directory by phax.

the class PDIndexerManager method close.

public void close() throws IOException {
    // Get all remaining objects and save them for late reuse
    final ICommonsList<IIndexerWorkItem> aRemainingWorkItems = m_aIndexerWorkQueue.stop();
    if (aRemainingWorkItems.isNotEmpty()) {
        LOGGER.info("Persisting " + aRemainingWorkItems.size() + " indexer work items");
        final IMicroDocument aDoc = new MicroDocument();
        final IMicroElement eRoot = aDoc.appendElement(ELEMENT_ROOT);
        for (final IIndexerWorkItem aItem : aRemainingWorkItems) eRoot.appendChild(MicroTypeConverter.convertToMicroElement(aItem, ELEMENT_ITEM));
        if (MicroWriter.writeToFile(aDoc, m_aIndexerWorkItemFile).isFailure())
            throw new IllegalStateException("Failed to write IndexerWorkItems to " + m_aIndexerWorkItemFile);
    }
    // Unschedule the job to avoid problems on shutdown. Use the saved instance
    // because GlobalQuartzScheduler.getInstance() would fail because the global
    // scope is already in destruction.
    m_aScheduler.unscheduleJob(m_aTriggerKey);
    // Close Lucene index etc.
    m_aStorageMgr.close();
}
Also used : IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) IMicroDocument(com.helger.xml.microdom.IMicroDocument) MicroDocument(com.helger.xml.microdom.MicroDocument) IMicroElement(com.helger.xml.microdom.IMicroElement) IMicroDocument(com.helger.xml.microdom.IMicroDocument)

Example 2 with IIndexerWorkItem

use of com.helger.pd.indexer.index.IIndexerWorkItem in project phoss-directory by phax.

the class ReIndexWorkItemMicroTypeConverter method convertToNative.

@Nullable
public ReIndexWorkItem convertToNative(@Nonnull final IMicroElement aElement) {
    final IIndexerWorkItem aWorkItem = MicroTypeConverter.convertToNative(aElement.getFirstChildElement(ELEMENT_WORK_ITEM), IndexerWorkItem.class);
    final LocalDateTime aMaxRetryDT = aElement.getAttributeValueWithConversion(ATTR_MAX_RETRY_DT, LocalDateTime.class);
    final String sRetryCount = aElement.getAttributeValue(ATTR_RETRY_COUNT);
    final int nRetryCount = StringParser.parseInt(sRetryCount, -1);
    if (nRetryCount < 0)
        throw new IllegalStateException("Invalid retry count '" + sRetryCount + "'");
    final LocalDateTime aPreviousRetryDT = aElement.getAttributeValueWithConversion(ATTR_PREVIOUS_RETRY_DT, LocalDateTime.class);
    final LocalDateTime aNextRetryDT = aElement.getAttributeValueWithConversion(ATTR_NEXT_RETRY_DT, LocalDateTime.class);
    return new ReIndexWorkItem(aWorkItem, aMaxRetryDT, nRetryCount, aPreviousRetryDT, aNextRetryDT);
}
Also used : LocalDateTime(java.time.LocalDateTime) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) Nullable(javax.annotation.Nullable)

Example 3 with IIndexerWorkItem

use of com.helger.pd.indexer.index.IIndexerWorkItem in project phoss-directory by phax.

the class PageSecureListIndex method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    // Add toolbar
    {
        final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
        aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
        aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
    }
    final LinkedBlockingQueue<Object> aQueue = PDMetaManager.getIndexerMgr().getIndexerWorkQueue().getQueue();
    final int nLength = aQueue.size();
    if (nLength == 0) {
        aNodeList.addChild(success("The Index Queue is currently empty"));
    } else {
        aNodeList.addChild(info("The Index Queue contains " + nLength + " entries"));
        final BootstrapTable aTable = new BootstrapTable(new DTCol("Queue date time").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant ID"), new DTCol("Action"), new DTCol("Owner"), new DTCol("Requestor")).setID("indexqueue");
        for (final Object o : aQueue) if (o instanceof IIndexerWorkItem) {
            final IIndexerWorkItem aObj = (IIndexerWorkItem) o;
            final HCRow aRow = aTable.addBodyRow();
            aRow.addCell(PDTToString.getAsString(aObj.getCreationDateTime(), aDisplayLocale));
            aRow.addCell(aObj.getParticipantID().getURIEncoded());
            aRow.addCell(aObj.getType().getDisplayName());
            aRow.addCell(aObj.getOwnerID());
            aRow.addCell(aObj.getRequestingHost());
        }
        aNodeList.addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
    }
}
Also used : Locale(java.util.Locale) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) HCRow(com.helger.html.hc.html.tabular.HCRow) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 4 with IIndexerWorkItem

use of com.helger.pd.indexer.index.IIndexerWorkItem in project phoss-directory by phax.

the class AbstractPageSecureReIndex method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    // Add toolbar
    {
        final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
        aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
        aToolbar.addChild(new BootstrapButton().addChild("Delete all entries").setIcon(EDefaultIcon.DELETE).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_DELETE_ALL)));
        aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
    }
    final HCTable aTable = new HCTable(new DTCol("Reg date").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant"), new DTCol("Action"), new DTCol("Retries").setDisplayType(EDTColType.INT, aDisplayLocale), m_bDeadIndex ? null : new DTCol("Next retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new DTCol("Last retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final IReIndexWorkItem aItem : getReIndexWorkItemList().getAllItems()) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aItem);
        final IIndexerWorkItem aWorkItem = aItem.getWorkItem();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
        aRow.addCell(aWorkItem.getParticipantID().getURIEncoded());
        aRow.addCell(aWorkItem.getType().getDisplayName());
        aRow.addCell(Integer.toString(aItem.getRetryCount()));
        if (!m_bDeadIndex)
            aRow.addCell(PDTToString.getAsString(aItem.getNextRetryDT(), aDisplayLocale));
        aRow.addCell(PDTToString.getAsString(aItem.getMaxRetryDT(), aDisplayLocale));
        final IHCCell<?> aActionCell = aRow.addCell();
        if (m_bDeadIndex) {
            aActionCell.addChild(new HCA(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_REINDEX_NOW).add(CPageParam.PARAM_OBJECT, aItem.getID())).setTitle("Re-index the entry now").addChild(EDefaultIcon.NEXT.getAsNode()));
            aActionCell.addChild(" ");
        }
        aActionCell.addChild(createDeleteLink(aWPEC, aItem));
    }
    aNodeList.addChild(aTable);
    aNodeList.addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) IReIndexWorkItem(com.helger.pd.indexer.reindex.IReIndexWorkItem) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 5 with IIndexerWorkItem

use of com.helger.pd.indexer.index.IIndexerWorkItem in project phoss-directory by phax.

the class AbstractPageSecureReIndex method showSelectedObject.

@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final IReIndexWorkItem aSelectedObject) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPURLProvider aURLProvider = PDServerConfiguration.getURLProvider();
    final IIndexerWorkItem aWorkItem = aSelectedObject.getWorkItem();
    final IParticipantIdentifier aParticipantID = aWorkItem.getParticipantID();
    final BootstrapViewForm aViewForm = aNodeList.addAndReturnChild(new BootstrapViewForm());
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Creation datetime").setCtrl(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Participant ID").setCtrl(aParticipantID.getURIEncoded()));
    final String sBCSuffix = "/businesscard/" + aParticipantID.getURIPercentEncoded();
    {
        final HCNodeList aURLs = new HCNodeList();
        for (final ISMLInfo aSMLInfo : PDPMetaManager.getSMLInfoMgr().getAll()) {
            if (aURLs.hasChildren())
                aURLs.addChild(div("or"));
            try {
                aURLs.addChild(div(HCA.createLinkedWebsite(aURLProvider.getSMPURIOfParticipant(aParticipantID, aSMLInfo).toString() + sBCSuffix)));
            } catch (final SMPDNSResolutionException ex) {
                // Non existing participant!
                aURLs.addChild(div(aParticipantID.getURIPercentEncoded() + " on " + aSMLInfo.getDisplayName() + " @ " + sBCSuffix + " [" + ex.getMessage() + "]"));
            }
        }
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Business Card URL").setCtrl(aURLs));
    }
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Action type").setCtrl(aWorkItem.getType().getDisplayName()));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Owner").setCtrl(aWorkItem.getOwnerID()));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Requesting host").setCtrl(aWorkItem.getRequestingHost()));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Retries so far").setCtrl(Integer.toString(aSelectedObject.getRetryCount())));
    if (aSelectedObject.hasPreviousRetryDT())
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Previous retry").setCtrl(PDTToString.getAsString(aSelectedObject.getPreviousRetryDT(), aDisplayLocale)));
    if (!m_bDeadIndex)
        aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Next retry").setCtrl(PDTToString.getAsString(aSelectedObject.getNextRetryDT(), aDisplayLocale)));
    aViewForm.addFormGroup(new BootstrapFormGroup().setLabel("Last retry").setCtrl(PDTToString.getAsString(aSelectedObject.getMaxRetryDT(), aDisplayLocale)));
}
Also used : Locale(java.util.Locale) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) ISMPURLProvider(com.helger.smpclient.url.ISMPURLProvider) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) SMPDNSResolutionException(com.helger.smpclient.url.SMPDNSResolutionException) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Aggregations

IIndexerWorkItem (com.helger.pd.indexer.index.IIndexerWorkItem)5 HCNodeList (com.helger.html.hc.impl.HCNodeList)3 Locale (java.util.Locale)3 HCRow (com.helger.html.hc.html.tabular.HCRow)2 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)2 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)2 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)2 PDTToString (com.helger.commons.datetime.PDTToString)1 ISimpleURL (com.helger.commons.url.ISimpleURL)1 HCTable (com.helger.html.hc.html.tabular.HCTable)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 IReIndexWorkItem (com.helger.pd.indexer.reindex.IReIndexWorkItem)1 ISMLInfo (com.helger.peppol.sml.ISMLInfo)1 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)1 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)1 BootstrapViewForm (com.helger.photon.bootstrap4.form.BootstrapViewForm)1 BootstrapTable (com.helger.photon.bootstrap4.table.BootstrapTable)1 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)1 ISMPURLProvider (com.helger.smpclient.url.ISMPURLProvider)1 SMPDNSResolutionException (com.helger.smpclient.url.SMPDNSResolutionException)1