Package org.javasimon

Examples of org.javasimon.Split


  /* (non-Javadoc)
   * @see org.directmemory.supervisor.Supervisor#checkLimits(org.directmemory.CacheStore)
   */
  public void disposeOverflow(CacheStore cache) {
        Stopwatch stopWatch = SimonManager.getStopwatch("supervisor.asyncbatch.checkLimits");
    Split split = stopWatch.start();
   
    if (totalCalls++ >= batchSize) {
      totalCalls = 0;
      new ThreadUsingCache(cache) {
        public void run() {
          logger.debug("checking memory limits");
          cache.disposeHeapOverflow();
          cache.disposeOffHeapOverflow();
          logger.debug("checking expired entries");
          cache.disposeExpired();
        }
      }.start();
    }
    split.stop();
  }
View Full Code Here


  /* (non-Javadoc)
   * @see org.directmemory.supervisor.Supervisor#checkLimits(org.directmemory.CacheStore)
   */
  public void disposeOverflow(CacheStore cache) {
        Stopwatch stopWatch = SimonManager.getStopwatch("supervisor.batch.checkLimits");
    Split split = stopWatch.start();
   
    if (totalCalls++ >= batchSize) {
      totalCalls = 0;
      logger.debug("checking memory limits");
      cache.disposeHeapOverflow();
      cache.disposeOffHeapOverflow();
      logger.debug("checking expired entries");
      cache.disposeExpired();
    }
    split.stop();
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.directmemory.supervisor.Supervisor#checkLimits(org.directmemory.CacheStore)
   */
  public void disposeOverflow(CacheStore cache) {
        Stopwatch stopWatch = SimonManager.getStopwatch("supervisor.asimple.checkLimits");
    Split split = stopWatch.start();
   
    logger.debug("checking memory limits");
    cache.disposeHeapOverflow();
    cache.disposeOffHeapOverflow();
   
    if (count >= checkForExpiredEvery) {
      count = 0;
      logger.debug("checking expired entries");
      cache.disposeExpired();
    } else {
      count++;
    }
    split.stop();
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.directmemory.supervisor.Supervisor#checkLimits(org.directmemory.CacheStore)
   */
  public void disposeOverflow(CacheStore cache) {
    Stopwatch stopWatch = SimonManager.getStopwatch("supervisor.timed.checkLimits");
    Split split = stopWatch.start();
    long passed = new Date().getTime() - lastCheck.getTime();
    if (passed >= batchInterval) {
      lastCheck = new Date();
      new ThreadUsingCache(cache) {
        public void run() {
          logger.debug("checking memory limits");
          cache.disposeHeapOverflow();
          cache.disposeOffHeapOverflow();
          logger.debug("checking expired entries");
          cache.disposeExpired();
        }
      }.start();
    }
    split.stop();
  }
View Full Code Here

    Stopwatch deserializeMon = SimonManager.getStopwatch("deserializeMon");

//    System.out.println("reader thread started");
    int count = 0;
    for (CacheEntry entry : map.values()) {
      Split split = readerMon.start();
      //System.out.println(entry.key + " of size" + entry.size);
      byte[] dest = new byte[entry.size];
      synchronized (entry.buffer) {
        entry.buffer.position(entry.position);
        entry.buffer.get(dest);
      }
      split.stop();
      try {
        Split deserSplit = deserializeMon.start();
        @SuppressWarnings("unused")
        DummyPojo obj = Starter.deserialize(dest);
        deserSplit.stop();
//        System.out.println(obj.getName() + " count=" + count);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
View Full Code Here

    Stopwatch deserializeMon = SimonManager.getStopwatch("deserializeMon");

    int count = 0;

    for (CacheEntry entry : map.values()) {
      Split split = readerMon.start();
      byte[] dest = new byte[entry.size];
      synchronized (entry.buffer) {
        entry.buffer.position(entry.position);
        entry.buffer.get(dest);
      }
      split.stop();
      DummyPojo obj = null;
      try {
        Split deserSplit = deserializeMon.start();
        obj = Starter.deserialize(dest);
        deserSplit.stop();
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      } catch (ClassNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      } catch (StringIndexOutOfBoundsException e1) {
        e1.printStackTrace();       
      }
     
      byte[] src = null;
      try {
        Split serSplit = serializeMon.start();
        src = Starter.serialize(obj);
        serSplit.stop();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      Split split2 = writerMon.start();
      synchronized (entry.buffer) {
        entry.buffer.position(entry.position);
        entry.buffer.put(src);
      }
      count++;
      split2.stop();
    }
   
//    long elapsed = Calendar.getInstance().getTimeInMillis()-started;
//    System.out.println("writer did " + count + " writes in " + (elapsed) + " msecs - " + ((double)count / (double)elapsed) + " ops per msec");
//    System.out.println("writer ops took " + ((double)elapsed / (double)count) + " msecs each");
View Full Code Here

    while (memoryUsed <= cacheSize - objectSize) {
      CacheEntry entry = new CacheEntry();
      entry.key = "key"+(count++);
      DummyPojo obj = new DummyPojo(entry.key, objectSize);
     
      Split serSplit = serializeMon.start();
      byte[] src = serialize(obj);
      serSplit.stop();
      Split split = setupMon.start();
      entry.size = src.length;
      entry.buffer = buffer.duplicate();
      entry.position = memoryUsed;
      entry.buffer.position(memoryUsed);
     
     
      try {
        entry.buffer.put(src);
      } catch (BufferOverflowException e) {
        // TODO: handle exception
        e.printStackTrace();
      }
      map.put(entry.key, entry);
      memoryUsed+=entry.size;
      split.stop();
    }
       
        System.out.println("setupMon: " + setupMon);
    System.out.println("average append duration: " + (double)(setupMon.getTotal() / setupMon.getCounter())/1000000 + "ms");
    System.out.println("average serialize duration: " + (double)(serializeMon.getTotal() / serializeMon.getCounter())/1000000 + "ms");
View Full Code Here

   * @see org.directmemory.utils.Serializer#serialize(java.lang.Object, java.lang.Class)
   */
  @SuppressWarnings("unchecked")
  public byte[] serialize(Object obj, @SuppressWarnings("rawtypes") Class clazz) throws IOException {
        Stopwatch stopWatch = SimonManager.getStopwatch("serializer.PSSerialize");
    Split split = stopWatch.start();
    @SuppressWarnings("rawtypes")
    Schema schema = RuntimeSchema.getSchema(clazz);
    final LinkedBuffer buffer = LinkedBuffer.allocate(serBufferSize);
    byte[] protostuff = null;

    try {
      protostuff = ProtostuffIOUtil.toByteArray(obj, schema, buffer);
    } finally {
      buffer.clear();
    }   
    split.stop();
    return protostuff;
  }
View Full Code Here

   * @see org.directmemory.utils.Serializer#deserialize(byte[], java.lang.Class)
   */
  @SuppressWarnings("unchecked")
  public Object deserialize(byte[] source, @SuppressWarnings("rawtypes") Class clazz) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        Stopwatch stopWatch = SimonManager.getStopwatch("serializer.PSDeserialize");
    Split split = stopWatch.start();
    final Object object = clazz.newInstance();
    @SuppressWarnings("rawtypes")
    final Schema schema = RuntimeSchema.getSchema(clazz);
    ProtostuffIOUtil.mergeFrom(source, object, schema);
    split.stop();
    return object;
 
View Full Code Here

public class StandardSerializer implements Serializer {
 
  public byte[] serialize(Object obj, @SuppressWarnings("rawtypes") Class clazz) throws IOException {
        Stopwatch stopWatch = SimonManager.getStopwatch("serializer.javaSerialize");
    Split split = stopWatch.start();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(obj);
    oos.flush();
    oos.close();
    split.stop();
    return baos.toByteArray();   
  }
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.