@Override public boolean isDelta() { return dna.isDelta(); }
@Override public Object getNewInstance(ClientObjectManager objectManager, DNA dna) { try { // DNACursor cursor = dna.getCursor(); // Assert.assertTrue("DNA contains action", cursor.next()); /* * This trickery is necessary to avoid getting an instance of class loaded by the wrong classloader. Otherwise we * get ClassCastExceptions when we try and store the result in the ConcurrentStringMap instance. */ Class wanMapClazz = objectManager.getClassFor(WAN_DSO_CLASSNAME, LoaderDescription.fromString(dna .getDefiningLoaderDescription())); Constructor cons = wanMapClazz.getDeclaredConstructor(); cons.setAccessible(true); return cons.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } } }
private Object createNewPojoObject(TCClass clazz, DNA dna) { if (clazz.isUseNonDefaultConstructor()) { try { return this.factory.getNewPeerObject(clazz, dna); } catch (final IOException e) { throw new TCRuntimeException(e); } catch (final ClassNotFoundException e) { throw new TCRuntimeException(e); } } else { return createNewPojoObject(clazz, dna.getArraySize(), dna.getObjectID(), dna.getParentObjectID()); } }
@Override public void hydrate(final ApplicatorObjectManager objectManager, final TCObjectExternal tcObjectExternal, final DNA dna, final Object pojo) throws ClassNotFoundException, IOException { final DNACursor cursor = dna.getCursor(); if (!dna.isDelta()) { // Shouldn't have anything to hydrate if (cursor.next(this.encoding)) { throw new AssertionError("CDSM shouldn't fault in entry mappings : DNA " + dna); } return; } boolean clearFound = false; // Transactions could be folded, hence ignoring other changes. while (cursor.next(this.encoding)) { final LogicalAction action = cursor.getLogicalAction(); final int method = action.getMethod(); if (method == SerializationUtil.CLEAR || method == SerializationUtil.CLEAR_LOCAL_CACHE) { ((TCObjectServerMap) tcObjectExternal).clearLocalCache((TCServerMap) pojo); clearFound = true; } else { getLogger().warn("CDSM received delta changes for methods other than CLEAR : " + method); } } if (!clearFound) { // Can't assert here as resent transactions on server crash can be broadcasted as it might skip apply at the // server. getLogger() .warn("CDSM shouldn't normally be broadcasting changes unless its a clear, but could be a resent txn after crash : DNA " + dna); } }
final boolean isUninitialized = isUninitialized(); final long dna_version = dna.getVersion(); if (dna_version <= this.version) { if (ignoreIfOlderDNA) { if (dna.isDelta() && isUninitialized) { throw new AssertionError("Uninitalized Object is applied with a delta DNA ! ManagedObjectImpl = " + toString() + " DNA = " + dna + " TransactionID = " + txnID); } else if (!dna.isDelta() && !isUninitialized) { instanceMonitor.instanceCreated(dna.getTypeName()); final DNACursor cursor = dna.getCursor(); throw new AssertionError("Creating state on an initialized object."); setState(getStateFactory().createState(this.id, dna.getParentObjectID(), dna.getTypeName(), cursor));
private TCObject createObjectWithDNA(DNA dna) throws ClassNotFoundException { TCObject obj = null; Class clazz = this.classProvider.getClassFor(dna.getTypeName()); TCClass tcClazz = clazzFactory.getOrCreate(clazz, this); Object pojo = createNewPojoObject(tcClazz, dna); obj = this.factory.getNewInstance(dna.getObjectID(), pojo, clazz, false); Assert.assertFalse(dna.isDelta()); // now hydrate the object, this could call resolveReferences which would call this method recursively if (obj instanceof TCObjectSelf) { obj.hydrate(dna, false, null); } else { obj.hydrate(dna, false, newWeakObjectReference(dna.getObjectID(), pojo)); } basicAddLocal(obj); return obj; }
@Override public Object getNewInstance(ApplicatorObjectManager objectManager, DNA dna) { try { final DNACursor cursor = dna.getCursor(); Assert.assertTrue("DNA missing physical action", cursor.next()); PhysicalAction physicalAction = cursor.getPhysicalAction(); final Object lockType = physicalAction.getObject(); Assert.assertTrue("DNA missing physical action", cursor.next()); physicalAction = cursor.getPhysicalAction(); Object lockStrategy = objectManager.lookupObject((ObjectID) physicalAction.getObject()); /* * This trickery is necessary to avoid getting an instance of class loaded by the wrong classloader. Otherwise we * get ClassCastExceptions when we try and store the result in the ConcurrentDistributedMap instance. */ Class cdmClazz = objectManager.getClassFor(CDM_DSO, LoaderDescription.fromString(dna .getDefiningLoaderDescription())); final Method newCDM = cdmClazz.getMethod("newCDM", NEW_CDM_ARGS); newCDM.setAccessible(true); return newCDM.invoke(null, lockType, lockStrategy); } catch (final Exception e) { throw new RuntimeException(e); } }
@Override public ObjectID getObjectID() throws DNAException { return dna.getObjectID(); }
for (final Iterator i = this.changes.iterator(); i.hasNext();) { final DNA dna = (DNA) i.next(); added &= ids.add(dna.getObjectID()); if (!dna.isDelta()) { newIDs.add(dna.getObjectID());
long version = orgDNA.getVersion(); if (version == DNA.NULL_VERSION) { Assert.assertFalse(gtxID.isNull()); final ManagedObject mo = (ManagedObject) objects.get(change.getObjectID()); mo.apply(change, txnID, applyInfo, instanceMonitor, !active); if ((this.broadcastStatsLoggingEnabled || this.objectStatsRecorder.getBroadcastDebug()) dnaImpl.setTypeClassName(mo.getManagedObjectState().getClassName()); if (active && !change.isDelta() && isClient) {
@Override public String getTypeName() { return dna.getTypeName(); }
@Override public void hydrate(final TCObject tcObject, final DNA dna, final Object pojo, final boolean force) throws IOException, ClassNotFoundException { // Okay...long story here The application of the DNA used to be a synchronized(applicator) block. As best as Steve // and I could tell, the synchronization was solely a memory boundary and not a mutual exlusion mechanism. For the // time being, we have resolved that we need no synchronization here (either for memory, or exclusion). The memory // barrier aspect isn't known to be a problem and the concurrency is handled by the server (ie. we won't get // concurrent updates). At some point it would be a good idea to detect (and error out) when updates are received // from L2 but local read/writes have been made on the target TCObject final long localVersion = tcObject.getVersion(); final long dnaVersion = dna.getVersion(); if (force || (localVersion < dnaVersion)) { tcObject.setVersion(dnaVersion); this.applicator.hydrate(this.objectManager, tcObject, dna, pojo); } else if (logger.isDebugEnabled()) { logger .debug("IGNORING UPDATE, local object at version " + localVersion + ", dna update is version " + dnaVersion); } }
@Override public int getArraySize() { return dna.getArraySize(); }
@Override public void hydrate(final ApplicatorObjectManager objectManager, final TCObjectExternal tcObjectExternal, final DNA dna, final Object pojo) throws ClassNotFoundException, IOException { final DNACursor cursor = dna.getCursor(); if (!dna.isDelta()) { // Shouldn't have anything to hydrate if (cursor.next(this.encoding)) { throw new AssertionError("CDSM shouldn't fault in entry mappings : DNA " + dna); } return; } boolean clearFound = false; // Transactions could be folded, hence ignoring other changes. while (cursor.next(this.encoding)) { final LogicalAction action = cursor.getLogicalAction(); final int method = action.getMethod(); if (method == SerializationUtil.CLEAR || method == SerializationUtil.CLEAR_LOCAL_CACHE) { ((TCObjectServerMap) tcObjectExternal).clearLocalCache((TCServerMap) pojo); clearFound = true; } else { getLogger().warn("CDSM received delta changes for methods other than CLEAR : " + method); } } if (!clearFound) { // Can't assert here as resent transactions on server crash can be broadcasted as it might skip apply at the // server. getLogger() .warn("CDSM shouldn't normally be broadcasting changes unless its a clear, but could be a resent txn after crash : DNA " + dna); } }
private TCObject createObjectWithDNA(DNA dna) throws ClassNotFoundException { TCObject obj = null; Class clazz = this.classProvider.getClassFor(Namespace.parseClassNameIfNecessary(dna.getTypeName())); TCClass tcClazz = clazzFactory.getOrCreate(clazz, this); Object pojo = createNewPojoObject(tcClazz, dna); obj = this.factory.getNewInstance(dna.getObjectID(), pojo, clazz, false); Assert.assertFalse(dna.isDelta()); // now hydrate the object, this could call resolveReferences which would call this method recursively if (obj instanceof TCObjectSelf) { obj.hydrate(dna, false, null); } else { obj.hydrate(dna, false, newWeakObjectReference(dna.getObjectID(), pojo)); } basicAddLocal(obj); return obj; }
@Override public Object getNewInstance(ApplicatorObjectManager objectManager, DNA dna) { try { final DNACursor cursor = dna.getCursor(); Assert.assertTrue("DNA missing physical action", cursor.next()); PhysicalAction physicalAction = cursor.getPhysicalAction(); final Object lockType = physicalAction.getObject(); Assert.assertTrue("DNA missing physical action", cursor.next()); physicalAction = cursor.getPhysicalAction(); Object lockStrategy = objectManager.lookupObject((ObjectID) physicalAction.getObject()); /* * This trickery is necessary to avoid getting an instance of class loaded by the wrong classloader. Otherwise we * get ClassCastExceptions when we try and store the result in the ConcurrentDistributedMap instance. */ Class cdmClazz = objectManager.getClassFor(CDM_DSO, LoaderDescription.fromString(dna .getDefiningLoaderDescription())); final Method newCDM = cdmClazz.getMethod("newCDM", NEW_CDM_ARGS); newCDM.setAccessible(true); return newCDM.invoke(null, lockType, lockStrategy); } catch (final Exception e) { throw new RuntimeException(e); } }
@Override public ObjectID getObjectID() throws DNAException { return dna.getObjectID(); }
for (Iterator j = changes.iterator(); j.hasNext();) { DNA dna = (DNA) j.next(); ObjectID id = dna.getObjectID(); if (!dna.isDelta()) {
private Object createNewPojoObject(TCClass clazz, DNA dna) { if (clazz.isUseNonDefaultConstructor()) { try { return this.factory.getNewPeerObject(clazz, dna); } catch (final IOException e) { throw new TCRuntimeException(e); } catch (final ClassNotFoundException e) { throw new TCRuntimeException(e); } } else { return createNewPojoObject(clazz, dna.getArraySize(), dna.getObjectID(), dna.getParentObjectID()); } }