use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class SolrInformationServer method categorizeNodes.
private void categorizeNodes(List<Node> nodes, Map<Long, Node> nodeIdsToNodes, EnumMap<SolrApiNodeStatus, List<Long>> nodeStatusToNodeIds) {
for (Node node : nodes) {
nodeIdsToNodes.put(node.getId(), node);
List<Long> nodeIds = nodeStatusToNodeIds.get(node.getStatus());
if (nodeIds == null) {
nodeIds = new LinkedList<>();
nodeStatusToNodeIds.put(node.getStatus(), nodeIds);
}
nodeIds.add(node.getId());
}
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class MetadataTracker method reindexTransactions.
private void reindexTransactions() throws IOException, AuthenticationException, JSONException {
long startElapsed = System.nanoTime();
int docCount = 0;
while (transactionsToReindex.peek() != null) {
Long transactionId = transactionsToReindex.poll();
if (transactionId != null) {
// make sure it is cleaned out so we do not miss deletes
this.infoSrv.deleteByTransactionId(transactionId);
Transactions transactions = client.getTransactions(null, transactionId, null, transactionId + 1, 1);
if ((transactions.getTransactions().size() > 0) && (transactionId.equals(transactions.getTransactions().get(0).getId()))) {
Transaction info = transactions.getTransactions().get(0);
this.infoSrv.dirtyTransaction(info.getId());
GetNodesParameters gnp = new GetNodesParameters();
ArrayList<Long> txs = new ArrayList<Long>();
txs.add(info.getId());
gnp.setTransactionIds(txs);
gnp.setStoreProtocol(storeRef.getProtocol());
gnp.setStoreIdentifier(storeRef.getIdentifier());
List<Node> nodes = client.getNodes(gnp, (int) info.getUpdates());
for (Node node : nodes) {
docCount++;
if (log.isDebugEnabled()) {
log.debug(node.toString());
}
this.infoSrv.indexNode(node, true);
checkShutdown();
}
// Index the transaction doc after the node - if this is not found then a reindex will be done.
this.infoSrv.indexTransaction(info, true);
}
}
if (docCount > batchCount) {
if (this.infoSrv.getRegisteredSearcherCount() < getMaxLiveSearchers()) {
checkShutdown();
long endElapsed = System.nanoTime();
trackerStats.addElapsedNodeTime(docCount, endElapsed - startElapsed);
startElapsed = endElapsed;
docCount = 0;
}
}
}
if (docCount > 0) {
checkShutdown();
// this.infoSrv.commit();
long endElapsed = System.nanoTime();
trackerStats.addElapsedNodeTime(docCount, endElapsed - startElapsed);
}
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class MetadataTracker method checkNode.
public NodeReport checkNode(Long dbid) {
NodeReport nodeReport = new NodeReport();
nodeReport.setDbid(dbid);
// In DB
GetNodesParameters parameters = new GetNodesParameters();
parameters.setFromNodeId(dbid);
parameters.setToNodeId(dbid);
List<Node> dbnodes;
try {
dbnodes = client.getNodes(parameters, 1);
if (dbnodes.size() == 1) {
Node dbnode = dbnodes.get(0);
nodeReport.setDbNodeStatus(dbnode.getStatus());
nodeReport.setDbTx(dbnode.getTxnId());
} else {
nodeReport.setDbNodeStatus(SolrApiNodeStatus.UNKNOWN);
nodeReport.setDbTx(-1l);
}
} catch (IOException e) {
nodeReport.setDbNodeStatus(SolrApiNodeStatus.UNKNOWN);
nodeReport.setDbTx(-2l);
} catch (JSONException e) {
nodeReport.setDbNodeStatus(SolrApiNodeStatus.UNKNOWN);
nodeReport.setDbTx(-3l);
} catch (AuthenticationException e1) {
nodeReport.setDbNodeStatus(SolrApiNodeStatus.UNKNOWN);
nodeReport.setDbTx(-4l);
}
this.infoSrv.addCommonNodeReportInfo(nodeReport);
return nodeReport;
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class MetadataTracker method indexBatchOfTransactions.
private int indexBatchOfTransactions(List<Transaction> txBatch) throws AuthenticationException, IOException, JSONException {
int nodeCount = 0;
ArrayList<Transaction> nonEmptyTxs = new ArrayList<>(txBatch.size());
GetNodesParameters gnp = new GetNodesParameters();
ArrayList<Long> txIds = new ArrayList<Long>();
for (Transaction tx : txBatch) {
if (tx.getUpdates() > 0 || tx.getDeletes() > 0) {
nonEmptyTxs.add(tx);
txIds.add(tx.getId());
}
}
gnp.setTransactionIds(txIds);
gnp.setStoreProtocol(storeRef.getProtocol());
gnp.setStoreIdentifier(storeRef.getIdentifier());
gnp.setShardProperty(shardProperty);
List<Node> nodes = client.getNodes(gnp, Integer.MAX_VALUE);
ArrayList<Node> nodeBatch = new ArrayList<>();
for (Node node : nodes) {
if (log.isDebugEnabled()) {
log.debug(node.toString());
}
nodeBatch.add(node);
if (nodeBatch.size() > nodeBatchSize) {
nodeCount += nodeBatch.size();
NodeIndexWorkerRunnable niwr = new NodeIndexWorkerRunnable(this.threadHandler, nodeBatch, this.infoSrv);
this.threadHandler.scheduleTask(niwr);
nodeBatch = new ArrayList<>();
}
}
if (nodeBatch.size() > 0) {
nodeCount += nodeBatch.size();
NodeIndexWorkerRunnable niwr = new NodeIndexWorkerRunnable(this.threadHandler, nodeBatch, this.infoSrv);
this.threadHandler.scheduleTask(niwr);
nodeBatch = new ArrayList<>();
}
return nodeCount;
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class MetadataTracker method indexNodes.
private void indexNodes() throws IOException, AuthenticationException, JSONException {
boolean requiresCommit = false;
while (nodesToIndex.peek() != null) {
Long nodeId = nodesToIndex.poll();
if (nodeId != null) {
Node node = new Node();
node.setId(nodeId);
node.setStatus(SolrApiNodeStatus.UNKNOWN);
node.setTxnId(Long.MAX_VALUE);
this.infoSrv.indexNode(node, false);
requiresCommit = true;
}
checkShutdown();
}
if (requiresCommit) {
checkShutdown();
// this.infoSrv.commit();
}
}
Aggregations