コード例 #1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.opendedup.collections.AbstractHashesMap#update(org.opendedup.sdfs
  * .filestore.ChunkData)
  */
 @Override
 public boolean update(ChunkData cm) throws IOException {
   this.arlock.lock();
   try {
     boolean added = false;
     if (!this.isClaimed(cm)) {
       cm.persistData(true);
       added = this.getReadMap(cm.getHash()).update(cm.getHash(), cm.getcPos());
     }
     if (added) {
       this.compactKsz++;
     }
     return added;
   } catch (KeyNotFoundException e) {
     return false;
   } finally {
     this.arlock.unlock();
   }
 }
コード例 #2
0
  @Override
  public boolean remove(ChunkData cm) throws IOException {
    if (this.isClosed()) {
      throw new IOException("hashtable [" + this.fileName + "] is close");
    }
    Lock l = gcLock.readLock();
    l.lock();
    try {
      if (!this.runningGC && !lbf.mightContain(cm.getHash())) return false;
      try {
        if (cm.getHash().length == 0) return true;
        AbstractShard m = this.getReadMap(cm.getHash());
        if (m == null) return false;
        if (!m.remove(cm.getHash())) {
          return false;
        } else {
          cm.setmDelete(true);
          this.arlock.lock();
          try {
            if (this.isClosed()) {
              throw new IOException("hashtable [" + this.fileName + "] is close");
            }
            try {
              this.kSz.decrementAndGet();
            } catch (Exception e) {
            }
          } finally {
            this.arlock.unlock();
          }

          return true;
        }
      } catch (Exception e) {
        SDFSLogger.getLog().fatal("error getting record", e);
        return false;
      }
    } finally {
      l.unlock();
    }
  }
コード例 #3
0
 @Override
 public boolean put(ChunkData cm) throws IOException, HashtableFullException {
   if (this.isClosed())
     throw new HashtableFullException("Hashtable " + this.fileName + " is close");
   if (this.kSz.get() >= this.maxSz)
     throw new HashtableFullException(
         "entries is greater than or equal to the maximum number of entries. You need to expand"
             + "the volume or DSE allocation size");
   if (cm.getHash().length != this.FREE.length) throw new IOException("key length mismatch");
   if (this.isClosed()) {
     throw new IOException("hashtable [" + this.fileName + "] is close");
   }
   // this.flushFullBuffer();
   boolean added = false;
   added = this.put(cm, true);
   return added;
 }
コード例 #4
0
  @Override
  public boolean put(ChunkData cm, boolean persist) throws IOException, HashtableFullException {
    // persist = false;
    if (this.isClosed())
      throw new HashtableFullException("Hashtable " + this.fileName + " is close");
    if (kSz.get() >= this.maxSz) throw new HashtableFullException("maximum sized reached");
    boolean added = false;
    // if (persist)
    // this.flushFullBuffer();
    Lock l = gcLock.readLock();
    l.lock();
    ProgressiveFileByteArrayLongMap bm = null;
    try {
      // long tm = System.currentTimeMillis();
      if (this.getReadMap(cm.getHash()) == null) {
        // this.misses.incrementAndGet();
        // tm = System.currentTimeMillis() - tm;
        if (persist) {
          try {
            bm = this.getWriteMap();
            added = bm.put(cm);
          } catch (HashtableFullException e) {
            bm.setActive(false);
            bm = this.createWriteMap();
            added = bm.put(cm);
          }
          if (added) {
            this.lbf.put(cm.getHash());
            this.kSz.incrementAndGet();
          }
        } else {
          try {
            bm = this.getWriteMap();
            added = bm.put(cm.getHash(), cm.getcPos());
            this.lbf.put(cm.getHash());
          } catch (HashtableFullException e) {
            bm.setActive(false);
            bm = this.createWriteMap();
            added = bm.put(cm.getHash(), cm.getcPos());

            this.lbf.put(cm.getHash());
          }
        }
      } else {
        // tm = System.currentTimeMillis() - tm;
      }
      // this.msTr.addAndGet(tm);

    } finally {
      try {
        if (bm != null) {
          bm.setActive(true);
          this.activeWriteMaps.offer(bm);
        }
      } catch (Exception e) {

      } finally {
        l.unlock();
      }
    }
    /*
     * this.trs.incrementAndGet(); if(this.trs.get() == 10000) { long tpm =
     * 0; if(this.misses.get() > 0) tpm = this.msTr.get()/this.misses.get();
     * SDFSLogger.getLog().info("trs=" + this.trs.get() + " misses=" +
     * this.misses.get() + " mtm=" + this.msTr.get() + " tpm=" + tpm);
     * this.trs.set(0); this.misses.set(0); this.msTr.set(0); }
     */
    return added;
  }