@Override public boolean cancel() { return delegate.cancel(); }
@Override public void close() { readWriteTransaction.cancel(); } }
@Override public void onFailure(Throwable error) { LOG.error("Error when reading Monitoring State for key: {} to process the Packet received", monitorKey, error); //FIXME: Not sure if the transaction status is valid to cancel tx.cancel(); releaseLock(lock); } });
private boolean update(String uuid, S delta, ReadWriteTransaction tx) throws InterruptedException, ExecutionException { Preconditions.checkNotNull(tx); if (!exists(uuid, tx)) { tx.cancel(); return false; } updateMd(delta, tx); return true; }
@Deprecated private void removeTenantSubnet(TenantId tenantId, SubnetId subnetId, ReadWriteTransaction rwTx) { Optional<Subnet> potentialSubnet = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnetId), rwTx); if (!potentialSubnet.isPresent()) { LOG.warn("Illegal state - subnet {} does not exist.", subnetId.getValue()); rwTx.cancel(); return; } } }
/** * {@inheritDoc} */ @Override public void cancelTransaction() { ReadWriteTransaction tx = transaction; if (tx != null) { transaction = null; readSpecific.clear(); specific.clear(); if (!submitted) { tx.cancel(); } } // Clear submit hooks registered by the previous transaction. preSubmitHooks.clear(); postSubmitHooks.clear(); // Clear log records. logRecords.clear(); }
@Override public void onCreated(SecurityGroup createdSecGroup, Neutron neutron) { LOG.trace("created securityGroup - {}", createdSecGroup); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); boolean isSecGroupCreated = addNeutronSecurityGroup(createdSecGroup, rwTx); if (isSecGroupCreated) { DataStoreHelper.submitToDs(rwTx); } else { rwTx.cancel(); } }
private boolean remove(String uuid, ReadWriteTransaction tx) throws InterruptedException, ExecutionException { Preconditions.checkNotNull(tx); if (!exists(uuid, tx)) { tx.cancel(); return false; } removeMd(toMd(uuid), tx); return true; }
@Override public void onCreated(SecurityRule secRule, Neutron neutron) { LOG.trace("created securityRule - {}", secRule); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); boolean isNeutronSecurityRuleAdded = addNeutronSecurityRule(secRule, neutron, rwTx); if (isNeutronSecurityRuleAdded) { DataStoreHelper.submitToDs(rwTx); } else { rwTx.cancel(); } }
@Override public void onDeleted(SecurityRule deletedSecRule, Neutron oldNeutron, Neutron newNeutron) { LOG.trace("deleted securityRule - {}", deletedSecRule); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); boolean isNeutronSecurityRuleDeleted = deleteNeutronSecurityRule(deletedSecRule, oldNeutron, rwTx); if (isNeutronSecurityRuleDeleted) { DataStoreHelper.submitToDs(rwTx); } else { rwTx.cancel(); } }
private boolean add(S input, ReadWriteTransaction tx) throws InterruptedException, ExecutionException { Preconditions.checkNotNull(tx); if (exists(input.getID(), tx)) { tx.cancel(); return false; } addMd(input, tx); return true; }
@Override public ListenableFuture<Void> apply(Optional<InterfaceMonitorEntry> optEntry) throws Exception { if(optEntry.isPresent()) { InterfaceMonitorEntry entry = optEntry.get(); List<Long> monitorIds = entry.getMonitorIds(); monitorIds.remove(monitorId); InterfaceMonitorEntry newEntry = new InterfaceMonitorEntryBuilder(entry) .setKey(new InterfaceMonitorEntryKey(interfaceName)).setMonitorIds(monitorIds).build(); tx.put(LogicalDatastoreType.OPERATIONAL, getInterfaceMonitorMapId(interfaceName), newEntry, CREATE_MISSING_PARENT); return tx.submit(); } else { LOG.warn("No Interface map entry found {} to remove monitorId {}", interfaceName, monitorId); tx.cancel(); return Futures.immediateFuture(null); } } });
private void initializeTopology(LogicalDatastoreType type) { ReadWriteTransaction transaction = db.newReadWriteTransaction(); InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path); try { if (!topology.get().isPresent()) { NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type,path,ntb.build()); transaction.submit(); } else { transaction.cancel(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error initializing ovsdb topology", e); } }
private void initializeTZNode(DataBroker db) { ReadWriteTransaction transaction = db.newReadWriteTransaction(); InstanceIdentifier<TransportZones> path = InstanceIdentifier.create(TransportZones.class); CheckedFuture<Optional<TransportZones>, ReadFailedException> tzones = transaction.read(LogicalDatastoreType.CONFIGURATION,path); try { if (!tzones.get().isPresent()) { TransportZonesBuilder tzb = new TransportZonesBuilder(); transaction.put(LogicalDatastoreType.CONFIGURATION,path,tzb.build()); transaction.submit(); } else { transaction.cancel(); } } catch (Exception e) { LOG.error("Error initializing TransportZones {}",e); } }
private void initializeTopology(final LogicalDatastoreType type) { final ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); final InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class); final CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path); try { if (!topology.get().isPresent()) { final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder(); transaction.put(type,path,ntb.build()); transaction.submit().get(); } else { transaction.cancel(); } } catch (final Exception e) { LOG.error("Error initializing unimgr topology {}", e); } }
@Override public void onDeleted(SecurityGroup deletedSecGroup, Neutron oldNeutron, Neutron newNeutron) { LOG.trace("deleted securityGroup - {}", deletedSecGroup); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); TenantId tenantId = new TenantId(deletedSecGroup.getTenantId().getValue()); EndpointGroupId epgId = new EndpointGroupId(deletedSecGroup.getUuid().getValue()); Optional<EndpointGroup> potentialEpg = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, IidFactory.endpointGroupIid(tenantId, epgId), rwTx); if (!potentialEpg.isPresent()) { LOG.warn("Illegal state - Endpoint group {} does not exist.", epgId.getValue()); rwTx.cancel(); return; } DataStoreHelper.submitToDs(rwTx); }
@Override public void onDeleted( org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet neutronSubnet, Neutron oldNeutron, Neutron newNeutron) { LOG.trace("deleted subnet - {}", neutronSubnet); ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); NetworkDomainId subnetId = new NetworkDomainId(neutronSubnet.getUuid().getValue()); TenantId tenantId = new TenantId(neutronSubnet.getTenantId().getValue()); Optional<NetworkDomain> potentialSubnetDomain = DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.subnetIid(tenantId, subnetId), rwTx); if (!potentialSubnetDomain.isPresent()) { LOG.warn("Illegal state - subnet network domain {} does not exist.", subnetId.getValue()); rwTx.cancel(); return; } removeTenantSubnet(tenantId, new SubnetId(subnetId), rwTx); // TODO remove default gateway EP in case when subnet is in provider physical network DataStoreHelper.submitToDs(rwTx); }
private void initializeOvsdbTopology(LogicalDatastoreType type) { InstanceIdentifier<Topology> path = InstanceIdentifier .create(NetworkTopology.class) .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID)); initializeTopology(type); ReadWriteTransaction transaction = db.newReadWriteTransaction(); CheckedFuture<Optional<Topology>, ReadFailedException> ovsdbTp = transaction.read(type, path); try { if (!ovsdbTp.get().isPresent()) { TopologyBuilder tpb = new TopologyBuilder(); tpb.setTopologyId(SouthboundConstants.OVSDB_TOPOLOGY_ID); transaction.put(type, path, tpb.build()); transaction.submit(); } else { transaction.cancel(); } } catch (InterruptedException | ExecutionException e) { LOG.error("Error initializing ovsdb topology", e); } }
@Deprecated private void processTenantSubnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet neutronSubnet, Network networkOfSubnet, TenantId tenantId, ReadWriteTransaction rwTx) { Subnet subnet; if (NetworkUtils.isProviderPhysicalNetwork(networkOfSubnet)) { // add virtual router IP only in case it is provider physical network subnet = createTenantSubnet(neutronSubnet, neutronSubnet.getGatewayIp()); IpAddress gatewayIp = neutronSubnet.getGatewayIp(); boolean registeredDefaultRoute = epRegistrator.registerExternalL3PrefixEndpoint(MappingUtils.DEFAULT_ROUTE, new L3ContextId(neutronSubnet.getNetworkId().getValue()), gatewayIp, tenantId); if (!registeredDefaultRoute) { LOG.warn("Could not add EndpointL3Prefix as default route. Subnet within provider physical network {}", neutronSubnet); rwTx.cancel(); return; } } else { // virtual router IP is not set and it will be set when router gateway port is set // or when a router port is attached to a network subnet = createTenantSubnet(neutronSubnet, null); } rwTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.subnetIid(tenantId, subnet.getId()), subnet, true); }
protected void initDatastore(final LogicalDatastoreType type, final TopologyId topoId) { final InstanceIdentifier<Topology> path = InstanceIdentifier .create(NetworkTopology.class) .child(Topology.class, new TopologyKey(topoId)); initializeTopology(type); final ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction(); final CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type, path); try { if (!unimgrTp.get().isPresent()) { final TopologyBuilder tpb = new TopologyBuilder(); tpb.setTopologyId(topoId); transaction.put(type, path, tpb.build()); transaction.submit().get(); } else { transaction.cancel(); } } catch (final Exception e) { LOG.error("Error initializing unimgr topology", e); } }