import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.utils.batching.ActionableResource;
-import org.opendaylight.genius.utils.batching.ActionableResourceImpl;
+import org.opendaylight.genius.utils.batching.ActionableResources;
import org.opendaylight.genius.utils.batching.DefaultBatchHandler;
import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
import org.opendaylight.mdsal.binding.api.DataBroker;
}
public <T extends DataObject> void update(final InstanceIdentifier<T> path, final T data) {
- ActionableResourceImpl actResource = new ActionableResourceImpl(path.toString());
- actResource.setAction(ActionableResource.UPDATE);
- actResource.setInstanceIdentifier(path);
- actResource.setInstance(data);
- bgpResourcesBufferQ.add(actResource);
+ bgpResourcesBufferQ.add(ActionableResources.update(path, data));
}
public <T extends DataObject> void write(final InstanceIdentifier<T> path, final T data) {
- ActionableResourceImpl actResource = new ActionableResourceImpl(path.toString());
- actResource.setAction(ActionableResource.CREATE);
- actResource.setInstanceIdentifier(path);
- actResource.setInstance(data);
- bgpResourcesBufferQ.add(actResource);
+ bgpResourcesBufferQ.add(ActionableResources.create(path, data));
}
public <T extends DataObject> void delete(final InstanceIdentifier<T> path) {
- ActionableResourceImpl actResource = new ActionableResourceImpl(path.toString());
- actResource.setAction(ActionableResource.DELETE);
- actResource.setInstanceIdentifier(path);
- actResource.setInstance(null);
- bgpResourcesBufferQ.add(actResource);
+ bgpResourcesBufferQ.add(ActionableResources.delete(path));
}
// Convert ProtocolType to thrift protocol_type
*/
package org.opendaylight.netvirt.fibmanager;
+import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId;
import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
import org.opendaylight.genius.utils.batching.ActionableResource;
-import org.opendaylight.genius.utils.batching.ActionableResourceImpl;
+import org.opendaylight.genius.utils.batching.ActionableResources;
import org.opendaylight.genius.utils.batching.ResourceBatchingManager;
import org.opendaylight.genius.utils.batching.ResourceHandler;
import org.opendaylight.genius.utils.batching.SubTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes;
+import org.opendaylight.yangtools.concepts.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
@Singleton
public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler implements ResourceHandler {
+ private static final class ActionableResourceIdentifier implements Identifier {
+ private static final long serialVersionUID = 1L;
+
+ private final String routeDistinguisher;
+ private final String destPrefix;
+
+ ActionableResourceIdentifier(final String routeDistinguisher, final String destPrefix) {
+ this.routeDistinguisher = requireNonNull(routeDistinguisher);
+ this.destPrefix = requireNonNull(destPrefix);
+ }
+
+ @Override
+ public int hashCode() {
+ return routeDistinguisher.hashCode() * 31 + destPrefix.hashCode();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof ActionableResourceIdentifier)) {
+ return false;
+ }
+ final ActionableResourceIdentifier other = (ActionableResourceIdentifier) obj;
+ return routeDistinguisher.equals(other.routeDistinguisher) && destPrefix.equals(other.destPrefix);
+ }
+
+ @Override
+ public String toString() {
+ return routeDistinguisher + destPrefix;
+ }
+ }
private static final Logger LOG = LoggerFactory.getLogger(BgpRouteVrfEntryHandler.class);
private static final int BATCH_INTERVAL = 500;
}
void createFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
- ActionableResourceImpl actResource = new ActionableResourceImpl(rd + vrfEntry.getDestPrefix());
- actResource.setAction(ActionableResource.CREATE);
- actResource.setInstanceIdentifier(identifier);
- actResource.setInstance(vrfEntry);
- vrfEntryBufferQ.add(actResource);
+ vrfEntryBufferQ.add(ActionableResources.create(new ActionableResourceIdentifier(rd, vrfEntry.getDestPrefix()),
+ identifier, vrfEntry));
}
void removeFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
- ActionableResourceImpl actResource = new ActionableResourceImpl(rd + vrfEntry.getDestPrefix());
- actResource.setAction(ActionableResource.DELETE);
- actResource.setInstanceIdentifier(identifier);
- actResource.setInstance(vrfEntry);
- vrfEntryBufferQ.add(actResource);
+ vrfEntryBufferQ.add(ActionableResources.delete(new ActionableResourceIdentifier(rd, vrfEntry.getDestPrefix()),
+ identifier, vrfEntry));
}
void updateFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry original, VrfEntry update, String rd) {
- ActionableResourceImpl actResource = new ActionableResourceImpl(rd + update.getDestPrefix());
- actResource.setAction(ActionableResource.UPDATE);
- actResource.setInstanceIdentifier(identifier);
- actResource.setInstance(update);
- actResource.setOldInstance(original);
- vrfEntryBufferQ.add(actResource);
+ vrfEntryBufferQ.add(ActionableResources.update(new ActionableResourceIdentifier(rd, update.getDestPrefix()),
+ identifier, update, original));
}
/*