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 public AbstractExecutionStrategy(final Parameters params, final List<NetconfMessage> editConfigMsgs, 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 = Lists.newArrayList();
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() {