Skip to content

Commit 348b4da

Browse files
committed
Add performance related datapoints
PLAYERS_ONLINE_AVERAGE CPU_AVERAGE RAM_AVERAGE MSPT_AVERAGE ENTITIES_AVERAGE CHUNKS_AVERAGE Renamed TPS_AVERAGE (was AVERAGE_TPS) UPTIME_CURRENT (was CURRENT_UPTIME
1 parent b03864b commit 348b4da

20 files changed

Lines changed: 690 additions & 66 deletions

File tree

Plan/common/src/main/java/com/djrapitops/plan/delivery/domain/auth/WebPermission.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,30 +148,36 @@ public enum WebPermission implements Supplier<String>, Lang {
148148
DATA_NETWORK_REGULAR_PLAYERS("See Regular players -datapoint of network"),
149149
DATA_SERVER_NEW_PLAYERS("See New players -datapoint of servers"),
150150
DATA_NETWORK_NEW_PLAYERS("See New players -datapoint of network"),
151-
DATA_PLAYER_SESSION_COUNT("See Session count datapoint of players"),
152-
DATA_SERVER_SESSION_COUNT("See Session count datapoint of servers"),
153-
DATA_NETWORK_SESSION_COUNT("See Session count datapoint of network"),
154-
DATA_PLAYER_SESSION_LENGTH_AVERAGE("See Average session length datapoint of players"),
155-
DATA_SERVER_SESSION_LENGTH_AVERAGE("See Average session length datapoint of servers"),
156-
DATA_NETWORK_SESSION_LENGTH_AVERAGE("See Average session length datapoint of network"),
157-
DATA_SERVER_PLAYTIME_PER_PLAYER_AVERAGE("See Average playtime per player datapoint of servers"),
158-
DATA_NETWORK_PLAYTIME_PER_PLAYER_AVERAGE("See Average playtime per player datapoint of network"),
151+
DATA_PLAYER_SESSION_COUNT("See Session count -datapoint of players"),
152+
DATA_SERVER_SESSION_COUNT("See Session count -datapoint of servers"),
153+
DATA_NETWORK_SESSION_COUNT("See Session count -datapoint of network"),
154+
DATA_PLAYER_SESSION_LENGTH_AVERAGE("See Average session length -datapoint of players"),
155+
DATA_SERVER_SESSION_LENGTH_AVERAGE("See Average session length -datapoint of servers"),
156+
DATA_NETWORK_SESSION_LENGTH_AVERAGE("See Average session length -datapoint of network"),
157+
DATA_SERVER_PLAYTIME_PER_PLAYER_AVERAGE("See Average playtime per player -datapoint of servers"),
158+
DATA_NETWORK_PLAYTIME_PER_PLAYER_AVERAGE("See Average playtime per player -datapoint of network"),
159159
DATA_SERVER_PLAYERS_ONLINE_PEAK("See Player online peak -datapoint of servers"),
160160
DATA_NETWORK_PLAYERS_ONLINE_PEAK("See Player online peak -datapoint of network"),
161161
DATA_SERVER_PLAYERS_ONLINE("See Players online -datapoint of servers"),
162162
DATA_NETWORK_PLAYERS_ONLINE("See Players online -datapoint of network"),
163-
DATA_SERVER_CURRENT_UPTIME("See Current uptime -datapoint of servers"),
164-
DATA_NETWORK_CURRENT_UPTIME("See Current uptime -datapoint of network"),
165-
DATA_PLAYER_MOB_KILLS("See Mob kills datapoint of players"),
166-
DATA_SERVER_MOB_KILLS("See Mob kills datapoint of servers"),
167-
DATA_NETWORK_MOB_KILLS("See Mob kills datapoint of network"),
168-
DATA_PLAYER_PLAYER_KILLS("See Player kills datapoint of players"),
169-
DATA_SERVER_PLAYER_KILLS("See Player kills datapoint of servers"),
170-
DATA_NETWORK_PLAYER_KILLS("See Player kills datapoint of network"),
163+
DATA_SERVER_UPTIME_CURRENT("See Current uptime -datapoint of servers"),
164+
DATA_NETWORK_UPTIME_CURRENT("See Current uptime -datapoint of network"),
165+
DATA_PLAYER_MOB_KILLS("See Mob kills -datapoint of players"),
166+
DATA_SERVER_MOB_KILLS("See Mob kills -datapoint of servers"),
167+
DATA_NETWORK_MOB_KILLS("See Mob kills -datapoint of network"),
168+
DATA_PLAYER_PLAYER_KILLS("See Player kills -datapoint of players"),
169+
DATA_SERVER_PLAYER_KILLS("See Player kills -datapoint of servers"),
170+
DATA_NETWORK_PLAYER_KILLS("See Player kills -datapoint of network"),
171171
DATA_PLAYER_DEATHS("See Deaths datapoint of players"),
172172
DATA_SERVER_DEATHS("See Deaths datapoint of servers"),
173173
DATA_NETWORK_DEATHS("See Deaths datapoint of network"),
174-
DATA_SERVER_AVERAGE_TPS("See Average TPS datapoint of servers"),
174+
DATA_SERVER_TPS_AVERAGE("See Average TPS -datapoint of servers"),
175+
DATA_SERVER_RAM_AVERAGE("See Average RAM -datapoint of servers"),
176+
DATA_SERVER_MSPT_AVERAGE("See Average MSPT -datapoint of servers"),
177+
DATA_SERVER_CPU_AVERAGE("See Average CPU -datapoint of servers"),
178+
DATA_SERVER_PLAYERS_ONLINE_AVERAGE("See Average Player online -datapoint of servers"),
179+
DATA_SERVER_ENTITIES_AVERAGE("See Average Entities -datapoint of servers"),
180+
DATA_SERVER_CHUNKS_AVERAGE("See Average Chunks -datapoint of servers"),
175181

176182
ACCESS("Controls access to pages"),
177183
ACCESS_PLAYER("Allows accessing any /player pages"),

Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public void exportJSON(Path toDirectory, ServerUUID serverUUID) throws IOExcepti
115115
String afterMillis = "&afterMillisAgo=";
116116
String beforeMillis = "&beforeMillisAgo=";
117117
exportJSON(toDirectory,
118-
"network/overview",
119118
"network/servers",
120119
"network/playerbaseOverview",
121120
"graph?type=playersOnline&server=" + serverUUID,
@@ -160,7 +159,7 @@ public void exportJSON(Path toDirectory, ServerUUID serverUUID) throws IOExcepti
160159
datapointType + DatapointType.PLAYER_KILLS,
161160
datapointType + DatapointType.MOB_KILLS,
162161
datapointType + DatapointType.DEATHS,
163-
datapointType + DatapointType.CURRENT_UPTIME,
162+
datapointType + DatapointType.UPTIME_CURRENT,
164163
// Week comparison
165164
datapointType + DatapointType.UNIQUE_PLAYERS + afterMillis + TimeUnit.DAYS.toMillis(14) + beforeMillis + TimeUnit.DAYS.toMillis(7L),
166165
datapointType + DatapointType.NEW_PLAYERS + afterMillis + TimeUnit.DAYS.toMillis(14) + beforeMillis + TimeUnit.DAYS.toMillis(7L),

Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ServerPageExporter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ public void exportJSON(Path toDirectory, ServerUUID serverUUID) throws IOExcepti
167167
datapointType + DatapointType.PLAYER_KILLS + server,
168168
datapointType + DatapointType.MOB_KILLS + server,
169169
datapointType + DatapointType.DEATHS + server,
170-
datapointType + DatapointType.CURRENT_UPTIME + server,
170+
datapointType + DatapointType.UPTIME_CURRENT + server,
171+
datapointType + DatapointType.TPS_AVERAGE + afterMillis + TimeUnit.DAYS.toMillis(7) + server,
171172
// Week comparison
172173
datapointType + DatapointType.UNIQUE_PLAYERS + afterMillis + TimeUnit.DAYS.toMillis(14) + beforeMillis + TimeUnit.DAYS.toMillis(7L) + server,
173174
datapointType + DatapointType.NEW_PLAYERS + afterMillis + TimeUnit.DAYS.toMillis(14) + beforeMillis + TimeUnit.DAYS.toMillis(7L) + server,

Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/datapoint/DatapointType.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ public enum DatapointType {
4545
PLAYTIME_PER_PLAYER_AVERAGE(PlaytimePerPlayerAverage.class, DatapointCacheKey.SESSION),
4646
PLAYERS_ONLINE_PEAK(PlayersOnlinePeak.class, DatapointCacheKey.TPS),
4747
PLAYERS_ONLINE(PlayersOnline.class, DatapointCacheKey.TPS),
48-
CURRENT_UPTIME(CurrentUptime.class),
48+
UPTIME_CURRENT(UptimeCurrent.class),
4949
MOB_KILLS(MobKills.class, DatapointCacheKey.SESSION),
5050
PLAYER_KILLS(PlayerKills.class, DatapointCacheKey.SESSION),
5151
DEATHS(Deaths.class, DatapointCacheKey.SESSION),
52-
AVERAGE_TPS(AverageTPS.class, DatapointCacheKey.TPS);
52+
PLAYERS_ONLINE_AVERAGE(PlayersOnlineAverage.class, DatapointCacheKey.TPS),
53+
TPS_AVERAGE(TPSAverage.class, DatapointCacheKey.TPS),
54+
MSPT_AVERAGE(MSPTAverage.class, DatapointCacheKey.TPS),
55+
CPU_AVERAGE(CPUAverage.class, DatapointCacheKey.TPS),
56+
RAM_AVERAGE(RAMAverage.class, DatapointCacheKey.TPS),
57+
ENTITIES_AVERAGE(EntitiesAverage.class, DatapointCacheKey.TPS),
58+
CHUNKS_AVERAGE(ChunksAverage.class, DatapointCacheKey.TPS);
5359

5460
private final Class<? extends Datapoint<?>> datapointClass;
5561
private final DatapointCacheKey[] cacheKeys;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* This file is part of Player Analytics (Plan).
3+
*
4+
* Plan is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License v3 as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Plan is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package com.djrapitops.plan.delivery.rendering.json.datapoint.types;
18+
19+
import com.djrapitops.plan.delivery.domain.auth.WebPermission;
20+
import com.djrapitops.plan.delivery.domain.datatransfer.GenericFilter;
21+
import com.djrapitops.plan.delivery.rendering.json.datapoint.Datapoint;
22+
import com.djrapitops.plan.delivery.rendering.json.datapoint.DatapointType;
23+
import com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException;
24+
import com.djrapitops.plan.storage.database.DBSystem;
25+
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
26+
27+
import javax.inject.Inject;
28+
import javax.inject.Singleton;
29+
import java.util.Optional;
30+
31+
/**
32+
* Datapoint for looking up Average CPU usage within the timeframe.
33+
*
34+
* @author AuroraLS3
35+
*/
36+
@Singleton
37+
public class CPUAverage implements Datapoint<Double> {
38+
39+
private final DBSystem dbSystem;
40+
41+
@Inject
42+
public CPUAverage(DBSystem dbSystem) {
43+
this.dbSystem = dbSystem;
44+
}
45+
46+
@Override
47+
public Optional<Double> getValue(GenericFilter filter) {
48+
if (filter.getPlayerUUID().isPresent()) {
49+
throw new BadRequestException("CPU_AVERAGE does not support player parameter");
50+
}
51+
52+
if (filter.getServerUUIDs().isEmpty()) {
53+
throw new BadRequestException("CPU_AVERAGE is only available for servers");
54+
}
55+
56+
double average = dbSystem.getDatabase().query(TPSQueries.averageCPU(filter.getAfter(), filter.getBefore(), filter.getServerUUIDs()));
57+
return average != -1.0 ? Optional.of(average) : Optional.empty();
58+
}
59+
60+
@Override
61+
public WebPermission getPermission(GenericFilter filter) {
62+
if (filter.getPlayerUUID().isPresent()) {
63+
return WebPermission.DATA_PLAYER;
64+
} else if (!filter.getServerUUIDs().isEmpty()) {
65+
return WebPermission.DATA_SERVER_CPU_AVERAGE;
66+
} else {
67+
return WebPermission.DATA_NETWORK;
68+
}
69+
}
70+
71+
@Override
72+
public DatapointType getType() {
73+
return DatapointType.CPU_AVERAGE;
74+
}
75+
76+
@Override
77+
public FormatType getFormatType() {
78+
return FormatType.PERCENTAGE;
79+
}
80+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* This file is part of Player Analytics (Plan).
3+
*
4+
* Plan is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License v3 as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Plan is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package com.djrapitops.plan.delivery.rendering.json.datapoint.types;
18+
19+
import com.djrapitops.plan.delivery.domain.auth.WebPermission;
20+
import com.djrapitops.plan.delivery.domain.datatransfer.GenericFilter;
21+
import com.djrapitops.plan.delivery.rendering.json.datapoint.Datapoint;
22+
import com.djrapitops.plan.delivery.rendering.json.datapoint.DatapointType;
23+
import com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException;
24+
import com.djrapitops.plan.storage.database.DBSystem;
25+
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
26+
27+
import javax.inject.Inject;
28+
import javax.inject.Singleton;
29+
import java.util.Optional;
30+
31+
/**
32+
* Datapoint for looking up Average CHUNKS usage within the timeframe.
33+
*
34+
* @author AuroraLS3
35+
*/
36+
@Singleton
37+
public class ChunksAverage implements Datapoint<Long> {
38+
39+
private final DBSystem dbSystem;
40+
41+
@Inject
42+
public ChunksAverage(DBSystem dbSystem) {
43+
this.dbSystem = dbSystem;
44+
}
45+
46+
@Override
47+
public Optional<Long> getValue(GenericFilter filter) {
48+
if (filter.getPlayerUUID().isPresent()) {
49+
throw new BadRequestException("CHUNKS_AVERAGE does not support player parameter");
50+
}
51+
52+
if (filter.getServerUUIDs().isEmpty()) {
53+
throw new BadRequestException("CHUNKS_AVERAGE is only available for servers");
54+
}
55+
56+
long average = dbSystem.getDatabase().query(TPSQueries.averageChunks(filter.getAfter(), filter.getBefore(), filter.getServerUUIDs()));
57+
return average != -1L ? Optional.of(average) : Optional.empty();
58+
}
59+
60+
@Override
61+
public WebPermission getPermission(GenericFilter filter) {
62+
if (filter.getPlayerUUID().isPresent()) {
63+
return WebPermission.DATA_PLAYER;
64+
} else if (!filter.getServerUUIDs().isEmpty()) {
65+
return WebPermission.DATA_SERVER_CHUNKS_AVERAGE;
66+
} else {
67+
return WebPermission.DATA_NETWORK;
68+
}
69+
}
70+
71+
@Override
72+
public DatapointType getType() {
73+
return DatapointType.CHUNKS_AVERAGE;
74+
}
75+
76+
@Override
77+
public FormatType getFormatType() {
78+
return FormatType.NONE;
79+
}
80+
}

Plan/common/src/main/java/com/djrapitops/plan/delivery/rendering/json/datapoint/types/DatapointModule.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public interface DatapointModule {
9898

9999
@Binds
100100
@IntoSet
101-
Datapoint<?> bindCurrentUptime(CurrentUptime currentUptime);
101+
Datapoint<?> bindUptimeCurrent(UptimeCurrent uptimeCurrent);
102102

103103
@Binds
104104
@IntoSet
@@ -110,5 +110,29 @@ public interface DatapointModule {
110110

111111
@Binds
112112
@IntoSet
113-
Datapoint<?> bindAverageTPS(AverageTPS averageTPS);
113+
Datapoint<?> bindTPSAverage(TPSAverage tpsAverage);
114+
115+
@Binds
116+
@IntoSet
117+
Datapoint<?> bindCPUAverage(CPUAverage cpuAverage);
118+
119+
@Binds
120+
@IntoSet
121+
Datapoint<?> bindMSPTAverage(MSPTAverage msptaverage);
122+
123+
@Binds
124+
@IntoSet
125+
Datapoint<?> bindPlayersOnlineAverage(PlayersOnlineAverage playersOnlineAverage);
126+
127+
@Binds
128+
@IntoSet
129+
Datapoint<?> bindRAMAverage(RAMAverage ramAverage);
130+
131+
@Binds
132+
@IntoSet
133+
Datapoint<?> bindEntitiesAverage(EntitiesAverage entitiesAverage);
134+
135+
@Binds
136+
@IntoSet
137+
Datapoint<?> bindChunksAverage(ChunksAverage chunksAverage);
114138
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* This file is part of Player Analytics (Plan).
3+
*
4+
* Plan is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License v3 as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Plan is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
package com.djrapitops.plan.delivery.rendering.json.datapoint.types;
18+
19+
import com.djrapitops.plan.delivery.domain.auth.WebPermission;
20+
import com.djrapitops.plan.delivery.domain.datatransfer.GenericFilter;
21+
import com.djrapitops.plan.delivery.rendering.json.datapoint.Datapoint;
22+
import com.djrapitops.plan.delivery.rendering.json.datapoint.DatapointType;
23+
import com.djrapitops.plan.delivery.web.resolver.exception.BadRequestException;
24+
import com.djrapitops.plan.storage.database.DBSystem;
25+
import com.djrapitops.plan.storage.database.queries.objects.TPSQueries;
26+
27+
import javax.inject.Inject;
28+
import javax.inject.Singleton;
29+
import java.util.Optional;
30+
31+
/**
32+
* Datapoint for looking up Average ENTITIES usage within the timeframe.
33+
*
34+
* @author AuroraLS3
35+
*/
36+
@Singleton
37+
public class EntitiesAverage implements Datapoint<Long> {
38+
39+
private final DBSystem dbSystem;
40+
41+
@Inject
42+
public EntitiesAverage(DBSystem dbSystem) {
43+
this.dbSystem = dbSystem;
44+
}
45+
46+
@Override
47+
public Optional<Long> getValue(GenericFilter filter) {
48+
if (filter.getPlayerUUID().isPresent()) {
49+
throw new BadRequestException("ENTITIES_AVERAGE does not support player parameter");
50+
}
51+
52+
if (filter.getServerUUIDs().isEmpty()) {
53+
throw new BadRequestException("ENTITIES_AVERAGE is only available for servers");
54+
}
55+
56+
long average = dbSystem.getDatabase().query(TPSQueries.averageEntities(filter.getAfter(), filter.getBefore(), filter.getServerUUIDs()));
57+
return average != -1L ? Optional.of(average) : Optional.empty();
58+
}
59+
60+
@Override
61+
public WebPermission getPermission(GenericFilter filter) {
62+
if (filter.getPlayerUUID().isPresent()) {
63+
return WebPermission.DATA_PLAYER;
64+
} else if (!filter.getServerUUIDs().isEmpty()) {
65+
return WebPermission.DATA_SERVER_ENTITIES_AVERAGE;
66+
} else {
67+
return WebPermission.DATA_NETWORK;
68+
}
69+
}
70+
71+
@Override
72+
public DatapointType getType() {
73+
return DatapointType.ENTITIES_AVERAGE;
74+
}
75+
76+
@Override
77+
public FormatType getFormatType() {
78+
return FormatType.NONE;
79+
}
80+
}

0 commit comments

Comments
 (0)