Examples of LuceneClient


Examples of net.sf.katta.lib.lucene.LuceneClient

  public void testContentServer() throws Exception {
    deployTestIndices(1, getNodeCount());
    final InteractionProtocol protocol = _miniCluster.getProtocol();
    assertEquals(1, protocol.getIndices().size());

    LuceneClient luceneClient = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    luceneClient.count(query, new String[] { INDEX_NAME });
    luceneClient.close();
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

  }

  @Test(timeout = 50000)
  public void testNodeFailure() throws Exception {
    deployTestIndices(1, getNodeCount());
    final LuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo:bar");
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));

    // kill 1st of 3 nodes
    _miniCluster.shutdownNode(0);
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));

    // kill 2nd of 3 nodes
    _miniCluster.shutdownNode(0);
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));

    // add a 4th node
    Node node4 = _miniCluster.startAdditionalNode();
    TestUtil.waitUntilNodeServesShards(_protocol, node4.getName(), SHARD_COUNT);
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));

    // kill 3rd node
    Thread.sleep(5000);
    _miniCluster.shutdownNode(0);
    assertEquals(4, client.count(query, new String[] { INDEX_NAME }));
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

  public void measureSearchPerformance() throws Exception {
    DeployClient deployClient = new DeployClient(_miniCluster.getProtocol());
    deployClient.addIndex("index1", TestResources.INDEX1.getAbsolutePath(), 1).joinDeployment();
    deployClient.addIndex("index2", TestResources.INDEX2.getAbsolutePath(), 1).joinDeployment();

    final ILuceneClient client = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo: bar");
    long start = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) {
      client.search(query, new String[] { "index2", "index1" });
    }
    System.out.println("search took: " + (System.currentTimeMillis() - start));

    start = System.currentTimeMillis();
    for (int i = 0; i < 10000; i++) {
      client.count(query, new String[] { "index2", "index1" });
    }
    System.out.println("count took: " + (System.currentTimeMillis() - start));
    client.close();
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

    writeIndex(shard2, _documents2);
    writeIndex(_luceneIndex, combineDocuments(_documents1, _documents2));

    // deploy 2 indexes to katta
    deployIndexToKatta(_deployClient, _kattaIndex, 2);
    _client = new LuceneClient(_miniCluster.getZkConfiguration());
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

  @Test
  public void testSearchAndCount_NodeProxyDownAfterClientInitialization() throws Exception {
    deployTestIndices(1, getNodeCount());
    // start search client
    LuceneClient luceneClient = new LuceneClient(_miniCluster.getZkConfiguration());

    // shutdown proxy of node1
    _miniCluster.getNode(0).getRpcServer().stop();

    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    System.out.println("=========================");
    assertSearchResults(10, luceneClient.search(query, new String[] { INDEX_NAME }, 10));
    assertEquals(937, luceneClient.count(query, new String[] { INDEX_NAME }));
    assertSearchResults(10, luceneClient.search(query, new String[] { INDEX_NAME }, 10));
    assertEquals(937, luceneClient.count(query, new String[] { INDEX_NAME }));
    // search 2 time to ensure we get all availible nodes
    System.out.println("=========================");
    _miniCluster.shutdownNode(0);
    luceneClient.close();
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

  }

  @Test
  public void testGetDetails_NodeProxyDownAfterClientInitialization() throws Exception {
    deployTestIndices(1, getNodeCount());
    LuceneClient luceneClient = new LuceneClient(_miniCluster.getZkConfiguration());
    ((NodeProxyManager) luceneClient.getClient().getProxyManager()).setSuccessiveProxyFailuresBeforeReestablishing(1);
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    Hits hits = luceneClient.search(query, new String[] { INDEX_NAME }, 10);

    // shutdown proxy of node1
    System.out.println("=========================");
    if (_miniCluster.getNode(0).getName().equals(hits.getHits().get(0).getNode())) {
      _miniCluster.shutdownNodeRpc(0);
    } else {
      _miniCluster.shutdownNodeRpc(1);
    }
    assertFalse(luceneClient.getDetails(hits.getHits().get(0)).isEmpty());
    assertFalse(luceneClient.getDetails(hits.getHits().get(0)).isEmpty());
    // search 2 time to ensure we get all available nodes
    System.out.println("=========================");
    shutdownNodes();
    luceneClient.close();
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

  }

  @Test
  public void testAllNodeProxyDownAfterClientInitialization() throws Exception {
    deployTestIndices(1, getNodeCount());
    LuceneClient luceneClient = new LuceneClient(_miniCluster.getZkConfiguration());
    final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("content: the");
    for (int i = 0; i < _miniCluster.getRunningNodeCount(); i++) {
      _miniCluster.shutdownNodeRpc(i);
    }

    System.out.println("=========================");
    try {
      luceneClient.search(query, new String[] { INDEX_NAME }, 10);
      fail("should throw exception");
    } catch (ShardAccessException e) {
      // expected
    }
    System.out.println("=========================");
    shutdownNodes();
    luceneClient.close();
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

    long startTime = System.currentTimeMillis();

    // start search threads
    int expectedHitCount = 12;
    SearchThread[] searchThreads = new SearchThread[SEARCH_THREAD_COUNT];
    ILuceneClient searchClient = new LuceneClient();
    for (int i = 0; i < searchThreads.length; i++) {
      searchThreads[i] = new SearchThread(searchClient, expectedHitCount);
      searchThreads[i].start();
    }

    startAndStopNodes(QUERY_TIME);

    // stop everything
    long firedQueries = 0;
    long unexpectedResultCount = 0;
    List<Exception> exceptions = new ArrayList<Exception>();
    int i = 0;
    for (SearchThread searchThread : searchThreads) {
      searchThread.interrupt();
      searchThread.join();
      firedQueries += searchThread.getFiredQueryCount();
      unexpectedResultCount += searchThread.getUnexpectedResultCount();
      exceptions.addAll(searchThread.getThrownExceptions());
      i++;
    }
    searchClient.close();

    checkResults(startTime, QUERY_TIME, firedQueries, unexpectedResultCount, exceptions);
  }
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

    @Override
    public void run() {
      try {
        ILuceneClient client;
        if (_client == null) {
          client = new LuceneClient();
        } else {
          client = _client;
        }
        while (!_stopped) {
          final Query query = new QueryParser(Version.LUCENE_30, "", new KeywordAnalyzer()).parse("foo:bar");
View Full Code Here

Examples of net.sf.katta.lib.lucene.LuceneClient

    _count = count;
  }

  @Override
  public void init(NodeContext nodeContext) throws Exception {
    _client = new LuceneClient(_zkConfOfTargetCluster);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.