Search in sources :

Example 1 with AclReaders

use of org.alfresco.solr.client.AclReaders in project SearchServices by Alfresco.

the class SolrInformationServer method indexAcl.

@Override
public long indexAcl(List<AclReaders> aclReaderList, boolean overwrite) throws IOException {
    long start = System.nanoTime();
    SolrQueryRequest request = null;
    UpdateRequestProcessor processor = null;
    try {
        request = getLocalSolrQueryRequest();
        processor = this.core.getUpdateProcessingChain(null).createProcessor(request, new SolrQueryResponse());
        for (AclReaders aclReaders : aclReaderList) {
            AddUpdateCommand cmd = new AddUpdateCommand(request);
            cmd.overwrite = overwrite;
            SolrInputDocument input = new SolrInputDocument();
            String id = AlfrescoSolrDataModel.getAclDocumentId(aclReaders.getTenantDomain(), aclReaders.getId());
            input.addField(FIELD_SOLR4_ID, id);
            input.addField(FIELD_VERSION, "0");
            input.addField(FIELD_ACLID, aclReaders.getId());
            input.addField(FIELD_INACLTXID, aclReaders.getAclChangeSetId());
            String tenant = aclReaders.getTenantDomain();
            for (String reader : aclReaders.getReaders()) {
                reader = addTenantToAuthority(reader, tenant);
                input.addField(FIELD_READER, reader);
            }
            for (String denied : aclReaders.getDenied()) {
                denied = addTenantToAuthority(denied, tenant);
                input.addField(FIELD_DENIED, denied);
            }
            input.addField(FIELD_DOC_TYPE, DOC_TYPE_ACL);
            cmd.solrDoc = input;
            processor.processAdd(cmd);
        }
    } finally {
        if (processor != null) {
            processor.finish();
        }
        if (request != null) {
            request.close();
        }
    }
    long end = System.nanoTime();
    return (end - start);
}
Also used : LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) SolrInputDocument(org.apache.solr.common.SolrInputDocument) UpdateRequestProcessor(org.apache.solr.update.processor.UpdateRequestProcessor) AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) AclReaders(org.alfresco.solr.client.AclReaders)

Example 2 with AclReaders

use of org.alfresco.solr.client.AclReaders in project SearchServices by Alfresco.

the class DistributedExpandDbidRangeAlfrescoSolrTrackerTest method testDbIdRange.

@Test
public void testDbIdRange() 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);
    SolrQueryResponse response0 = rangeCheck(0);
    NamedList values0 = response0.getValues();
    // {start=0,end=100,nodeCount=0,maxDbid=0,density=NaN,expand=0,expanded=false}
    assertEquals((long) values0.get("start"), 0);
    assertEquals((long) values0.get("end"), 100);
    assertEquals((long) values0.get("nodeCount"), 0);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values0.get("maxDbid"), 0);
    assertEquals((long) values0.get("expand"), 0);
    assertEquals((boolean) values0.get("expanded"), false);
    System.out.println("RANGECHECK0:" + values0);
    SolrQueryResponse response1 = rangeCheck(1);
    NamedList values1 = response1.getValues();
    // {start=100,end=200,nodeCount=0,maxDbid=0,density=0.0,expand=0,expanded=false}
    System.out.println("RANGECHECK1:" + values1);
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 200);
    assertEquals((long) values1.get("nodeCount"), 0);
    assertEquals((long) values1.get("minDbid"), 0);
    assertEquals((long) values1.get("maxDbid"), 0);
    assertEquals((long) values1.get("expand"), 0);
    assertEquals((boolean) values1.get("expanded"), false);
    int numNodes = 25;
    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((long) i, 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);
    waitForDocCountAllCores(new TermQuery(new Term(FIELD_DOC_TYPE, SolrInformationServer.DOC_TYPE_ACL)), numAcls, 80000);
    response0 = rangeCheck(0);
    values0 = response0.getValues();
    // {start=0,end=100,nodeCount=25,maxDbid=24,density=1.0416666666666667,expand=0,expanded=false}
    assertEquals((long) values0.get("start"), 0);
    assertEquals((long) values0.get("end"), 100);
    assertEquals((long) values0.get("nodeCount"), 25);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values0.get("maxDbid"), 24);
    assertEquals((long) values0.get("expand"), 0);
    assertEquals((boolean) values0.get("expanded"), false);
    System.out.println("_RANGECHECK0:" + values0);
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 200);
    assertEquals((long) values1.get("nodeCount"), 0);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values1.get("maxDbid"), 0);
    assertEquals((long) values1.get("expand"), 0);
    assertEquals((boolean) values1.get("expanded"), false);
    System.out.println("_RANGECHECK1:" + values1);
    numNodes = 26;
    nodes = new ArrayList();
    nodeMetaDatas = new ArrayList();
    bigTxn = getTransaction(0, numNodes);
    for (int i = 0; i < numNodes; i++) {
        int aclIndex = i % numAcls;
        Node node = getNode((long) i + 35, 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")), 51, 100000);
    response0 = rangeCheck(0);
    values0 = response0.getValues();
    // {start=0,end=100,nodeCount=51,maxDbid=60,density=0.85,expand=15,expanded=false}
    assertEquals((long) values0.get("start"), 0);
    assertEquals((long) values0.get("end"), 100);
    assertEquals((long) values0.get("nodeCount"), 51);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values0.get("maxDbid"), 60);
    assertEquals((double) values0.get("density"), .85, 0.0);
    assertEquals((long) values0.get("expand"), 17);
    assertEquals((boolean) values0.get("expanded"), false);
    System.out.println("_RANGECHECK0:" + values0);
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 200);
    assertEquals((long) values1.get("nodeCount"), 0);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values1.get("maxDbid"), 0);
    assertEquals((long) values1.get("expand"), 0);
    assertEquals((boolean) values1.get("expanded"), false);
    System.out.println("_RANGECHECK1:" + values1);
    numNodes = 5;
    nodes = new ArrayList();
    nodeMetaDatas = new ArrayList();
    bigTxn = getTransaction(0, numNodes);
    for (int i = 0; i < numNodes; i++) {
        int aclIndex = i % numAcls;
        Node node = getNode((long) i + 72, 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")), 56, 100000);
    response0 = rangeCheck(0);
    values0 = response0.getValues();
    // {start=0,end=100,nodeCount=56,maxDbid=76,density=0.7368421052631579,expand=-1,expanded=false}
    assertEquals((long) values0.get("start"), 0);
    assertEquals((long) values0.get("end"), 100);
    assertEquals((long) values0.get("nodeCount"), 56);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values0.get("maxDbid"), 76);
    assertEquals((double) values0.get("density"), 0.7368421052631579, 0.0);
    assertEquals((long) values0.get("expand"), -1);
    assertEquals((boolean) values0.get("expanded"), false);
    SolrQueryResponse expandResponse = expand(0, 35);
    NamedList expandValues = expandResponse.getValues();
    String ex = (String) expandValues.get("exception");
    assertEquals(ex, "Expansion cannot occur if max DBID in the index is more then 75% of range.");
    Number expanded = (Number) expandValues.get("expand");
    assertEquals(expanded.intValue(), -1);
    System.out.println("_RANGECHECK0:" + values0);
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    System.out.println("_RANGECHECK1:" + values1);
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 200);
    assertEquals((long) values1.get("nodeCount"), 0);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values1.get("maxDbid"), 0);
    assertEquals((long) values1.get("expand"), 0);
    assertEquals((boolean) values1.get("expanded"), false);
    numNodes = 5;
    nodes = new ArrayList();
    nodeMetaDatas = new ArrayList();
    bigTxn = getTransaction(0, numNodes);
    for (int i = 0; i < numNodes; i++) {
        int aclIndex = i % numAcls;
        Node node = getNode((long) i + 100, 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")), 61, 100000);
    response0 = rangeCheck(0);
    values0 = response0.getValues();
    // {start=0,end=100,nodeCount=56,maxDbid=76,density=0.7368421052631579,expand=-1,expanded=false}
    assertEquals((long) values0.get("start"), 0);
    assertEquals((long) values0.get("end"), 100);
    assertEquals((long) values0.get("nodeCount"), 56);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values0.get("maxDbid"), 76);
    assertEquals((double) values0.get("density"), 0.7368421052631579, 0.0);
    assertEquals((long) values0.get("expand"), -1);
    assertEquals((boolean) values0.get("expanded"), false);
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    System.out.println("_RANGECHECK1:" + values1);
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 200);
    assertEquals((long) values1.get("nodeCount"), 5);
    assertEquals((long) values1.get("minDbid"), 100);
    assertEquals((long) values1.get("maxDbid"), 104);
    assertEquals((long) values1.get("expand"), 0);
    assertEquals((boolean) values1.get("expanded"), false);
    numNodes = 35;
    nodes = new ArrayList();
    nodeMetaDatas = new ArrayList();
    bigTxn = getTransaction(0, numNodes);
    for (int i = 0; i < numNodes; i++) {
        int aclIndex = i % numAcls;
        Node node = getNode((long) i + 120, 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")), 96, 100000);
    response0 = rangeCheck(0);
    values0 = response0.getValues();
    // {start=0,end=100,nodeCount=56,maxDbid=76,density=0.7368421052631579,expand=-1,expanded=false}
    assertEquals((long) values0.get("start"), 0);
    assertEquals((long) values0.get("end"), 100);
    assertEquals((long) values0.get("nodeCount"), 56);
    assertEquals((long) values0.get("minDbid"), 0);
    assertEquals((long) values0.get("maxDbid"), 76);
    assertEquals((double) values0.get("density"), 0.7368421052631579, 0.0);
    assertEquals((long) values0.get("expand"), -1);
    assertEquals((boolean) values0.get("expanded"), false);
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    System.out.println("_RANGECHECK1:" + values1);
    // {start=100,end=200,nodeCount=40,maxDbid=154,density=0.7407407407407407,expand=35,expanded=false}
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 200);
    assertEquals((long) values1.get("nodeCount"), 40);
    assertEquals((long) values1.get("minDbid"), 100);
    assertEquals((long) values1.get("maxDbid"), 154);
    assertEquals((double) values1.get("density"), 0.7407407407407407, 0.0);
    assertEquals((long) values1.get("expand"), 35);
    assertEquals((boolean) values1.get("expanded"), false);
    // expand shard1 by 20
    expandResponse = expand(1, 35);
    expandValues = expandResponse.getValues();
    expanded = (Number) expandValues.get("expand");
    assertEquals(expanded.intValue(), 235);
    waitForShardsCount(new TermQuery(new Term(FIELD_SOLR4_ID, "TRACKER!STATE!CAP")), 1, 100000, System.currentTimeMillis());
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    System.out.println("_RANGECHECK1:" + values1);
    // {start=100,end=235,nodeCount=40,maxDbid=154,density=0.7407407407407407,expand=-1,expanded=true}
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 235);
    assertEquals((long) values1.get("nodeCount"), 40);
    assertEquals((long) values1.get("minDbid"), 100);
    assertEquals((long) values1.get("maxDbid"), 154);
    assertEquals((double) values1.get("density"), 0.7407407407407407, 0.0);
    assertEquals((long) values1.get("expand"), -1);
    assertEquals((boolean) values1.get("expanded"), true);
    numNodes = 3;
    nodes = new ArrayList();
    nodeMetaDatas = new ArrayList();
    bigTxn = getTransaction(0, numNodes);
    for (int i = 0; i < numNodes; i++) {
        int aclIndex = i % numAcls;
        Node node = getNode((long) i + 230, 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")), 99, 100000);
    response1 = rangeCheck(1);
    values1 = response1.getValues();
    System.out.println("_RANGECHECK1:" + values1);
    // {start=100,end=235,nodeCount=43,maxDbid=232,density=0.32575757575757575,expand=-1,expanded=true}
    assertEquals((long) values1.get("start"), 100);
    assertEquals((long) values1.get("end"), 235);
    assertEquals((long) values1.get("nodeCount"), 43);
    assertEquals((long) values1.get("minDbid"), 100);
    assertEquals((long) values1.get("maxDbid"), 232);
    assertEquals((double) values1.get("density"), 0.32575757575757575, 0.0);
    assertEquals((long) values1.get("expand"), -1);
    assertEquals((boolean) values1.get("expanded"), true);
// assert(false);
// Do a reload
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) NodeMetaData(org.alfresco.solr.client.NodeMetaData) AlfrescoSolrUtils.getNodeMetaData(org.alfresco.solr.AlfrescoSolrUtils.getNodeMetaData) NamedList(org.apache.solr.common.util.NamedList) Node(org.alfresco.solr.client.Node) AlfrescoSolrUtils.getNode(org.alfresco.solr.AlfrescoSolrUtils.getNode) ArrayList(java.util.ArrayList) Acl(org.alfresco.solr.client.Acl) AlfrescoSolrUtils.getAcl(org.alfresco.solr.AlfrescoSolrUtils.getAcl) Term(org.apache.lucene.index.Term) Transaction(org.alfresco.solr.client.Transaction) AlfrescoSolrUtils.getTransaction(org.alfresco.solr.AlfrescoSolrUtils.getTransaction) AlfrescoSolrUtils.getAclChangeSet(org.alfresco.solr.AlfrescoSolrUtils.getAclChangeSet) AlfrescoSolrUtils.indexAclChangeSet(org.alfresco.solr.AlfrescoSolrUtils.indexAclChangeSet) AclChangeSet(org.alfresco.solr.client.AclChangeSet) AlfrescoSolrUtils.getAclReaders(org.alfresco.solr.AlfrescoSolrUtils.getAclReaders) AclReaders(org.alfresco.solr.client.AclReaders) Test(org.junit.Test) AbstractAlfrescoDistributedTest(org.alfresco.solr.AbstractAlfrescoDistributedTest)

Example 3 with AclReaders

use of org.alfresco.solr.client.AclReaders in project SearchServices by Alfresco.

the class AlfrescoSolrUtils method indexAclChangeSet.

/**
 * @param aclChangeSet
 * @param aclList
 * @param aclReadersList
 */
public static void indexAclChangeSet(AclChangeSet aclChangeSet, List<Acl> aclList, List<AclReaders> aclReadersList) {
    // First map the nodes to a transaction.
    SOLRAPIQueueClient.aclMap.put(aclChangeSet.getId(), aclList);
    // Next map a node to the NodeMetaData
    for (AclReaders aclReaders : aclReadersList) {
        SOLRAPIQueueClient.aclReadersMap.put(aclReaders.getId(), aclReaders);
    }
    // Next add the transaction to the queue
    SOLRAPIQueueClient.aclChangeSetQueue.add(aclChangeSet);
}
Also used : AclReaders(org.alfresco.solr.client.AclReaders)

Example 4 with AclReaders

use of org.alfresco.solr.client.AclReaders 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);
    }
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) NodeMetaData(org.alfresco.solr.client.NodeMetaData) AlfrescoSolrUtils.getNodeMetaData(org.alfresco.solr.AlfrescoSolrUtils.getNodeMetaData) Node(org.alfresco.solr.client.Node) AlfrescoSolrUtils.getNode(org.alfresco.solr.AlfrescoSolrUtils.getNode) ArrayList(java.util.ArrayList) Acl(org.alfresco.solr.client.Acl) AlfrescoSolrUtils.getAcl(org.alfresco.solr.AlfrescoSolrUtils.getAcl) Term(org.apache.lucene.index.Term) Transaction(org.alfresco.solr.client.Transaction) AlfrescoSolrUtils.getTransaction(org.alfresco.solr.AlfrescoSolrUtils.getTransaction) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) AlfrescoSolrUtils.getAclChangeSet(org.alfresco.solr.AlfrescoSolrUtils.getAclChangeSet) AlfrescoSolrUtils.indexAclChangeSet(org.alfresco.solr.AlfrescoSolrUtils.indexAclChangeSet) AclChangeSet(org.alfresco.solr.client.AclChangeSet) AlfrescoSolrUtils.getAclReaders(org.alfresco.solr.AlfrescoSolrUtils.getAclReaders) AclReaders(org.alfresco.solr.client.AclReaders) Test(org.junit.Test) AbstractAlfrescoDistributedTest(org.alfresco.solr.AbstractAlfrescoDistributedTest)

Example 5 with AclReaders

use of org.alfresco.solr.client.AclReaders 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);
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) Tracker(org.alfresco.solr.tracker.Tracker) NodeMetaData(org.alfresco.solr.client.NodeMetaData) AlfrescoSolrUtils.getNodeMetaData(org.alfresco.solr.AlfrescoSolrUtils.getNodeMetaData) Node(org.alfresco.solr.client.Node) AlfrescoSolrUtils.getNode(org.alfresco.solr.AlfrescoSolrUtils.getNode) ArrayList(java.util.ArrayList) Acl(org.alfresco.solr.client.Acl) AlfrescoSolrUtils.getAcl(org.alfresco.solr.AlfrescoSolrUtils.getAcl) Term(org.apache.lucene.index.Term) Transaction(org.alfresco.solr.client.Transaction) AlfrescoSolrUtils.getTransaction(org.alfresco.solr.AlfrescoSolrUtils.getTransaction) AlfrescoSolrUtils.getAclChangeSet(org.alfresco.solr.AlfrescoSolrUtils.getAclChangeSet) AlfrescoSolrUtils.indexAclChangeSet(org.alfresco.solr.AlfrescoSolrUtils.indexAclChangeSet) AclChangeSet(org.alfresco.solr.client.AclChangeSet) AlfrescoSolrUtils.getAclReaders(org.alfresco.solr.AlfrescoSolrUtils.getAclReaders) AclReaders(org.alfresco.solr.client.AclReaders) Test(org.junit.Test)

Aggregations

AclReaders (org.alfresco.solr.client.AclReaders)15 Acl (org.alfresco.solr.client.Acl)13 AclChangeSet (org.alfresco.solr.client.AclChangeSet)10 AlfrescoSolrUtils.getAcl (org.alfresco.solr.AlfrescoSolrUtils.getAcl)8 AlfrescoSolrUtils.getAclChangeSet (org.alfresco.solr.AlfrescoSolrUtils.getAclChangeSet)8 AlfrescoSolrUtils.getAclReaders (org.alfresco.solr.AlfrescoSolrUtils.getAclReaders)8 AlfrescoSolrUtils.getNode (org.alfresco.solr.AlfrescoSolrUtils.getNode)8 AlfrescoSolrUtils.getNodeMetaData (org.alfresco.solr.AlfrescoSolrUtils.getNodeMetaData)8 AlfrescoSolrUtils.getTransaction (org.alfresco.solr.AlfrescoSolrUtils.getTransaction)8 AlfrescoSolrUtils.indexAclChangeSet (org.alfresco.solr.AlfrescoSolrUtils.indexAclChangeSet)8 Node (org.alfresco.solr.client.Node)8 NodeMetaData (org.alfresco.solr.client.NodeMetaData)8 Transaction (org.alfresco.solr.client.Transaction)8 Term (org.apache.lucene.index.Term)8 TermQuery (org.apache.lucene.search.TermQuery)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 AbstractAlfrescoDistributedTest (org.alfresco.solr.AbstractAlfrescoDistributedTest)4 BooleanClause (org.apache.lucene.search.BooleanClause)4 BooleanQuery (org.apache.lucene.search.BooleanQuery)4