Ejemplo n.º 1
0
 public long size() {
   synchronized (this) {
     if (!initialized) {
       return 0;
     }
   }
   try {
     return journal.getDiskSize() + pageFile.getDiskSize();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 2
0
 public void run() {
   try {
     if (isStopping()) {
       return;
     }
     final int lastJournalFileId = journal.getLastAppendLocation().getDataFileId();
     final Set<Integer> candidates = journal.getFileMap().keySet();
     LOG.trace("Full gc candidate set:" + candidates);
     if (candidates.size() > 1) {
       // prune current write
       for (Iterator<Integer> iterator = candidates.iterator(); iterator.hasNext(); ) {
         if (iterator.next() >= lastJournalFileId) {
           iterator.remove();
         }
       }
       List<PListImpl> plists = null;
       synchronized (indexLock) {
         synchronized (this) {
           plists = new ArrayList<PListImpl>(persistentLists.values());
         }
       }
       for (PListImpl list : plists) {
         list.claimFileLocations(candidates);
         if (isStopping()) {
           return;
         }
         LOG.trace(
             "Remaining gc candidate set after refs from: " + list.getName() + ":" + candidates);
       }
       LOG.trace("GC Candidate set:" + candidates);
       this.journal.removeDataFiles(candidates);
     }
   } catch (IOException e) {
     LOG.error("Exception on periodic cleanup: " + e, e);
   }
 }
Ejemplo n.º 3
0
 @Override
 protected synchronized void doStop(ServiceStopper stopper) throws Exception {
   if (scheduler != null) {
     if (PListStoreImpl.class.getSimpleName().equals(scheduler.getName())) {
       scheduler.stop();
       scheduler = null;
     }
   }
   for (PListImpl pl : this.persistentLists.values()) {
     pl.unload(null);
   }
   if (this.pageFile != null) {
     this.pageFile.unload();
   }
   if (this.journal != null) {
     journal.close();
   }
   if (this.lockFile != null) {
     this.lockFile.unlock();
   }
   this.lockFile = null;
   this.initialized = false;
   LOG.info(this + " stopped");
 }