}
}
public Boolean _setOwnership(String appName, Object keyId, String newOwner, Long remoteVersion)
{
PackagedSession session = this.getAppMap(appName).get(keyId);
Lock lock = session.getLock();
if (!lock.tryLock())
{
return Boolean.FALSE;
}
try
{
if (!session.getOwner().equals(this.myNodeName))
{
// this is not our business... we don't care
// we do not update the owner of ps as another host may refuse the _setOwnership call
// anyway, the update will be sent to us later if state is modified
//
return Boolean.TRUE;
}
else if (session.getVersion() > remoteVersion.longValue())
{
// we are concerned and our version is more recent than the one of the remote host!
// it means that we have concurrent calls on the same state that has not yet been updated
// this means we will need to raise a java.rmi.RemoteException
//
return Boolean.FALSE;
}
// the remote host has the same version as us (or more recent? possible?)
// we need to update the ownership. We can do this because we know that no other
// node can refuse the _setOwnership call
session.setOwner(newOwner);
this.ownedObjectExternallyModified(appName, keyId, session, session);
return Boolean.TRUE;
}