Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
JLoadProfileInvocation.java
Go to the documentation of this file.
1 package com.griddynamics.jagger.user.test.configurations.load;
2 
3 import com.griddynamics.jagger.user.test.configurations.load.auxiliary.InvocationCount;
4 import com.griddynamics.jagger.user.test.configurations.load.auxiliary.ThreadCount;
5 
6 import java.util.Objects;
7 
36 public class JLoadProfileInvocation implements JLoadProfile {
37 
38  private final int invocationCount;
39  private final int threadCount;
40  private final int delayBetweenInvocationsInMilliseconds;
41  private final int periodInSeconds;
42  private final int tickInterval;
43 
45  this.invocationCount = builder.invocationCount;
46  this.threadCount = builder.threadCount;
47  this.delayBetweenInvocationsInMilliseconds = builder.delayBetweenInvocationsInMilliseconds;
48  this.periodInSeconds = builder.periodInSeconds;
49  this.tickInterval = builder.tickInterval;
50  }
51 
62  public static Builder builder(InvocationCount invocationCount, ThreadCount threadCount) {
63  return new Builder(invocationCount, threadCount);
64  }
65 
66  public static class Builder {
67  static final int DEFAULT_TICK_INTERVAL = 1000;
68  static final int DEFAULT_PERIOD = -1;
69  static final int DEFAULT_DELAY = 0;
70  private int invocationCount;
71  private int threadCount;
72  private int delayBetweenInvocationsInMilliseconds;
73  private int periodInSeconds;
74  // Tick interval doesn't have setter, since it's unclear if this field is needed. Check https://issues.griddynamics.net/browse/JFG-1031
75  private int tickInterval;
76 
77  public Builder(InvocationCount invocationCount, ThreadCount threadCount) {
78  Objects.requireNonNull(invocationCount);
79  Objects.requireNonNull(threadCount);
80 
81  this.tickInterval = DEFAULT_TICK_INTERVAL;
82  this.periodInSeconds = DEFAULT_PERIOD;
83  this.delayBetweenInvocationsInMilliseconds = DEFAULT_DELAY;
84 
85  this.invocationCount = invocationCount.value();
86  this.threadCount = threadCount.value();
87  }
88 
95  this.delayBetweenInvocationsInMilliseconds = delay;
96  return this;
97  }
98 
105  this.periodInSeconds = period;
106  return this;
107  }
108 
115  return new JLoadProfileInvocation(this);
116  }
117 
118 
119  }
120 
121  public int getThreadCount() {
122  return threadCount;
123  }
124 
125  public int getInvocationCount() {
126  return invocationCount;
127  }
128 
130  return delayBetweenInvocationsInMilliseconds;
131  }
132 
133  public int getPeriodInSeconds() {
134  return periodInSeconds;
135  }
136 
137  public int getTickInterval() {
138  return tickInterval;
139  }
140 }