}
batchI++;
LOG.info("Batch {} with size {} sent. Committing", batchI, editBatch);
- futures.add(sessionListener.sendRequest(StressClient.COMMIT_MSG, StressClient.COMMIT_QNAME));
+ if (params.candidateDatastore) {
+ futures.add(sessionListener.sendRequest(StressClient.COMMIT_MSG, StressClient.COMMIT_QNAME));
+ }
}
LOG.info("All batches sent. Waiting for responses");
}
}
- Preconditions.checkState(responseCounter.get() == editAmount + editBatches.size(), "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size());
+ Preconditions.checkState(responseCounter.get() == editAmount + (params.candidateDatastore ? editBatches.size() : 0),
+ "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size());
}
}
@Arg(dest = "edit-batch-size")
public int editBatchSize;
+ @Arg(dest = "candidate-datastore")
+ public boolean candidateDatastore;
+
@Arg(dest = "debug")
public boolean debug;
.type(Integer.class)
.required(false)
.setDefault(-1)
- .type(Integer.class)
.dest("edit-batch-size");
+ parser.addArgument("--candidate-datastore")
+ .type(Boolean.class)
+ .required(false)
+ .setDefault(true)
+ .help("Edit candidate or running datastore. Defaults to candidate.")
+ .dest("candidate-datastore");
+
parser.addArgument("--debug")
.type(Boolean.class)
.setDefault(false)
}
static final QName EDIT_QNAME = QName.create(EditConfigInput.QNAME, "edit-config");
- static final org.w3c.dom.Document editBlueprint;
+ static final org.w3c.dom.Document editCandidateBlueprint;
+ static final org.w3c.dom.Document editRunningBlueprint;
static {
try {
- editBlueprint = XmlUtil.readXmlToDocument(
+ editCandidateBlueprint = XmlUtil.readXmlToDocument(
"<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
" <edit-config xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
" <target>\n" +
" <config/>\n" +
" </edit-config>\n" +
"</rpc>");
+
+ editRunningBlueprint = XmlUtil.readXmlToDocument(
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <edit-config xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <target>\n" +
+ " <running/>\n" +
+ " </target>\n" +
+ " <default-operation>none</default-operation>" +
+ " <config/>\n" +
+ " </edit-config>\n" +
+ "</rpc>");
} catch (SAXException | IOException e) {
throw new ExceptionInInitializerError(e);
}
private static long macStart = 0xAABBCCDD0000L;
+ private static Parameters params;
+
public static void main(final String[] args) {
- final Parameters params = parseArgs(args, Parameters.getParser());
+ params = parseArgs(args, Parameters.getParser());
params.validate();
final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
}
static NetconfMessage prepareMessage(final int id, final String editContentString) {
- final Document msg = XmlUtil.createDocumentCopy(editBlueprint);
+ final Document msg = XmlUtil.createDocumentCopy(params.candidateDatastore ? editCandidateBlueprint : editRunningBlueprint);
msg.getDocumentElement().setAttribute("message-id", Integer.toString(id));
final NetconfMessage netconfMessage = new NetconfMessage(msg);
LOG.info("Batch {} with size {} sent. Committing", batchI, editBatch);
// Commit batch sync
- waitForResponse(responseCounter,
- sessionListener.sendRequest(StressClient.COMMIT_MSG, StressClient.COMMIT_QNAME));
+ if (params.candidateDatastore) {
+ waitForResponse(responseCounter,
+ sessionListener.sendRequest(StressClient.COMMIT_MSG, StressClient.COMMIT_QNAME));
+ }
}
- Preconditions.checkState(responseCounter.get() == editAmount + editBatches.size(), "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size());
+ Preconditions.checkState(responseCounter.get() == editAmount + (params.candidateDatastore ? editBatches.size() : 0),
+ "Not all responses were received, only %s from %s", responseCounter.get(), params.editCount + editBatches.size());
}
private void waitForResponse(AtomicInteger responseCounter, final ListenableFuture<RpcResult<NetconfMessage>> netconfMessageFuture) {