use of org.alfresco.solr.client.NodeMetaData in project SearchServices by Alfresco.
the class AbstractAlfrescoSolrTests method indexTransaction.
public void indexTransaction(Transaction transaction, List<Node> nodes, List<NodeMetaData> nodeMetaDatas) {
// First map the nodes to a transaction.
SOLRAPIQueueClient.nodeMap.put(transaction.getId(), nodes);
// Next map a node to the NodeMetaData
for (NodeMetaData nodeMetaData : nodeMetaDatas) {
SOLRAPIQueueClient.nodeMetaDataMap.put(nodeMetaData.getId(), nodeMetaData);
}
// Next add the transaction to the queue
SOLRAPIQueueClient.transactionQueue.add(transaction);
}
use of org.alfresco.solr.client.NodeMetaData 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.NodeMetaData in project SearchServices by Alfresco.
the class CascadeTracker method processCascades.
private void processCascades() throws IOException {
// System.out.println("######### processCascades()");
int num = 50;
List<Transaction> txBatch = null;
do {
try {
getWriteLock().acquire();
txBatch = infoSrv.getCascades(num);
if (txBatch.size() == 0) {
// No transactions to process for cascades.
return;
}
ArrayList<Long> txIds = new ArrayList<Long>();
Set<Long> txIdSet = new HashSet<Long>();
for (Transaction tx : txBatch) {
txIds.add(tx.getId());
txIdSet.add(tx.getId());
}
List<NodeMetaData> nodeMetaDatas = infoSrv.getCascadeNodes(txIds);
// System.out.println("########### Cascade node meta datas:"+nodeMetaDatas.size());
if (nodeMetaDatas.size() > 0) {
LinkedList<NodeMetaData> stack = new LinkedList<NodeMetaData>();
stack.addAll(nodeMetaDatas);
int batchSize = 10;
do {
List<NodeMetaData> batch = new ArrayList<NodeMetaData>();
while (batch.size() < batchSize && stack.size() > 0) {
batch.add(stack.removeFirst());
}
CascadeIndexWorkerRunnable worker = new CascadeIndexWorkerRunnable(this.threadHandler, batch, infoSrv);
this.threadHandler.scheduleTask(worker);
} while (stack.size() > 0);
}
// Update the transaction records.
updateTransactionsAfterAsynchronous(txBatch);
// System.out.println("######################: Finished Cascade Run #########");
} catch (AuthenticationException e) {
throw new IOException(e);
} catch (JSONException e) {
throw new IOException(e);
} catch (InterruptedException e) {
throw new IOException(e);
} finally {
// System.out.println("###################: Releasing Cascade write lock");
getWriteLock().release();
}
} while (txBatch.size() > 0);
}
use of org.alfresco.solr.client.NodeMetaData in project SearchServices by Alfresco.
the class AlfrescoSolrUtils method indexTransaction.
/**
* @param transaction
* @param nodes
* @param nodeMetaDatas
*/
public void indexTransaction(Transaction transaction, List<Node> nodes, List<NodeMetaData> nodeMetaDatas) {
// First map the nodes to a transaction.
SOLRAPIQueueClient.nodeMap.put(transaction.getId(), nodes);
// Next map a node to the NodeMetaData
for (NodeMetaData nodeMetaData : nodeMetaDatas) {
SOLRAPIQueueClient.nodeMetaDataMap.put(nodeMetaData.getId(), nodeMetaData);
}
// Next add the transaction to the queue
SOLRAPIQueueClient.transactionQueue.add(transaction);
}
use of org.alfresco.solr.client.NodeMetaData in project SearchServices by Alfresco.
the class AlfrescoSolrUtils method getNodeMetaData.
/**
* Get a nodes meta data.
* @param node
* @param txn
* @param acl
* @param owner
* @param ancestors
* @param createError
* @return {@link NodeMetaData}
*/
public static NodeMetaData getNodeMetaData(Node node, Transaction txn, Acl acl, String owner, Set<NodeRef> ancestors, boolean createError) {
NodeMetaData nodeMetaData = new NodeMetaData();
nodeMetaData.setId(node.getId());
nodeMetaData.setAclId(acl.getId());
nodeMetaData.setTxnId(txn.getId());
nodeMetaData.setOwner(owner);
nodeMetaData.setAspects(new HashSet<QName>());
nodeMetaData.setAncestors(ancestors);
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
props.put(ContentModel.PROP_IS_INDEXED, new StringPropertyValue("true"));
props.put(ContentModel.PROP_CONTENT, new ContentPropertyValue(Locale.US, 0l, "UTF-8", "text/plain", null));
nodeMetaData.setProperties(props);
// If create createError is true then we leave out the nodeRef which will cause an error
if (!createError) {
NodeRef nodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), createGUID());
nodeMetaData.setNodeRef(nodeRef);
}
nodeMetaData.setType(QName.createQName(TEST_NAMESPACE, "testSuperType"));
nodeMetaData.setAncestors(ancestors);
nodeMetaData.setPaths(new ArrayList<Pair<String, QName>>());
nodeMetaData.setNamePaths(new ArrayList<List<String>>());
return nodeMetaData;
}
Aggregations