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