List<OuterList> outerList = new ArrayList<>(outerElements);
for (int j = 0; j < outerElements; j++) {
outerList.add(new OuterListBuilder()
- .setId(j)
- .setInnerList(buildInnerList(j, innerElements))
- .withKey(new OuterListKey(j))
- .build());
+ .setId(j)
+ .setInnerList(buildInnerList(j, innerElements))
+ .withKey(new OuterListKey(j))
+ .build());
}
return outerList;
}
private static Map<InnerListKey, InnerList> buildInnerList(final int index, final int elements) {
Builder<InnerListKey, InnerList> innerList = ImmutableMap.builderWithExpectedSize(elements);
- final String itemStr = "Item-" + String.valueOf(index) + "-";
+ final String itemStr = "Item-" + index + "-";
for (int i = 0; i < elements; i++) {
final InnerListKey key = new InnerListKey(i);
innerList.put(key, new InnerListBuilder()
- .withKey(key)
- .setName(i)
- .setValue(itemStr + String.valueOf(i))
- .build());
+ .withKey(key)
+ .setName(i)
+ .setValue(itemStr + i)
+ .build());
}
return innerList.build();
}
}
protected LogicalDatastoreType getDataStoreType() {
- final LogicalDatastoreType dsType;
- if (dataStore == DataStore.CONFIG) {
- dsType = LogicalDatastoreType.CONFIGURATION;
- } else if ((dataStore == DataStore.OPERATIONAL) || (rn.nextBoolean() == true)) {
- dsType = LogicalDatastoreType.OPERATIONAL;
- } else {
- dsType = LogicalDatastoreType.CONFIGURATION;
- }
- return dsType;
+ return dataStore == DataStore.CONFIG || dataStore != DataStore.OPERATIONAL && !rn.nextBoolean()
+ ? LogicalDatastoreType.CONFIGURATION : LogicalDatastoreType.OPERATIONAL;
}
}
List<MapEntryNode> outerList = new ArrayList<>(outerElements);
for (int j = 0; j < outerElements; j++) {
outerList.add(ImmutableNodes.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(OuterList.QNAME, OL_ID, j))
- .withChild(ImmutableNodes.leafNode(OL_ID, j))
- .withChild(buildInnerList(j, innerElements))
- .build());
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(OuterList.QNAME, OL_ID, j))
+ .withChild(ImmutableNodes.leafNode(OL_ID, j))
+ .withChild(buildInnerList(j, innerElements))
+ .build());
}
return outerList;
}
private static MapNode buildInnerList(final int index, final int elements) {
CollectionNodeBuilder<MapEntryNode, SystemMapNode> innerList = ImmutableNodes.mapNodeBuilder(InnerList.QNAME);
- final String itemStr = "Item-" + String.valueOf(index) + "-";
+ final String itemStr = "Item-" + index + "-";
for (int i = 0; i < elements; i++) {
innerList.addChild(ImmutableNodes.mapEntryBuilder()
- .withNodeIdentifier(NodeIdentifierWithPredicates.of(InnerList.QNAME, IL_NAME, i))
- .withChild(ImmutableNodes.leafNode(IL_NAME, i))
- .withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i)))
- .build());
+ .withNodeIdentifier(NodeIdentifierWithPredicates.of(InnerList.QNAME, IL_NAME, i))
+ .withChild(ImmutableNodes.leafNode(IL_NAME, i))
+ .withChild(ImmutableNodes.leafNode(IL_VALUE, itemStr + String.valueOf(i)))
+ .build());
}
return innerList.build();
}
@RequireServiceComponentRuntime
public final class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DsbenchmarkProvider.class);
- private static final InstanceIdentifier<TestExec> TEST_EXEC_IID =
- InstanceIdentifier.builder(TestExec.class).build();
- private static final InstanceIdentifier<TestStatus> TEST_STATUS_IID =
- InstanceIdentifier.builder(TestStatus.class).build();
+ private static final InstanceIdentifier<TestExec> TEST_EXEC_IID = InstanceIdentifier.create(TestExec.class);
+ private static final InstanceIdentifier<TestStatus> TEST_STATUS_IID = InstanceIdentifier.create(TestStatus.class);
private final AtomicReference<ExecStatus> execStatus = new AtomicReference<>(ExecStatus.Idle);
private final DsbenchmarkListenerProvider listenerProvider;
- private final DOMDataBroker domDataBroker; // Async DOM Broker for use with all DOM operations
- private final DataBroker dataBroker; // Async Binding-Aware Broker for use in tx chains
+ // Async DOM Broker for use with all DOM operations
+ private final DOMDataBroker domDataBroker;
+ // Async Binding-Aware Broker for use in tx chains;
+ private final DataBroker dataBroker;
private final Registration rpcReg;
private long testsCompleted = 0;
LOG.info("Starting the data store benchmark test, input: {}", input);
// Check if there is a test in progress
- if (execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing) == false) {
+ if (!execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing)) {
LOG.info("Test in progress");
return RpcResultBuilder.success(new StartTestOutputBuilder()
- .setStatus(StartTestOutput.Status.TESTINPROGRESS)
- .build()).buildFuture();
+ .setStatus(StartTestOutput.Status.TESTINPROGRESS)
+ .build()).buildFuture();
}
// Cleanup data that may be left over from a previous test run
testsCompleted++;
} catch (final Exception e) {
- LOG.error("Test error: {}", e.toString());
+ LOG.error("Test error", e);
execStatus.set(ExecStatus.Idle);
return RpcResultBuilder.success(new StartTestOutputBuilder()
- .setStatus(StartTestOutput.Status.FAILED)
- .build()).buildFuture();
+ .setStatus(StartTestOutput.Status.FAILED)
+ .build()).buildFuture();
}
LOG.info("Test finished");
retVal = new SimpletxBaWrite(dataBroker, oper, outerListElem,
innerListElem, writesPerTx, dataStore);
}
+ } else if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new SimpletxDomDelete(domDataBroker, outerListElem,
+ innerListElem, writesPerTx, dataStore);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new SimpletxDomRead(domDataBroker, outerListElem,
+ innerListElem, writesPerTx, dataStore);
} else {
- if (StartTestInput.Operation.DELETE == oper) {
- retVal = new SimpletxDomDelete(domDataBroker, outerListElem,
- innerListElem, writesPerTx, dataStore);
- } else if (StartTestInput.Operation.READ == oper) {
- retVal = new SimpletxDomRead(domDataBroker, outerListElem,
- innerListElem, writesPerTx, dataStore);
- } else {
- retVal = new SimpletxDomWrite(domDataBroker, oper, outerListElem,
- innerListElem, writesPerTx, dataStore);
- }
+ retVal = new SimpletxDomWrite(domDataBroker, oper, outerListElem,
+ innerListElem, writesPerTx, dataStore);
}
- } else {
- if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
- if (StartTestInput.Operation.DELETE == oper) {
- retVal = new TxchainBaDelete(dataBroker, outerListElem,
- innerListElem, writesPerTx, dataStore);
- } else if (StartTestInput.Operation.READ == oper) {
- retVal = new TxchainBaRead(dataBroker, outerListElem,
- innerListElem,writesPerTx, dataStore);
- } else {
- retVal = new TxchainBaWrite(dataBroker, oper, outerListElem,
- innerListElem, writesPerTx, dataStore);
- }
+ } else if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
+ if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new TxchainBaDelete(dataBroker, outerListElem,
+ innerListElem, writesPerTx, dataStore);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new TxchainBaRead(dataBroker, outerListElem,
+ innerListElem,writesPerTx, dataStore);
} else {
- if (StartTestInput.Operation.DELETE == oper) {
- retVal = new TxchainDomDelete(domDataBroker, outerListElem,
- innerListElem, writesPerTx, dataStore);
- } else if (StartTestInput.Operation.READ == oper) {
- retVal = new TxchainDomRead(domDataBroker, outerListElem,
- innerListElem, writesPerTx, dataStore);
-
- } else {
- retVal = new TxchainDomWrite(domDataBroker, oper, outerListElem,
- innerListElem,writesPerTx, dataStore);
- }
+ retVal = new TxchainBaWrite(dataBroker, oper, outerListElem,
+ innerListElem, writesPerTx, dataStore);
}
+ } else if (StartTestInput.Operation.DELETE == oper) {
+ retVal = new TxchainDomDelete(domDataBroker, outerListElem,
+ innerListElem, writesPerTx, dataStore);
+ } else if (StartTestInput.Operation.READ == oper) {
+ retVal = new TxchainDomRead(domDataBroker, outerListElem,
+ innerListElem, writesPerTx, dataStore);
+
+ } else {
+ retVal = new TxchainDomWrite(domDataBroker, oper, outerListElem,
+ innerListElem,writesPerTx, dataStore);
}
} finally {
execStatus.set(ExecStatus.Idle);
}
for (int i = 0; i < outerList.getInnerList().size(); i++) {
String itemStr = objectsArray[i];
- if (!itemStr.contentEquals("Item-" + String.valueOf(l) + "-" + String.valueOf(i))) {
+ if (!itemStr.contentEquals("Item-" + l + "-" + i)) {
LOG.error("innerList: name: {}, value: {}", i, itemStr);
break;
}
if (optionalDataObject != null && optionalDataObject.isPresent()) {
OuterList outerList = optionalDataObject.get();
- String[] objectsArray = new String[outerList.getInnerList().size()];
- for (InnerList innerList : outerList.getInnerList().values()) {
+ String[] objectsArray = new String[outerList.nonnullInnerList().size()];
+ for (InnerList innerList : outerList.nonnullInnerList().values()) {
if (objectsArray[innerList.getName()] != null) {
LOG.error("innerList: DUPLICATE name: {}, value: {}", innerList.getName(),
innerList.getValue());
}
objectsArray[innerList.getName()] = innerList.getValue();
}
- for (int i = 0; i < outerList.getInnerList().size(); i++) {
+ for (int i = 0; i < outerList.nonnullInnerList().size(); i++) {
String itemStr = objectsArray[i];
- if (!itemStr.contentEquals("Item-" + String.valueOf(l) + "-" + String.valueOf(i))) {
+ if (!itemStr.contentEquals("Item-" + l + "-" + i)) {
LOG.error("innerList: name: {}, value: {}", i, itemStr);
break;
}
listenerRegistration.getInstance().getAllDone().get();
}
} catch (final InterruptedException | ExecutionException e) {
- LOG.error("Out of time: test did not finish within the {} min deadline ", TEST_TIMEOUT);
+ LOG.error("Out of time: test did not finish within the {} min deadline ", TEST_TIMEOUT, e);
}
final long producerEndTime = System.nanoTime();
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.util.Set;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
}
public NormalizedNode parseDataElement(final Element element, final SchemaTreeInference dataSchema)
- throws XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException {
+ throws XMLStreamException, IOException, SAXException, URISyntaxException {
final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
final XmlParserStream xmlParser = XmlParserStream.create(writer, dataSchema);
xmlParser.traverse(new DOMSource(element));
final NormalizedNode result = resultHolder.getResult();
- if (result instanceof MapNode) {
- final MapNode mapNode = (MapNode) result;
- final MapEntryNode mapEntryNode = mapNode.body().iterator().next();
- return mapEntryNode;
- }
-
- return result;
+ return result instanceof MapNode mapNode ? mapNode.body().iterator().next() : result;
}
public abstract NormalizedNode newDefaultNode(SchemaTreeInference dataSchema);
@FunctionalInterface
public interface FallbackConfigProvider {
NormalizedNode get(SchemaTreeInference dataSchema)
- throws IOException, XMLStreamException, ParserConfigurationException, SAXException, URISyntaxException;
+ throws IOException, XMLStreamException, SAXException, URISyntaxException;
}
@FunctionalInterface
@SuppressWarnings("unchecked")
public T createDefaultInstance(final FallbackConfigProvider fallback) throws ConfigXMLReaderException,
- URISyntaxException, ParserConfigurationException, XMLStreamException, SAXException, IOException {
+ URISyntaxException, XMLStreamException, SAXException, IOException {
YangInstanceIdentifier yangPath = bindingSerializer.toYangInstanceIdentifier(bindingContext.appConfigPath);
LOG.debug("{}: Creating app config instance from path {}, Qname: {}", logName, yangPath,
LOG.debug("{}: Parsed data node: {}", logName, dataNode);
return dataNode;
- } catch (final IOException | SAXException | XMLStreamException | ParserConfigurationException
- | URISyntaxException e) {
+ } catch (final IOException | SAXException | XMLStreamException | URISyntaxException e) {
String msg = String.format("%s: Could not read/parse app config %s", logName, url);
LOG.error(msg, e);
throw new ConfigXMLReaderException(msg, e);
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
import org.eclipse.jdt.annotation.NonNull;
}
});
- } catch (final ConfigXMLReaderException | IOException | SAXException | XMLStreamException
- | ParserConfigurationException | URISyntaxException e) {
+ } catch (ConfigXMLReaderException | IOException | SAXException | XMLStreamException | URISyntaxException e) {
if (e.getCause() == null) {
setFailureMessage(e.getMessage());
} else {
}
private @Nullable NormalizedNode parsePossibleDefaultAppConfigElement(final SchemaTreeInference dataSchema)
- throws URISyntaxException, IOException, ParserConfigurationException, SAXException, XMLStreamException {
+ throws URISyntaxException, IOException, SAXException, XMLStreamException {
if (defaultAppConfigElement == null) {
return null;
}
* @param now tick number corresponding to caller's present
*/
ProgressTracker(final ProgressTracker oldTracker, final long now) {
- this.defaultTicksPerTask = oldTracker.defaultTicksPerTask;
- this.tasksEncountered = this.tasksClosed = oldTracker.tasksClosed;
- this.lastClosed = oldTracker.lastClosed;
- this.nearestAllowed = oldTracker.nearestAllowed; // Call cancelDebt explicitly if needed.
- this.lastIdle = oldTracker.lastIdle;
- this.elapsedBeforeIdle = oldTracker.elapsedBeforeIdle;
+ defaultTicksPerTask = oldTracker.defaultTicksPerTask;
+ tasksEncountered = tasksClosed = oldTracker.tasksClosed;
+ lastClosed = oldTracker.lastClosed;
+ // Call cancelDebt explicitly if needed.
+ nearestAllowed = oldTracker.nearestAllowed;
+ lastIdle = oldTracker.lastIdle;
+ elapsedBeforeIdle = oldTracker.elapsedBeforeIdle;
if (!oldTracker.isIdle()) {
transitToIdle(now);
}
*
* @return number of tasks started but not finished yet
*/
- final long tasksOpen() { // TODO: Should we return int?
+ // TODO: Should we return int?
+ final long tasksOpen() {
// TODO: Should we check the return value is non-negative?
return tasksEncountered - tasksClosed;
}
private final Deque<TransmittedConnectionEntry> inflight = new ArrayDeque<>();
private final Deque<ConnectionEntry> pending = new ArrayDeque<>();
- private final AveragingProgressTracker tracker; // Cannot be just ProgressTracker as we are inheriting limits.
+ // Cannot be just ProgressTracker as we are inheriting limits.
+ private final AveragingProgressTracker tracker;
private ReconnectForwarder successor;
/**
}
// Check if the entry has (ever) been transmitted
- if (!(e instanceof TransmittedConnectionEntry)) {
+ if (!(e instanceof TransmittedConnectionEntry te)) {
return Optional.empty();
}
- final TransmittedConnectionEntry te = (TransmittedConnectionEntry) e;
-
// Now check session match
if (envelope.getSessionId() != te.getSessionId()) {
LOG.debug("Expecting session {}, ignoring response {}", te.getSessionId(), envelope);
+ "all members {} self member: {}", logName(), unreachable, members, selfMember);
// no unreachable peers means we cannot be isolated
- if (unreachable.size() == 0) {
+ if (unreachable.isEmpty()) {
return false;
}
membersToCheck.removeAll(unreachable);
// check if the only member not unreachable is us
- if (membersToCheck.size() == 1 && membersToCheck.iterator().next().equals(selfMember)) {
- return true;
- }
-
- return false;
+ return membersToCheck.size() == 1 && membersToCheck.iterator().next().equals(selfMember);
}
private void handleInstallSnapshot(final ActorRef sender, final InstallSnapshot installSnapshot) {
}
private SkipTransactionsResponse handleSkipTransactionsRequest(final SkipTransactionsRequest request,
- final RequestEnvelope envelope, final long now) throws RequestException {
+ final RequestEnvelope envelope, final long now) {
final var first = request.getTarget();
final var others = request.getOthers();
final var ids = new ArrayList<UnsignedLong>(others.size() + 1);
synchronized (queuedTxOperations) {
contextOnEntry = transactionContext;
if (contextOnEntry == null) {
- checkState(pendingEnqueue == false, "Concurrent access to transaction %s detected", getIdentifier());
+ checkState(!pendingEnqueue, "Concurrent access to transaction %s detected", getIdentifier());
pendingEnqueue = true;
}
}
return false;
}
- ShardIdentifier that = (ShardIdentifier) obj;
-
- if (!memberName.equals(that.memberName)) {
- return false;
- }
- if (!shardName.equals(that.shardName)) {
- return false;
- }
- if (!type.equals(that.type)) {
- return false;
- }
-
- return true;
+ final var that = (ShardIdentifier) obj;
+ return memberName.equals(that.memberName) && shardName.equals(that.shardName) && type.equals(that.type);
}
@Override
}
public Builder shardName(final String newShardName) {
- this.shardName = newShardName;
+ shardName = newShardName;
return this;
}
public Builder memberName(final MemberName newMemberName) {
- this.memberName = newMemberName;
+ memberName = newMemberName;
return this;
}
public Builder type(final String newType) {
- this.type = newType;
+ type = newType;
return this;
}
public class ShardManagerIdentifier {
private final String type;
- public ShardManagerIdentifier(String type) {
+ public ShardManagerIdentifier(final String type) {
this.type = type;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
-
- ShardManagerIdentifier that = (ShardManagerIdentifier) obj;
-
- if (!type.equals(that.type)) {
- return false;
- }
-
- return true;
+ return type.equals(((ShardManagerIdentifier) obj).type);
}
@Override
public static class Builder {
private String type;
- public Builder type(String newType) {
- this.type = newType;
+ public Builder type(final String newType) {
+ type = newType;
return this;
}
public ShardManagerIdentifier build() {
- return new ShardManagerIdentifier(this.type);
+ return new ShardManagerIdentifier(type);
}
-
}
}
private final ReadWriteShardDataTreeTransaction transaction;
private final boolean doImmediateCommit;
private final short txnClientVersion;
- private @Nullable final SortedSet<String> participatingShardNames;
+ private final @Nullable SortedSet<String> participatingShardNames;
- public ForwardedReadyTransaction(TransactionIdentifier transactionId, short txnClientVersion,
- ReadWriteShardDataTreeTransaction transaction, boolean doImmediateCommit,
- Optional<SortedSet<String>> participatingShardNames) {
+ public ForwardedReadyTransaction(final TransactionIdentifier transactionId, final short txnClientVersion,
+ final ReadWriteShardDataTreeTransaction transaction, final boolean doImmediateCommit,
+ final Optional<SortedSet<String>> participatingShardNames) {
this.transactionId = requireNonNull(transactionId);
this.transaction = requireNonNull(transaction);
this.txnClientVersion = txnClientVersion;