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");
}
}
}
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));
}
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));
}
}
Aggregations