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
9 package org.opendaylight.netconf.test.tool.client.stress;
11 import com.google.common.collect.Lists;
12 import java.util.List;
13 import org.opendaylight.netconf.api.NetconfMessage;
14 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
16 abstract class AbstractExecutionStrategy implements ExecutionStrategy {
17 private final Parameters params;
18 private final List<NetconfMessage> preparedMessages;
19 private final NetconfDeviceCommunicator sessionListener;
20 private final List<Integer> editBatches;
21 private final int editAmount;
23 AbstractExecutionStrategy(final Parameters params, final List<NetconfMessage> editConfigMsgs,
24 final NetconfDeviceCommunicator sessionListener) {
25 editAmount = editConfigMsgs.size();
27 this.preparedMessages = editConfigMsgs;
28 this.sessionListener = sessionListener;
29 this.editBatches = countEditBatchSizes(params, editConfigMsgs.size());
32 private static List<Integer> countEditBatchSizes(final Parameters params, final int amount) {
33 final List<Integer> editBatches = Lists.newArrayList();
34 if (params.editBatchSize != amount) {
35 final int fullBatches = amount / params.editBatchSize;
36 for (int i = 0; i < fullBatches; i++) {
37 editBatches.add(params.editBatchSize);
40 if (amount % params.editBatchSize != 0) {
41 editBatches.add(amount % params.editBatchSize);
44 editBatches.add(params.editBatchSize);
50 protected Parameters getParams() {
54 protected List<NetconfMessage> getPreparedMessages() {
55 return preparedMessages;
58 protected NetconfDeviceCommunicator getSessionListener() {
59 return sessionListener;
62 protected List<Integer> getEditBatches() {
66 protected int getEditAmount() {