• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CoreAdminHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: doReloadTest

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void doReloadTest(String which) throws Exception {

    CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
    try {
      final CoreAdminHandler admin = new CoreAdminHandler(cc);
      SolrQueryResponse resp = new SolrQueryResponse();
      admin.handleRequestBody
          (req(CoreAdminParams.ACTION,
              CoreAdminParams.CoreAdminAction.RELOAD.toString(),
              CoreAdminParams.CORE, which),
              resp);
      assertNull("Exception on reload", resp.getException());

      origMatchesPersist(cc, SOLR_XML_LOTS_SYSVARS);
    } finally {
      cc.shutdown();
      if (solrHomeDirectory.exists()) {
        FileUtils.deleteDirectory(solrHomeDirectory);
      }
    }

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


示例2: tryCreateFail

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void tryCreateFail(CoreAdminHandler admin, String name, String dataDir, String... errs) throws Exception {
  try {
    SolrQueryResponse resp = new SolrQueryResponse();

    SolrQueryRequest request = req(CoreAdminParams.ACTION,
        CoreAdminParams.CoreAdminAction.CREATE.toString(),
        CoreAdminParams.DATA_DIR, dataDir,
        CoreAdminParams.NAME, name,
        "schema", "schema.xml",
        "config", "solrconfig.xml");

    admin.handleRequestBody(request, resp);
    fail("Should have thrown an error");
  } catch (SolrException se) {
    //SolrException cause = (SolrException)se.getCause();
    assertEquals("Exception code should be 500", 500, se.code());
    for (String err : errs) {
     assertTrue("Should have seen an exception containing the an error",
          se.getMessage().contains(err));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:TestLazyCores.java


示例3: checkStatus

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void checkStatus(CoreContainer cc, Boolean ok, String core) throws Exception {
  SolrQueryResponse resp = new SolrQueryResponse();
  final CoreAdminHandler admin = new CoreAdminHandler(cc);
  admin.handleRequestBody
      (req(CoreAdminParams.ACTION,
          CoreAdminParams.CoreAdminAction.STATUS.toString(),
          CoreAdminParams.CORE, core),
          resp);

  Map<String, Exception> failures =
      (Map<String, Exception>) resp.getValues().get("initFailures");

  if (ok) {
    if (failures.size() != 0) {
      fail("Should have cleared the error, but there are failues " + failures.toString());
    }
  } else {
    if (failures.size() == 0) {
      fail("Should have had errors here but the status return has no failures!");
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:TestLazyCores.java


示例4: newAdminHandlerInstance

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
public CoreAdminHandler newAdminHandlerInstance(final CoreContainer coreContainer, String cname, String ... subpackages) {
  Class<? extends CoreAdminHandler> clazz = findClass(cname, CoreAdminHandler.class, subpackages);
  if( clazz == null ) {
    throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
        "Can not find class: "+cname + " in " + classLoader);
  }
  
  CoreAdminHandler obj = null;
  try {
    Constructor<? extends CoreAdminHandler> ctor = clazz.getConstructor(CoreContainer.class);
    obj = ctor.newInstance(coreContainer);
  } 
  catch (Exception e) {
    throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
        "Error instantiating class: '" + clazz.getName()+"'", e);
  }

  if (!live) {
    //TODO: Does SolrCoreAware make sense here since in a multi-core context
    // which core are we talking about ?
    if (org.apache.solr.util.plugin.ResourceLoaderAware.class.isInstance(obj)) {
      log.warn("Class [{}] uses org.apache.solr.util.plugin.ResourceLoaderAware " +
          "which is deprecated. Change to org.apache.lucene.analysis.util.ResourceLoaderAware.", cname);
    }
    if( obj instanceof ResourceLoaderAware ) {
      assertAwareCompatibility( ResourceLoaderAware.class, obj );
      waitingForResources.add( (ResourceLoaderAware)obj );
    }
  }

  return obj;
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:SolrResourceLoader.java


示例5: assertSchemaResource

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void assertSchemaResource(String collection, String expectedSchemaResource) throws Exception {
  final CoreContainer cores = h.getCoreContainer();
  final CoreAdminHandler admin = new CoreAdminHandler(cores);
  SolrQueryRequest request = req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
  SolrQueryResponse response = new SolrQueryResponse();
  admin.handleRequestBody(request, response);
  assertNull("Exception on create", response.getException());
  NamedList responseValues = response.getValues();
  NamedList status = (NamedList)responseValues.get("status");
  NamedList collectionStatus = (NamedList)status.get(collection);
  String collectionSchema = (String)collectionStatus.get(CoreAdminParams.SCHEMA);
  assertEquals("Schema resource name differs from expected name", expectedSchemaResource, collectionSchema);
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:TestManagedSchema.java


示例6: testCreateSame

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
@Test
public void testCreateSame() throws Exception {
  final CoreContainer cc = init();
  try {
    // First, try all 4 combinations of load on startup and transient
    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    SolrCore lc2 = cc.getCore("collectionLazy2");
    SolrCore lc4 = cc.getCore("collectionLazy4");
    SolrCore lc5 = cc.getCore("collectionLazy5");
    SolrCore lc6 = cc.getCore("collectionLazy6");

    copyMinConf(new File(solrHomeDirectory, "t2"));
    copyMinConf(new File(solrHomeDirectory, "t4"));
    copyMinConf(new File(solrHomeDirectory, "t5"));
    copyMinConf(new File(solrHomeDirectory, "t6"));


    // Should also fail with the same name
    tryCreateFail(admin, "collectionLazy2", "t12", "Core with name", "collectionLazy2", "already exists");
    tryCreateFail(admin, "collectionLazy4", "t14", "Core with name", "collectionLazy4", "already exists");
    tryCreateFail(admin, "collectionLazy5", "t15", "Core with name", "collectionLazy5", "already exists");
    tryCreateFail(admin, "collectionLazy6", "t16", "Core with name", "collectionLazy6", "already exists");

    lc2.close();
    lc4.close();
    lc5.close();
    lc6.close();

  } finally {
    cc.shutdown();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:TestLazyCores.java


示例7: createViaAdmin

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void createViaAdmin(CoreContainer cc, String name, String instanceDir, boolean isTransient,
                            boolean loadOnStartup) throws Exception {

  final CoreAdminHandler admin = new CoreAdminHandler(cc);
  SolrQueryResponse resp = new SolrQueryResponse();
  admin.handleRequestBody
      (req(CoreAdminParams.ACTION,
          CoreAdminParams.CoreAdminAction.CREATE.toString(),
          CoreAdminParams.INSTANCE_DIR, instanceDir,
          CoreAdminParams.NAME, name,
          CoreAdminParams.TRANSIENT, Boolean.toString(isTransient),
          CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)),
          resp);

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


示例8: unloadViaAdmin

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void unloadViaAdmin(CoreContainer cc, String name) throws Exception {

    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.UNLOAD.toString(),
            CoreAdminParams.CORE, name),
            resp);

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


示例9: getMultiCoreHandler

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
public CoreAdminHandler getMultiCoreHandler() {
  return coreAdminHandler;
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:CoreContainer.java


示例10: MockCoreContainer

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
public MockCoreContainer() {
  super((Object)null);
  this.shardHandlerFactory = new HttpShardHandlerFactory();
  this.coreAdminHandler = new CoreAdminHandler();
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:ZkControllerTest.java


示例11: doTestRename

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void doTestRename(String which) throws Exception {
  CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
  SolrXMLCoresLocator.NonPersistingLocator locator
      = (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();

  try {
    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.RENAME.toString(),
            CoreAdminParams.CORE, which,
            CoreAdminParams.OTHER, "RenamedCore"),
            resp);
    assertNull("Exception on rename", resp.getException());

    // OK, Assure that if I change everything that has been renamed with the original value for the core, it matches
    // the old list
    String[] persistList = getAllNodes();
    String[] expressions = new String[persistList.length];

    for (int idx = 0; idx < persistList.length; ++idx) {
      expressions[idx] = persistList[idx].replaceAll("RenamedCore", which);
    }

    //assertXmlFile(origXml, expressions);
    TestHarness.validateXPath(SOLR_XML_LOTS_SYSVARS, expressions);

    // Now the other way, If I replace the original name in the original XML file with "RenamedCore", does it match
    // what was persisted?
    persistList = getAllNodes(SOLR_XML_LOTS_SYSVARS);
    expressions = new String[persistList.length];
    for (int idx = 0; idx < persistList.length; ++idx) {
      // /solr/cores/core[@name='SystemVars1' and @collection='${collection:collection1}']
      expressions[idx] = persistList[idx].replace("@name='" + which + "'", "@name='RenamedCore'");
    }

    TestHarness.validateXPath(locator.xml, expressions);

  } finally {
    cc.shutdown();
    if (solrHomeDirectory.exists()) {
      FileUtils.deleteDirectory(solrHomeDirectory);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:TestSolrXmlPersistence.java


示例12: doTestSwap

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void doTestSwap(String from, String to) throws Exception {
  CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
  SolrXMLCoresLocator.NonPersistingLocator locator
      = (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();

  int coreCount = countOccurrences(locator.xml, "<core ");

  try {
    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.SWAP.toString(),
            CoreAdminParams.CORE, from,
            CoreAdminParams.OTHER, to),
            resp);
    assertNull("Exception on swap", resp.getException());

    assertThat("Swapping cores should leave the same number of cores as before",
        countOccurrences(locator.xml, "<core "), is(coreCount));

    String[] persistList = getAllNodes();
    String[] expressions = new String[persistList.length];

    // Now manually change the names back and it should match exactly to the original XML.
    for (int idx = 0; idx < persistList.length; ++idx) {
      String fromName = "@name='" + from + "'";
      String toName = "@name='" + to + "'";
      if (persistList[idx].contains(fromName)) {
        expressions[idx] = persistList[idx].replace(fromName, toName);
      } else {
        expressions[idx] = persistList[idx].replace(toName, fromName);
      }
    }

    //assertXmlFile(origXml, expressions);
    TestHarness.validateXPath(SOLR_XML_LOTS_SYSVARS, expressions);

  } finally {
    cc.shutdown();
    if (solrHomeDirectory.exists()) {
      FileUtils.deleteDirectory(solrHomeDirectory);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:TestSolrXmlPersistence.java


示例13: doTestUnloadCreate

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
private void doTestUnloadCreate(String which) throws Exception {
  CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
  try {
    final CoreAdminHandler admin = new CoreAdminHandler(cc);

    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.UNLOAD.toString(),
            CoreAdminParams.CORE, which),
            resp);
    assertNull("Exception on unload", resp.getException());

    //origMatchesPersist(cc, new File(solrHomeDirectory, "unloadcreate1.solr.xml"));

    String instPath = new File(solrHomeDirectory, which).getAbsolutePath();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.CREATE.toString(),
            CoreAdminParams.INSTANCE_DIR, instPath,
            CoreAdminParams.NAME, which),
            resp);
    assertNull("Exception on create", resp.getException());

    String[] persistList = getAllNodes();
    String[] expressions = new String[persistList.length];

    // Now manually change the names back and it should match exactly to the original XML.
    for (int idx = 0; idx < persistList.length; ++idx) {
      String name = "@name='" + which + "'";

      if (persistList[idx].contains(name)) {
        if (persistList[idx].contains("@schema='schema.xml'")) {
          expressions[idx] = persistList[idx].replace("schema.xml", "${schema:schema.xml}");
        } else if (persistList[idx].contains("@config='solrconfig.xml'")) {
          expressions[idx] = persistList[idx].replace("solrconfig.xml", "${solrconfig:solrconfig.xml}");
        } else if (persistList[idx].contains("@instanceDir=")) {
          expressions[idx] = persistList[idx].replaceFirst("instanceDir\\='.*?'", "instanceDir='" + which + "/'");
        } else {
          expressions[idx] = persistList[idx];
        }
      } else {
        expressions[idx] = persistList[idx];
      }
    }

    //assertXmlFile(origXml, expressions);
    TestHarness.validateXPath(SOLR_XML_LOTS_SYSVARS, expressions);

  } finally {
    cc.shutdown();
    if (solrHomeDirectory.exists()) {
      FileUtils.deleteDirectory(solrHomeDirectory);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:57,代码来源:TestSolrXmlPersistence.java


示例14: testCreatePersistCore

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
@Test
public void testCreatePersistCore() throws Exception {
  // Template for creating a core.
  CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2", "props1", "props2");
  SolrXMLCoresLocator.NonPersistingLocator locator
      = (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();

  try {
    final CoreAdminHandler admin = new CoreAdminHandler(cc);
    // create a new core (using CoreAdminHandler) w/ properties

    SolrQueryResponse resp = new SolrQueryResponse();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.CREATE.toString(),
            CoreAdminParams.NAME, "props1",
            CoreAdminParams.TRANSIENT, "true",
            CoreAdminParams.LOAD_ON_STARTUP, "true",
            CoreAdminParams.PROPERTY_PREFIX + "prefix1", "valuep1",
            CoreAdminParams.PROPERTY_PREFIX + "prefix2", "valueP2",
            "wt", "json", // need to insure that extra parameters are _not_ preserved (actually happened).
            "qt", "admin/cores"),
            resp);
    assertNull("Exception on create", resp.getException());

    String instPath2 = new File(solrHomeDirectory, "props2").getAbsolutePath();
    admin.handleRequestBody
        (req(CoreAdminParams.ACTION,
            CoreAdminParams.CoreAdminAction.CREATE.toString(),
            CoreAdminParams.INSTANCE_DIR, instPath2,
            CoreAdminParams.NAME, "props2",
            CoreAdminParams.PROPERTY_PREFIX + "prefix2_1", "valuep2_1",
            CoreAdminParams.PROPERTY_PREFIX + "prefix2_2", "valueP2_2",
            CoreAdminParams.CONFIG, "solrconfig.xml",
            CoreAdminParams.DATA_DIR, "./dataDirTest",
            CoreAdminParams.SCHEMA, "schema.xml"),
            resp);
    assertNull("Exception on create", resp.getException());

    // Everything that was in the original XML file should be in the persisted one.
    TestHarness.validateXPath(locator.xml, getAllNodes(SOLR_XML_LOTS_SYSVARS));

    // And the params for the new core should be in the persisted file.
    TestHarness.validateXPath
        (
            locator.xml,
            "/solr/cores/core[@name='props1']/property[@name='prefix1' and @value='valuep1']"
            , "/solr/cores/core[@name='props1']/property[@name='prefix2' and @value='valueP2']"
            , "/solr/cores/core[@name='props1' and @transient='true']"
            , "/solr/cores/core[@name='props1' and @loadOnStartup='true']"
            , "/solr/cores/core[@name='props1' and @instanceDir='props1" + File.separator + "']"
            , "/solr/cores/core[@name='props2']/property[@name='prefix2_1' and @value='valuep2_1']"
            , "/solr/cores/core[@name='props2']/property[@name='prefix2_2' and @value='valueP2_2']"
            , "/solr/cores/core[@name='props2' and @config='solrconfig.xml']"
            , "/solr/cores/core[@name='props2' and @schema='schema.xml']"
            , "/solr/cores/core[@name='props2' and not(@loadOnStartup)]"
            , "/solr/cores/core[@name='props2' and not(@transient)]"
            , "/solr/cores/core[@name='props2' and @instanceDir='" + instPath2 + "']"
            , "/solr/cores/core[@name='props2' and @dataDir='./dataDirTest']"
        );

  } finally {
    cc.shutdown();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:66,代码来源:TestSolrXmlPersistence.java


示例15: createMultiCoreHandler

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
/** 
 * Creates a CoreAdminHandler for this MultiCore.
 * @return a CoreAdminHandler
 */
protected CoreAdminHandler createMultiCoreHandler(final String adminHandlerClass) {
  // :TODO: why create a new SolrResourceLoader? why not use this.loader ???
  SolrResourceLoader loader = new SolrResourceLoader(solrHome, libLoader, null);
  return loader.newAdminHandlerInstance(CoreContainer.this, adminHandlerClass);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:10,代码来源:CoreContainer.java


示例16: createMultiCoreHandler

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
/**
 * Creates a CoreAdminHandler for this MultiCore.
 * 
 * @return a CoreAdminHandler
 */
protected CoreAdminHandler createMultiCoreHandler(final String adminHandlerClass) {
	// :TODO: why create a new SolrResourceLoader? why not use this.loader ???
	SolrResourceLoader loader = new SolrResourceLoader(solrHome, libLoader, null);
	return loader.newAdminHandlerInstance(CoreContainer.this, adminHandlerClass);
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:11,代码来源:CoreContainer.java


示例17: getMultiCoreHandler

import org.apache.solr.handler.admin.CoreAdminHandler; //导入依赖的package包/类
public CoreAdminHandler getMultiCoreHandler() {
	return coreAdminHandler;
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:4,代码来源:CoreContainer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpanBytesEncoder类代码示例发布时间:2022-05-22
下一篇:
Java ArtifactInstaller类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap