2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.test.tool.client.stress;
10 import java.util.ArrayList;
11 import java.util.List;
12 import org.opendaylight.netconf.api.NetconfMessage;
13 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
15 abstract class AbstractExecutionStrategy implements ExecutionStrategy {
16 private final Parameters params;
17 private final List<NetconfMessage> preparedMessages;
18 private final NetconfDeviceCommunicator sessionListener;
19 private final List<Integer> editBatches;
20 private final int editAmount;
22 AbstractExecutionStrategy(final Parameters params, final List<NetconfMessage> editConfigMsgs,
23 final NetconfDeviceCommunicator sessionListener) {
24 editAmount = editConfigMsgs.size();
26 this.preparedMessages = editConfigMsgs;
27 this.sessionListener = sessionListener;
28 this.editBatches = countEditBatchSizes(params, editConfigMsgs.size());
31 private static List<Integer> countEditBatchSizes(final Parameters params, final int amount) {
32 final List<Integer> editBatches = new ArrayList<>();
33 if (params.editBatchSize != amount) {
34 final int fullBatches = amount / params.editBatchSize;
35 for (int i = 0; i < fullBatches; i++) {
36 editBatches.add(params.editBatchSize);
39 if (amount % params.editBatchSize != 0) {
40 editBatches.add(amount % params.editBatchSize);
43 editBatches.add(params.editBatchSize);
49 protected Parameters getParams() {
53 protected List<NetconfMessage> getPreparedMessages() {
54 return preparedMessages;
57 protected NetconfDeviceCommunicator getSessionListener() {
58 return sessionListener;
61 protected List<Integer> getEditBatches() {
65 protected int getEditAmount() {