Jagger
 All Classes Namespaces Files Functions Variables 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 
11 public class JLoadProfileUsers {
12 
13  private final long numberOfUsers;
14  private final long lifeTimeInSeconds;
15  private final long startDelayInSeconds;
16  private final long slewRateUsersPerSecond;
17 
19  this.numberOfUsers = builder.numberOfUsers.value();
20  this.lifeTimeInSeconds = builder.lifeTimeInSeconds;
21  this.startDelayInSeconds = builder.startDelayInSeconds;
22  this.slewRateUsersPerSecond = builder.slewRateUsersPerSecond;
23  }
24 
31  public static Builder builder(NumberOfUsers numberOfUsers) {
32  return new Builder(numberOfUsers);
33  }
34 
35  public static class Builder {
36  private final NumberOfUsers numberOfUsers;
37  private long lifeTimeInSeconds;
38  private long startDelayInSeconds;
39  private long slewRateUsersPerSecond;
40 
47  private Builder(NumberOfUsers numberOfUsers) {
48  Objects.requireNonNull(numberOfUsers);
49 
50  this.numberOfUsers = numberOfUsers;
51  this.lifeTimeInSeconds = 60 * 60 * 48; // 2 days
52  this.slewRateUsersPerSecond = numberOfUsers.value();
53  }
54 
59  return new JLoadProfileUsers(this);
60  }
61 
66  public Builder withLifeTimeInSeconds(long lifeTimeInSeconds) {
67  if (lifeTimeInSeconds <= 0) {
68  throw new IllegalArgumentException(String.format("Life time must be > 0. Provided value is %s", lifeTimeInSeconds));
69  }
70  this.lifeTimeInSeconds = lifeTimeInSeconds;
71  return this;
72  }
73 
78  public Builder withStartDelayInSeconds(long startDelayInSeconds) {
79  if (startDelayInSeconds < 0) {
80  throw new IllegalArgumentException(String.format("Start delay must be >= 0. Provided value is %s", startDelayInSeconds));
81  }
82  this.startDelayInSeconds = startDelayInSeconds;
83  return this;
84  }
85 
90  public Builder withSlewRateUsersPerSecond(long slewRateUsersPerSecond) {
91  if (slewRateUsersPerSecond <= 0) {
92  throw new IllegalArgumentException(
93  String.format("Slew rate users per second must be > 0. Provided value is %s", slewRateUsersPerSecond));
94  }
95  this.slewRateUsersPerSecond = slewRateUsersPerSecond;
96  return this;
97  }
98  }
99 
100  public long getNumberOfUsers() {
101  return numberOfUsers;
102  }
103 
104  public long getLifeTimeInSeconds() {
105  return lifeTimeInSeconds;
106  }
107 
108  public long getStartDelayInSeconds() {
109  return startDelayInSeconds;
110  }
111 
113  return slewRateUsersPerSecond;
114  }
115 }