Search in sources :

Example 1 with IReIndexWorkItem

use of com.helger.pd.indexer.reindex.IReIndexWorkItem in project phoss-directory by phax.

the class PDIndexerManager method expireOldEntries.

/**
 * Expire all re-index entries that are in the list for a too long time. This
 * is called from a scheduled job only. All respective items are move from the
 * re-index list to the dead list.
 */
public void expireOldEntries() {
    // Expire old entries
    final ICommonsList<IReIndexWorkItem> aExpiredItems = m_aReIndexList.getAndRemoveAllEntries(IReIndexWorkItem::isExpired);
    if (aExpiredItems.isNotEmpty()) {
        LOGGER.info("Expiring " + aExpiredItems.size() + " re-index work items and move them to the dead list");
        for (final IReIndexWorkItem aItem : aExpiredItems) {
            // remove them from the overall list but move to dead item list
            m_aRWLock.writeLockedBoolean(() -> m_aUniqueItems.remove(aItem.getWorkItem()));
            // move all to the dead item list
            m_aDeadList.addItem((ReIndexWorkItem) aItem);
            LOGGER.info("Added " + aItem.getLogText() + " to the dead list");
        }
    }
}
Also used : IReIndexWorkItem(com.helger.pd.indexer.reindex.IReIndexWorkItem)

Example 2 with IReIndexWorkItem

use of com.helger.pd.indexer.reindex.IReIndexWorkItem 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 3 with IReIndexWorkItem

use of com.helger.pd.indexer.reindex.IReIndexWorkItem in project phoss-directory by phax.

the class PDIndexerManager method reIndexParticipantData.

/**
 * Re-index all entries that are ready to be re-indexed now. This is called
 * from a scheduled job only.
 */
public void reIndexParticipantData() {
    final LocalDateTime aNow = PDTFactory.getCurrentLocalDateTime();
    // Get and remove all items to re-index "now"
    final List<IReIndexWorkItem> aReIndexNowItems = m_aReIndexList.getAndRemoveAllEntries(aWorkItem -> aWorkItem.isRetryPossible(aNow));
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Re-indexing " + aReIndexNowItems.size() + " work items");
    for (final IReIndexWorkItem aReIndexItem : aReIndexNowItems) {
        LOGGER.info("Try to re-index " + aReIndexItem.getLogText());
        PDIndexExecutor.executeWorkItem(m_aStorageMgr, aReIndexItem.getWorkItem(), 1 + aReIndexItem.getRetryCount(), aSuccessItem -> _onReIndexSuccess(aSuccessItem), aFailureItem -> _onReIndexFailure(aReIndexItem));
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) IReIndexWorkItem(com.helger.pd.indexer.reindex.IReIndexWorkItem)

Aggregations

IReIndexWorkItem (com.helger.pd.indexer.reindex.IReIndexWorkItem)3 ISimpleURL (com.helger.commons.url.ISimpleURL)1 HCRow (com.helger.html.hc.html.tabular.HCRow)1 HCTable (com.helger.html.hc.html.tabular.HCTable)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 IIndexerWorkItem (com.helger.pd.indexer.index.IIndexerWorkItem)1 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)1 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)1 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)1 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)1 LocalDateTime (java.time.LocalDateTime)1 Locale (java.util.Locale)1