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


Java CommitUpdateCommand类代码示例

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


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

示例1: doLocalCommit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
private void doLocalCommit(CommitUpdateCommand cmd) throws IOException {
  if (vinfo != null) {
    vinfo.lockForUpdate();
  }
  try {

    if (ulog == null || ulog.getState() == UpdateLog.State.ACTIVE || (cmd.getFlags() & UpdateCommand.REPLAY) != 0) {
      super.processCommit(cmd);
    } else {
      log.info("Ignoring commit while not ACTIVE - state: " + ulog.getState() + " replay:" + (cmd.getFlags() & UpdateCommand.REPLAY));
    }

  } finally {
    if (vinfo != null) {
      vinfo.unlockForUpdate();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:DistributedUpdateProcessor.java

示例2: processCommit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
protected void processCommit(final String chain) throws IOException {
  SolrCore core = h.getCore();
  UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain);
  assertNotNull("No Chain named: " + chain, pc);

  SolrQueryResponse rsp = new SolrQueryResponse();

  SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());

  CommitUpdateCommand cmd = new CommitUpdateCommand(req,false);
  UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
  try {
    processor.processCommit(cmd);
  } finally {
    req.close();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:UpdateProcessorTestBase.java

示例3: addNode

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
private NodeRef addNode(SolrCore core, AlfrescoSolrDataModel dataModel, int txid, int dbid, int aclid, QName type,
            QName[] aspects, Map<QName, PropertyValue> properties, Map<QName, String> content, String owner,
            ChildAssociationRef[] parentAssocs, NodeRef[] ancestors, String[] paths, NodeRef nodeRef, boolean commit)
            throws IOException
{
    AddUpdateCommand addDocCmd = new AddUpdateCommand(solrQueryRequest);
    addDocCmd.overwrite = true;
    addDocCmd.solrDoc = createDocument(dataModel, new Long(txid), new Long(dbid), nodeRef, type, aspects, 
                properties, content, new Long(aclid), paths, owner, parentAssocs, ancestors);
    core.getUpdateHandler().addDoc(addDocCmd);

    if (commit)
    {
        core.getUpdateHandler().commit(new CommitUpdateCommand(solrQueryRequest, false));
    }

    return nodeRef;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:19,代码来源:AlfrescoCoreAdminTester.java

示例4: addStoreRoot

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
private void addStoreRoot(SolrCore core, AlfrescoSolrDataModel dataModel, 
            NodeRef rootNodeRef, int txid, int dbid, int acltxid, int aclid) throws IOException
{
    AddUpdateCommand addDocCmd = new AddUpdateCommand(this.solrQueryRequest);
    addDocCmd.overwrite = true;
    addDocCmd.solrDoc = createDocument(dataModel, new Long(txid), new Long(dbid), rootNodeRef, 
                ContentModel.TYPE_STOREROOT, new QName[] { ContentModel.ASPECT_ROOT }, null, null, new Long(aclid),
                new String[] { "/" }, "system", null, null);
    core.getUpdateHandler().addDoc(addDocCmd);
    addAcl(core, dataModel, acltxid, aclid, 0, 0);

    AddUpdateCommand txCmd = new AddUpdateCommand(this.solrQueryRequest);
    txCmd.overwrite = true;
    SolrInputDocument input = new SolrInputDocument();
    String id = AlfrescoSolrDataModel.getTransactionDocumentId(new Long(txid));
    input.addField(FIELD_SOLR4_ID, id);
    input.addField(FIELD_VERSION, "0");
    input.addField(FIELD_TXID, txid);
    input.addField(FIELD_INTXID, txid);
    input.addField(FIELD_TXCOMMITTIME, (new Date()).getTime());
    input.addField(FIELD_DOC_TYPE, SolrInformationServer.DOC_TYPE_TX);
    txCmd.solrDoc = input;
    core.getUpdateHandler().addDoc(txCmd);

    core.getUpdateHandler().commit(new CommitUpdateCommand(this.solrQueryRequest, false));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:27,代码来源:AlfrescoCoreAdminTester.java

示例5: commit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Override
public void commit(final CommitUpdateCommand cmd,
        final UpdateHandlerFilterChain chain) throws IOException {
    final UpdateLog ulog = updateHandler.getUpdateLog();
    final File logDir = new File(ulog.getLogDir());
    final long lastLogId = ulog.getLastLogId();
    final String lastLogName = String.format(Locale.ROOT,
            UpdateLog.LOG_FILENAME_PATTERN, UpdateLog.TLOG_NAME, lastLogId);

    chain.commit(cmd);

    final File logFile = new File(logDir, lastLogName);
    if(logFile.exists()) {
        if (logger.isInfoEnabled()) {
            logger.info("Create " + logFile.getAbsolutePath());
        }
        suggestUpdateController.addTransactionLog(logFile);
    } else {
        if(logger.isInfoEnabled()) {
            logger.info(logFile.getName() + " does not exist.");
        }
    }
}
 
开发者ID:codelibs,项目名称:fess-solr-plugin,代码行数:24,代码来源:SuggestTranslogUpdateHandlerFilter.java

示例6: handleRequestBody

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
    formatResponseAsJson(req);

    if (req.getContentStreams() == null) {
        LOGGER.warn("no content stream");
        rsp.add("error", "No content stream");
        return;
    }

    boolean commit = Boolean.parseBoolean(req.getParams().get("commit", "true"));

    InputStream stream = req.getContentStreams().iterator().next().getStream();
    stream = detectGzip(stream);

    MetricTimeSeriesConverter converter = new MetricTimeSeriesConverter();

    UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(req.getParams());
    UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);
    try {
        for (MetricTimeSeries series : formatParser.parse(stream)) {
            SolrInputDocument document = new SolrInputDocument();
            converter.to(series).getFields().forEach(document::addField);
            storeDocument(document, processor, req);
        }

        if (commit) {
            LOGGER.debug("Committing transaction...");
            processor.processCommit(new CommitUpdateCommand(req, false));
            LOGGER.debug("Committed transaction");
        } else {
            LOGGER.debug("Only adding documents.");
        }
    } finally {
        processor.finish();
    }
}
 
开发者ID:ChronixDB,项目名称:chronix.server,代码行数:39,代码来源:AbstractIngestionHandler.java

示例7: processCommit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Override
public void processCommit(CommitUpdateCommand cmd) throws IOException {
  updateCommand = cmd;
  List<Node> nodes = null;
  boolean singleLeader = false;
  if (zkEnabled) {
    zkCheck();
    
    nodes = getCollectionUrls(req, req.getCore().getCoreDescriptor()
        .getCloudDescriptor().getCollectionName());
    if (isLeader && nodes.size() == 1) {
      singleLeader = true;
    }
  }
  
  if (!zkEnabled || req.getParams().getBool(COMMIT_END_POINT, false) || singleLeader) {
    doLocalCommit(cmd);
  } else if (zkEnabled) {
    ModifiableSolrParams params = new ModifiableSolrParams(filterParams(req.getParams()));
    if (!req.getParams().getBool(COMMIT_END_POINT, false)) {
      params.set(COMMIT_END_POINT, true);
      params.set(DISTRIB_UPDATE_PARAM, DistribPhase.FROMLEADER.toString());
      params.set(DISTRIB_FROM, ZkCoreNodeProps.getCoreUrl(
          zkController.getBaseUrl(), req.getCore().getName()));
      if (nodes != null) {
        cmdDistrib.distribCommit(cmd, nodes, params);
        finish();
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:DistributedUpdateProcessor.java

示例8: processCommit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Override
public void processCommit( CommitUpdateCommand cmd ) throws IOException {
  if (logDebug) { log.debug("PRE_UPDATE " + cmd.toString() + " " + req); }
  if (next != null) next.processCommit(cmd);


  final String msg = cmd.optimize ? "optimize" : "commit";
  toLog.add(msg, "");
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:LogUpdateProcessorFactory.java

示例9: updateCommit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
/**
 * Modify UpdateCommand based on request parameters
 */
public static void updateCommit(CommitUpdateCommand cmd, SolrParams params) {
  if( params == null ) return;

  cmd.openSearcher = params.getBool( UpdateParams.OPEN_SEARCHER, cmd.openSearcher );
  cmd.waitSearcher = params.getBool( UpdateParams.WAIT_SEARCHER, cmd.waitSearcher );
  cmd.softCommit = params.getBool( UpdateParams.SOFT_COMMIT, cmd.softCommit );
  cmd.expungeDeletes = params.getBool( UpdateParams.EXPUNGE_DELETES, cmd.expungeDeletes );
  cmd.maxOptimizeSegments = params.getInt( UpdateParams.MAX_OPTIMIZE_SEGMENTS, cmd.maxOptimizeSegments );
  cmd.prepareCommit = params.getBool( UpdateParams.PREPARE_COMMIT,   cmd.prepareCommit );
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:RequestHandlerUtils.java

示例10: testOptimizeDiffSchemas

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Test
public void testOptimizeDiffSchemas() throws Exception {
  // load up a core (why not put it on disk?)
  CoreContainer cc = init();
  try (SolrCore changed = cc.getCore("changed")) {

    // add some documents
    addDoc(changed, "id", "1", "which", "15", "text", "some stuff with which");
    addDoc(changed, "id", "2", "which", "15", "text", "some stuff with which");
    addDoc(changed, "id", "3", "which", "15", "text", "some stuff with which");
    addDoc(changed, "id", "4", "which", "15", "text", "some stuff with which");
    SolrQueryRequest req = new LocalSolrQueryRequest(changed, new NamedList<>());
    changed.getUpdateHandler().commit(new CommitUpdateCommand(req, false));

    // write the new schema out and make it current
    FileUtils.writeStringToFile(schemaFile, withoutWhich, Charsets.UTF_8.toString());

    IndexSchema iSchema = IndexSchemaFactory.buildIndexSchema("schema.xml", changed.getSolrConfig());
    changed.setLatestSchema(iSchema);

    addDoc(changed, "id", "1", "text", "some stuff without which");
    addDoc(changed, "id", "5", "text", "some stuff without which");

    changed.getUpdateHandler().commit(new CommitUpdateCommand(req, false));
    changed.getUpdateHandler().commit(new CommitUpdateCommand(req, true));
  } finally {
    if (cc != null) cc.shutdown();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:ChangedSchemaMergeTest.java

示例11: checkSearch

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
private void checkSearch(SolrCore core) throws IOException {
  addLazy(core, "id", "0");
  addLazy(core, "id", "1", "v_t", "Hello Dude");
  addLazy(core, "id", "2", "v_t", "Hello Yonik");
  addLazy(core, "id", "3", "v_s", "{!literal}");
  addLazy(core, "id", "4", "v_s", "other stuff");
  addLazy(core, "id", "5", "v_f", "3.14159");
  addLazy(core, "id", "6", "v_f", "8983");

  SolrQueryRequest req = makeReq(core);
  CommitUpdateCommand cmtCmd = new CommitUpdateCommand(req, false);
  core.getUpdateHandler().commit(cmtCmd);

  // Just get a couple of searches to work!
  assertQ("test prefix query",
      makeReq(core, "q", "{!prefix f=v_t}hel", "wt", "xml")
      , "//result[@numFound='2']"
  );

  assertQ("test raw query",
      makeReq(core, "q", "{!raw f=v_t}hello", "wt", "xml")
      , "//result[@numFound='2']"
  );

  // no analysis is done, so these should match nothing
  assertQ("test raw query",
      makeReq(core, "q", "{!raw f=v_t}Hello", "wt", "xml")
      , "//result[@numFound='0']"
  );
  assertQ("test raw query",
      makeReq(core, "q", "{!raw f=v_f}1.5", "wt", "xml")
      , "//result[@numFound='0']"
  );
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:TestLazyCores.java

示例12: processCommit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Override
public void processCommit(CommitUpdateCommand cmd) throws IOException {
    synchronized (esProcessor) {
        esProcessor.commit();
    }
    super.processCommit(cmd);
}
 
开发者ID:jmlucjav,项目名称:esURP,代码行数:8,代码来源:EsUpdateRequestProcessorFactory.java

示例13: commit

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
@Override
public void commit() throws IOException
{
    // avoid multiple commits and warming searchers
    commitAndRollbackLock.writeLock().lock();
    try
    {
        canUpdate();
        SolrQueryRequest request = null;
        UpdateRequestProcessor processor = null;
        try
        {
            request = getLocalSolrQueryRequest();
            processor = this.core.getUpdateProcessingChain(null).createProcessor(request, new SolrQueryResponse());
            processor.processCommit(new CommitUpdateCommand(request, false));
        }
        finally
        {
            if(processor != null) {processor.finish();}
            if(request != null) {request.close();}
        }
    }
    finally
    {
        commitAndRollbackLock.writeLock().unlock();
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:28,代码来源:SolrInformationServer.java

示例14: run

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
/** This is the worker part for the ScheduledFuture **/
public synchronized void run()
{
    long started = System.currentTimeMillis();
    try
    {
        CommitUpdateCommand command = new CommitUpdateCommand(false);
        command.waitFlush = true;
        command.waitSearcher = true;
        // no need for command.maxOptimizeSegments = 1; since it is not optimizing
        commit(command);
        autoCommitCount++;
    }
    catch (Exception e)
    {
        log.error("auto commit error...");
        e.printStackTrace();
    }
    finally
    {
        pending = null;
    }

    // check if docs have been submitted since the commit started
    if (lastAddedTime > started)
    {
        if (docsUpperBound > 0 && docsSinceCommit > docsUpperBound)
        {
            pending = scheduler.schedule(this, 100, TimeUnit.MILLISECONDS);
        }
        else if (timeUpperBound > 0)
        {
            pending = scheduler.schedule(this, timeUpperBound, TimeUnit.MILLISECONDS);
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:37,代码来源:AlfrescoUpdateHandler.java

示例15: addNode

import org.apache.solr.update.CommitUpdateCommand; //导入依赖的package包/类
private NodeRef addNode(SolrCore core, AlfrescoSolrDataModel dataModel, int txid, int dbid, int aclid, QName type, QName[] aspects, Map<QName, PropertyValue> properties,
        Map<QName, String> content, String owner, ChildAssociationRef[] parentAssocs, NodeRef[] ancestors, String[] paths, NodeRef nodeRef, boolean commit) throws IOException
{
    AddUpdateCommand leafDocCmd = new AddUpdateCommand();
    leafDocCmd.overwriteCommitted = true;
    leafDocCmd.overwritePending = true;
    leafDocCmd.solrDoc = createLeafDocument(dataModel, txid, dbid, nodeRef, type, aspects, properties, content);
    leafDocCmd.doc = LegacySolrInformationServer.toDocument(leafDocCmd.getSolrInputDocument(), core.getSchema(), dataModel);

    AddUpdateCommand auxDocCmd = new AddUpdateCommand();
    auxDocCmd.overwriteCommitted = true;
    auxDocCmd.overwritePending = true;
    auxDocCmd.solrDoc = createAuxDocument(txid, dbid, aclid, paths, owner, parentAssocs, ancestors);
    auxDocCmd.doc = LegacySolrInformationServer.toDocument(auxDocCmd.getSolrInputDocument(), core.getSchema(), dataModel);

    if (leafDocCmd.doc != null)
    {
        core.getUpdateHandler().addDoc(leafDocCmd);
    }
    if (auxDocCmd.doc != null)
    {
        core.getUpdateHandler().addDoc(auxDocCmd);
    }

    if (commit)
    {
        core.getUpdateHandler().commit(new CommitUpdateCommand(false));
    }

    return nodeRef;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:32,代码来源:AlfrescoCoreAdminHandler.java


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