Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
JLoadProfileUsers.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.NumberOfUsers;
4 
5 import java.util.Objects;
6 
7 
30 public class JLoadProfileUsers {
31 
32  private final long numberOfUsers;
33  private final long lifeTimeInSeconds;
34  private final long startDelayInSeconds;
35  private final double slewRateUsersPerSecond;
36 
38  this.numberOfUsers = builder.numberOfUsers.value();
39  this.lifeTimeInSeconds = builder.lifeTimeInSeconds;
40  this.startDelayInSeconds = builder.startDelayInSeconds;
41  this.slewRateUsersPerSecond = builder.slewRateUsersPerSecond;
42  }
43 
50  public static Builder builder(NumberOfUsers numberOfUsers) {
51  return new Builder(numberOfUsers);
52  }
53 
54  public static class Builder {
55  private final NumberOfUsers numberOfUsers;
56  private long lifeTimeInSeconds;
57  private long startDelayInSeconds;
58  private double slewRateUsersPerSecond;
59 
66  private Builder(NumberOfUsers numberOfUsers) {
67  Objects.requireNonNull(numberOfUsers);
68 
69  this.numberOfUsers = numberOfUsers;
70  this.lifeTimeInSeconds = 60 * 60 * 48; // 2 days
71  this.slewRateUsersPerSecond = numberOfUsers.value();
72  }
73 
78  return new JLoadProfileUsers(this);
79  }
80 
85  public Builder withLifeTimeInSeconds(long lifeTimeInSeconds) {
86  if (lifeTimeInSeconds <= 0) {
87  throw new IllegalArgumentException(String.format("Life time must be > 0. Provided value is %s", lifeTimeInSeconds));
88  }
89  this.lifeTimeInSeconds = lifeTimeInSeconds;
90  return this;
91  }
92 
97  public Builder withStartDelayInSeconds(long startDelayInSeconds) {
98  if (startDelayInSeconds < 0) {
99  throw new IllegalArgumentException(String.format("Start delay must be >= 0. Provided value is %s", startDelayInSeconds));
100  }
101  this.startDelayInSeconds = startDelayInSeconds;
102  return this;
103  }
104 
109  public Builder withSlewRateUsersPerSecond(double slewRateUsersPerSecond) {
110  if (slewRateUsersPerSecond <= 0) {
111  throw new IllegalArgumentException(
112  String.format("Slew rate users per second must be > 0. Provided value is %s", slewRateUsersPerSecond));
113  }
114  this.slewRateUsersPerSecond = slewRateUsersPerSecond;
115  return this;
116  }
117  }
118 
119  public long getNumberOfUsers() {
120  return numberOfUsers;
121  }
122 
123  public long getLifeTimeInSeconds() {
124  return lifeTimeInSeconds;
125  }
126 
127  public long getStartDelayInSeconds() {
128  return startDelayInSeconds;
129  }
130 
131  public double getSlewRateUsersPerSecond() {
132  return slewRateUsersPerSecond;
133  }
134 }