use of org.opendaylight.mdsal.eos.binding.api.Entity in project genius by opendaylight.
the class EntityOwnershipUtils method runOnlyInOwnerNode.
/**
* Runs a job task if the local node is the owner of an entity.
*
* @param entityType the entity type
* @param entityName the entity name
* @param coordinator the JobCoordinator on which to run the job
* @param jobKey the job key
* @param jobDesc description of the job for logging
* @param job the job task
*/
public void runOnlyInOwnerNode(String entityType, String entityName, JobCoordinator coordinator, String jobKey, String jobDesc, Callable<List<ListenableFuture<Void>>> job) {
final Entity entity = new Entity(entityType, entityName);
coordinator.enqueueJob(entity.toString(), () -> {
if (isEntityOwner(entity)) {
LOG.debug("Scheduling job {} for {}", jobDesc, entity);
coordinator.enqueueJob(jobKey, job, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
} else {
LOG.debug("runOnlyInOwnerNode: job {} was not run as I'm not the owner of {} ", jobDesc, entity);
}
return Collections.singletonList(Futures.immediateFuture(null));
});
}
use of org.opendaylight.mdsal.eos.binding.api.Entity in project genius by opendaylight.
the class EntityOwnershipUtils method runOnlyInOwnerNode.
/**
* Runs a job task if the local node is the owner of an entity.
*
* @param entityType the entity type
* @param entityName the entity name
* @param coordinator the JobCoordinator on which to run the job task
* @param jobDesc description of the job for logging
* @param job the job task
*/
public void runOnlyInOwnerNode(String entityType, String entityName, JobCoordinator coordinator, String jobDesc, Runnable job) {
final Entity entity = new Entity(entityType, entityName);
coordinator.enqueueJob(entity.toString(), () -> {
if (isEntityOwner(entity)) {
LOG.debug("Running job {} for {}", jobDesc, entity);
job.run();
} else {
LOG.debug("runOnlyInOwnerNode: job {} was not run as I'm not the owner of {} ", jobDesc, entity);
}
return Collections.singletonList(Futures.immediateFuture(null));
});
}
use of org.opendaylight.mdsal.eos.binding.api.Entity in project genius by opendaylight.
the class ItmProvider method registerEntityForOwnership.
private void registerEntityForOwnership() {
try {
Entity registryCandidate = new Entity(ITMConstants.ITM_CONFIG_ENTITY, ITMConstants.ITM_CONFIG_ENTITY);
entityOwnershipService.registerCandidate(registryCandidate);
} catch (CandidateAlreadyRegisteredException e) {
LOG.error("failed to register entity {} for entity-ownership-service", e.getEntity());
}
}
Aggregations