@Test public void testOverFlow() throws Exception { File directory = store.getDirectory(); store.stop(); IOHelper.mkdirs(directory); IOHelper.deleteChildren(directory); store = createPListStore(); store.setDirectory(directory); store.start(); for (int i=0;i<2000; i++) { new Job(i, PListTestSupport.TaskType.ADD, 5).run(); } // LOG.info("After Load index file: " + store.pageFile.getFile().length()); // LOG.info("After remove index file: " + store.pageFile.getFile().length()); }
protected void startStore(File directory) throws Exception { store = createPListStore(); store.setDirectory(directory); store.start(); plist = store.getPList("main"); }
private void destroyDiskList() throws Exception { if (diskList != null) { store.removePList(name); diskList = null; } }
/** * @param tempDataStore * the tempDataStore to set */ public void setTempDataStore(PListStore tempDataStore) { this.tempDataStore = tempDataStore; if (tempDataStore != null) { if (tmpDataDirectory == null) { tmpDataDirectory = tempDataStore.getDirectory(); } else if (tempDataStore.getDirectory() == null) { tempDataStore.setDirectory(tmpDataDirectory); } } configureService(tempDataStore); }
/** * @return the tempDataStore */ public synchronized PListStore getTempDataStore() { if (tempDataStore == null && !hasStartException()) { if (!isPersistent()) { return null; } try { PersistenceAdapter pa = getPersistenceAdapter(); if( pa!=null && pa instanceof PListStore) { return (PListStore) pa; } } catch (IOException e) { throw new RuntimeException(e); } try { String clazz = "org.apache.activemq.store.kahadb.plist.PListStoreImpl"; this.tempDataStore = (PListStore) getClass().getClassLoader().loadClass(clazz).newInstance(); this.tempDataStore.setDirectory(getTmpDataDirectory()); configureService(tempDataStore); } catch (ClassNotFoundException e) { throw new RuntimeException("Kahadb class PListStoreImpl not found. Add activemq-kahadb jar or set persistent to false on BrokerService.", e); } catch (Exception e) { throw new RuntimeException(e); } } return tempDataStore; }
case CREATE: Thread.currentThread().setName("C:"+id); plist = store.getPList(String.valueOf(id)); LOG.info("Job-" + id + ", CREATE"); break; case DELETE: Thread.currentThread().setName("D:"+id); store.removePList(String.valueOf(id)); break; case ADD: Thread.currentThread().setName("A:"+id); plist = store.getPList(String.valueOf(id)); case REMOVE: Thread.currentThread().setName("R:"+id); plist = store.getPList(String.valueOf(id)); synchronized (plistLocks(plist)) { case ITERATE: Thread.currentThread().setName("I:"+id); plist = store.getPList(String.valueOf(id)); int iterateCount = 0; synchronized (plistLocks(plist)) { plist = store.getPList(String.valueOf(id));
@After public void tearDown() throws Exception { if (executor != null) { executor.shutdownNow(); } store.stop(); exceptions.clear(); }
public PList getDiskList() { if (diskList == null) { try { diskList = store.getPList(name); } catch (Exception e) { LOG.error("Caught an IO Exception getting the DiskList {}", name, e); throw new RuntimeException(e); } } return diskList; }
@Override protected void updateLimitBasedOnPercent() { usageLock.writeLock().lock(); try { percentLimitFromFile(store != null ? store.getDirectory() : null); } finally { usageLock.writeLock().unlock(); } }
try { tempDataStore.start(); } catch (Exception e) { RuntimeException exception = new RuntimeException(
@Override protected long retrieveUsage() { if (store == null) { return 0; } return store.size(); }
/** * @param tempDataStore * the tempDataStore to set */ public void setTempDataStore(PListStore tempDataStore) { this.tempDataStore = tempDataStore; if (tempDataStore != null) { if (tmpDataDirectory == null) { tmpDataDirectory = tempDataStore.getDirectory(); } else if (tempDataStore.getDirectory() == null) { tempDataStore.setDirectory(tmpDataDirectory); } } configureService(tempDataStore); }
/** * @return the tempDataStore */ public synchronized PListStore getTempDataStore() { if (tempDataStore == null) { if (!isPersistent()) { return null; } try { PersistenceAdapter pa = getPersistenceAdapter(); if( pa!=null && pa instanceof PListStore) { return (PListStore) pa; } } catch (IOException e) { throw new RuntimeException(e); } try { String clazz = "org.apache.activemq.store.kahadb.plist.PListStoreImpl"; this.tempDataStore = (PListStore) getClass().getClassLoader().loadClass(clazz).newInstance(); this.tempDataStore.setDirectory(getTmpDataDirectory()); configureService(tempDataStore); } catch (ClassNotFoundException e) { throw new RuntimeException("Kahadb class PListStoreImpl not found. Add activemq-kahadb jar or set persistent to false on BrokerService.", e); } catch (Exception e) { throw new RuntimeException(e); } } return tempDataStore; }
tempDataStore.stop(); tempDataStore = null;
public PList getDiskList() { if (diskList == null) { try { diskList = store.getPList(name); } catch (Exception e) { LOG.error("Caught an IO Exception getting the DiskList {}", name, e); throw new RuntimeException(e); } } return diskList; }
@Override protected void updateLimitBasedOnPercent() { usageLock.writeLock().lock(); try { percentLimitFromFile(store != null ? store.getDirectory() : null); } finally { usageLock.writeLock().unlock(); } }
try { tempDataStore.start(); } catch (Exception e) { RuntimeException exception = new RuntimeException(
@Override protected long retrieveUsage() { if (store == null) { return 0; } return store.size(); }
@Test public void testConcurrentAddLast() throws Exception { File directory = store.getDirectory(); store.stop(); IOHelper.mkdirs(directory); IOHelper.deleteChildren(directory); store = createPListStore(); store.setDirectory(directory); store.start(); final int numThreads = 20; final int iterations = 1000; executor = Executors.newFixedThreadPool(100); for (int i=0; i<numThreads; i++) { new Job(i, PListTestSupport.TaskType.ADD, iterations).run(); } for (int i=0; i<numThreads; i++) { executor.execute(new Job(i, PListTestSupport.TaskType.ITERATE, iterations)); } for (int i=0; i<100; i++) { executor.execute(new Job(i+20, PListTestSupport.TaskType.ADD, 100)); } executor.shutdown(); boolean finishedInTime = executor.awaitTermination(60*5, TimeUnit.SECONDS); assertTrue("finished ok", finishedInTime); }
/** * @param tempDataStore * the tempDataStore to set */ public void setTempDataStore(PListStore tempDataStore) { this.tempDataStore = tempDataStore; if (tempDataStore != null) { if (tmpDataDirectory == null) { tmpDataDirectory = tempDataStore.getDirectory(); } else if (tempDataStore.getDirectory() == null) { tempDataStore.setDirectory(tmpDataDirectory); } } configureService(tempDataStore); }