use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class DistributedAclIdAlfrescoSolrTrackerTest method testAclId.
@Test
public void testAclId() throws Exception {
putHandleDefaults();
int numAcls = 250;
AclChangeSet bulkAclChangeSet = getAclChangeSet(numAcls);
List<Acl> bulkAcls = new ArrayList();
List<AclReaders> bulkAclReaders = new ArrayList();
for (int i = 0; i < numAcls; i++) {
Acl bulkAcl = getAcl(bulkAclChangeSet);
bulkAcls.add(bulkAcl);
bulkAclReaders.add(getAclReaders(bulkAclChangeSet, bulkAcl, list("joel" + bulkAcl.getId()), list("phil" + bulkAcl.getId()), null));
}
indexAclChangeSet(bulkAclChangeSet, bulkAcls, bulkAclReaders);
int numNodes = 1000;
List<Node> nodes = new ArrayList();
List<NodeMetaData> nodeMetaDatas = new ArrayList();
Transaction bigTxn = getTransaction(0, numNodes);
for (int i = 0; i < numNodes; i++) {
int aclIndex = i % numAcls;
Node node = getNode(bigTxn, bulkAcls.get(aclIndex), Node.SolrApiNodeStatus.UPDATED);
nodes.add(node);
NodeMetaData nodeMetaData = getNodeMetaData(node, bigTxn, bulkAcls.get(aclIndex), "mike", null, false);
nodeMetaDatas.add(nodeMetaData);
}
indexTransaction(bigTxn, nodes, nodeMetaDatas);
waitForDocCount(new TermQuery(new Term("content@s___t@{http://www.alfresco.org/model/content/1.0}content", "world")), numNodes, 100000);
waitForDocCount(new TermQuery(new Term(FIELD_DOC_TYPE, SolrInformationServer.DOC_TYPE_ACL)), numAcls, 100000);
for (int i = 0; i < numAcls; i++) {
Acl acl = bulkAcls.get(i);
long aclId = acl.getId();
QueryResponse response = query(getDefaultTestClient(), true, "{\"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}], \"authorities\": [\"joel" + aclId + "\"], \"tenants\": [ \"\" ]}", params("q", "t1:world", "qt", "/afts", "shards.qt", "/afts", "start", "0", "rows", "100", "sort", "id asc", "fq", "{!afts}AUTHORITY_FILTER_FROM_JSON"));
assertTrue(response.getResults().getNumFound() > 0);
}
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class MetadataTrackerTest method getNodes.
private List<Node> getNodes() {
List<Node> nodes = new ArrayList<>();
Node node = getNode();
nodes.add(node);
return nodes;
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class AlfrescoSolrReloadTest method testReload.
@Test
public void testReload() throws Exception {
long localId = 0L;
logger.info("######### Starting tracker reload test NODES ###########");
AclChangeSet aclChangeSet = getAclChangeSet(1, ++localId);
Acl acl = getAcl(aclChangeSet);
AclReaders aclReaders = getAclReaders(aclChangeSet, acl, list("joel"), list("phil"), null);
indexAclChangeSet(aclChangeSet, list(acl), list(aclReaders));
int numNodes = 1000;
List<Node> nodes = new ArrayList();
List<NodeMetaData> nodeMetaDatas = new ArrayList();
Transaction bigTxn = getTransaction(0, numNodes, ++localId);
for (int i = 0; i < numNodes; i++) {
Node node = getNode(bigTxn, acl, Node.SolrApiNodeStatus.UPDATED);
nodes.add(node);
NodeMetaData nodeMetaData = getNodeMetaData(node, bigTxn, acl, "mike", null, false);
nodeMetaDatas.add(nodeMetaData);
}
indexTransaction(bigTxn, nodes, nodeMetaDatas);
waitForDocCount(new TermQuery(new Term("content@s___t@{http://www.alfresco.org/model/content/1.0}content", "world")), 1000, 100000);
Collection<Tracker> trackers = getTrackers();
int numOfTrackers = trackers.size();
int jobs = getJobsCount();
reloadAndAssertCorrect(trackers, numOfTrackers, jobs);
Transaction bigTxn2 = getTransaction(0, numNodes, ++localId);
for (int i = 0; i < numNodes; i++) {
Node node = getNode(bigTxn2, acl, Node.SolrApiNodeStatus.UPDATED);
nodes.add(node);
NodeMetaData nodeMetaData = getNodeMetaData(node, bigTxn2, acl, "mike", null, false);
nodeMetaDatas.add(nodeMetaData);
}
indexTransaction(bigTxn2, nodes, nodeMetaDatas);
waitForDocCount(new TermQuery(new Term("content@s___t@{http://www.alfresco.org/model/content/1.0}content", "world")), 2000, 100000);
}
use of org.alfresco.solr.client.Node in project SearchServices by Alfresco.
the class MetadataTracker method indexTransactions.
private void indexTransactions() throws IOException, AuthenticationException, JSONException {
long startElapsed = System.nanoTime();
int docCount = 0;
boolean requiresCommit = false;
while (transactionsToIndex.peek() != null) {
Long transactionId = transactionsToIndex.poll();
if (transactionId != null) {
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);
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());
gnp.setShardProperty(shardProperty);
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, false);
checkShutdown();
}
// Index the transaction doc after the node - if this is not found then a reindex will be done.
this.infoSrv.indexTransaction(info, false);
requiresCommit = true;
trackerStats.addTxDocs(nodes.size());
}
}
if (docCount > batchCount) {
if (this.infoSrv.getRegisteredSearcherCount() < getMaxLiveSearchers()) {
checkShutdown();
// this.infoSrv.commit();
long endElapsed = System.nanoTime();
trackerStats.addElapsedNodeTime(docCount, endElapsed - startElapsed);
startElapsed = endElapsed;
docCount = 0;
requiresCommit = false;
}
}
}
if (requiresCommit || (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 reindexNodes.
private void reindexNodes() throws IOException, AuthenticationException, JSONException {
boolean requiresCommit = false;
while (nodesToReindex.peek() != null) {
Long nodeId = nodesToReindex.poll();
if (nodeId != null) {
// make sure it is cleaned out so we do not miss deletes
this.infoSrv.deleteByNodeId(nodeId);
Node node = new Node();
node.setId(nodeId);
node.setStatus(SolrApiNodeStatus.UNKNOWN);
node.setTxnId(Long.MAX_VALUE);
this.infoSrv.indexNode(node, true);
requiresCommit = true;
}
checkShutdown();
}
if (requiresCommit) {
checkShutdown();
// this.infoSrv.commit();
}
}
Aggregations