import com.google.common.util.concurrent.Futures;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
import org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.connection.ConnectionReconciliationTask;
import org.opendaylight.ovsdb.hwvtepsouthbound.transact.DependencyQueue;
import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.HwvtepGlobalRemoveCommand;
-import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionCommand;
import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvoker;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
(InstanceIdentifier<Node>) HwvtepSouthboundUtil
.getInstanceIdentifierCodec().bindingDeserializer(entity.getId());
- txInvoker.invoke(new TransactionCommand() {
- @Override
- public void execute(ReadWriteTransaction transaction) {
- transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
- }
- });
+ txInvoker.invoke(transaction -> transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid));
}
private HwvtepConnectionInstance getConnectionInstanceFromEntity(Entity entity) {
}
public void scheduleTransaction(final TransactCommand transactCommand) {
- dependencyQueue.submit(new Runnable() {
- @Override
- public void run() {
- connectionInstance.transact(transactCommand);
- }
- });
+ dependencyQueue.submit(() -> connectionInstance.transact(transactCommand));
}
public void clearInTransitData() {
/*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ * Copyright © 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
public void enqueueForRetry(final ReconciliationTask task) {
LOG.trace("Reconciliation task re-queued for re-execution {}",task);
reconTaskManager.cacheTask(task, taskTriager.schedule(
- new Runnable() {
- @Override
- public void run() {
- task.checkReadinessAndProcess();
- }
- }, task.retryDelayInMills(), TimeUnit.MILLISECONDS
+ () -> task.checkReadinessAndProcess(), task.retryDelayInMills(), TimeUnit.MILLISECONDS
)
);
}
*/
package org.opendaylight.ovsdb.hwvtepsouthbound.reconciliation.configuration;
-import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
return null;
}
Iterable<LocalUcastMacs> removedLocalUcastMacs = Iterables.filter(localUcastMacs,
- new Predicate<LocalUcastMacs>() {
- @Override
- public boolean apply(LocalUcastMacs mac) {
- String ls = mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
- getHwvtepNodeName().getValue();
- if (removedSwitchNames.contains(ls)) {
- return true;
- }
- return false;
- }
- });
+ mac -> removedSwitchNames.contains(
+ mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
+ getHwvtepNodeName().getValue()));
return Lists.newArrayList(removedLocalUcastMacs);
}
return null;
}
Iterable<LocalMcastMacs> removedLocalMcastMacs = Iterables.filter(localMcastMacs,
- new Predicate<LocalMcastMacs>() {
- @Override
- public boolean apply(LocalMcastMacs mac) {
- String ls = mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
- getHwvtepNodeName().getValue();
- if (removedSwitchNames.contains(ls)) {
- return true;
- }
- return false;
- }
- });
+ mac -> removedSwitchNames.contains(
+ mac.getLogicalSwitchRef().getValue().firstKeyOf(LogicalSwitches.class).
+ getHwvtepNodeName().getValue()));
return Lists.newArrayList(removedLocalMcastMacs);
}
/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright © 2016, 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
LinkedBlockingQueue<DependentJob> queue) {
final List<DependentJob> readyJobs = getReadyJobs(queue);
if (readyJobs.size() > 0) {
- executorService.submit(new Runnable() {
+ executorService.submit(() -> hwvtepConnectionInstance.transact(new TransactCommand() {
@Override
- public void run() {
- hwvtepConnectionInstance.transact(new TransactCommand() {
- @Override
- public void execute(TransactionBuilder transactionBuilder) {
- HwvtepOperationalState operationalState = new HwvtepOperationalState(hwvtepConnectionInstance);
- for (DependentJob job : readyJobs) {
- job.onDependencyResolved(operationalState, transactionBuilder);
- }
- }
-
- @Override
- public void onConfigUpdate(TransactionBuilder transaction, InstanceIdentifier nodeIid,
- Identifiable data, InstanceIdentifier key, Object... extraData) {
- }
-
- @Override
- public void doDeviceTransaction(TransactionBuilder transaction, InstanceIdentifier nodeIid,
- Identifiable data, InstanceIdentifier key, Object... extraData) {
- }
- });
+ public void execute(TransactionBuilder transactionBuilder) {
+ HwvtepOperationalState operationalState = new HwvtepOperationalState(hwvtepConnectionInstance);
+ for (DependentJob job : readyJobs) {
+ job.onDependencyResolved(operationalState, transactionBuilder);
+ }
}
- });
+
+ @Override
+ public void onConfigUpdate(TransactionBuilder transaction, InstanceIdentifier nodeIid,
+ Identifiable data, InstanceIdentifier key, Object... extraData) {
+ }
+
+ @Override
+ public void doDeviceTransaction(TransactionBuilder transaction, InstanceIdentifier nodeIid,
+ Identifiable data, InstanceIdentifier key, Object... extraData) {
+ }
+ }));
}
}
/*
- * Copyright (c) 2014, 2015 EBay Software Foundation and others. All rights reserved.
+ * Copyright © 2014, 2017 EBay Software Foundation and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
public static final ListenableFuture<List<OperationResult>> transformTransactResponse(
ListenableFuture<List<JsonNode>> transactResponseFuture, final List<Operation> operations) {
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- return Futures.transform(transactResponseFuture, new Function<List<JsonNode>, List<OperationResult>>() {
- @Override
- public List<OperationResult> apply(List<JsonNode> jsonNodes) {
+ return Futures.transform(transactResponseFuture,
+ (Function<List<JsonNode>, List<OperationResult>>) jsonNodes -> {
final List<OperationResult> operationResults = new ArrayList<>();
for (int index = 0; index < jsonNodes.size(); index++) {
JsonNode jsonNode = jsonNodes.get(index);
}
return operationResults;
- }
- });
+ });
}
}
import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo.ConnectionType;
import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo.SocketConnectionType;
import org.opendaylight.ovsdb.lib.error.ParsingException;
-import org.opendaylight.ovsdb.lib.jsonrpc.Params;
import org.opendaylight.ovsdb.lib.message.MonitorRequest;
import org.opendaylight.ovsdb.lib.message.OvsdbRPC;
import org.opendaylight.ovsdb.lib.message.TableUpdate;
final MonitorCallBack callback) {
final ImmutableMap<String, MonitorRequest> reqMap = Maps.uniqueIndex(monitorRequest,
- new Function<MonitorRequest, String>() {
- @Override
- public String apply(MonitorRequest input) {
- return input.getTableName();
- }
- });
+ input -> input.getTableName());
final MonitorHandle monitorHandle = new MonitorHandle(UUID.randomUUID().toString());
registerCallback(monitorHandle, callback, dbSchema);
- ListenableFuture<JsonNode> monitor = rpc.monitor(new Params() {
- @Override
- public List<Object> params() {
- return Lists.<Object>newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap);
- }
- });
+ ListenableFuture<JsonNode> monitor = rpc.monitor(
+ () -> Lists.newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap));
JsonNode result;
try {
result = monitor.get();
final MonitorCallBack callback) {
final ImmutableMap<String, MonitorRequest> reqMap = Maps.uniqueIndex(monitorRequest,
- new Function<MonitorRequest, String>() {
- @Override
- public String apply(MonitorRequest input) {
- return input.getTableName();
- }
- });
+ input -> input.getTableName());
registerCallback(monitorHandle, callback, dbSchema);
- ListenableFuture<JsonNode> monitor = rpc.monitor(new Params() {
- @Override
- public List<Object> params() {
- return Lists.<Object>newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap);
- }
- });
+ ListenableFuture<JsonNode> monitor = rpc.monitor(
+ () -> Lists.newArrayList(dbSchema.getName(), monitorHandle.getId(), reqMap));
JsonNode result;
try {
result = monitor.get();
@Override
public void cancelMonitor(final MonitorHandle handler) {
- ListenableFuture<JsonNode> cancelMonitor = rpc.monitor_cancel(new Params() {
- @Override
- public List<Object> params() {
- return Lists.<Object>newArrayList(handler.getId());
- }
- });
+ ListenableFuture<JsonNode> cancelMonitor = rpc.monitor_cancel(() -> Lists.newArrayList(handler.getId()));
JsonNode result = null;
try {
if (databaseSchema == null) {
return Futures.transform(
- getSchemaFromDevice(Lists.newArrayList(database)),
- new Function<Map<String, DatabaseSchema>, DatabaseSchema>() {
- @Override
- public DatabaseSchema apply(Map<String, DatabaseSchema> result) {
- if (result.containsKey(database)) {
- DatabaseSchema dbSchema = result.get(database);
- dbSchema.populateInternallyGeneratedColumns();
- OvsdbClientImpl.this.schemas.put(database, dbSchema);
- return dbSchema;
- } else {
- return null;
- }
- }
- }, executorService);
+ getSchemaFromDevice(Lists.newArrayList(database)),
+ (Function<Map<String, DatabaseSchema>, DatabaseSchema>) result -> {
+ if (result.containsKey(database)) {
+ DatabaseSchema dbSchema = result.get(database);
+ dbSchema.populateInternallyGeneratedColumns();
+ OvsdbClientImpl.this.schemas.put(database, dbSchema);
+ return dbSchema;
+ } else {
+ return null;
+ }
+ }, executorService);
} else {
return Futures.immediateFuture(databaseSchema);
}
}
Futures.transform(rpc.get_schema(Lists.newArrayList(dbNames.get(0))),
- new com.google.common.base.Function<JsonNode, Void>() {
- @Override
- public Void apply(JsonNode jsonNode) {
- try {
- schema.put(dbNames.get(0), DatabaseSchema.fromJson(dbNames.get(0), jsonNode));
- if (schema.size() > 1 && !sfuture.isCancelled()) {
- populateSchema(dbNames.subList(1, dbNames.size()), schema, sfuture);
- } else if (schema.size() == 1) {
- sfuture.set(schema);
- }
- } catch (ParsingException e) {
- LOG.warn("Failed to populate schema {}:{}", dbNames, schema, e);
- sfuture.setException(e);
- }
- return null;
+ (Function<JsonNode, Void>) jsonNode -> {
+ try {
+ schema.put(dbNames.get(0), DatabaseSchema.fromJson(dbNames.get(0), jsonNode));
+ if (schema.size() > 1 && !sfuture.isCancelled()) {
+ populateSchema(dbNames.subList(1, dbNames.size()), schema, sfuture);
+ } else if (schema.size() == 1) {
+ sfuture.set(schema);
}
- });
+ } catch (ParsingException e) {
+ LOG.warn("Failed to populate schema {}:{}", dbNames, schema, e);
+ sfuture.setException(e);
+ }
+ return null;
+ });
}
public void setRpc(OvsdbRPC rpc) {
/*
- * Copyright (c) 2014, 2015 Red Hat, Inc. and others. All rights reserved.
+ * Copyright © 2014, 2017 Red Hat, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
final int ovsdbListenerPort = this.listenerPort;
if (!singletonCreated.getAndSet(true)) {
LOG.info("startOvsdbManager: Starting");
- new Thread() {
- @Override
- public void run() {
- ovsdbManager(ovsdbListenerPort);
- }
- }.start();
+ new Thread(() -> ovsdbManager(ovsdbListenerPort)).start();
return true;
} else {
return false;
public synchronized boolean startOvsdbManagerWithSsl(final int ovsdbListenPort,
final SSLContext sslContext, String[] protocols, String[] cipherSuites) {
if (!singletonCreated.getAndSet(true)) {
- new Thread() {
- @Override
- public void run() {
- ovsdbManagerWithSsl(ovsdbListenPort, sslContext, protocols, cipherSuites);
- }
- }.start();
+ new Thread(() -> ovsdbManagerWithSsl(ovsdbListenPort, sslContext, protocols, cipherSuites)).start();
return true;
} else {
return false;
/*
- * Copyright (c) 2016 , NEC Corporation and others. All rights reserved.
+ * Copyright © 2016, 2017 NEC Corporation and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
// scheduled task for ping response timeout. Connections that don't response to the
// ping or haven't disconnected after the timeout will be closed
final ScheduledFuture<?> echoTimeoutFuture =
- executorService.schedule(new Runnable() {
- @Override
- public void run() {
- for (OvsdbClient client : clientFutureMap.keySet()) {
- Future<?> clientFuture = clientFutureMap.get(client);
- if (!clientFuture.isDone() && !clientFuture.isCancelled()) {
- clientFuture.cancel(true);
- }
- if (client.isActive()) {
- client.disconnect();
- }
+ executorService.schedule(() -> {
+ for (OvsdbClient client : clientFutureMap.keySet()) {
+ Future<?> clientFuture = clientFutureMap.get(client);
+ if (!clientFuture.isDone() && !clientFuture.isCancelled()) {
+ clientFuture.cancel(true);
+ }
+ if (client.isActive()) {
+ client.disconnect();
}
}
}, ECHO_TIMEOUT, TimeUnit.SECONDS);
/*
- * Copyright (c) 2013, 2015 EBay Software Foundation and others. All rights reserved.
+ * Copyright © 2013, 2017 EBay Software Foundation and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.channel.Channel;
-import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
public <T> T getClient(final Object context, Class<T> klazz) {
- return Reflection.newProxy(klazz, new InvocationHandler() {
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
- if (method.getName().equals(OvsdbRPC.REGISTER_CALLBACK_METHOD)) {
- if ((args == null) || args.length != 1 || !(args[0] instanceof OvsdbRPC.Callback)) {
- return false;
- }
- requestCallbacks.put(context, (OvsdbRPC.Callback)args[0]);
- return true;
+ return Reflection.newProxy(klazz, (proxy, method, args) -> {
+ if (method.getName().equals(OvsdbRPC.REGISTER_CALLBACK_METHOD)) {
+ if ((args == null) || args.length != 1 || !(args[0] instanceof OvsdbRPC.Callback)) {
+ return false;
}
+ requestCallbacks.put(context, (OvsdbRPC.Callback)args[0]);
+ return true;
+ }
- JsonRpc10Request request = new JsonRpc10Request(UUID.randomUUID().toString());
- request.setMethod(method.getName());
+ JsonRpc10Request request = new JsonRpc10Request(UUID.randomUUID().toString());
+ request.setMethod(method.getName());
- if (args != null && args.length != 0) {
- List<Object> params = null;
+ if (args != null && args.length != 0) {
+ List<Object> params = null;
- if (args.length == 1) {
- if (args[0] instanceof Params) {
- params = ((Params) args[0]).params();
- } else if (args[0] instanceof List) {
- params = (List<Object>) args[0];
- }
+ if (args.length == 1) {
+ if (args[0] instanceof Params) {
+ params = ((Params) args[0]).params();
+ } else if (args[0] instanceof List) {
+ params = (List<Object>) args[0];
+ }
- if (params == null) {
- throw new UnsupportedArgumentException("do not understand this argument yet");
- }
- request.setParams(params);
+ if (params == null) {
+ throw new UnsupportedArgumentException("do not understand this argument yet");
}
+ request.setParams(params);
}
+ }
- String requestString = objectMapper.writeValueAsString(request);
- LOG.trace("getClient Request : {}", requestString);
-
- SettableFuture<Object> sf = SettableFuture.create();
- methodContext.put(request.getId(), new CallContext(request, method, sf));
- FUTURE_REAPER_SERVICE.schedule(new Runnable() {
- @Override
- public void run() {
- CallContext cc = methodContext.remove(request.getId());
- if (cc != null) {
- if (cc.getFuture().isDone() || cc.getFuture().isCancelled()) {
- return;
- }
- cc.getFuture().cancel(false);
- }
+ String requestString = objectMapper.writeValueAsString(request);
+ LOG.trace("getClient Request : {}", requestString);
+
+ SettableFuture<Object> sf = SettableFuture.create();
+ methodContext.put(request.getId(), new CallContext(request, method, sf));
+ FUTURE_REAPER_SERVICE.schedule(() -> {
+ CallContext cc = methodContext.remove(request.getId());
+ if (cc != null) {
+ if (cc.getFuture().isDone() || cc.getFuture().isCancelled()) {
+ return;
}
- }, reaperInterval, TimeUnit.MILLISECONDS);
+ cc.getFuture().cancel(false);
+ }
+ }, reaperInterval, TimeUnit.MILLISECONDS);
- nettyChannel.writeAndFlush(requestString);
+ nettyChannel.writeAndFlush(requestString);
- return sf;
- }
+ return sf;
}
);
}
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright © 2014, 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
import org.opendaylight.ovsdb.southbound.reconciliation.configuration.BridgeConfigReconciliationTask;
import org.opendaylight.ovsdb.southbound.reconciliation.connection.ConnectionReconciliationTask;
import org.opendaylight.ovsdb.southbound.transactions.md.OvsdbNodeRemoveCommand;
-import org.opendaylight.ovsdb.southbound.transactions.md.TransactionCommand;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAttributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
@SuppressWarnings("unchecked") final InstanceIdentifier<Node> nodeIid =
(InstanceIdentifier<Node>) instanceIdentifierCodec.bindingDeserializer(entity.getId());
- txInvoker.invoke(new TransactionCommand() {
- @Override
- public void execute(ReadWriteTransaction transaction) {
- Optional<Node> ovsdbNodeOpt = SouthboundUtil.readNode(transaction, nodeIid);
- if (ovsdbNodeOpt.isPresent()) {
- Node ovsdbNode = ovsdbNodeOpt.get();
- OvsdbNodeAugmentation nodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
- if (nodeAugmentation != null) {
- if (nodeAugmentation.getManagedNodeEntry() != null) {
- for (ManagedNodeEntry managedNode : nodeAugmentation.getManagedNodeEntry()) {
- transaction.delete(
- LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
- }
- } else {
- LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
+ txInvoker.invoke(transaction -> {
+ Optional<Node> ovsdbNodeOpt = SouthboundUtil.readNode(transaction, nodeIid);
+ if (ovsdbNodeOpt.isPresent()) {
+ Node ovsdbNode = ovsdbNodeOpt.get();
+ OvsdbNodeAugmentation nodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+ if (nodeAugmentation != null) {
+ if (nodeAugmentation.getManagedNodeEntry() != null) {
+ for (ManagedNodeEntry managedNode : nodeAugmentation.getManagedNodeEntry()) {
+ transaction.delete(
+ LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
}
+ } else {
+ LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
}
- transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
}
+ transaction.delete(LogicalDatastoreType.OPERATIONAL, nodeIid);
}
});
/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright © 2014, 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Set;
-import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
private TransactUtils() { }
private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataBefore() {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return input != null && input.getDataBefore() != null;
- }
- };
+ return input -> input != null && input.getDataBefore() != null;
}
private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataBeforeAndDataAfter() {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return input != null && input.getDataBefore() != null && input.getDataAfter() != null;
- }
- };
+ return input -> input != null && input.getDataBefore() != null && input.getDataAfter() != null;
}
private static <T extends DataObject> Predicate<DataObjectModification<T>> hasNoDataBefore() {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return input != null && input.getDataBefore() == null;
- }
- };
+ return input -> input != null && input.getDataBefore() == null;
}
private static <T extends DataObject> Predicate<DataObjectModification<T>> hasDataAfterAndMatchesFilter(
final Predicate<DataObjectModification<T>> filter) {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return input != null && input.getDataAfter() != null && filter.apply(input);
- }
- };
+ return input -> input != null && input.getDataAfter() != null && filter.apply(input);
}
private static <T extends DataObject> Predicate<DataObjectModification<T>> matchesEverything() {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return true;
- }
- };
+ return input -> true;
}
private static <T extends DataObject> Predicate<DataObjectModification<T>> modificationIsDeletion() {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return input != null && input.getModificationType() == DataObjectModification
- .ModificationType.DELETE;
- }
- };
+ return input -> input != null && input.getModificationType() == DataObjectModification
+ .ModificationType.DELETE;
}
private static <T extends DataObject> Predicate<DataObjectModification<T>>
modificationIsDeletionAndHasDataBefore() {
- return new Predicate<DataObjectModification<T>>() {
- @Override
- public boolean apply(@Nullable DataObjectModification<T> input) {
- return input != null && input.getModificationType() == DataObjectModification
- .ModificationType.DELETE && input.getDataBefore() != null;
- }
- };
+ return input -> input != null && input.getModificationType() == DataObjectModification
+ .ModificationType.DELETE && input.getDataBefore() != null;
}
public static Map<InstanceIdentifier<Node>,Node> extractNode(
/*
- * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
+ * Copyright © 2016, 2017 Brocade Communications Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
public void enqueueForRetry(final ReconciliationTask task) {
LOG.trace("Reconciliation task re-queued for re-execution {}",task);
reconTaskManager.cacheTask(task, taskTriager.schedule(
- new Runnable() {
- @Override
- public void run() {
- task.checkReadinessAndProcess();
- }
- }, task.retryDelayInMills(), TimeUnit.MILLISECONDS
+ () -> task.checkReadinessAndProcess(), task.retryDelayInMills(), TimeUnit.MILLISECONDS
)
);
}
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
.thenReturn(yiid);
mock(InstanceIdentifier.class);
- when(bindingNormalizedNodeSerializer.fromYangInstanceIdentifier(yiid))
- .thenAnswer(new Answer<InstanceIdentifier<?>>() {
- public InstanceIdentifier<?> answer(InvocationOnMock invocation) throws Exception {
- return (InstanceIdentifier<?>) invocation.getArguments()[0];
- }
- });
+ when(bindingNormalizedNodeSerializer.fromYangInstanceIdentifier(yiid)).thenAnswer(
+ (Answer<InstanceIdentifier<?>>) invocation -> (InstanceIdentifier<?>) invocation.getArguments()[0]);
assertEquals("Error, did not return correct InstanceIdentifier<?> object", any(InstanceIdentifier.class),
instanceIdCodec.bindingDeserializer(""));
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import java.util.Set;
import org.junit.Test;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.notation.Column;
@Test
public void testCreateDatapathType() throws Exception {
OvsdbBridgeAugmentation mdsalbridge = mock(OvsdbBridgeAugmentation.class);
- when(mdsalbridge.getDatapathType()).thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
- public Class<? extends DatapathTypeBase> answer(
- InvocationOnMock invocation) throws Exception {
- return DatapathTypeNetdev.class;
- }
- });
+ when(mdsalbridge.getDatapathType()).thenAnswer(
+ (Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeNetdev.class);
assertEquals("netdev", SouthboundMapper.createDatapathType(mdsalbridge));
- when(mdsalbridge.getDatapathType()).thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
- public Class<? extends DatapathTypeBase> answer(
- InvocationOnMock invocation) throws Exception {
- return DatapathTypeSystem.class;
- }
- });
+ when(mdsalbridge.getDatapathType()).thenAnswer(
+ (Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeSystem.class);
assertEquals("system", SouthboundMapper.createDatapathType(mdsalbridge));
}
ProtocolEntry protocolEntry = mock(ProtocolEntry.class);
protocolList.add(protocolEntry);
when(ovsdbBridgeNode.getProtocolEntry()).thenReturn(protocolList);
- when(protocolEntry.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
- public Class<? extends OvsdbBridgeProtocolBase> answer(
- InvocationOnMock invocation) throws Exception {
- return OvsdbBridgeProtocolOpenflow10.class;
- }
- });
+ when(protocolEntry.getProtocol()).thenAnswer(
+ (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
Set<String> protocols = new HashSet<>();
protocols.add("OpenFlow10");
assertEquals(protocols, SouthboundMapper.createOvsdbBridgeProtocols(ovsdbBridgeNode));
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
ReadOnlyTransaction transaction = mock(ReadOnlyTransaction.class);
when(db.newReadOnlyTransaction()).thenReturn(transaction);
when(mn.getManagedBy()).thenReturn(ref);
- when(ref.getValue()).thenAnswer(new Answer<InstanceIdentifier<Node>>() {
- public InstanceIdentifier<Node> answer(InvocationOnMock invocation) throws Exception {
- return (InstanceIdentifier<Node>) mock(InstanceIdentifier.class);
- }
- });
+ when(ref.getValue()).thenAnswer(
+ (Answer<InstanceIdentifier<Node>>) invocation -> (InstanceIdentifier<Node>) mock(
+ InstanceIdentifier.class));
CheckedFuture<Optional<Node>, ReadFailedException> nf = mock(CheckedFuture.class);
when(transaction.read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class))).thenReturn(nf);
doNothing().when(transaction).close();
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.ovsdb.lib.notation.Column;
PowerMockito.suppress(MemberMatcher.methodsDeclaredIn(InstanceIdentifier.class));
ProtocolEntry protocol = mock(ProtocolEntry.class);
- when(protocol.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
- public Class<? extends OvsdbBridgeProtocolBase> answer(
- InvocationOnMock invocation) throws Exception {
- return OvsdbBridgeProtocolOpenflow10.class;
- }
- });
+ when(protocol.getProtocol()).thenAnswer(
+ (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
BridgeOperationalState bridgeOpState = mock(BridgeOperationalState.class);
when(bridgeOpState.getProtocolEntry(any(InstanceIdentifier.class))).thenReturn(Optional.of(protocol));
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.ovsdb.lib.notation.Column;
OvsdbBridgeName ovsdbBridgeName = mock(OvsdbBridgeName.class);
when(ovsdbBridge.getBridgeName()).thenReturn(ovsdbBridgeName);
- when(protocolEntry.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
- public Class<? extends OvsdbBridgeProtocolBase> answer(
- InvocationOnMock invocation) throws Exception {
- return OvsdbBridgeProtocolOpenflow10.class;
- }
- });
+ when(protocolEntry.getProtocol()).thenAnswer(
+ (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
Bridge bridge = mock(Bridge.class);
PowerMockito.mockStatic(TyperUtils.class);
/*
- * Copyright (c) 2016 , NEC Corporation and others. All rights reserved.
+ * Copyright © 2016, 2017 NEC Corporation and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
when(ovsdbBridgeAugmentation.getBridgeName()).thenReturn(ovsdbBridgeName);
ProtocolEntry protocolEntry = mock(ProtocolEntry.class);
ProtocolEntryKey protocolEntryKey = mock(ProtocolEntryKey.class);
- Mockito.when(protocolEntry.getProtocol()).thenAnswer(new Answer<Class<? extends OvsdbBridgeProtocolBase>>() {
- public Class<? extends OvsdbBridgeProtocolBase> answer(
- InvocationOnMock invocation) throws Exception {
- return OvsdbBridgeProtocolOpenflow10.class;
- }
- });
+ Mockito.when(protocolEntry.getProtocol()).thenAnswer(
+ (Answer<Class<? extends OvsdbBridgeProtocolBase>>) invocation -> OvsdbBridgeProtocolOpenflow10.class);
when(protocolEntry.getKey()).thenReturn(protocolEntryKey);
when(ovsdbBridgeAugmentation.getProtocolEntry()).thenReturn(Arrays.asList(protocolEntry));
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
when(column.getData()).thenReturn(set);
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.createInterfaceType(anyString()))
- .thenAnswer(new Answer<Class<? extends InterfaceTypeBase>>() {
- public Class<? extends InterfaceTypeBase> answer(InvocationOnMock invocation) throws Exception {
- return InterfaceTypeInternal.class;
- }
- });
+ .thenAnswer((Answer<Class<? extends InterfaceTypeBase>>) invocation -> InterfaceTypeInternal.class);
InterfaceTypeEntry ifEntry = mock(InterfaceTypeEntry.class);
InterfaceTypeEntryBuilder interfaceTypeEntryBldr = mock(InterfaceTypeEntryBuilder.class);
when(column.getData()).thenReturn(set);
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.createDatapathType(anyString()))
- .thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
- public Class<? extends DatapathTypeBase> answer(InvocationOnMock invocation) throws Exception {
- return DatapathTypeSystem.class;
- }
- });
+ .thenAnswer((Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeSystem.class);
DatapathTypeEntry dpEntry = mock(DatapathTypeEntry.class);
DatapathTypeEntryBuilder datapathTypeEntryBuilder = mock(DatapathTypeEntryBuilder.class);
PowerMockito.whenNew(DatapathTypeEntryBuilder.class).withNoArguments().thenReturn(datapathTypeEntryBuilder);
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
when(column.getData()).thenReturn("system");
PowerMockito.mockStatic(SouthboundMapper.class);
when(SouthboundMapper.createDatapathType(anyString()))
- .thenAnswer(new Answer<Class<? extends DatapathTypeBase>>() {
- public Class<? extends DatapathTypeBase> answer(InvocationOnMock invocation) throws Exception {
- return DatapathTypeSystem.class;
- }
- });
+ .thenAnswer((Answer<Class<? extends DatapathTypeBase>>) invocation -> DatapathTypeSystem.class);
OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = mock(OvsdbBridgeAugmentationBuilder.class);
when(ovsdbBridgeAugmentationBuilder.setDatapathType(any(Class.class)))
.thenReturn(ovsdbBridgeAugmentationBuilder);
/*
- * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
+ * Copyright © 2015, 2017 Inocybe Technologies and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
when(ovsdbTerminationPointBuilder.setInterfaceUuid(any(Uuid.class))).thenReturn(ovsdbTerminationPointBuilder);
PowerMockito.mockStatic(SouthboundMapper.class);
PowerMockito.when(SouthboundMapper.createInterfaceType(anyString()))
- .thenAnswer(new Answer<Class<? extends InterfaceTypeBase>>() {
- public Class<? extends InterfaceTypeBase> answer(InvocationOnMock invocation) throws Exception {
- return InterfaceTypeInternal.class;
- }
- });
+ .thenAnswer((Answer<Class<? extends InterfaceTypeBase>>) invocation -> InterfaceTypeInternal.class);
when(ovsdbTerminationPointBuilder.setInterfaceType(any(Class.class))).thenReturn(ovsdbTerminationPointBuilder);
suppress(method(OvsdbPortUpdateCommand.class, "updateOfPort", Interface.class,
OvsdbTerminationPointAugmentationBuilder.class));