long heartbeatInterval = this.lockProps.getHeartBeatIntervalProperty();
cleanLockTable();
- heartbeat = new Heartbeat(uuid, lockProps);
+ initHeartbeat(lockProps);
this.scheduledExecutorService = Executors.newScheduledThreadPool(1);
this.scheduledExecutorService.scheduleAtFixedRate(heartbeat, heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS);
}
+ /**
+ * Initialize the static heartbeat object
+ */
+ private static void initHeartbeat(DistributedLockingProperties lockProps) {
+ heartbeat = new Heartbeat(uuid, lockProps);
+
+ }
+
public static Heartbeat getHeartbeat() {
return heartbeat;
}
}
- return doBoolIntercept(impl -> impl.beforeIsLocked(resourceId), () -> {
+ return doBoolIntercept(impl -> impl.beforeIsLocked(resourceId), () ->
// implementer didn't do the work - defer to the superclass
- return super.isLocked(resourceId);
- });
+ super.isLocked(resourceId)
+ );
}
/**
throw makeNullArgException(MSG_NULL_OWNER);
}
- return doBoolIntercept(impl -> impl.beforeIsLockedBy(resourceId, owner), () -> {
+ return doBoolIntercept(impl -> impl.beforeIsLockedBy(resourceId, owner), () ->
// implementer didn't do the work - defer to the superclass
- return super.isLockedBy(resourceId, owner);
- });
+ super.isLockedBy(resourceId, owner)
+ );
}
/**
*/
private static class Singleton {
+ private static final PolicyResourceLockManager instance = new PolicyResourceLockManager();
+
/**
* Not invoked.
*/
super();
}
- private static final PolicyResourceLockManager instance = new PolicyResourceLockManager();
}
/**
super();
}
- // TODO: for ease of use by clients, should we always invoke the callback, even though
- // this is synchronous?
-
/**
* Attempts to lock a resource. This method ignores the callback and always returns a
* {@link CompletedLockRequest}.