EntityOwnershipState state = ownershipStateCache.get(nodeId);
if (state == null) {
LOG.debug("The ownership state for node {} is not cached. Retrieving from the EOS Datastore");
- java.util.Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(nodeId);
+ Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(nodeId);
if (status.isPresent()) {
state = status.get();
ownershipStateCache.put(nodeId, state);
}
}
- private java.util.Optional<EntityOwnershipState> getCurrentOwnershipStatus(final String nodeId) {
+ private Optional<EntityOwnershipState> getCurrentOwnershipStatus(final String nodeId) {
org.opendaylight.mdsal.eos.binding.api.Entity entity = createNodeEntity(nodeId);
Optional<EntityOwnershipState> ownershipStatus = eos.getOwnershipState(entity);
if (ownershipStatus.isPresent()) {
LOG.trace("Fetched ownership status for node {} is {}", nodeId, ownershipStatus.get());
- return java.util.Optional.of(ownershipStatus.get());
}
- return java.util.Optional.empty();
+ return ownershipStatus;
}
private org.opendaylight.mdsal.eos.binding.api.Entity createNodeEntity(final String nodeId) {
Preconditions.checkNotNull(eos, "Entity ownership service must not be null");
EntityOwnershipState state = null;
- java.util.Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(eos, nodeId);
+ Optional<EntityOwnershipState> status = getCurrentOwnershipStatus(eos, nodeId);
if (status.isPresent()) {
state = status.get();
} else {
return state != null && state.equals(EntityOwnershipState.IS_OWNER);
}
- private static java.util.Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos,
+ private static Optional<EntityOwnershipState> getCurrentOwnershipStatus(final EntityOwnershipService eos,
final String nodeId) {
Entity entity = createNodeEntity(nodeId);
Optional<EntityOwnershipState> ownershipStatus = eos.getOwnershipState(entity);
if (ownershipStatus.isPresent()) {
LOG.debug("Fetched ownership status for node {} is {}", nodeId, ownershipStatus.get());
- return java.util.Optional.of(ownershipStatus.get());
}
- return java.util.Optional.empty();
+ return ownershipStatus;
}
private static Entity createNodeEntity(final String nodeId) {