//\TODO try to execute outside of the critical path of commit
try {
- if(partition != null)
- relinquishIfRequired(partition);
+ if(partition != null) {
+ mi.relinquish(partition);
+ }
} catch (MDBCServiceException e) {
logger.warn("Error trying to relinquish: "+partition.toString());
}
logger.debug("Connection was closed for id:" + id);
}
try {
- mi.relinquish(partition.getLockId(),partition.getMRIIndex().toString());
+ mi.relinquish(partition);
} catch (MDBCServiceException e) {
throw new SQLException("Failure during relinquish of partition",e);
}
private void relinquish(DatabasePartition partition){
try {
- musicInterface.relinquish(partition.getLockId(),partition.getMRIIndex().toString());
+ musicInterface.relinquish(partition);
} catch (MDBCServiceException e) {
logger.error("Relinquish failed, would need to forcefully obtain lock later");
}
/**
* This functions relinquishes a range
+ * @param partition db partition to be relinquished
+ * @throws MusicLockingException
+ */
+ public void relinquish(DatabasePartition partition) throws MDBCServiceException;
+
+ /**
+ * This functions relinquishes a range
* @param lockId id of the lock to be relinquished
* @param rangeId id of the range to be relinquished
* @throws MusicLockingException
}
+ @Override
+ public void relinquish(DatabasePartition partition) throws MDBCServiceException {
+ String ownerId = partition.getLockId();
+ String rangeId = partition.getMRIIndex().toString();
+ if(ownerId==null||ownerId.isEmpty()||rangeId==null||rangeId.isEmpty()){
+ return;
+ }
+ unlockKeyInMusic(musicRangeInformationTableName, rangeId, ownerId);
+ }
@Override
public void relinquish(String lockId, String rangeId) throws MDBCServiceException{
private boolean canTryRelinquishing(){
//\TODO: Fix this!!!! REALLY IMPORTANT TO BE FIX
// This should actually have some mechanism to relinquish ownership
- return false;
+ return true;
}
@Override
if(lockQueueSize> 1){
//If there is any other node waiting, we just relinquish ownership
try {
- relinquish(partition.getLockId(),partition.getMRIIndex().toString());
+ relinquish(partition);
} catch (MDBCServiceException e) {
logger.error("Error relinquishing lock, will use timeout to solve");
}