Package org.javasimon

Examples of org.javasimon.Split


    logger.info("Cache initialization ok");
  }
 
  public void disposeExpired() {
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.disposeExpired");
    Split split = stopWatch.start();
   
    for (Iterator<CacheEntry> iterator = entries.values().iterator(); iterator.hasNext();) {
      CacheEntry entry = iterator.next();
      if (entry.expired()) {
        remove(entry.key);
      }
    }
   
    split.stop();
 
View Full Code Here


  public void disposeHeapOverflow() {
    if (entriesLimit == -1) {
      return;
    }
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.disposeHeapOverflow");
    Split split = stopWatch.start();
   
    moveEntriesOffHeap(lruQueue.size() - entriesLimit);

    split.stop();
  }
View Full Code Here

    split.stop();
  }
 
  public void disposeOffHeapOverflow() {
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.disposeOffHeapOverflow");
    Split split = stopWatch.start();
    int bytes2free = usedMemory.get()-(pageSize*pages);
   
    moveEntriesToDisk(bytes2free);
   
    split.stop();
  }
 
View Full Code Here

//    split.stop();
//  }
 
  public void askSupervisorForDisposal() {
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.disposeOverflow");
    Split split = stopWatch.start();
    supervisor.disposeOverflow(this);
    split.stop();
  }
View Full Code Here

//    split.stop();
//  }
 
  protected void moveInHeap(CacheEntry entry) {
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.moveinheap");
    Split split = stopWatch.start();
    byte[] source = null;
    source = new byte[entry.size];
    try {
      synchronized (entry) {
        ByteBuffer buf = entry.buffer;
        buf.position(entry.position);
        buf.get(source);
        Object obj = serializer.deserialize(source, entry.clazz);
        entry.object = obj;
        entry.buffer = null;
        CacheEntry freeSlot = new CacheEntry();
        freeSlot.buffer = buf;
        freeSlot.position = entry.position;
        freeSlot.buffer.position(freeSlot.position);
        freeSlot.size = entry.size;
        slots.add(freeSlot);
        logger.debug("added slot of " + freeSlot.size + " bytes");
      }

      lruOffheapQueue.remove(entry);
     
      usedMemory.addAndGet(-source.length);
      lruQueue.remove(entry);
      lruQueue.add(entry);
    } catch (UTFDataFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (StreamCorruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (EOFException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    split.stop();
  }
View Full Code Here

   
  }

  public CacheEntry put(String key, Object object) {
        Stopwatch stopWatch = SimonManager.getStopwatch("cache.put");
    Split split = stopWatch.start();
    CacheEntry entry = new CacheEntry();
    entry.key = key;
    entry.object = object;
    entries.put(key, entry);
    lruQueue.add(entry);
    askSupervisorForDisposal();
    split.stop();
    return entry;
  }
View Full Code Here

    return entry;
  }
 
  public Object get(String key) {
        Stopwatch stopWatch = SimonManager.getStopwatch("cache.get");
    Split split = stopWatch.start();
    CacheEntry entry = getEntry(key);
    askSupervisorForDisposal();
    split.stop();
    if (entry == null) {
      return null;
    } else {
      return entry.object;
    }
View Full Code Here

    }
  }
 
  public CacheEntry remove(String key) {
        Stopwatch stopWatch = SimonManager.getStopwatch("cache.remove");
    Split split = stopWatch.start();
    CacheEntry entry = entries.remove(key);
    if (entry.inHeap()) {
      lruQueue.remove(entry);
    } else {
      usedMemory.addAndGet(-entry.size);
      lruOffheapQueue.remove(entry);
      slots.add(entry);
      logger.debug("added slot of " + entry.size + " bytes");
    }
    askSupervisorForDisposal();
    split.stop();
    return entry;
  }
View Full Code Here

    return entry;
  }
 
  public CacheEntry removeLast() {
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.removelast");
    Split split = stopWatch.start();
    CacheEntry next = lruQueue.peek();
    if (next.size > slots.last().size) {
      split.stop();
      return null;
    }
    CacheEntry last = lruQueue.poll();
    entries.remove(last.key);
    split.stop();
    return last;
  }
View Full Code Here

    return last;
  }
 
  public CacheEntry removeLastOffHeap() {
        Stopwatch stopWatch = SimonManager.getStopwatch("detail.removelastoffheap");
    Split split = stopWatch.start();
    CacheEntry last = lruOffheapQueue.poll();
    if (last == null) {
      logger.warn("no lru from off heap");
      split.stop();
      return null;
    }
   
    usedMemory.addAndGet(-last.size);
    entries.remove(last.key);
    slots.add(last);
    logger.debug("added slot of " + last.size + " bytes");
    split.stop();
    return last;
  }
View Full Code Here

TOP

Related Classes of org.javasimon.Split

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.