use of com.djrapitops.plan.storage.database.transactions.ExecBatchStatement in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllPlanServerInformation.
/**
* Execute a big batch of server information insert statements.
*
* @param servers Collection of Plan Servers.
* @return Executable, use inside a {@link com.djrapitops.plan.storage.database.transactions.Transaction}
*/
public static Executable storeAllPlanServerInformation(Collection<Server> servers) {
if (servers == null || servers.isEmpty())
return Executable.empty();
return new ExecBatchStatement(ServerTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
for (Server server : servers) {
ServerUUID serverUUID = server.getUuid();
if (serverUUID == null) {
continue;
}
statement.setString(1, serverUUID.toString());
statement.setString(2, server.getName());
statement.setString(3, server.getWebAddress());
statement.setBoolean(4, true);
statement.setBoolean(5, server.isProxy());
statement.setString(6, server.getPlanVersion());
statement.addBatch();
}
}
};
}
use of com.djrapitops.plan.storage.database.transactions.ExecBatchStatement in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllNicknameData.
/**
* Execute a big batch of nickname insert statements.
*
* @param ofServersAndUsers Multimap: Server UUID - (Player UUID - List of nicknames)
* @return Executable, use inside a {@link com.djrapitops.plan.storage.database.transactions.Transaction}
*/
public static Executable storeAllNicknameData(Map<ServerUUID, Map<UUID, List<Nickname>>> ofServersAndUsers) {
if (ofServersAndUsers == null || ofServersAndUsers.isEmpty())
return Executable.empty();
return new ExecBatchStatement(NicknamesTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
// Every Server
for (Map.Entry<ServerUUID, Map<UUID, List<Nickname>>> serverEntry : ofServersAndUsers.entrySet()) {
ServerUUID serverUUID = serverEntry.getKey();
// Every User
for (Map.Entry<UUID, List<Nickname>> entry : serverEntry.getValue().entrySet()) {
UUID uuid = entry.getKey();
// Every Nickname
List<Nickname> nicknames = entry.getValue();
for (Nickname nickname : nicknames) {
statement.setString(1, uuid.toString());
statement.setString(2, serverUUID.toString());
statement.setString(3, nickname.getName());
statement.setLong(4, nickname.getDate());
statement.addBatch();
}
}
}
}
};
}
use of com.djrapitops.plan.storage.database.transactions.ExecBatchStatement in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllGeoInformation.
/**
* Execute a big batch of GeoInfo insert statements.
*
* @param ofUsers Map: Player UUID - List of GeoInfo
* @return Executable, use inside a {@link com.djrapitops.plan.storage.database.transactions.Transaction}
*/
public static Executable storeAllGeoInformation(Map<UUID, List<GeoInfo>> ofUsers) {
if (ofUsers == null || ofUsers.isEmpty())
return Executable.empty();
return new ExecBatchStatement(GeoInfoTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
// Every User
for (Map.Entry<UUID, List<GeoInfo>> playerEntry : ofUsers.entrySet()) {
UUID playerUUID = playerEntry.getKey();
// Every GeoInfo
for (GeoInfo info : playerEntry.getValue()) {
String geoLocation = info.getGeolocation();
long lastUsed = info.getDate();
statement.setString(1, playerUUID.toString());
statement.setString(2, geoLocation);
statement.setLong(3, lastUsed);
statement.addBatch();
}
}
}
};
}
use of com.djrapitops.plan.storage.database.transactions.ExecBatchStatement in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllTPSData.
/**
* Execute a big batch of TPS insert statements.
*
* @param ofServers Map: Server UUID - List of TPS data
* @return Executable, use inside a {@link com.djrapitops.plan.storage.database.transactions.Transaction}
*/
public static Executable storeAllTPSData(Map<ServerUUID, List<TPS>> ofServers) {
if (ofServers == null || ofServers.isEmpty())
return Executable.empty();
return new ExecBatchStatement(TPSTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
// Every Server
for (Map.Entry<ServerUUID, List<TPS>> entry : ofServers.entrySet()) {
ServerUUID serverUUID = entry.getKey();
// Every TPS Data point
List<TPS> tpsList = entry.getValue();
for (TPS tps : tpsList) {
statement.setString(1, serverUUID.toString());
statement.setLong(2, tps.getDate());
statement.setDouble(3, tps.getTicksPerSecond());
statement.setInt(4, tps.getPlayers());
statement.setDouble(5, tps.getCPUUsage());
statement.setLong(6, tps.getUsedMemory());
statement.setDouble(7, tps.getEntityCount());
statement.setDouble(8, tps.getChunksLoaded());
statement.setLong(9, tps.getFreeDiskSpace());
statement.addBatch();
}
}
}
};
}
use of com.djrapitops.plan.storage.database.transactions.ExecBatchStatement in project Plan by plan-player-analytics.
the class LargeStoreQueries method storeAllPingData.
public static Executable storeAllPingData(Map<UUID, List<Ping>> ofUsers) {
if (ofUsers == null || ofUsers.isEmpty())
return Executable.empty();
return new ExecBatchStatement(PingTable.INSERT_STATEMENT) {
@Override
public void prepare(PreparedStatement statement) throws SQLException {
for (Map.Entry<UUID, List<Ping>> entry : ofUsers.entrySet()) {
UUID uuid = entry.getKey();
List<Ping> pings = entry.getValue();
for (Ping ping : pings) {
ServerUUID serverUUID = ping.getServerUUID();
long date = ping.getDate();
int minPing = ping.getMin();
int maxPing = ping.getMax();
double avgPing = ping.getAverage();
statement.setString(1, uuid.toString());
statement.setString(2, serverUUID.toString());
statement.setLong(3, date);
statement.setInt(4, minPing);
statement.setInt(5, maxPing);
statement.setDouble(6, avgPing);
statement.addBatch();
}
}
}
};
}
Aggregations