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

Java DirectUpdateHandler2类代码示例

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

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



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

示例1: tearDown

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
  super.tearDown();
  if (commondCloudSolrServer != null) {
    commondCloudSolrServer.shutdown();
  }
  if (otherCollectionClients != null) {
    for (List<SolrServer> clientList : otherCollectionClients.values()) {
      for (SolrServer client : clientList) {
        client.shutdown();
      }
    }
  }
  otherCollectionClients = null;
  List<Runnable> tasks = executor.shutdownNow();
  assertTrue(tasks.isEmpty());
  
  System.clearProperty("numShards");
  System.clearProperty("zkHost");
  System.clearProperty("solr.xml.persist");
  
  // insurance
  DirectUpdateHandler2.commitOnClose = true;
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:BasicDistributedZkTest.java


示例2: tearDown

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Override
@After
public void tearDown() throws Exception {
  super.tearDown();

  if (VERBOSE || printLayoutOnTearDown) {
    super.printLayout();
  }
  if (controlClient != null) {
    controlClient.shutdown();
  }
  if (cloudClient != null) {
    cloudClient.shutdown();
  }
  if (controlClientCloud != null) {
    controlClientCloud.shutdown();
  }
  super.tearDown();

  System.clearProperty("zkHost");
  System.clearProperty("numShards");
  System.clearProperty("solr.xml.persist");

  // insurance
  DirectUpdateHandler2.commitOnClose = true;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:MigrateRouteKeyTest.java


示例3: randomlyEnableAutoSoftCommit

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的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


示例4: enableAutoSoftCommit

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的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


示例5: stopTheMonkey

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
public void stopTheMonkey() {
  stop = true;
  try {
    monkeyThread.join();
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  
  DirectUpdateHandler2.commitOnClose = true;
  
  float runtime = (System.currentTimeMillis() - startTime)/1000.0f;
  if (runtime > 20 && stops.get() == 0) {
    LuceneTestCase.fail("The Monkey ran for over 20 seconds and no jetties were stopped - this is worth investigating!");
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:ChaosMonkey.java


示例6: testUpdateNoTLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
public void testUpdateNoTLog() throws Exception {
  try {
    System.setProperty("enable.update.log", "false");
    initCore("solrconfig.xml","schema15.xml");
    
    UpdateHandler uh = h.getCore().getUpdateHandler();
    assertTrue("this test requires DirectUpdateHandler2",
               uh instanceof DirectUpdateHandler2);

    assertNull("this test requires that the updateLog not be enabled, it " +
               "seems that someone modified the configs",
               ((DirectUpdateHandler2)uh).getUpdateLog());
    
    // creating docs should work fine
    addAndGetVersion(sdoc("id", "1", "val_i", "42"), null);
    assertU(commit());

    try {
      ignoreException("updateLog");

      // updating docs should fail
      addAndGetVersion(sdoc("id", "1", "val_i", map("inc",-666)), null);
      
      fail("didn't get error about needing updateLog");
    } catch (SolrException ex) {
      assertEquals(400, ex.code());
      // if the message doesn't match our expectation, wrap & rethrow
      if (ex.getMessage().indexOf("unless <updateLog/> is configured") < 0) {
        throw new RuntimeException("exception message is not expected", ex);
      }
    } finally {
      resetExceptionIgnores();
    }

  } finally {
    System.clearProperty("enable.update.log");
    deleteCore();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:40,代码来源:TestAtomicUpdateErrorCases.java


示例7: tearDown

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
  super.tearDown();
  System.clearProperty("numShards");
  System.clearProperty("zkHost");
  System.clearProperty("solr.xml.persist");
  
  // insurance
  DirectUpdateHandler2.commitOnClose = true;
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:MultiThreadedOCPTest.java


示例8: tearDown

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
  super.tearDown();
  System.clearProperty("numShards");
  System.clearProperty("zkHost");
  System.clearProperty("solr.xml.persist");

  // insurance
  DirectUpdateHandler2.commitOnClose = true;
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:CustomCollectionTest.java


示例9: testUpdateNoTLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
public void testUpdateNoTLog() throws Exception {
  try {
    initCore("solrconfig.xml","schema15.xml");
    
    UpdateHandler uh = h.getCore().getUpdateHandler();
    assertTrue("this test requires DirectUpdateHandler2",
               uh instanceof DirectUpdateHandler2);

    assertNull("this test requires that the updateLog not be enabled, it " +
               "seems that someone modified the configs",
               ((DirectUpdateHandler2)uh).getUpdateLog());
    
    // creating docs should work fine
    addAndGetVersion(sdoc("id", "1", "val_i", "42"), null);
    assertU(commit());

    try {
      ignoreException("updateLog");

      // updating docs should fail
      addAndGetVersion(sdoc("id", "1", "val_i", map("inc",-666)), null);
      
      fail("didn't get error about needing updateLog");
    } catch (SolrException ex) {
      assertEquals(400, ex.code());
      // if the message doesn't match our expectation, wrap & rethrow
      if (ex.getMessage().indexOf("unless <updateLog/> is configured") < 0) {
        throw new RuntimeException("exception message is not expected", ex);
      }
    } finally {
      resetExceptionIgnores();
    }

  } finally {
    deleteCore();
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:38,代码来源:TestAtomicUpdateErrorCases.java


示例10: tearDown

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
  super.tearDown();
  if (commondCloudSolrServer != null) {
    commondCloudSolrServer.shutdown();
  }
  System.clearProperty("numShards");
  System.clearProperty("zkHost");
  System.clearProperty("solr.xml.persist");
  
  // insurance
  DirectUpdateHandler2.commitOnClose = true;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:14,代码来源:BasicDistributedZkTest.java


示例11: testTermIndexInterval

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testTermIndexInterval() throws Exception {
  RefCounted<IndexWriter> iw = ((DirectUpdateHandler2) h.getCore()
      .getUpdateHandler()).getSolrCoreState().getIndexWriter(h.getCore());
  int interval = 0;
  try {
    IndexWriter writer = iw.get();
    interval = writer.getConfig().getTermIndexInterval();
  } finally {
    iw.decref();
  }
  assertEquals(256, interval);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:14,代码来源:TestConfig.java


示例12: startTheMonkey

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
public void startTheMonkey(boolean killLeaders, final int roundPauseUpperLimit) {
  if (!MONKEY_ENABLED) {
    monkeyLog("The Monkey is disabled and will not start");
    return;
  }
  monkeyLog("starting");
  
  
  if (LuceneTestCase.random().nextBoolean()) {
    monkeyLog("Jetty will not commit on shutdown");
    DirectUpdateHandler2.commitOnClose = false;
  }
  
  this.aggressivelyKillLeaders = killLeaders;
  startTime = System.currentTimeMillis();
  // TODO: when kill leaders is on, lets kill a higher percentage of leaders
  
  stop = false;
  monkeyThread = new Thread() {

    @Override
    public void run() {
      while (!stop) {
        try {
  
          Random random = LuceneTestCase.random();
          Thread.sleep(random.nextInt(roundPauseUpperLimit));
          if (random.nextBoolean()) {
           if (!deadPool.isEmpty()) {
             int index = random.nextInt(deadPool.size());
             JettySolrRunner jetty = deadPool.get(index).jetty;
             if (jetty.isStopped() && !ChaosMonkey.start(jetty)) {
               continue;
             }
             //System.out.println("started on port:" + jetty.getLocalPort());
             deadPool.remove(index);
             starts.incrementAndGet();
             continue;
           }
          }
          
          int rnd = random.nextInt(10);

          if (expireSessions && rnd < EXPIRE_PERCENT) {
            expireRandomSession();
          } 
          
          if (causeConnectionLoss && rnd < CONLOSS_PERCENT) {
            randomConnectionLoss();
          }
          
          CloudJettyRunner cjetty;
          if (random.nextBoolean()) {
            cjetty = stopRandomShard();
          } else {
            cjetty = killRandomShard();
          }
          if (cjetty == null) {
            // we cannot kill
          } else {
            deadPool.add(cjetty);
          }
          
        } catch (InterruptedException e) {
          //
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      monkeyLog("finished");
      monkeyLog("I ran for " + (System.currentTimeMillis() - startTime)/1000.0f + "sec. I stopped " + stops + " and I started " + starts
          + ". I also expired " + expires.get() + " and caused " + connloss
          + " connection losses");
    }
  };
  monkeyThread.start();
}
 
开发者ID:europeana,项目名称:search,代码行数:79,代码来源:ChaosMonkey.java


示例13: testCleanShutdown

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testCleanShutdown() throws Exception {
  DirectUpdateHandler2.commitOnClose = true;
  final Semaphore logReplay = new Semaphore(0);
  final Semaphore logReplayFinish = new Semaphore(0);

  UpdateLog.testing_logReplayHook = new Runnable() {
    @Override
    public void run() {
      try {
        assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  };

  UpdateLog.testing_logReplayFinishHook = new Runnable() {
    @Override
    public void run() {
      logReplayFinish.release();
    }
  };


  SolrQueryRequest req = req();
  UpdateHandler uhandler = req.getCore().getUpdateHandler();
  UpdateLog ulog = uhandler.getUpdateLog();

  try {
    clearIndex();
    assertU(commit());

    assertU(adoc("id","E1", "val_i","1"));
    assertU(adoc("id","E2", "val_i","1"));

    // set to a high enough number so this test won't hang on a bug
    logReplay.release(10);

    h.close();
    createCore();

    // make sure the docs got committed
    assertJQ(req("q","*:*"),"/response/numFound==2");

    // make sure no replay happened
    assertEquals(10, logReplay.availablePermits());

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;

    req().close();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:57,代码来源:TestRecovery.java


示例14: testTruncatedLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testTruncatedLog() throws Exception {
  try {
    DirectUpdateHandler2.commitOnClose = false;
    final Semaphore logReplay = new Semaphore(0);
    final Semaphore logReplayFinish = new Semaphore(0);

    UpdateLog.testing_logReplayHook = new Runnable() {
      @Override
      public void run() {
        try {
          assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    };

    UpdateLog.testing_logReplayFinishHook = new Runnable() {
      @Override
      public void run() {
        logReplayFinish.release();
      }
    };

    UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
    File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());

    clearIndex();
    assertU(commit());

    assertU(adoc("id","F1"));
    assertU(adoc("id","F2"));
    assertU(adoc("id","F3"));

    h.close();
    String[] files = ulog.getLogList(logDir);
    Arrays.sort(files);
    RandomAccessFile raf = new RandomAccessFile(new File(logDir, files[files.length-1]), "rw");
    raf.seek(raf.length());  // seek to end
    raf.writeLong(0xffffffffffffffffL);
    raf.writeChars("This should be appended to a good log file, representing a bad partially written record.");
    raf.close();

    logReplay.release(1000);
    logReplayFinish.drainPermits();
    ignoreException("OutOfBoundsException");  // this is what the corrupted log currently produces... subject to change.
    createCore();
    assertTrue(logReplayFinish.tryAcquire(timeout, TimeUnit.SECONDS));
    resetExceptionIgnores();
    assertJQ(req("q","*:*") ,"/response/numFound==3");

    //
    // Now test that the bad log file doesn't mess up retrieving latest versions
    //

    updateJ(jsonAdd(sdoc("id","F4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","F5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","F6", "_version_","106")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));

    // This currently skips the bad log file and also returns the version of the clearIndex (del *:*)
    // assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]");
    assertJQ(req("qt","/get", "getVersions","3"), "/versions==[106,105,104]");

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:71,代码来源:TestRecovery.java


示例15: testCorruptLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testCorruptLog() throws Exception {
  try {
    DirectUpdateHandler2.commitOnClose = false;

    UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
    File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());

    clearIndex();
    assertU(commit());

    assertU(adoc("id","G1"));
    assertU(adoc("id","G2"));
    assertU(adoc("id","G3"));

    h.close();


    String[] files = ulog.getLogList(logDir);
    Arrays.sort(files);
    RandomAccessFile raf = new RandomAccessFile(new File(logDir, files[files.length-1]), "rw");
    long len = raf.length();
    raf.seek(0);  // seek to start
    raf.write(new byte[(int)len]);  // zero out file
    raf.close();


    ignoreException("Failure to open existing log file");  // this is what the corrupted log currently produces... subject to change.
    createCore();
    resetExceptionIgnores();

    // just make sure it responds
    assertJQ(req("q","*:*") ,"/response/numFound==0");

    //
    // Now test that the bad log file doesn't mess up retrieving latest versions
    //

    updateJ(jsonAdd(sdoc("id","G4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","G5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","G6", "_version_","106")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));

    // This currently skips the bad log file and also returns the version of the clearIndex (del *:*)
    // assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]");
    assertJQ(req("qt","/get", "getVersions","3"), "/versions==[106,105,104]");

    assertU(commit());

    assertJQ(req("q","*:*") ,"/response/numFound==3");

    // This messes up some other tests (on windows) if we don't remove the bad log.
    // This *should* hopefully just be because the tests are too fragile and not because of real bugs - but it should be investigated further.
    deleteLogs();

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:61,代码来源:TestRecovery.java


示例16: testRecoveryMultipleLogs

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testRecoveryMultipleLogs() throws Exception {
  try {
    DirectUpdateHandler2.commitOnClose = false;
    final Semaphore logReplay = new Semaphore(0);
    final Semaphore logReplayFinish = new Semaphore(0);

    UpdateLog.testing_logReplayHook = new Runnable() {
      @Override
      public void run() {
        try {
          assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    };

    UpdateLog.testing_logReplayFinishHook = new Runnable() {
      @Override
      public void run() {
        logReplayFinish.release();
      }
    };

    UpdateLog ulog = h.getCore().getUpdateHandler().getUpdateLog();
    File logDir = new File(h.getCore().getUpdateHandler().getUpdateLog().getLogDir());

    clearIndex();
    assertU(commit());

    assertU(adoc("id","AAAAAA"));
    assertU(adoc("id","BBBBBB"));
    assertU(adoc("id","CCCCCC"));

    h.close();
    String[] files = ulog.getLogList(logDir);
    Arrays.sort(files);
    String fname = files[files.length-1];
    RandomAccessFile raf = new RandomAccessFile(new File(logDir, fname), "rw");
    raf.seek(raf.length());  // seek to end
    raf.writeLong(0xffffffffffffffffL);
    raf.writeChars("This should be appended to a good log file, representing a bad partially written record.");
    
    byte[] content = new byte[(int)raf.length()];
    raf.seek(0);
    raf.readFully(content);

    raf.close();

    // Now make a newer log file with just the IDs changed.  NOTE: this may not work if log format changes too much!
    findReplace("AAAAAA".getBytes(StandardCharsets.UTF_8), "aaaaaa".getBytes(StandardCharsets.UTF_8), content);
    findReplace("BBBBBB".getBytes(StandardCharsets.UTF_8), "bbbbbb".getBytes(StandardCharsets.UTF_8), content);
    findReplace("CCCCCC".getBytes(StandardCharsets.UTF_8), "cccccc".getBytes(StandardCharsets.UTF_8), content);

    // WARNING... assumes format of .00000n where n is less than 9
    long logNumber = Long.parseLong(fname.substring(fname.lastIndexOf(".") + 1));
    String fname2 = String.format(Locale.ROOT,
        UpdateLog.LOG_FILENAME_PATTERN,
        UpdateLog.TLOG_NAME,
        logNumber + 1);
    raf = new RandomAccessFile(new File(logDir, fname2), "rw");
    raf.write(content);
    raf.close();
    

    logReplay.release(1000);
    logReplayFinish.drainPermits();
    ignoreException("OutOfBoundsException");  // this is what the corrupted log currently produces... subject to change.
    createCore();
    assertTrue(logReplayFinish.tryAcquire(timeout, TimeUnit.SECONDS));
    resetExceptionIgnores();
    assertJQ(req("q","*:*") ,"/response/numFound==6");

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:81,代码来源:TestRecovery.java


示例17: testTruncatedLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testTruncatedLog() throws Exception {
  try {
    DirectUpdateHandler2.commitOnClose = false;
    final Semaphore logReplay = new Semaphore(0);
    final Semaphore logReplayFinish = new Semaphore(0);

    UpdateLog.testing_logReplayHook = new Runnable() {
      @Override
      public void run() {
        try {
          assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    };

    UpdateLog.testing_logReplayFinishHook = new Runnable() {
      @Override
      public void run() {
        logReplayFinish.release();
      }
    };

    String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();

    clearIndex();
    assertU(commit());

    assertU(adoc("id","F1"));
    assertU(adoc("id","F2"));
    assertU(adoc("id","F3"));
    
    h.close();
    

    
    String[] files = HdfsUpdateLog.getLogList(fs, new Path(logDir));
    Arrays.sort(files);

    FSDataOutputStream dos = fs.append(new Path(logDir, files[files.length-1]));
  
    dos.writeLong(0xffffffffffffffffL);
    dos.writeChars("This should be appended to a good log file, representing a bad partially written record.");
    dos.close();

    logReplay.release(1000);
    logReplayFinish.drainPermits();
    ignoreException("OutOfBoundsException");  // this is what the corrupted log currently produces... subject to change.
    createCore();
    assertTrue(logReplayFinish.tryAcquire(timeout, TimeUnit.SECONDS));
    resetExceptionIgnores();
    assertJQ(req("q","*:*") ,"/response/numFound==3");

    //
    // Now test that the bad log file doesn't mess up retrieving latest versions
    //

    updateJ(jsonAdd(sdoc("id","F4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","F5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","F6", "_version_","106")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));

    // This currently skips the bad log file and also returns the version of the clearIndex (del *:*)
    // assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]");
    assertJQ(req("qt","/get", "getVersions","3"), "/versions==[106,105,104]");

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:74,代码来源:TestRecoveryHdfs.java


示例18: testCorruptLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testCorruptLog() throws Exception {
  try {
    DirectUpdateHandler2.commitOnClose = false;

    String logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();
 
    clearIndex();
    assertU(commit());

    assertU(adoc("id","G1"));
    assertU(adoc("id","G2"));
    assertU(adoc("id","G3"));

    h.close();

    String[] files = HdfsUpdateLog.getLogList(fs, new Path(logDir));
    Arrays.sort(files);

    FSDataOutputStream dos = fs.create(new Path(logDir, files[files.length-1]), (short)1);
    dos.write(new byte[(int)800]);  // zero out file
    dos.close();


    ignoreException("Failure to open existing log file");  // this is what the corrupted log currently produces... subject to change.
    createCore();
    resetExceptionIgnores();

    // just make sure it responds
    assertJQ(req("q","*:*") ,"/response/numFound==0");

    //
    // Now test that the bad log file doesn't mess up retrieving latest versions
    //

    updateJ(jsonAdd(sdoc("id","G4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","G5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","G6", "_version_","106")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));

    // This currently skips the bad log file and also returns the version of the clearIndex (del *:*)
    // assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]");
    assertJQ(req("qt","/get", "getVersions","3"), "/versions==[106,105,104]");

    assertU(commit());

    assertJQ(req("q","*:*") ,"/response/numFound==3");

    // This messes up some other tests (on windows) if we don't remove the bad log.
    // This *should* hopefully just be because the tests are too fragile and not because of real bugs - but it should be investigated further.
    deleteLogs();

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:58,代码来源:TestRecoveryHdfs.java


示例19: getName

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
public String getName()
{
    return DirectUpdateHandler2.class.getName();
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:5,代码来源:AlfrescoUpdateHandler.java


示例20: testTruncatedLog

import org.apache.solr.update.DirectUpdateHandler2; //导入依赖的package包/类
@Test
public void testTruncatedLog() throws Exception {
  try {
    DirectUpdateHandler2.commitOnClose = false;
    final Semaphore logReplay = new Semaphore(0);
    final Semaphore logReplayFinish = new Semaphore(0);

    UpdateLog.testing_logReplayHook = new Runnable() {
      @Override
      public void run() {
        try {
          assertTrue(logReplay.tryAcquire(timeout, TimeUnit.SECONDS));
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    };

    UpdateLog.testing_logReplayFinishHook = new Runnable() {
      @Override
      public void run() {
        logReplayFinish.release();
      }
    };

    File logDir = h.getCore().getUpdateHandler().getUpdateLog().getLogDir();

    clearIndex();
    assertU(commit());

    assertU(adoc("id","F1"));
    assertU(adoc("id","F2"));
    assertU(adoc("id","F3"));

    h.close();
    String[] files = UpdateLog.getLogList(logDir);
    Arrays.sort(files);
    RandomAccessFile raf = new RandomAccessFile(new File(logDir, files[files.length-1]), "rw");
    raf.seek(raf.length());  // seek to end
    raf.writeLong(0xffffffffffffffffL);
    raf.writeChars("This should be appended to a good log file, representing a bad partially written record.");
    raf.close();

    logReplay.release(1000);
    logReplayFinish.drainPermits();
    ignoreException("OutOfBoundsException");  // this is what the corrupted log currently produces... subject to change.
    createCore();
    assertTrue(logReplayFinish.tryAcquire(timeout, TimeUnit.SECONDS));
    resetExceptionIgnores();
    assertJQ(req("q","*:*") ,"/response/numFound==3");

    //
    // Now test that the bad log file doesn't mess up retrieving latest versions
    //

    updateJ(jsonAdd(sdoc("id","F4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","F5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
    updateJ(jsonAdd(sdoc("id","F6", "_version_","106")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));

    // This currently skips the bad log file and also returns the version of the clearIndex (del *:*)
    // assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]");
    assertJQ(req("qt","/get", "getVersions","3"), "/versions==[106,105,104]");

  } finally {
    DirectUpdateHandler2.commitOnClose = true;
    UpdateLog.testing_logReplayHook = null;
    UpdateLog.testing_logReplayFinishHook = null;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:70,代码来源:TestRecovery.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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