E getItem() { if (null == item) return null; E i = item; if (i instanceof ObjectID) { ObjectID oid = (ObjectID) i; i = (E) ManagerUtil.lookupObject(oid); item = i; } return i; } }
private Object resolveValue(Object value) { if (value instanceof ObjectID) { value = ManagerUtil.lookupObject((ObjectID) value); } return value; }
E getItem() { if (null == item) return null; E i = item; if (i instanceof ObjectID) { ObjectID oid = (ObjectID) i; i = (E) ManagerUtil.lookupObject(oid); item = i; } return i; } }
private Object resolveValue(Object value) { if (value instanceof ObjectID) { value = ManagerUtil.lookupObject((ObjectID) value); } return value; }
E getItem() { if (null == item) return null; E i = item; if (i instanceof ObjectID) { ObjectID oid = (ObjectID) i; i = (E) ManagerUtil.lookupObject(oid); item = i; } return i; } }
/** * If the passed object is an ObjectID, looks it up and returns it. */ private V lookup(final Object obj) { if (obj instanceof ObjectID) { try { return (V) ManagerUtil.lookupObject((ObjectID) obj); } catch (final TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Returning null as the only sensible result. Caller should have removed the local mapping.", e); return null; } } else { return (V) obj; } }
/** * If the passed object is an ObjectID, looks it up and returns it. */ private V lookup(Object obj) { if (obj instanceof ObjectID) { try { return (V) ManagerUtil.lookupObject((ObjectID) obj); } catch (TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Returning null as the only sensible result. Caller should have removed the local mapping.", e); return null; } } else { return (V) obj; } }
/** * If the passed object is an ObjectID, looks it up and returns it. */ private V lookup(final Object obj) { if (obj instanceof ObjectID) { try { return (V) ManagerUtil.lookupObject((ObjectID) obj); } catch (final TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Returning null as the only sensible result. Caller should have removed the local mapping.", e); return null; } } else { return (V) obj; } }
/** * If the passed object is an ObjectID, looks it up and returns it. */ private V lookup(final Object obj) { if (obj instanceof ObjectID) { try { return (V) ManagerUtil.lookupObject((ObjectID) obj); } catch (final TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Returning null as the only sensible result. Caller should have removed the local mapping.", e); return null; } } else { return (V) obj; } }
/** * If the value associated with the supplied key is an ObjectID then the value is looked up and faulted into the map. * This operation is safe in the absence of all locking, but no guarantees can then be made about subsequent gets of * the key. */ private void fault(Object key) { Object obj = store.get(key); if (obj instanceof ObjectID) { try { V value = (V) ManagerUtil.lookupObject((ObjectID) obj); store.replace(key, obj, value); } catch (TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Removing local entry for this key [" + key + "] to restore L1-L2 correspondence.", e); store.remove(key, obj); } } }
/** * If the passed object is an ObjectID looks it up and returns it, after attempting to replace the original ObjectID * value in the map. Safe in the absence of all locking. */ private V lookupAndFaultIn(Object key, Object obj) { if (obj instanceof ObjectID) { try { V value = (V) ManagerUtil.lookupObject((ObjectID) obj); // We should really assert that the replace succeeds here store.replace(key, obj, value); return value; } catch (TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Removing local entry for this key [" + key + "] to restore L1-L2 correspondence.", e); store.remove(key, obj); return null; } } else { return (V) obj; } }
void applyPut(Object key, Object value) { if (value instanceof ObjectID) { value = ManagerUtil.lookupObject((ObjectID) value); } Element tw = (Element) value; tw.clearLocal(); insertLocal(tw); }
private void buildLocalStoreFromIds(Object[] ids, long lastModifiedTimeStamp) { LoggingUtil.info("Going to update " + ids.length + " objects to local index"); LoggingUtil.info("After l1CachedMapData size = " + l1CachedMapData.size() + " tsinfo size = " + tsInfo.getCreationtimeMap().size()); long startTime = System.currentTimeMillis(); for(int i = 0; i < ids.length; i++) { /** prefetching objects in a bunch, so as to get the better faulting from L2 **/ if(i%1000 == 0) { int countToFault = (ids.length - i) > 1000 ? 1000 : (ids.length - i); for(int k = 0; k < countToFault; k++) { ManagerUtil.preFetchObject( l1CachedMapData.get(ids[i+k]).valueObject); } } ObjectData<K> od = null; od = l1CachedMapData.get(ids[i]); Assert.assertNotNull(od); SerializationAdaptor<K,V> adaptor = new TCSearializationAdaptor<K,V>(lastModifiedTimeStamp); Object adaptedValue = ManagerUtil.lookupObject(od.valueObject); if(adaptedValue != null) { adaptor.setKey((K)ids[i]); adaptor.setAdaptedValue(adaptedValue); // deliberately ensuring that we do not deserialize the value object here // it will be deserialized by the datastore update threads. This ensures // even distribution of load across threads } ds.putNoWait(adaptor); } ds.waitUntilNoPendingUpdates(); LoggingUtil.info("SearchableMap.buildLocalStoreFromMap() Indexed " + ids.length + " with average " + (System.currentTimeMillis() - startTime)/1000); }
public void __tc_applicator_put(Object key, Object value) { ObjectID valueId = (ObjectID)value; if(initialized) { Object adaptedValue = ManagerUtil.lookupObject(valueId); SerializationAdaptor<K,V> adaptor = new TCSearializationAdaptor<K,V>(tsInfo.getMapLastModifiedTime()); adaptor.setKey((K)key); adaptor.setAdaptedValue(adaptedValue); LoggingUtil.debug("__tc_applicator_put putting key " + key); localPut((K)key, adaptor, valueId, false); } else{ l1CachedMapData.put((K)key, new ObjectData(key, valueId)); } }
public V getFromL2(K key) throws SearchException { checkshutdown(); V value = null; ObjectData<K> od = l1CachedMapData.get(key); if(od != null) { SerializationAdaptor<K,V> adaptor = new TCSearializationAdaptor<K,V>(0); // ManagerUtil.preFetchObject(od.valueObject); if(!coherentReads) { try { value = (V)adaptor.adaptStoreToApp(ManagerUtil.lookupObject(od.valueObject)); }catch(TCObjectNotFoundException tconfe) { LoggingUtil.info("key " + key + " does not exist at L2"); } } else { String lockId = ls.getLock(key); ManagerUtil.monitorEnter(lockId, Manager.LOCK_TYPE_READ); try { value = (V)adaptor.adaptStoreToApp(ManagerUtil.lookupObject(od.valueObject)); }finally { ManagerUtil.monitorExit(lockId, Manager.LOCK_TYPE_READ); } } tsInfo.entryAccessed(key); } return value; }
/** * If the value associated with the supplied key is an ObjectID then the value is looked up and faulted into the map. * This operation is safe in the absence of all locking, but no guarantees can then be made about subsequent gets of * the key. */ private V fault(final Object key) { final Object obj = this.store.get(key); if (obj instanceof ObjectID) { try { final V value = (V) ManagerUtil.lookupObject((ObjectID) obj); if (this.store.replace(key, obj, value)) { localSizeIncrement(); } return value; } catch (final TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Removing local entry for this key [" + key + "] to restore L1-L2 correspondence.", e); this.store.remove(key, obj); unpinLock(generateLockIdForKey((K) key)); return null; } } else { return (V) obj; } }
private V lookupAndFaultIn(final Object key, final Object obj, final boolean coherent) { if (obj instanceof ObjectID) { try { final V value = (V) ManagerUtil.lookupObject((ObjectID) obj);
private V lookupAndFaultIn(final Object key, final Object obj, final boolean coherent) { if (obj instanceof ObjectID) { try { final V value = (V) ManagerUtil.lookupObject((ObjectID) obj);
/** * If the value associated with the supplied key is an ObjectID then the value is looked up and faulted into the map. * This operation is safe in the absence of all locking, but no guarantees can then be made about subsequent gets of * the key. */ private V fault(final Object key) { final Object obj = this.store.get(key); if (obj instanceof ObjectID) { try { final V value = (V) ManagerUtil.lookupObject((ObjectID) obj); if (this.store.replace(key, obj, value)) { localSizeIncrement(); } return value; } catch (final TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Removing local entry for this key [" + key + "] to restore L1-L2 correspondence.", e); this.store.remove(key, obj); unpinLock(generateLockIdForKey((K) key)); return null; } } else { return (V) obj; } }
/** * If the value associated with the supplied key is an ObjectID then the value is looked up and faulted into the map. * This operation is safe in the absence of all locking, but no guarantees can then be made about subsequent gets of * the key. */ private V fault(final Object key) { final Object obj = this.store.get(key); if (obj instanceof ObjectID) { try { final V value = (V) ManagerUtil.lookupObject((ObjectID) obj); if (this.store.replace(key, obj, value)) { localSizeIncrement(); } return value; } catch (final TCObjectNotFoundException e) { LOGGER.info("Missing object caused by concurrent map-level and key-level operations\n" + "Removing local entry for this key [" + key + "] to restore L1-L2 correspondence.", e); this.store.remove(key, obj); unpinLock(generateLockIdForKey((K) key)); return null; } } else { return (V) obj; } }