use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project bgpcep by opendaylight.
the class ProgrammingServiceImpl method scheduleInstruction.
@Override
public synchronized ListenableFuture<Instruction> scheduleInstruction(final SubmitInstructionInput input) throws SchedulerException {
final InstructionId id = input.getId();
if (this.insns.get(id) != null) {
LOG.info("Instruction ID {} already present", id);
throw new SchedulerException("Instruction ID currently in use", new FailureBuilder().setType(DuplicateInstructionId.class).build());
}
// First things first: check the deadline
final Nanotime now = NanotimeUtil.currentTime();
final BigInteger left = input.getDeadline().getValue().subtract(now.getValue());
if (left.compareTo(BigInteger.ZERO) <= 0) {
LOG.debug("Instruction {} deadline has already passed by {}ns", id, left);
throw new SchedulerException("Instruction arrived after specified deadline", new FailureBuilder().setType(DeadOnArrival.class).build());
}
// Resolve dependencies
final List<InstructionImpl> dependencies = checkDependencies(input);
/*
* All pre-flight checks done are at this point, the following
* steps can only fail in catastrophic scenarios (OOM and the
* like).
*/
// Schedule a timeout for the instruction
final Timeout t = this.timer.newTimeout(timeout -> timeoutInstruction(input.getId()), left.longValue(), TimeUnit.NANOSECONDS);
// Put it into the instruction list
final SettableFuture<Instruction> ret = SettableFuture.create();
final InstructionImpl instruction = new InstructionImpl(new InstructionPusher(id, input.getDeadline()), ret, id, dependencies, t);
this.insns.put(id, instruction);
// Attach it into its dependencies
for (final InstructionImpl d : dependencies) {
d.addDependant(instruction);
}
/*
* All done. The next part is checking whether the instruction can
* run, which we can figure out after sending out the acknowledgement.
* This task should be ingress-weighed, so we reinsert it into the
* same execution service.
*/
this.executor.submit(() -> tryScheduleInstruction(instruction));
return ret;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project lispflowmapping by opendaylight.
the class PortDataProcessor method update.
@Override
public void update(Port port) {
final String hostId = port.getAugmentation(PortBindingExtension.class).getHostId();
if (hostId == null) {
LOG.error("Updating port to lisp mapping service failed. Port does not have a HostID. Port: {}", port.toString());
return;
}
List<FixedIps> fixedIPs = port.getFixedIps();
if (fixedIPs != null && fixedIPs.size() > 0) {
Eid eidAddress;
for (FixedIps ip : fixedIPs) {
eidAddress = getEid(port, ip);
PortData portData = new PortData(port.getUuid().getValue(), eidAddress);
hostInformationManager.addHostRelatedInfo(hostId, portData);
}
}
LOG.info("Neutron Port updated: Port name: " + port.getName() + " Port Fixed IP: " + (port.getFixedIps() != null ? port.getFixedIps().get(0) : "No Fixed IP assigned"));
LOG.debug("Neutron Port Updated : " + port.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project lispflowmapping by opendaylight.
the class SubnetDataProcessor method create.
/**
* Method adds the newly created subnet as an EID prefix to the
* MappingService. The subnet's network UUID is used as the key for this EID
* prefix.
*/
@Override
public void create(Subnet subnet) {
// TODO update for multi-tenancy
LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
LOG.debug("Lisp Neutron Subnet: " + subnet.toString());
// Determine the IANA code for the subnet IP version
// Default is set to IPv4 for neutron subnets
final Eid eid = LispAddressUtil.asIpv4PrefixEid(String.valueOf(subnet.getCidr().getValue()));
try {
final OdlMappingserviceService lfmdb = lispNeutronService.getMappingDbService();
if (lfmdb == null) {
LOG.debug("lfmdb is null!!!");
return;
}
final AddKeyInput addKeyInput = LispUtil.buildAddKeyInput(eid, subnet.getUuid().getValue());
final Future<RpcResult<Void>> result = lfmdb.addKey(addKeyInput);
final Boolean isSuccessful = result.get().isSuccessful();
if (isSuccessful) {
LOG.debug("Neutron Subnet Added to MapServer : Subnet name: " + subnet.getName() + " EID Prefix: " + subnet.getCidr() + " Key: " + subnet.getUuid());
}
LOG.info("Neutron Subnet Created request : Subnet name: " + subnet.getName() + " Subnet Cidr: " + subnet.getCidr());
} catch (InterruptedException | ExecutionException e) {
LOG.error("Adding new subnet to lisp service mapping service failed. Subnet : " + subnet.toString() + "Error: " + ExceptionUtils.getStackTrace(e));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project lispflowmapping by opendaylight.
the class MappingSystemTest method getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord_IndexOutOfBounds.
/**
* Tests {@link MappingSystem#getMapping} method with ServicePath type dst address and single ExplicitLocatorPath
* type locator record. Service index out of bounds. Returns the original mapping.
*/
@Test
public void getMappingTest_NbFirst_withServicePathDestinationAddress_singleELPLocatorRecord_IndexOutOfBounds() {
final MappingRecord mappingRecord = getDefaultMappingRecordBuilder().setLocatorRecord(Lists.newArrayList(getDefaultLocatorRecordBuilder().setRloc(getELPTypeRloc()).build())).build();
final MappingData mappingData = getDefaultMappingData(mappingRecord);
Mockito.when(pmcMock.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH_INDEX_OOB)).thenReturn(mappingData);
assertEquals(mappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_SERVICE_PATH_INDEX_OOB));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project lispflowmapping by opendaylight.
the class MappingSystem method getMappingNbSbIntersection.
private MappingData getMappingNbSbIntersection(Eid src, Eid dst) {
// lookupPolicy == NB_AND_SB, we return intersection
// of NB and SB mappings, or NB mapping if intersection is empty.
MappingData nbMappingData = (MappingData) pmc.getMapping(src, dst);
if (nbMappingData == null) {
return nbMappingData;
}
// no intersection for Service Path mappings
if (dst.getAddress() instanceof ServicePath) {
return updateServicePathMappingRecord(nbMappingData, dst);
}
MappingData sbMappingData = getSbMappingWithExpiration(src, dst, null);
if (sbMappingData == null) {
return nbMappingData;
}
// both NB and SB mappings exist. Compute intersection of the mappings
return MappingMergeUtil.computeNbSbIntersection(nbMappingData, sbMappingData);
}
Aggregations