Beispiel #1
0
 /**
  * Fetch all the values for the specified keys. Null is returned if the key isn't found.
  *
  * @param keys
  * @return
  */
 public Map<K, V> getAll(Collection<K> keys) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   Map<K, V> rc = utils.getAll(keys, bmap);
   mbean.getGetMetrics().logTime(System.nanoTime() - start);
   return rc;
 }
Beispiel #2
0
 WXSMap(WXSUtils utils, String mapName) {
   this.mapName = mapName;
   this.utils = utils;
   grid = utils.getObjectGrid();
   bmap = utils.grid.getMap(mapName);
   tls = new ThreadLocalSession(utils);
 }
Beispiel #3
0
 /**
  * This does a single entry insert. If the key already exists then an exception is thrown.
  *
  * @param k
  * @param v
  */
 public void insert(K k, V v) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   try {
     tls.getMap(mapName).insert(k, v);
     mbean.getInsertMetrics().logTime(System.nanoTime() - start);
   } catch (Exception e) {
     mbean.getInsertMetrics().logException(e);
     throw new ObjectGridRuntimeException(e);
   }
 }
Beispiel #4
0
 /**
  * Fetch a value from the Map
  *
  * @param k
  * @return
  */
 public V get(K k) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   try {
     V rc = (V) tls.getMap(mapName).get(k);
     mbean.getGetMetrics().logTime(System.nanoTime() - start);
     return rc;
   } catch (Exception e) {
     mbean.getGetMetrics().logException(e);
     throw new ObjectGridRuntimeException(e);
   }
 }
Beispiel #5
0
 /**
  * Check if the entry exists for the key
  *
  * @param k
  * @return
  */
 public boolean contains(K k) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   try {
     boolean rc = tls.getMap(mapName).containsKey(k);
     mbean.getContainsMetrics().logTime(System.nanoTime() - start);
     return rc;
   } catch (Exception e) {
     mbean.getContainsMetrics().logException(e);
     throw new ObjectGridRuntimeException(e);
   }
 }
Beispiel #6
0
 /**
  * Set the value for the key. If the entry doesn't exist then it is inserted otherwise it's
  * updated.
  *
  * @param k
  * @param v
  */
 public void put(K k, V v) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   try {
     InsertAgent<K, V> a = new InsertAgent<K, V>();
     a.doGet = true;
     a.batch = new Hashtable<K, V>();
     a.batch.put(k, v);
     tls.getMap(mapName).getAgentManager().callReduceAgent(a, Collections.singletonList(k));
     mbean.getPutMetrics().logTime(System.nanoTime() - start);
   } catch (Exception e) {
     mbean.getPutMetrics().logException(e);
     throw new ObjectGridRuntimeException(e);
   }
 }
Beispiel #7
0
 /**
  * Remove all entries with these keys
  *
  * @param keys
  */
 public void removeAll(Collection<K> keys) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   utils.removeAll(keys, bmap);
   mbean.getRemoveMetrics().logTime(System.nanoTime() - start);
 }
Beispiel #8
0
 /**
  * Parallel insert all the entries. This does a real insert, not a put (get/update)
  *
  * @param batch
  */
 public void insertAll(Map<K, V> batch) {
   WXSMapMBeanImpl mbean = WXSUtils.getWXSMapMBeanManager().getBean(grid, mapName);
   long start = System.nanoTime();
   utils.insertAll(batch, bmap);
   mbean.getInsertMetrics().logTime(System.nanoTime() - start);
 }