Search in sources :

Example 1 with Duration

use of org.alfresco.service.cmr.repository.datatype.Duration in project SearchServices by Alfresco.

the class LoadAFTSTestData method getOrderProperties.

private static Map<QName, PropertyValue> getOrderProperties() {
    double orderDoubleCount = -0.11d + orderTextCount * ((orderTextCount % 2 == 0) ? 0.1d : -0.1d);
    float orderFloatCount = -3.5556f + orderTextCount * ((orderTextCount % 2 == 0) ? 0.82f : -0.82f);
    long orderLongCount = -1999999999999999l + orderTextCount * ((orderTextCount % 2 == 0) ? 299999999999999l : -299999999999999l);
    int orderIntCount = -45764576 + orderTextCount * ((orderTextCount % 2 == 0) ? 8576457 : -8576457);
    Map<QName, PropertyValue> testProperties = new HashMap<QName, PropertyValue>();
    testProperties.put(createdDate, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
    testProperties.put(createdTime, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDate)));
    testProperties.put(orderDouble, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderDoubleCount)));
    testProperties.put(orderFloat, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderFloatCount)));
    testProperties.put(orderLong, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderLongCount)));
    testProperties.put(orderInt, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, orderIntCount)));
    testProperties.put(orderText, new StringPropertyValue(DefaultTypeConverter.INSTANCE.convert(String.class, new String(new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " cabbage")));
    testProperties.put(ContentModel.PROP_NAME, new StringPropertyValue(orderNames[orderTextCount]));
    testProperties.put(orderLocalisedText, new StringPropertyValue(orderLocalisedNames[orderTextCount]));
    MLTextPropertyValue mlTextPropLocalisedOrder = new MLTextPropertyValue();
    if (orderLocaliseMLText_en[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(Locale.ENGLISH, orderLocaliseMLText_en[orderTextCount]);
    }
    if (orderLocaliseMLText_fr[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(Locale.FRENCH, orderLocaliseMLText_fr[orderTextCount]);
    }
    if (orderLocaliseMLText_es[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(new Locale("es"), orderLocaliseMLText_es[orderTextCount]);
    }
    if (orderLocaliseMLText_de[orderTextCount].length() > 0) {
        mlTextPropLocalisedOrder.addValue(Locale.GERMAN, orderLocaliseMLText_de[orderTextCount]);
    }
    testProperties.put(orderLocalisedMLText, mlTextPropLocalisedOrder);
    MLTextPropertyValue mlTextPropVal = new MLTextPropertyValue();
    mlTextPropVal.addValue(Locale.ENGLISH, new String(new char[] { (char) ('l' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " banana");
    mlTextPropVal.addValue(Locale.FRENCH, new String(new char[] { (char) ('L' + ((orderTextCount % 2 == 0) ? -orderTextCount : orderTextCount)) }) + " banane");
    mlTextPropVal.addValue(Locale.CHINESE, new String(new char[] { (char) ('香' + ((orderTextCount % 2 == 0) ? orderTextCount : -orderTextCount)) }) + " 香蕉");
    testProperties.put(orderMLText, mlTextPropVal);
    orderDate = Duration.subtract(orderDate, new Duration("P1D"));
    orderTextCount++;
    return testProperties;
}
Also used : Locale(java.util.Locale) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue) MultiPropertyValue(org.alfresco.solr.client.MultiPropertyValue) PropertyValue(org.alfresco.solr.client.PropertyValue) StringPropertyValue(org.alfresco.solr.client.StringPropertyValue) ContentPropertyValue(org.alfresco.solr.client.ContentPropertyValue) Duration(org.alfresco.service.cmr.repository.datatype.Duration) MLTextPropertyValue(org.alfresco.solr.client.MLTextPropertyValue)

Example 2 with Duration

use of org.alfresco.service.cmr.repository.datatype.Duration in project SearchServices by Alfresco.

the class HandlerReportBuilder method addCoreSummary.

/**
 * Adds a core summary
 * @param cname
 * @param detail
 * @param hist
 * @param values
 * @param srv
 * @param report
 * @throws IOException
 */
public static void addCoreSummary(TrackerRegistry trackerRegistry, String cname, boolean detail, boolean hist, boolean values, InformationServer srv, NamedList<Object> report) throws IOException {
    NamedList<Object> coreSummary = new SimpleOrderedMap<Object>();
    coreSummary.addAll((SimpleOrderedMap<Object>) srv.getCoreStats());
    MetadataTracker metaTrkr = trackerRegistry.getTrackerForCore(cname, MetadataTracker.class);
    TrackerState metadataTrkrState = metaTrkr.getTrackerState();
    long lastIndexTxCommitTime = metadataTrkrState.getLastIndexedTxCommitTime();
    long lastIndexedTxId = metadataTrkrState.getLastIndexedTxId();
    long lastTxCommitTimeOnServer = metadataTrkrState.getLastTxCommitTimeOnServer();
    long lastTxIdOnServer = metadataTrkrState.getLastTxIdOnServer();
    Date lastIndexTxCommitDate = new Date(lastIndexTxCommitTime);
    Date lastTxOnServerDate = new Date(lastTxCommitTimeOnServer);
    long transactionsToDo = lastTxIdOnServer - lastIndexedTxId;
    if (transactionsToDo < 0) {
        transactionsToDo = 0;
    }
    AclTracker aclTrkr = trackerRegistry.getTrackerForCore(cname, AclTracker.class);
    TrackerState aclTrkrState = aclTrkr.getTrackerState();
    long lastIndexChangeSetCommitTime = aclTrkrState.getLastIndexedChangeSetCommitTime();
    long lastIndexedChangeSetId = aclTrkrState.getLastIndexedChangeSetId();
    long lastChangeSetCommitTimeOnServer = aclTrkrState.getLastChangeSetCommitTimeOnServer();
    long lastChangeSetIdOnServer = aclTrkrState.getLastChangeSetIdOnServer();
    Date lastIndexChangeSetCommitDate = new Date(lastIndexChangeSetCommitTime);
    Date lastChangeSetOnServerDate = new Date(lastChangeSetCommitTimeOnServer);
    long changeSetsToDo = lastChangeSetIdOnServer - lastIndexedChangeSetId;
    if (changeSetsToDo < 0) {
        changeSetsToDo = 0;
    }
    long nodesToDo = 0;
    long remainingTxTimeMillis = 0;
    if (transactionsToDo > 0) {
        // We now use the elapsed time as seen by the single thread farming out metadata indexing
        double meanDocsPerTx = srv.getTrackerStats().getMeanDocsPerTx();
        double meanNodeElaspedIndexTime = srv.getTrackerStats().getMeanNodeElapsedIndexTime();
        nodesToDo = (long) (transactionsToDo * meanDocsPerTx);
        remainingTxTimeMillis = (long) (nodesToDo * meanNodeElaspedIndexTime);
    }
    Date now = new Date();
    Date end = new Date(now.getTime() + remainingTxTimeMillis);
    Duration remainingTx = new Duration(now, end);
    long remainingChangeSetTimeMillis = 0;
    if (changeSetsToDo > 0) {
        // We now use the elapsed time as seen by the single thread farming out alc indexing
        double meanAclsPerChangeSet = srv.getTrackerStats().getMeanAclsPerChangeSet();
        double meanAclElapsedIndexTime = srv.getTrackerStats().getMeanAclElapsedIndexTime();
        remainingChangeSetTimeMillis = (long) (changeSetsToDo * meanAclsPerChangeSet * meanAclElapsedIndexTime);
    }
    now = new Date();
    end = new Date(now.getTime() + remainingChangeSetTimeMillis);
    Duration remainingChangeSet = new Duration(now, end);
    NamedList<Object> ftsSummary = new SimpleOrderedMap<Object>();
    long remainingContentTimeMillis = 0;
    srv.addFTSStatusCounts(ftsSummary);
    long cleanCount = ((Long) ftsSummary.get("Node count with FTSStatus Clean")).longValue();
    long dirtyCount = ((Long) ftsSummary.get("Node count with FTSStatus Dirty")).longValue();
    long newCount = ((Long) ftsSummary.get("Node count with FTSStatus New")).longValue();
    long nodesInIndex = ((Long) coreSummary.get("Alfresco Nodes in Index"));
    long contentYetToSee = nodesInIndex > 0 ? nodesToDo * (cleanCount + dirtyCount + newCount) / nodesInIndex : 0;
    ;
    if (dirtyCount + newCount + contentYetToSee > 0) {
        // We now use the elapsed time as seen by the single thread farming out alc indexing
        double meanContentElapsedIndexTime = srv.getTrackerStats().getMeanContentElapsedIndexTime();
        remainingContentTimeMillis = (long) ((dirtyCount + newCount + contentYetToSee) * meanContentElapsedIndexTime);
    }
    now = new Date();
    end = new Date(now.getTime() + remainingContentTimeMillis);
    Duration remainingContent = new Duration(now, end);
    coreSummary.add("FTS", ftsSummary);
    Duration txLag = new Duration(lastIndexTxCommitDate, lastTxOnServerDate);
    if (lastIndexTxCommitDate.compareTo(lastTxOnServerDate) > 0) {
        txLag = new Duration();
    }
    long txLagSeconds = (lastTxCommitTimeOnServer - lastIndexTxCommitTime) / 1000;
    if (txLagSeconds < 0) {
        txLagSeconds = 0;
    }
    Duration changeSetLag = new Duration(lastIndexChangeSetCommitDate, lastChangeSetOnServerDate);
    if (lastIndexChangeSetCommitDate.compareTo(lastChangeSetOnServerDate) > 0) {
        changeSetLag = new Duration();
    }
    long changeSetLagSeconds = (lastChangeSetCommitTimeOnServer - lastIndexChangeSetCommitTime) / 1000;
    if (txLagSeconds < 0) {
        txLagSeconds = 0;
    }
    ContentTracker contentTrkr = trackerRegistry.getTrackerForCore(cname, ContentTracker.class);
    TrackerState contentTrkrState = contentTrkr.getTrackerState();
    // Leave ModelTracker out of this check, because it is common
    boolean aTrackerIsRunning = aclTrkrState.isRunning() || metadataTrkrState.isRunning() || contentTrkrState.isRunning();
    coreSummary.add("Active", aTrackerIsRunning);
    ModelTracker modelTrkr = trackerRegistry.getModelTracker();
    TrackerState modelTrkrState = modelTrkr.getTrackerState();
    coreSummary.add("ModelTracker Active", modelTrkrState.isRunning());
    coreSummary.add("ContentTracker Active", contentTrkrState.isRunning());
    coreSummary.add("MetadataTracker Active", metadataTrkrState.isRunning());
    coreSummary.add("AclTracker Active", aclTrkrState.isRunning());
    // TX
    coreSummary.add("Last Index TX Commit Time", lastIndexTxCommitTime);
    coreSummary.add("Last Index TX Commit Date", lastIndexTxCommitDate);
    coreSummary.add("TX Lag", txLagSeconds + " s");
    coreSummary.add("TX Duration", txLag.toString());
    coreSummary.add("Timestamp for last TX on server", lastTxCommitTimeOnServer);
    coreSummary.add("Date for last TX on server", lastTxOnServerDate);
    coreSummary.add("Id for last TX on server", lastTxIdOnServer);
    coreSummary.add("Id for last TX in index", lastIndexedTxId);
    coreSummary.add("Approx transactions remaining", transactionsToDo);
    coreSummary.add("Approx transaction indexing time remaining", remainingTx.largestComponentformattedString());
    // Change set
    coreSummary.add("Last Index Change Set Commit Time", lastIndexChangeSetCommitTime);
    coreSummary.add("Last Index Change Set Commit Date", lastIndexChangeSetCommitDate);
    coreSummary.add("Change Set Lag", changeSetLagSeconds + " s");
    coreSummary.add("Change Set Duration", changeSetLag.toString());
    coreSummary.add("Timestamp for last Change Set on server", lastChangeSetCommitTimeOnServer);
    coreSummary.add("Date for last Change Set on server", lastChangeSetOnServerDate);
    coreSummary.add("Id for last Change Set on server", lastChangeSetIdOnServer);
    coreSummary.add("Id for last Change Set in index", lastIndexedChangeSetId);
    coreSummary.add("Approx change sets remaining", changeSetsToDo);
    coreSummary.add("Approx change set indexing time remaining", remainingChangeSet.largestComponentformattedString());
    coreSummary.add("Approx content indexing time remaining", remainingContent.largestComponentformattedString());
    // Stats
    coreSummary.add("Model sync times (ms)", srv.getTrackerStats().getModelTimes().getNamedList(detail, hist, values));
    coreSummary.add("Acl index time (ms)", srv.getTrackerStats().getAclTimes().getNamedList(detail, hist, values));
    coreSummary.add("Node index time (ms)", srv.getTrackerStats().getNodeTimes().getNamedList(detail, hist, values));
    coreSummary.add("Docs/Tx", srv.getTrackerStats().getTxDocs().getNamedList(detail, hist, values));
    coreSummary.add("Doc Transformation time (ms)", srv.getTrackerStats().getDocTransformationTimes().getNamedList(detail, hist, values));
    // Model
    Map<String, Set<String>> modelErrors = srv.getModelErrors();
    if (modelErrors.size() > 0) {
        NamedList<Object> errorList = new SimpleOrderedMap<Object>();
        for (Map.Entry<String, Set<String>> modelNameToErrors : modelErrors.entrySet()) {
            errorList.add(modelNameToErrors.getKey(), modelNameToErrors.getValue());
        }
        coreSummary.add("Model changes are not compatible with the existing data model and have not been applied", errorList);
    }
    report.add(cname, coreSummary);
}
Also used : Set(java.util.Set) Duration(org.alfresco.service.cmr.repository.datatype.Duration) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap) Date(java.util.Date) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap) Map(java.util.Map)

Aggregations

Duration (org.alfresco.service.cmr.repository.datatype.Duration)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Set (java.util.Set)1 QName (org.alfresco.service.namespace.QName)1 ContentPropertyValue (org.alfresco.solr.client.ContentPropertyValue)1 MLTextPropertyValue (org.alfresco.solr.client.MLTextPropertyValue)1 MultiPropertyValue (org.alfresco.solr.client.MultiPropertyValue)1 PropertyValue (org.alfresco.solr.client.PropertyValue)1 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)1 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)1