<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>features-test</artifactId>
- <version>0.7.0-SNAPSHOT</version>
</dependency>
<!-- dependency for opendaylight-karaf-empty for use by testing -->
<dependency>
final String jspFilter = "jspFilter";
final String exactMatch = "/somePath";
final String prefixFilter = "prefixFilter";
- LinkedHashMap<String, String> patternMap = new LinkedHashMap<String, String>() {
- {
- put(exactMatch, exactMatchFilter);
- put("/*", defaultFilter);
- put("*.jsp", jspFilter);
- put("/foo/*", prefixFilter);
- }
- };
+ LinkedHashMap<String, String> patternMap = new LinkedHashMap<>();
+ patternMap.put(exactMatch, exactMatchFilter);
+ patternMap.put("/*", defaultFilter);
+ patternMap.put("*.jsp", jspFilter);
+ patternMap.put("/foo/*", prefixFilter);
urlMatcher = new UrlMatcher<>(patternMap);
assertMatches("/abc", defaultFilter);
assertMatches(exactMatch, exactMatchFilter, defaultFilter);
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>controller/checkstyle.xml</configLocation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>controller/checkstyle.xml</configLocation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>${surefire.version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<configLocation>controller/checkstyle.xml</configLocation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>${surefire.version}</version>
<configuration>
<argLine>${testvm.argLine} ${jacoco.agent.ut.arg}</argLine>
<systemProperties>
import org.opendaylight.controller.config.persist.api.PropertiesProvider;
public class PropertiesProviderTest implements PropertiesProvider {
- private final Map<String,String> properties = new HashMap();
+ private final Map<String,String> properties = new HashMap<>();
public void addProperty(String key,String value){
properties.put(key,value);
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/</excludes>
</configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/</excludes>
</configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.version}</version>
<configuration>
<excludes>**\/target\/,**\/bin\/,**\/target-ide\/,**\/configuration\/initial\/</excludes>
</configuration>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
- <version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-inmemory-datastore</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<dependency>
<groupId>org.opendaylight.controller.model</groupId>
<artifactId>model-topology</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
<!-- toaster example I'm pretty sure we should trim -->
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>sample-toaster</artifactId>
- <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>sample-toaster-consumer</artifactId>
- <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller.samples</groupId>
<artifactId>sample-toaster-provider</artifactId>
- <version>${mdsal.version}</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<dependency>
<groupId>org.opendaylight.yangtools.thirdparty</groupId>
<artifactId>antlr4-runtime-osgi-nohead</artifactId>
- <version>4.0</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools.thirdparty</groupId>
<artifactId>xtend-lib-osgi</artifactId>
- <version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.openexi</groupId>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-clustering-commons</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
@Override protected void applySnapshot(final ByteString snapshot) {
state.clear();
try {
- state.putAll((HashMap) toObject(snapshot));
+ state.putAll((Map<String, String>) toObject(snapshot));
} catch (Exception e) {
LOG.error(e, "Exception in applying snapshot");
}
if(LOG.isDebugEnabled()) {
- LOG.debug("Snapshot applied to state : {}", ((HashMap) state).size());
+ LOG.debug("Snapshot applied to state : {}", ((Map<?, ?>) state).size());
}
}
public class Leader extends AbstractRaftActorBehavior {
- protected final Map<String, FollowerLogInformation> followerToLog = new HashMap();
+ protected final Map<String, FollowerLogInformation> followerToLog = new HashMap<>();
protected final Map<String, FollowerToSnapshot> mapFollowerToSnapshot = new HashMap<>();
private final Set<String> followers;
*/
public class AppendEntries extends AbstractRaftRPC {
- public static final Class SERIALIZABLE_CLASS = AppendEntriesMessages.AppendEntries.class;
+ public static final Class<AppendEntriesMessages.AppendEntries> SERIALIZABLE_CLASS = AppendEntriesMessages.AppendEntries.class;
private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(AppendEntries.class);
public class InstallSnapshot extends AbstractRaftRPC {
- public static final Class SERIALIZABLE_CLASS = InstallSnapshotMessages.InstallSnapshot.class;
+ public static final Class<InstallSnapshotMessages.InstallSnapshot> SERIALIZABLE_CLASS = InstallSnapshotMessages.InstallSnapshot.class;
private final String leaderId;
private final long lastIncludedIndex;
private long lastApplied = 0;
private final ElectionTerm electionTerm;
private ReplicatedLog replicatedLog;
- private Map<String, String> peerAddresses = new HashMap();
+ private Map<String, String> peerAddresses = new HashMap<>();
private ConfigParams configParams;
public MockRaftActorContext(){
Object data = toObject(snapshot);
System.out.println("!!!!!applyRecoverySnapshot: "+data);
if (data instanceof List) {
- state.addAll((List) data);
+ state.addAll((List<?>) data);
}
} catch (Exception e) {
e.printStackTrace();
return raftActor;
}
- public boolean waitForLogMessage(final Class logEventClass, String message){
+ public boolean waitForLogMessage(final Class<?> logEventClass, String message){
// Wait for a specific log message to show up
return
new JavaTestKit.EventFilter<Boolean>(logEventClass
MockRaftActorContext actorContext = (MockRaftActorContext) createActorContext();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
MockRaftActorContext actorContext =
(MockRaftActorContext) createActorContext();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
new JavaTestKit(getSystem()) {{
ActorRef followerActor = getSystem().actorOf(Props.create(MessageCollectorActor.class));
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ActorRef followerActor = getTestActor();
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ForwardMessageToBehaviorActor.setBehavior(follower);
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
ForwardMessageToBehaviorActor.setBehavior(follower);
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put(followerActor.path().toString(),
followerActor.path().toString());
MockRaftActorContext leaderActorContext =
new MockRaftActorContext("leader", getSystem(), leaderActor);
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put("follower-1",
followerActor.path().toString());
leaderActorContext.setReplicatedLog(
new MockRaftActorContext.MockReplicatedLogBuilder().createEntries(0, 3, 1).build());
- Map<String, String> peerAddresses = new HashMap();
+ Map<String, String> peerAddresses = new HashMap<>();
peerAddresses.put("follower-1",
followerActor.path().toString());
* @param clazz
* @return
*/
- public static Object getFirstMatching(ActorRef actor, Class clazz) throws Exception {
+ public static Object getFirstMatching(ActorRef actor, Class<?> clazz) throws Exception {
List<Object> allMessages = getAllMessages(actor);
for(Object message : allMessages){
return null;
}
- public static List<Object> getAllMatching(ActorRef actor, Class clazz) throws Exception {
+ public static List<Object> getAllMatching(ActorRef actor, Class<?> clazz) throws Exception {
List<Object> allMessages = getAllMessages(actor);
List<Object> output = Lists.newArrayList();
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-data-codec</artifactId>
- <version>0.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
*/
package org.opendaylight.controller.config.yang.md.sal.binding.impl;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.Hashtable;
-import java.util.Map.Entry;
-import java.util.Set;
import javassist.ClassPool;
import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
-import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
-import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
*/
public final class RuntimeMappingModule extends AbstractRuntimeMappingModule {
- private static final Logger LOG = LoggerFactory.getLogger(RuntimeMappingModule.class);
-
private BundleContext bundleContext;
public RuntimeMappingModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
public java.lang.AutoCloseable createInstance() {
final GeneratedClassLoadingStrategy classLoading = getGlobalClassLoadingStrategy();
final BindingIndependentMappingService legacyMapping = getGlobalLegacyMappingService(classLoading);
- BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(new StreamWriterGenerator(SingletonHolder.JAVASSIST));
+ BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
BindingToNormalizedNodeCodec instance = new BindingToNormalizedNodeCodec(classLoading, legacyMapping, codecRegistry);
bundleContext.registerService(SchemaContextListener.class, instance, new Hashtable<String,String>());
return instance;
public void setBundleContext(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
-
- private static final class RuntimeGeneratedMappingServiceProxy implements //
- BindingIndependentMappingService, //
- Delegator<BindingIndependentMappingService>, //
- AutoCloseable {
-
- private BindingIndependentMappingService delegate;
- private ServiceReference<BindingIndependentMappingService> reference;
- private BundleContext bundleContext;
-
- public RuntimeGeneratedMappingServiceProxy(final BundleContext bundleContext,
- final ServiceReference<BindingIndependentMappingService> serviceRef,
- final BindingIndependentMappingService delegate) {
- this.bundleContext = Preconditions.checkNotNull(bundleContext);
- this.reference = Preconditions.checkNotNull(serviceRef);
- this.delegate = Preconditions.checkNotNull(delegate);
- }
-
- @Override
- public CodecRegistry getCodecRegistry() {
- return delegate.getCodecRegistry();
- }
-
- @Override
- public CompositeNode toDataDom(final DataObject data) {
- return delegate.toDataDom(data);
- }
-
- @Override
- public Entry<YangInstanceIdentifier, CompositeNode> toDataDom(
- final Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry) {
- return delegate.toDataDom(entry);
- }
-
- @Override
- public YangInstanceIdentifier toDataDom(final InstanceIdentifier<? extends DataObject> path) {
- return delegate.toDataDom(path);
- }
-
- @Override
- public DataObject dataObjectFromDataDom(
- final InstanceIdentifier<? extends DataObject> path,
- final CompositeNode result) throws DeserializationException {
- return delegate.dataObjectFromDataDom(path, result);
- }
-
- @Override
- public InstanceIdentifier<?> fromDataDom(final YangInstanceIdentifier entry)
- throws DeserializationException {
- return delegate.fromDataDom(entry);
- }
-
- @Override
- public Set<QName> getRpcQNamesFor(final Class<? extends RpcService> service) {
- return delegate.getRpcQNamesFor(service);
- }
-
- @Override
- public Optional<Class<? extends RpcService>> getRpcServiceClassFor(final String namespace, final String revision) {
- return delegate.getRpcServiceClassFor(namespace,revision);
- }
-
- @Override
- public DataContainer dataObjectFromDataDom(final Class<? extends DataContainer> inputClass, final CompositeNode domInput) {
- return delegate.dataObjectFromDataDom(inputClass, domInput);
- }
-
- @Override
- public void close() {
- if(delegate != null) {
- delegate = null;
-
- try {
- bundleContext.ungetService(reference);
- } catch (IllegalStateException e) {
- // Indicates the BundleContext is no longer valid which can happen normally on shutdown.
- LOG.debug( "Error unregistering service", e );
- }
-
- bundleContext= null;
- reference = null;
- }
- }
-
- @Override
- public BindingIndependentMappingService getDelegate() {
- return delegate;
- }
- }
}
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-test-model</artifactId>
- <version>1.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
- <version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
- <version>1.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
- <version>1.5</version>
</dependency>
<dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
- <version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
builder.setInstanceIdentifierValue(
InstanceIdentifierUtils.toSerializable((YangInstanceIdentifier) value, context));
} else if(value instanceof Set) {
- Set set = (Set) value;
+ Set<?> set = (Set<?>) value;
if (!set.isEmpty()) {
for (Object o : set) {
if (o instanceof String) {
return InstanceIdentifierUtils.fromSerializable(
node.getInstanceIdentifierValue(), context);
} else if(node.getIntValueType() == ValueType.BITS_TYPE.ordinal()){
- return new HashSet(node.getBitsValueList());
+ return new HashSet<>(node.getBitsValueList());
} else if(node.getIntValueType() == ValueType.BINARY_TYPE.ordinal()){
return node.getBytesValue().toByteArray();
}
BIG_DECIMAL_TYPE,
BINARY_TYPE;
- private static Map<Class, ValueType> types = new HashMap<>();
+ private static Map<Class<?>, ValueType> types = new HashMap<>();
static {
types.put(String.class, STRING_TYPE);
}
}
- private void writeObjSet(Set set) throws IOException {
+ private void writeObjSet(Set<?> set) throws IOException {
if(!set.isEmpty()){
writer.writeInt(set.size());
for(Object o : set){
writer.writeShort((Short) value);
break;
case ValueTypes.BITS_TYPE:
- writeObjSet((Set) value);
+ writeObjSet((Set<?>) value);
break;
case ValueTypes.YANG_IDENTIFIER_TYPE:
writeYangInstanceIdentifier((YangInstanceIdentifier) value);
public static final byte BIG_INTEGER_TYPE = 10;
public static final byte BIG_DECIMAL_TYPE = 11;
- private static Map<Class, Byte> types = new HashMap<>();
+ private static Map<Class<?>, Byte> types = new HashMap<>();
static {
types.put(String.class, Byte.valueOf(STRING_TYPE));
package org.opendaylight.controller.cluster.datastore.node.utils;
+import com.google.common.collect.ImmutableSet;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.util.TestModel;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
import static junit.framework.TestCase.assertEquals;
public class PathUtilsTest {
}
private YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier(){
- Set<QName> childNames = new HashSet();
- childNames.add(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics"));
+ Set<QName> childNames = ImmutableSet.of(QNameFactory.create("(urn:opendaylight:flow:table:statistics?revision=2013-12-15)flow-table-statistics"));
return new YangInstanceIdentifier.AugmentationIdentifier(childNames);
}
nodeBuilder.build());
assertTrue(o instanceof Set);
- assertTrue(((Set)o).contains("foo"));
- assertTrue(((Set) o).contains("bar"));
+ assertTrue(((Set<?>)o).contains("foo"));
+ assertTrue(((Set<?>) o).contains("bar"));
}
package org.opendaylight.controller.cluster.datastore.util;
+import com.google.common.collect.ImmutableSet;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.cluster.datastore.node.utils.serialization.QNameDeSerializationContext;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
public class InstanceIdentifierUtilsTest {
@Test
public void testAugmentationIdentifier() {
- YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.AugmentationIdentifier(new HashSet(
- Arrays.asList(TEST_QNAME)));
+ YangInstanceIdentifier.PathArgument p1 = new YangInstanceIdentifier.AugmentationIdentifier(
+ ImmutableSet.of(TEST_QNAME));
List<YangInstanceIdentifier.PathArgument> arguments = new ArrayList<>();
import akka.actor.ActorSelection;
import akka.dispatch.OnComplete;
import com.google.common.base.Preconditions;
-import java.util.AbstractMap.SimpleEntry;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
private interface State {
boolean isReady();
- SimpleEntry<Object, List<Future<ActorSelection>>> getReadyFutures();
-
- void setReadyFutures(Object txIdentifier, List<Future<ActorSelection>> readyFutures);
+ List<Future<ActorSelection>> getPreviousReadyFutures();
}
private static class Allocated implements State {
- private volatile SimpleEntry<Object, List<Future<ActorSelection>>> readyFutures;
+ private final ChainedTransactionProxy transaction;
- @Override
- public boolean isReady() {
- return readyFutures != null;
+ Allocated(ChainedTransactionProxy transaction) {
+ this.transaction = transaction;
}
@Override
- public SimpleEntry<Object, List<Future<ActorSelection>>> getReadyFutures() {
- return readyFutures != null ? readyFutures : EMPTY_READY_FUTURES;
+ public boolean isReady() {
+ return transaction.isReady();
}
@Override
- public void setReadyFutures(Object txIdentifier, List<Future<ActorSelection>> readyFutures) {
- this.readyFutures = new SimpleEntry<>(txIdentifier, readyFutures);
+ public List<Future<ActorSelection>> getPreviousReadyFutures() {
+ return transaction.getReadyFutures();
}
}
private static abstract class AbstractDefaultState implements State {
@Override
- public SimpleEntry<Object, List<Future<ActorSelection>>> getReadyFutures() {
- return EMPTY_READY_FUTURES;
- }
-
- @Override
- public void setReadyFutures(Object txIdentifier, List<Future<ActorSelection>> readyFutures) {
- throw new IllegalStateException("No transaction is allocated");
+ public List<Future<ActorSelection>> getPreviousReadyFutures() {
+ return Collections.emptyList();
}
}
}
};
- private static final SimpleEntry<Object, List<Future<ActorSelection>>> EMPTY_READY_FUTURES =
- new SimpleEntry<Object, List<Future<ActorSelection>>>("",
- Collections.<Future<ActorSelection>>emptyList());
-
- private static final AtomicReferenceFieldUpdater<TransactionChainProxy, State> STATE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(TransactionChainProxy.class, State.class, "state");
+ private static final AtomicInteger counter = new AtomicInteger(0);
private final ActorContext actorContext;
private final String transactionChainId;
- private volatile State state = IDLE_STATE;
- private static final AtomicInteger counter = new AtomicInteger(0);
+ private volatile State currentState = IDLE_STATE;
public TransactionChainProxy(ActorContext actorContext) {
this.actorContext = actorContext;
- transactionChainId = actorContext.getCurrentMemberName() + "-transaction-chain-" + counter.incrementAndGet();
+ transactionChainId = actorContext.getCurrentMemberName() + "-txn-chain-" + counter.incrementAndGet();
}
public String getTransactionChainId() {
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- checkReadyState();
- return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY);
+ State localState = currentState;
+ checkReadyState(localState);
+
+ return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY,
+ transactionChainId, localState.getPreviousReadyFutures());
}
@Override
@Override
public void close() {
- state = CLOSED_STATE;
+ currentState = CLOSED_STATE;
// Send a close transaction chain request to each and every shard
actorContext.broadcast(new CloseTransactionChain(transactionChainId));
}
private ChainedTransactionProxy allocateWriteTransaction(TransactionProxy.TransactionType type) {
- checkReadyState();
+ State localState = currentState;
+
+ checkReadyState(localState);
- ChainedTransactionProxy txProxy = new ChainedTransactionProxy(actorContext, type);
- STATE_UPDATER.compareAndSet(this, IDLE_STATE, new Allocated());
+ // Pass the ready Futures from the previous Tx.
+ ChainedTransactionProxy txProxy = new ChainedTransactionProxy(actorContext, type,
+ transactionChainId, localState.getPreviousReadyFutures());
+
+ currentState = new Allocated(txProxy);
return txProxy;
}
- private void checkReadyState() {
- Preconditions.checkState(state.isReady(), "Previous transaction %s is not ready yet",
- state.getReadyFutures().getKey());
+ private void checkReadyState(State state) {
+ Preconditions.checkState(state.isReady(), "Previous transaction is not ready yet");
}
- private class ChainedTransactionProxy extends TransactionProxy {
+ private static class ChainedTransactionProxy extends TransactionProxy {
+
+ /**
+ * Stores the ready Futures from the previous Tx in the chain.
+ */
+ private final List<Future<ActorSelection>> previousReadyFutures;
+
+ /**
+ * Stores the ready Futures from this transaction when it is readied.
+ */
+ private volatile List<Future<ActorSelection>> readyFutures;
- ChainedTransactionProxy(ActorContext actorContext, TransactionType transactionType) {
+ private ChainedTransactionProxy(ActorContext actorContext, TransactionType transactionType,
+ String transactionChainId, List<Future<ActorSelection>> previousReadyFutures) {
super(actorContext, transactionType, transactionChainId);
+ this.previousReadyFutures = previousReadyFutures;
+ }
+
+ List<Future<ActorSelection>> getReadyFutures() {
+ return readyFutures;
+ }
+
+ boolean isReady() {
+ return readyFutures != null;
}
@Override
protected void onTransactionReady(List<Future<ActorSelection>> readyFutures) {
- LOG.debug("onTransactionReady {} pending readyFutures size {} chain {}", getIdentifier(), readyFutures.size(), TransactionChainProxy.this.transactionChainId);
- state.setReadyFutures(getIdentifier(), readyFutures);
+ LOG.debug("onTransactionReady {} pending readyFutures size {} chain {}", getIdentifier(),
+ readyFutures.size(), getTransactionChainId());
+ this.readyFutures = readyFutures;
}
/**
final Object serializedCreateMessage) {
// Check if there are any previous ready Futures, otherwise let the super class handle it.
- // The second check is done to ensure the the previous ready Futures aren't for this
- // Tx instance as deadlock would occur if we tried to wait on our own Futures. This can
- // occur in this scenario:
- //
- // - the TransactionProxy is created and the client does a write.
- //
- // - the TransactionProxy then attempts to create the shard Tx. However it first
- // sends a FindPrimaryShard message to the shard manager to find the local shard
- // This call is done async.
- //
- // - the client submits the Tx and the TransactionProxy is readied and we cache
- // the ready Futures here.
- //
- // - then the FindPrimaryShard call completes and this method is called to create
- // the shard Tx. However the cached Futures were from the ready on this Tx. If we
- // tried to wait on them, it would cause a form of deadlock as the ready Future
- // would be waiting on the Tx create Future and vice versa.
- SimpleEntry<Object, List<Future<ActorSelection>>> readyFuturesEntry = state.getReadyFutures();
- List<Future<ActorSelection>> readyFutures = readyFuturesEntry.getValue();
- if(readyFutures.isEmpty() || getIdentifier().equals(readyFuturesEntry.getKey())) {
+ if(previousReadyFutures.isEmpty()) {
return super.sendCreateTransaction(shard, serializedCreateMessage);
}
// Combine the ready Futures into 1.
Future<Iterable<ActorSelection>> combinedFutures = akka.dispatch.Futures.sequence(
- readyFutures, actorContext.getActorSystem().dispatcher());
+ previousReadyFutures, getActorContext().getActorSystem().dispatcher());
// Add a callback for completion of the combined Futures.
final Promise<Object> createTxPromise = akka.dispatch.Futures.promise();
// A Ready Future failed so fail the returned Promise.
createTxPromise.failure(failure);
} else {
+ LOG.debug("Previous Tx readied - sending CreateTransaction for {} on chain {}",
+ getIdentifier(), getTransactionChainId());
+
// Send the CreateTx message and use the resulting Future to complete the
// returned Promise.
- createTxPromise.completeWith(actorContext.executeOperationAsync(shard,
+ createTxPromise.completeWith(getActorContext().executeOperationAsync(shard,
serializedCreateMessage));
}
}
};
- combinedFutures.onComplete(onComplete, actorContext.getActorSystem().dispatcher());
+ combinedFutures.onComplete(onComplete, getActorContext().getActorSystem().dispatcher());
return createTxPromise.future();
}
return transactionChainId;
}
+ protected ActorContext getActorContext() {
+ return actorContext;
+ }
+
/**
* Interface for a transaction operation to be invoked later.
*/
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
}};
}
+ @Test
+ public void testCreateChainedTransactionsInQuickSuccession() throws Exception{
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionsInQuickSuccession", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ int nTxs = 20;
+ List<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(nTxs);
+ for(int i = 0; i < nTxs; i++) {
+ DOMStoreReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
+
+ rwTx.merge(TestModel.TEST_PATH, testNode);
+
+ cohorts.add(rwTx.ready());
+
+ }
+
+ for(DOMStoreThreePhaseCommitCohort cohort: cohorts) {
+ doCommit(cohort);
+ }
+
+ txChain.close();
+
+ cleanup(dataStore);
+ }};
+ }
+
+ @Test
+ public void testCreateChainedTransactionAfterEmptyTxReadied() throws Exception{
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionAfterEmptyTxReadied", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ DOMStoreReadWriteTransaction rwTx1 = txChain.newReadWriteTransaction();
+
+ rwTx1.ready();
+
+ DOMStoreReadWriteTransaction rwTx2 = txChain.newReadWriteTransaction();
+
+ Optional<NormalizedNode<?, ?>> optional = rwTx2.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
+ assertEquals("isPresent", false, optional.isPresent());
+
+ txChain.close();
+
+ cleanup(dataStore);
+ }};
+ }
+
@Test
public void testCreateChainedTransactionWhenPreviousNotReady() throws Throwable {
new IntegrationTestKit(getSystem()) {{
super(actorSystem);
}
- protected void waitForLogMessage(final Class logLevel, ActorRef subject, String logMessage){
+ protected void waitForLogMessage(final Class<?> logLevel, ActorRef subject, String logMessage){
// Wait for a specific log message to show up
final boolean result =
new JavaTestKit.EventFilter<Boolean>(logLevel
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-inmemory-datastore</artifactId>
- <version>1.2.0-SNAPSHOT</version>
-
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
private DataNormalizer mockNormalizer() throws DataNormalizationException {
final DataNormalizer mock = mock(DataNormalizer.class);
- doReturn(new AbstractMap.SimpleEntry<YangInstanceIdentifier, NormalizedNode<?, ?>>(id, normalizedNode) {})
+ doReturn(new AbstractMap.SimpleEntry<YangInstanceIdentifier, NormalizedNode<?, ?>>(id, normalizedNode))
.when(mock).toNormalized(any(YangInstanceIdentifier.class), any(CompositeNode.class));
doReturn(compositeNode).when(mock).toLegacy(any(YangInstanceIdentifier.class), any(NormalizedNode.class));
doReturn(id).when(mock).toLegacy(any(YangInstanceIdentifier.class));
return cacheLoadedSuccessfuly;
}
- private static Map<Class, Set<Class>> superClassMap = new HashMap<Class, Set<Class>>();
+ private static Map<Class<?>, Set<Class<?>>> superClassMap = new HashMap<>();
- public static Set<Class> getInheritance(Class myObjectClass,
- Class returnType) {
+ public static Set<Class<?>> getInheritance(Class<?> myObjectClass,
+ Class<?> returnType) {
if (returnType != null && myObjectClass.equals(returnType)) {
- return new HashSet<Class>();
+ return new HashSet<>();
}
- Set<Class> result = superClassMap.get(myObjectClass);
+ Set<Class<?>> result = superClassMap.get(myObjectClass);
if (result != null) {
return result;
}
- result = new HashSet<Class>();
+ result = new HashSet<>();
superClassMap.put(myObjectClass, result);
if (returnType != null) {
if (!returnType.equals(myObjectClass)) {
- Class mySuperClass = myObjectClass.getSuperclass();
+ Class<?> mySuperClass = myObjectClass.getSuperclass();
while (mySuperClass != null) {
result.add(mySuperClass);
mySuperClass = mySuperClass.getSuperclass();
return result;
}
- public static Set<Class> collectInterfaces(Class cls) {
- Set<Class> result = new HashSet();
- Class myInterfaces[] = cls.getInterfaces();
+ public static Set<Class<?>> collectInterfaces(Class<?> cls) {
+ Set<Class<?>> result = new HashSet<>();
+ Class<?> myInterfaces[] = cls.getInterfaces();
if (myInterfaces != null) {
- for (Class in : myInterfaces) {
+ for (Class<?> in : myInterfaces) {
result.add(in);
result.addAll(collectInterfaces(in));
}
map.put(blNode.getBluePrintNodeName(), blNode);
}
- public Class getGenericType(ParameterizedType type) {
+ public Class<?> getGenericType(ParameterizedType type) {
Type[] typeArguments = type.getActualTypeArguments();
for (Type typeArgument : typeArguments) {
if (typeArgument instanceof ParameterizedType) {
ParameterizedType pType = (ParameterizedType) typeArgument;
- return (Class) pType.getRawType();
+ return (Class<?>) pType.getRawType();
} else if (typeArgument instanceof Class) {
- return (Class) typeArgument;
+ return (Class<?>) typeArgument;
}
}
return null;
}
- public Class getMethodReturnTypeFromGeneric(Method m) {
+ public Class<?> getMethodReturnTypeFromGeneric(Method m) {
Type rType = m.getGenericReturnType();
if (rType instanceof ParameterizedType) {
return getGenericType((ParameterizedType) rType);
this.children.add(ch);
}
- public boolean isModelChild(Class p) {
+ public boolean isModelChild(Class<?> p) {
if (this.relations.size() == 0) {
return false;
}
return "Unknown";
}
- public Class getInterface() {
+ public Class<?> getInterface() {
return this.myInterface;
}
}
}
- public List execute(Object o) {
- List result = new LinkedList();
+ public List<?> execute(Object o) {
+ List<Object> result = new LinkedList<>();
if (o == null) {
return null;
}
if (Set.class.isAssignableFrom(o.getClass())) {
- Set lst = (Set) o;
+ Set<?> lst = (Set<?>) o;
for (Object oo : lst) {
addToResult(result, execute(oo));
}
return result;
} else if (List.class.isAssignableFrom(o.getClass())) {
- List lst = (List) o;
+ List<?> lst = (List<?>) o;
for (Object oo : lst) {
addToResult(result, execute(oo));
}
return result;
}
- public static void addToResult(List result, Object o) {
+ private static void addToResult(List<Object> result, Object o) {
if (o == null) {
return;
}
if (Set.class.isAssignableFrom(o.getClass())) {
- Set lst = (Set) o;
+ Set<?> lst = (Set<?>) o;
for (Object oo : lst) {
result.add(oo);
}
} else if (List.class.isAssignableFrom(o.getClass())) {
- List lst = (List) o;
+ List<?> lst = (List<?>) o;
for (Object oo : lst) {
result.add(oo);
}
private String name = null;
private String tableName = null;
private int charWidth = -1;
- private Class type = null;
+ private Class<?> type = null;
private transient Object bluePrintNode = null;
private String origName = null;
private String origTableName = null;
types.put(Status.class, Status.class);
}
- public static boolean isColumnType(Class cls) {
+ public static boolean isColumnType(Class<?> cls) {
return types.containsKey(cls);
}
return "NULL";
}
- public static Class getTypeForODLColumn(Object odlNode){
+ public static Class<?> getTypeForODLColumn(Object odlNode){
Object type = get(odlNode,"type");
if(type instanceof Uint32 || type instanceof Uint64){
return long.class;
return 1;
}
- public int isObjectFitCriteria(Object element, Class cls) {
+ public int isObjectFitCriteria(Object element, Class<?> cls) {
Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria.get(cls
.getName());
if (tblCriteria == null) {
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Messages.BucketStoreMessages.UpdateRemoteBuckets.class);
}
- private JavaTestKit createProbeForMessage(ActorSystem node, ActorPath subjectPath, final Class clazz) {
+ private JavaTestKit createProbeForMessage(ActorSystem node, ActorPath subjectPath, final Class<?> clazz) {
final JavaTestKit probe = new JavaTestKit(node);
ConditionalProbe conditionalProbe =
<artifactId>sal-rest-docgen</artifactId>
<packaging>bundle</packaging>
- <properties>
- <jaxrs-api.version>3.0.4.Final</jaxrs-api.version>
- </properties>
-
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
- <version>${jaxrs-api.version}</version>
</dependency>
<dependency>
notifications.add(new QName(notificationType.toString()));
String notificationStreamName = RemoteStreamTools.createNotificationStream(salRemoteService, notifications);
final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext, notificationStreamName);
- RemoteNotificationListener remoteNotificationListener = new RemoteNotificationListener(listener);
+ RemoteNotificationListener<T> remoteNotificationListener = new RemoteNotificationListener<T>(listener);
final ListenerRegistration<?> listenerRegistration = restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName)))
.registerNotificationListener(remoteNotificationListener);
package org.opendaylight.controller.sal.restconf.broker.listeners;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.Notification;
-public class RemoteNotificationListener implements org.opendaylight.yangtools.yang.binding.NotificationListener {
+public class RemoteNotificationListener<T extends Notification> implements org.opendaylight.yangtools.yang.binding.NotificationListener {
- org.opendaylight.controller.sal.binding.api.NotificationListener listener;
+ NotificationListener<T> listener;
- public RemoteNotificationListener(NotificationListener listener){
+ public RemoteNotificationListener(NotificationListener<T> listener){
this.listener = listener;
}
- public NotificationListener getListener(){
+ public NotificationListener<T> getListener() {
return this.listener;
}
import org.opendaylight.yangtools.yang.binding.Notification;
-public class SalNotificationListener implements NotificationListener {
- private NotificationListener notificationListener;
+public class SalNotificationListener<T extends Notification> implements NotificationListener<T> {
+ private NotificationListener<T> notificationListener;
- public SalNotificationListener( NotificationListener notificationListener){
+ public SalNotificationListener( NotificationListener<T> notificationListener){
this.notificationListener = notificationListener;
}
@Override
public void onNotification(Notification notification) {
- this.notificationListener.onNotification(notification);
+ this.notificationListener.onNotification((T)notification);
}
}
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Util.checkType(listOfStrings, List.class);
StringBuilder b = new StringBuilder();
- for (Object character: (List)listOfStrings) {
+ for (Object character: (List<?>)listOfStrings) {
Util.checkType(character, String.class);
b.append(character);
}
package org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc;
import static org.junit.Assert.assertEquals;
-
+import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
return Arrays.asList(new Object[][] {
// With namespaces
{ "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']/b:listener-state[b:peer-id='127.0.0.1']",
- new HashMap<String, String>() {{
- put("listener-state", "127.0.0.1");
- }}},
+ new HashMap<>(ImmutableMap.of("listener-state", "127.0.0.1"))},
{ "/a:modules/a:module[a:name='instanceName'][a:type='moduleType']",
null},
{ "/modules/module[name=instanceName and type=moduleType]/inner[key=\"b\"]", Collections.singletonMap("inner", "b")},
{ "/modules/module[name=instanceName and type=\"moduleType\"]/inner[key2=a]/inner2[key=b]",
- new HashMap<String, String>() {{
- put("inner", "a");
- put("inner2", "b");
- }}
+ new HashMap<>(ImmutableMap.of("inner", "a", "inner2", "b"))
},
});
}
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
negotiator.channelActive(null);
- Set caps = Sets.newSet("a", "b");
+ Set<String> caps = Sets.newSet("a", "b");
NetconfHelloMessage helloServerMessage = NetconfHelloMessage.createServerHello(caps, 10);
negotiator.handleMessage(helloServerMessage);
verify(promise).setSuccess(anyObject());
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, exiMessage);
negotiator.channelActive(null);
- Set caps = Sets.newSet("exi:1.0");
+ Set<String> caps = Sets.newSet("exi:1.0");
NetconfHelloMessage helloMessage = NetconfHelloMessage.createServerHello(caps, 10);
doAnswer(new Answer<Object>() {
private Channel channel;
private ChannelFuture channelFuture;
- Set caps;
+ Set<String> caps;
private NetconfHelloMessage helloMessage;
private NetconfMessage message;
private NetconfClientSessionListener sessionListener;
public void testGetSchemas3() throws Exception {
doReturn("").when(managementSession).toString();
Capability cap = mock(Capability.class);
- Set caps = Sets.newHashSet(cap);
- Set services = Sets.newHashSet(operationService);
+ Set<Capability> caps = Sets.newHashSet(cap);
+ Set<NetconfOperationService> services = Sets.newHashSet(operationService);
doReturn(snapshot).when(operationProvider).openSnapshot(anyString());
doReturn(services).when(snapshot).getServices();
doReturn(caps).when(operationService).getCapabilities();
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
<executions>
<execution>
<goals>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.12</version>
<configuration>
<failsOnError>false</failsOnError>
<failOnViolation>false</failOnViolation>
if (classes == null || classes.size() == 0) return;
Map<String,String> names = new HashMap<String,String>();
StringBuilder conflictsMsg = new StringBuilder();
- for (Class c : classes) {
- XmlRootElement root = (XmlRootElement) c.getAnnotation(XmlRootElement.class);
+ for (Class<?> c : classes) {
+ XmlRootElement root = c.getAnnotation(XmlRootElement.class);
if (root == null) continue;
String rootName = root.name();
if ("##default".equals(rootName)) {
@QueryParam("name") String queryFirewallPolicyName,
@QueryParam("description") String querySecurityPolicyDescription,
@QueryParam("shared") String querySecurityPolicyIsShared,
- @QueryParam("firewall_rules") List querySecurityPolicyFirewallRules,
+ @QueryParam("firewall_rules") List<String> querySecurityPolicyFirewallRules,
@QueryParam("audited") Boolean querySecurityPolicyIsAudited,
// pagination
@QueryParam("limit") String limit,
package org.opendaylight.controller.networkconfig.neutron.northbound;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronNetworkRequest implements INeutronRequest {
+public class NeutronNetworkRequest implements INeutronRequest<NeutronNetwork> {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
singletonNetwork = net;
}
+ @Override
public NeutronNetwork getSingleton() {
return singletonNetwork;
}
+ @Override
public boolean isSingleton() {
return (singletonNetwork != null);
}
+ @Override
public List<NeutronNetwork> getBulk() {
return bulkRequest;
}
package org.opendaylight.controller.networkconfig.neutron.northbound;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-public class NeutronPortRequest implements INeutronRequest {
+public class NeutronPortRequest implements INeutronRequest<NeutronPort> {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
singletonPort = port;
}
+ @Override
public NeutronPort getSingleton() {
return singletonPort;
}
+ @Override
public boolean isSingleton() {
return (singletonPort != null);
}
+ @Override
public List<NeutronPort> getBulk() {
return bulkRequest;
}
package org.opendaylight.controller.networkconfig.neutron.northbound;
import java.util.List;
-
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
-
-public class NeutronSubnetRequest implements INeutronRequest {
+public class NeutronSubnetRequest implements INeutronRequest<NeutronSubnet> {
// See OpenStack Network API v2.0 Reference for description of
// annotated attributes
links = null;
}
+ @Override
public NeutronSubnet getSingleton() {
return singletonSubnet;
}
+ @Override
public List<NeutronSubnet> getBulk() {
return bulkRequest;
}
+ @Override
public boolean isSingleton() {
return (singletonSubnet != null);
}
package org.opendaylight.controller.networkconfig.neutron.northbound;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import javax.ws.rs.core.UriInfo;
import org.opendaylight.controller.networkconfig.neutron.INeutronObject;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import javax.ws.rs.core.UriInfo;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
public class PaginatedRequestFactory {
public static class PaginationResults<T extends INeutronObject> {
}
}
- public static <T extends INeutronObject> INeutronRequest createRequest(Integer limit, String marker,
+ /*
+ * SuppressWarnings is needed because the compiler does not understand that we
+ * are actually safe here.
+ *
+ * FIXME: the only caller performs a cast back, so this is not actually necessary.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends INeutronObject> INeutronRequest<T> createRequest(Integer limit, String marker,
Boolean pageReverse,
UriInfo uriInfo,
List<T> collection,
Class<T> clazz) {
- PaginationResults results = _paginate(limit, marker, pageReverse, uriInfo, collection);
+ PaginationResults<T> results = _paginate(limit, marker, pageReverse, uriInfo, collection);
if (clazz.equals(NeutronNetwork.class)){
- return new NeutronNetworkRequest(results.collection, results.links);
+ return (INeutronRequest<T>) new NeutronNetworkRequest((List<NeutronNetwork>) results.collection, results.links);
}
if (clazz.equals(NeutronSubnet.class)){
- return new NeutronSubnetRequest(results.collection, results.links);
+ return (INeutronRequest<T>) new NeutronSubnetRequest((List<NeutronSubnet>) results.collection, results.links);
}
if (clazz.equals(NeutronPort.class)){
- return new NeutronPortRequest(results.collection, results.links);
+ return (INeutronRequest<T>) new NeutronPortRequest((List<NeutronPort>) results.collection, results.links);
}
return null;
}
- private static <T extends INeutronObject> PaginationResults _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List<T> collection) {
+ private static <T extends INeutronObject> PaginationResults<T> _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List<T> collection) {
List<NeutronPageLink> links = new ArrayList<>();
Integer startPos = null;
String startMarker;
class MarkerObject implements INeutronObject {
private String id;
+ @Override
public String getID() {
return id;
}
+ @Override
public void setID(String id) {
this.id = id;
}
links.add(previous);
}
- return new PaginationResults(collection, links);
+ return new PaginationResults<T>(collection, links);
}
}
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>${bundle.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>topologymanager</artifactId>
- <version>${topologymanager.version}</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>${bundle.plugin.version}</version>
<configuration>
<instructions>
<Import-Package>org.apache.felix.service.command,