当前位置: 首页>>代码示例>>Java>>正文


Java SolrDispatchFilter类代码示例

本文整理汇总了Java中org.apache.solr.servlet.SolrDispatchFilter的典型用法代码示例。如果您正苦于以下问题:Java SolrDispatchFilter类的具体用法?Java SolrDispatchFilter怎么用?Java SolrDispatchFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SolrDispatchFilter类属于org.apache.solr.servlet包,在下文中一共展示了SolrDispatchFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stopJettySolrRunner

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private static void stopJettySolrRunner(JettySolrRunner jetty) throws Exception {
  assert(jetty != null);
  monkeyLog("stop shard! " + jetty.getLocalPort());
  // get a clean shutdown so that no dirs are left open...
  FilterHolder fh = jetty.getDispatchFilter();
  if (fh != null) {
    SolrDispatchFilter sdf = (SolrDispatchFilter) fh.getFilter();
    if (sdf != null) {
      sdf.destroy();
    }
  }
  jetty.stop();
  
  if (!jetty.isStopped()) {
    throw new RuntimeException("could not stop jetty");
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:ChaosMonkey.java

示例2: kill

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
public static void kill(JettySolrRunner jetty) throws Exception {
  FilterHolder filterHolder = jetty.getDispatchFilter();
  if (filterHolder != null) {
    Filter filter = filterHolder.getFilter();
    if (filter != null) {
      CoreContainer cores = ((SolrDispatchFilter) filter).getCores();
      if (cores != null) {
        int zklocalport = ((InetSocketAddress) cores.getZkController()
            .getZkClient().getSolrZooKeeper().getSocketAddress()).getPort();
        IpTables.blockPort(zklocalport);
      }
    }
  }

  IpTables.blockPort(jetty.getLocalPort());
  
  monkeyLog("kill shard! " + jetty.getLocalPort());
  
  jetty.stop();
  
  stop(jetty);
  
  if (!jetty.isStopped()) {
    throw new RuntimeException("could not kill jetty");
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:ChaosMonkey.java

示例3: checkForSingleIndex

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private void checkForSingleIndex(JettySolrRunner jetty) {
  CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter().getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    String ddir = core.getDataDir();
    CachingDirectoryFactory dirFactory = (CachingDirectoryFactory) core.getDirectoryFactory();
    synchronized (dirFactory) {
      Set<String> livePaths = dirFactory.getLivePaths();
      // one for data, one for hte index under data
      assertEquals(livePaths.toString(), 2, livePaths.size());
      // :TODO: assert that one of the paths is a subpath of hte other
    }
    if (dirFactory instanceof StandardDirectoryFactory) {
      System.out.println(Arrays.asList(new File(ddir).list()));
      assertEquals(Arrays.asList(new File(ddir).list()).toString(), 1, indexDirCount(ddir));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestReplicationHandler.java

示例4: testZkHostDiscovery

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
@Test
public void testZkHostDiscovery() throws ClassNotFoundException, NoSuchMethodException,
    IllegalAccessException, InstantiationException, InvocationTargetException {

  // Should see an error when zkHost is not defined but solr.solrxml.location is set to zookeeper.
  System.clearProperty("zkHost");
  try {
    Method method = SolrDispatchFilter.class.getDeclaredMethod("loadConfigSolr", SolrResourceLoader.class);
    method.setAccessible(true);
    method.invoke(new SolrDispatchFilter(), new SolrResourceLoader(null));
    fail("Should have thrown an exception");
  } catch (InvocationTargetException ite) {
    assertTrue("Should be catching a SolrException", ite.getTargetException() instanceof SolrException);
    assertEquals("Caught Solr exception", ite.getTargetException().getMessage(),
        "Could not load solr.xml from zookeeper: zkHost system property not set");
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SolrXmlInZkTest.java

示例5: checkInstanceDirs

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private void checkInstanceDirs(JettySolrRunner jetty) {
  CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter()
      .getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    if (!oldStyleSolrXml) {
      // look for core props file
      assertTrue("Could not find expected core.properties file",
          new File((String) core.getStatistics().get("instanceDir"),
              "core.properties").exists());
    }
    
    assertEquals(
       new File(SolrResourceLoader.normalizeDir(jetty.getSolrHome() + File.separator
            + core.getName())).getAbsolutePath(),
        new File(SolrResourceLoader.normalizeDir((String) core.getStatistics().get(
            "instanceDir"))).getAbsolutePath());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:CollectionsAPIDistributedZkTest.java

示例6: randomlyEnableAutoSoftCommit

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private void randomlyEnableAutoSoftCommit() {
  if (r.nextBoolean()) {
    log.info("Turning on auto soft commit");
    for (CloudJettyRunner jetty : shardToJetty.get("shard1")) {
      SolrCore core = ((SolrDispatchFilter) jetty.jetty.getDispatchFilter()
          .getFilter()).getCores().getCore("collection1");
      try {
        ((DirectUpdateHandler2) core.getUpdateHandler()).getCommitTracker()
            .setTimeUpperBound(5000);
      } finally {
        core.close();
      }
    }
  } else {
    log.info("Not turning on auto soft commit");
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:ChaosMonkeySafeLeaderTest.java

示例7: enableAutoSoftCommit

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
protected void enableAutoSoftCommit(int time) {
  log.info("Turning on auto soft commit: " + time);
  for (List<CloudJettyRunner> jettyList : shardToJetty.values()) {
    for (CloudJettyRunner jetty : jettyList) {
      CoreContainer cores = ((SolrDispatchFilter) jetty.jetty
          .getDispatchFilter().getFilter()).getCores();
      for (SolrCore core : cores.getCores()) {
        ((DirectUpdateHandler2) core.getUpdateHandler())
            .getSoftCommitTracker().setTimeUpperBound(time);
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:AbstractFullDistribZkTestBase.java

示例8: expireSession

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
public void expireSession(final JettySolrRunner jetty) {
    monkeyLog("expire session for " + jetty.getLocalPort() + " !");
    
    SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty
        .getDispatchFilter().getFilter();
    if (solrDispatchFilter != null) {
      CoreContainer cores = solrDispatchFilter.getCores();
      if (cores != null) {
        causeConnectionLoss(jetty, cores.getZkController().getClientTimeout() + 200);
      }
    }
    

//    Thread thread = new Thread() {
//      {
//        setDaemon(true);
//      }
//      public void run() {
//        SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty.getDispatchFilter().getFilter();
//        if (solrDispatchFilter != null) {
//          CoreContainer cores = solrDispatchFilter.getCores();
//          if (cores != null) {
//            try {
//              Thread.sleep(ZkTestServer.TICK_TIME * 2 + 800);
//            } catch (InterruptedException e) {
//              // we act as only connection loss
//              return;
//            }
//            long sessionId = cores.getZkController().getZkClient().getSolrZooKeeper().getSessionId();
//            zkServer.expire(sessionId);
//          }
//        }
//      }
//    };
//    thread.start();

  }
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:ChaosMonkey.java

示例9: causeConnectionLoss

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
public static void causeConnectionLoss(JettySolrRunner jetty, int pauseTime) {
  SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty
      .getDispatchFilter().getFilter();
  if (solrDispatchFilter != null) {
    CoreContainer cores = solrDispatchFilter.getCores();
    if (cores != null) {
      SolrZkClient zkClient = cores.getZkController().getZkClient();
      // must be at least double tick time...
      zkClient.getSolrZooKeeper().pauseCnxn(pauseTime);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:ChaosMonkey.java

示例10: testNoWriter

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
/**
 * Verify that things still work if an IW has not been opened (and hence the CommitPoints have not been communicated to the deletion policy)
 */
public void testNoWriter() throws Exception {
  useFactory(null);    // force a persistent directory

  // read-only setting (no opening from indexwriter)
  System.setProperty("solr.tests.nrtMode", "false");
  try {
  // stop and start so they see the new directory setting
  slaveJetty.stop();
  masterJetty.stop();
  slaveJetty.start(true);
  masterJetty.start(true);

  index(slaveClient, "id", "123456");
  slaveClient.commit();
  slaveJetty.stop();
  slaveJetty.start(true);
  } finally {
    System.clearProperty("solr.tests.nrtMode"); // dont mess with other tests
  }

  // Currently we open a writer on-demand.  This is to test that we are correctly testing
  // the code path when SolrDeletionPolicy.getLatestCommit() returns null.
  // When we are using an ephemeral directory, an IW will always be opened to create the index and hence
  // getLatestCommit will always be non-null.
  CoreContainer cores = ((SolrDispatchFilter) slaveJetty.getDispatchFilter().getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  assertEquals(1, theCores.size());
  SolrCore core = (SolrCore)theCores.toArray()[0];
  assertNull( core.getDeletionPolicy().getLatestCommit() );


  pullFromMasterToSlave();  // this will cause SnapPuller to be invoked and we will test when SolrDeletionPolicy.getLatestCommit() returns null

  resetFactory();
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:TestReplicationHandler.java

示例11: killSolr

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
/**
 * Kills the Solr instance identified by the given {@code nodeId}. Unlike {@link #stopSolr(String)}, this method
 * prevents Solr from doing a graceful shutdown, so that states recorded in ZooKeeper aren't consistent.
 */
public void killSolr(String nodeId) {
    final JettySolrRunner solrRunner = getJettySolrRunner(nodeId);
    final SolrDispatchFilter solrFilter = solrRunner.getSolrDispatchFilter();
    final SolrZooKeeper solrZooKeeper = solrFilter.getCores().getZkController().getZkClient().getSolrZooKeeper();
    try {
        // solrZooKeeper.closeCnxn() doesn't really work
        solrZooKeeper.close();
    } catch (final InterruptedException e) {
        throw new RuntimeException(e);
    }
    stopSolr(nodeId);
}
 
开发者ID:shaie,项目名称:lucenelab,代码行数:17,代码来源:MiniSolrCloudCluster.java

示例12: causeConnectionLoss

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private void causeConnectionLoss(JettySolrRunner jetty, int pauseTime) {
  SolrDispatchFilter solrDispatchFilter = (SolrDispatchFilter) jetty
      .getDispatchFilter().getFilter();
  if (solrDispatchFilter != null) {
    CoreContainer cores = solrDispatchFilter.getCores();
    if (cores != null) {
      SolrZkClient zkClient = cores.getZkController().getZkClient();
      // must be at least double tick time...
      zkClient.getSolrZooKeeper().pauseCnxn(pauseTime);
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:13,代码来源:ChaosMonkey.java

示例13: checkForSingleIndex

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private void checkForSingleIndex(JettySolrRunner jetty) {
  CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter().getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    String ddir = core.getDataDir();
    CachingDirectoryFactory dirFactory = (CachingDirectoryFactory) core.getDirectoryFactory();
    synchronized (dirFactory) {
      assertEquals(dirFactory.getPaths().toString(), 2, dirFactory.getPaths().size());
    }
    if (dirFactory instanceof StandardDirectoryFactory) {
      System.out.println(Arrays.asList(new File(ddir).list()));
      assertEquals(Arrays.asList(new File(ddir).list()).toString(), 1, indexDirCount(ddir));
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:TestReplicationHandler.java

示例14: getZkController

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
private static ZkController getZkController() {
    SolrDispatchFilter dispatchFilter =
            (SolrDispatchFilter) miniSolrCloudCluster.getJettySolrRunners().get(0).getDispatchFilter().getFilter();
    return dispatchFilter.getCores().getZkController();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:6,代码来源:SolrRunner.java

示例15: start

import org.apache.solr.servlet.SolrDispatchFilter; //导入依赖的package包/类
public static boolean start(JettySolrRunner jetty) throws Exception {

    IpTables.unblockPort(jetty.getLocalPort());
    try {
      jetty.start();
    } catch (Exception e) {
      jetty.stop();
      Thread.sleep(3000);
      try {
        jetty.start();
      } catch (Exception e2) {
        jetty.stop();
        Thread.sleep(10000);
        try {
          jetty.start();
        } catch (Exception e3) {
          jetty.stop();
          Thread.sleep(30000);
          try {
            jetty.start();
          } catch (Exception e4) {
            log.error("Could not get the port to start jetty again", e4);
            // we coud not get the port
            jetty.stop();
            return false;
          }
        }
      }
    }
    FilterHolder filterHolder = jetty.getDispatchFilter();
    if (filterHolder != null) {
      Filter filter = filterHolder.getFilter();
      if (filter != null) {
        CoreContainer cores = ((SolrDispatchFilter) filter).getCores();
        if (cores != null) {
          int zklocalport = ((InetSocketAddress) cores.getZkController()
              .getZkClient().getSolrZooKeeper().getSocketAddress()).getPort();
          IpTables.unblockPort(zklocalport);
        }
      }
    }
    return true;
  }
 
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:ChaosMonkey.java


注:本文中的org.apache.solr.servlet.SolrDispatchFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。