Search in sources :

Example 1 with ShardState

use of org.alfresco.repo.index.shard.ShardState in project SearchServices by Alfresco.

the class MetadataTracker method getSomeTransactions.

protected Transactions getSomeTransactions(BoundedDeque<Transaction> txnsFound, Long fromCommitTime, long timeStep, int maxResults, long endTime) throws AuthenticationException, IOException, JSONException, EncoderException {
    long actualTimeStep = timeStep;
    ShardState shardstate = getShardState();
    Transactions transactions;
    // step forward in time until we find something or hit the time bound
    // max id unbounded
    Long startTime = fromCommitTime == null ? Long.valueOf(0L) : fromCommitTime;
    do {
        transactions = client.getTransactions(startTime, null, startTime + actualTimeStep, null, maxResults, shardstate);
        startTime += actualTimeStep;
    } while (((transactions.getTransactions().size() == 0) && (startTime < endTime)) || ((transactions.getTransactions().size() > 0) && alreadyFoundTransactions(txnsFound, transactions)));
    return transactions;
}
Also used : Transactions(org.alfresco.solr.client.Transactions) ShardState(org.alfresco.repo.index.shard.ShardState)

Example 2 with ShardState

use of org.alfresco.repo.index.shard.ShardState in project SearchServices by Alfresco.

the class MetadataTracker method getShardState.

/**
 * @return
 */
private ShardState getShardState() {
    TrackerState state = super.getTrackerState();
    ShardState shardstate = ShardStateBuilder.shardState().withMaster(isMaster).withLastUpdated(System.currentTimeMillis()).withLastIndexedChangeSetCommitTime(state.getLastIndexedChangeSetCommitTime()).withLastIndexedChangeSetId(state.getLastIndexedChangeSetId()).withLastIndexedTxCommitTime(state.getLastIndexedTxCommitTime()).withLastIndexedTxId(state.getLastIndexedTxId()).withShardInstance().withBaseUrl(infoSrv.getBaseUrl()).withPort(infoSrv.getPort()).withHostName(infoSrv.getHostName()).withShard().withInstance(shardInstance).withFloc().withNumberOfShards(shardCount).withAddedStoreRef(storeRef).withTemplate(shardTemplate).withHasContent(transformContent).withShardMethod(ShardMethodEnum.getShardMethod(shardMethod)).endFloc().endShard().endShardInstance().build();
    return shardstate;
}
Also used : ShardState(org.alfresco.repo.index.shard.ShardState) TrackerState(org.alfresco.solr.TrackerState)

Example 3 with ShardState

use of org.alfresco.repo.index.shard.ShardState in project SearchServices by Alfresco.

the class MetadataTracker method trackRepository.

private void trackRepository() throws IOException, AuthenticationException, JSONException, EncoderException {
    checkShutdown();
    if (!isMaster && isSlave) {
        // Dynamic registration
        ShardState shardstate = getShardState();
        client.getTransactions(0L, null, 0L, null, 0, shardstate);
        return;
    }
    // Check we are tracking the correct repository
    TrackerState state = super.getTrackerState();
    if (state.getTrackerCycles() == 0) {
        // We have a new tracker state so do the checks.
        checkRepoAndIndexConsistency(state);
    }
    if (docRouter instanceof DBIDRangeRouter) {
        DBIDRangeRouter dbidRangeRouter = (DBIDRangeRouter) docRouter;
        long indexCap = infoSrv.getIndexCap();
        long endRange = dbidRangeRouter.getEndRange();
        assert (indexCap == -1 || indexCap >= endRange);
        if (indexCap > endRange) {
            dbidRangeRouter.setExpanded(true);
            dbidRangeRouter.setEndRange(indexCap);
        }
        dbidRangeRouter.setInitialized(true);
    }
    checkShutdown();
    trackTransactions();
}
Also used : ShardState(org.alfresco.repo.index.shard.ShardState) TrackerState(org.alfresco.solr.TrackerState)

Example 4 with ShardState

use of org.alfresco.repo.index.shard.ShardState in project alfresco-remote-api by Alfresco.

the class TransactionsGet method executeImpl.

protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
    String minTxnIdParam = req.getParameter("minTxnId");
    String fromCommitTimeParam = req.getParameter("fromCommitTime");
    String maxTxnIdParam = req.getParameter("maxTxnId");
    String toCommitTimeParam = req.getParameter("toCommitTime");
    String maxResultsParam = req.getParameter("maxResults");
    String baseUrl = req.getParameter("baseUrl");
    String hostName = req.getParameter("hostName");
    String template = req.getParameter("template");
    String instance = req.getParameter("instance");
    String numberOfShards = req.getParameter("numberOfShards");
    String port = req.getParameter("port");
    String stores = req.getParameter("stores");
    String isMaster = req.getParameter("isMaster");
    String hasContent = req.getParameter("hasContent");
    String shardMethod = req.getParameter("shardMethod");
    String lastUpdated = req.getParameter("lastUpdated");
    String lastIndexedChangeSetCommitTime = req.getParameter("lastIndexedChangeSetCommitTime");
    String lastIndexedChangeSetId = req.getParameter("lastIndexedChangeSetId");
    String lastIndexedTxCommitTime = req.getParameter("lastIndexedTxCommitTime");
    String lastIndexedTxId = req.getParameter("lastIndexedTxId");
    if (baseUrl != null) {
        ShardState shardState = ShardStateBuilder.shardState().withMaster(Boolean.valueOf(isMaster)).withLastUpdated(Long.valueOf(lastUpdated)).withLastIndexedChangeSetCommitTime(Long.valueOf(lastIndexedChangeSetCommitTime)).withLastIndexedChangeSetId(Long.valueOf(lastIndexedChangeSetId)).withLastIndexedTxCommitTime(Long.valueOf(lastIndexedTxCommitTime)).withLastIndexedTxId(Long.valueOf(lastIndexedTxId)).withShardInstance().withBaseUrl(baseUrl).withPort(Integer.valueOf(port)).withHostName(hostName).withShard().withInstance(Integer.valueOf(instance)).withFloc().withNumberOfShards(Integer.valueOf(numberOfShards)).withTemplate(template).withHasContent(Boolean.valueOf(hasContent)).withShardMethod(ShardMethodEnum.getShardMethod(shardMethod)).endFloc().endShard().endShardInstance().build();
        for (String store : stores.split(",")) {
            shardState.getShardInstance().getShard().getFloc().getStoreRefs().add(new StoreRef(store));
        }
        for (String pName : req.getParameterNames()) {
            if (pName.startsWith("floc.property.")) {
                String key = pName.substring("floc.property.".length());
                String value = req.getParameter(pName);
                shardState.getShardInstance().getShard().getFloc().getPropertyBag().put(key, value);
            } else if (pName.startsWith("state.property.")) {
                String key = pName.substring("state.property.".length());
                String value = req.getParameter(pName);
                shardState.getPropertyBag().put(key, value);
            }
        }
        solrTrackingComponent.registerShardState(shardState);
    }
    Long minTxnId = (minTxnIdParam == null ? null : Long.valueOf(minTxnIdParam));
    Long fromCommitTime = (fromCommitTimeParam == null ? null : Long.valueOf(fromCommitTimeParam));
    Long maxTxnId = (maxTxnIdParam == null ? null : Long.valueOf(maxTxnIdParam));
    Long toCommitTime = (toCommitTimeParam == null ? null : Long.valueOf(toCommitTimeParam));
    int maxResults = (maxResultsParam == null ? 1024 : Integer.valueOf(maxResultsParam));
    List<Transaction> transactions = solrTrackingComponent.getTransactions(minTxnId, fromCommitTime, maxTxnId, toCommitTime, maxResults);
    Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
    model.put("transactions", transactions);
    Long maxTxnCommitTime = solrTrackingComponent.getMaxTxnCommitTime();
    if (maxTxnCommitTime != null) {
        model.put("maxTxnCommitTime", maxTxnCommitTime);
    }
    Long maxTxnIdOnServer = solrTrackingComponent.getMaxTxnId();
    if (maxTxnIdOnServer != null) {
        model.put("maxTxnId", maxTxnIdOnServer);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
    }
    return model;
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) ShardState(org.alfresco.repo.index.shard.ShardState) Transaction(org.alfresco.repo.solr.Transaction) HashMap(java.util.HashMap)

Aggregations

ShardState (org.alfresco.repo.index.shard.ShardState)4 TrackerState (org.alfresco.solr.TrackerState)2 HashMap (java.util.HashMap)1 Transaction (org.alfresco.repo.solr.Transaction)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1 Transactions (org.alfresco.solr.client.Transactions)1