mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Removed redundant stuff about MySQL page transfer
This commit is contained in:
parent
bf77d6edfa
commit
fb994264e7
@ -6,7 +6,6 @@ package com.djrapitops.plan.system.database.databases.operation;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -21,28 +20,10 @@ public interface TransferOperations {
|
||||
|
||||
// Save
|
||||
|
||||
@Deprecated
|
||||
void storePlayerHtml(UUID player, String encodedHtml) throws DBException;
|
||||
|
||||
@Deprecated
|
||||
void storeServerHtml(UUID serverUUID, String encodedHtml) throws DBException;
|
||||
|
||||
@Deprecated
|
||||
void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException;
|
||||
|
||||
void storeConfigSettings(String encodedSettingString) throws DBException;
|
||||
|
||||
// Get
|
||||
|
||||
@Deprecated
|
||||
Map<UUID, String> getEncodedPlayerHtml() throws DBException;
|
||||
|
||||
@Deprecated
|
||||
Map<UUID, String> getEncodedNetworkPageContent() throws DBException;
|
||||
|
||||
@Deprecated
|
||||
Map<UUID, String> getEncodedServerHtml() throws DBException;
|
||||
|
||||
@Deprecated
|
||||
Optional<UUID> getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException;
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.djrapitops.plan.system.database.databases.operation.TransferOperation
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -24,60 +23,6 @@ public class SQLTransferOps extends SQLOps implements TransferOperations {
|
||||
super(db);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storePlayerHtml(UUID player, String encodedHtml) throws DBException {
|
||||
try {
|
||||
transferTable.storePlayerHtml(player, encodedHtml);
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeServerHtml(UUID serverUUID, String encodedHtml) throws DBException {
|
||||
try {
|
||||
transferTable.storeServerHtml(serverUUID, encodedHtml);
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException {
|
||||
try {
|
||||
transferTable.storeNetworkPageContent(serverUUID, encodedHtml);
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getEncodedPlayerHtml() throws DBException {
|
||||
try {
|
||||
return transferTable.getPlayerHtml();
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getEncodedNetworkPageContent() throws DBException {
|
||||
try {
|
||||
return transferTable.getNetworkPageContent();
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getEncodedServerHtml() throws DBException {
|
||||
try {
|
||||
return transferTable.getServerHtml();
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UUID> getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException {
|
||||
try {
|
||||
|
@ -11,19 +11,15 @@ import com.djrapitops.plan.system.database.databases.sql.processing.QueryStateme
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Column;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.Sql;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||
import com.djrapitops.plan.system.info.request.CacheAnalysisPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.CacheInspectPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.CacheInspectPluginsTabRequest;
|
||||
import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Table that is in charge of transferring data between network servers.
|
||||
@ -116,142 +112,6 @@ public class TransferTable extends Table {
|
||||
});
|
||||
}
|
||||
|
||||
public void storePlayerHtml(UUID player, String encodedHtml) throws SQLException {
|
||||
execute(new ExecStatement(insertStatementNoParts) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms());
|
||||
statement.setString(3, CacheInspectPageRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setString(4, player.toString());
|
||||
statement.setString(5, encodedHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void storeServerHtml(UUID serverUUID, String encodedHtml) throws SQLException {
|
||||
List<String> split = Base64Util.split(encodedHtml, 500000L);
|
||||
|
||||
int i = 0;
|
||||
long expires = MiscUtils.getTime() + TimeAmount.MINUTE.ms();
|
||||
for (String part : split) {
|
||||
final int partNumber = i;
|
||||
execute(new ExecStatement(insertStatementParts) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setLong(2, expires);
|
||||
statement.setString(3, CacheAnalysisPageRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setString(4, serverUUID.toString());
|
||||
statement.setString(5, part);
|
||||
statement.setInt(6, partNumber);
|
||||
}
|
||||
});
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws SQLException {
|
||||
execute(new ExecStatement(insertStatementNoParts) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms());
|
||||
statement.setString(3, CacheNetworkPageContentRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setString(4, serverUUID.toString());
|
||||
statement.setString(5, encodedHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Map<UUID, String> getHtmlPerUUIDForCacheRequest(Class c) throws SQLException {
|
||||
return query(new QueryStatement<Map<UUID, String>>(selectStatement, 250) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, c.getSimpleName().toLowerCase());
|
||||
statement.setLong(2, MiscUtils.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, String> htmlPerUUID = new HashMap<>();
|
||||
Map<UUID, Long> expiry = new HashMap<>();
|
||||
while (set.next()) {
|
||||
String uuidString = set.getString(Col.EXTRA_VARIABLES.get());
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
|
||||
long expires = set.getLong(Col.EXPIRY.get());
|
||||
|
||||
long correctExpiry = expiry.getOrDefault(uuid, expires);
|
||||
if (expires == correctExpiry) {
|
||||
htmlPerUUID.put(uuid, htmlPerUUID.getOrDefault(uuid, "") + set.getString(Col.CONTENT.get()));
|
||||
expiry.put(uuid, correctExpiry);
|
||||
}
|
||||
}
|
||||
return htmlPerUUID;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void storePlayerPluginsTab(UUID player, String encodedHtml) throws SQLException {
|
||||
execute(new ExecStatement(insertStatementNoParts) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms());
|
||||
statement.setString(3, CacheInspectPluginsTabRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setString(4, player.toString());
|
||||
statement.setString(5, encodedHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<UUID, String> getPlayerHtml() throws SQLException {
|
||||
return getHtmlPerUUIDForCacheRequest(CacheInspectPageRequest.class);
|
||||
}
|
||||
|
||||
public Map<UUID, String> getNetworkPageContent() throws SQLException {
|
||||
return getHtmlPerUUIDForCacheRequest(CacheNetworkPageContentRequest.class);
|
||||
}
|
||||
|
||||
public Map<UUID, String> getServerHtml() throws SQLException {
|
||||
return getHtmlPerUUIDForCacheRequest(CacheAnalysisPageRequest.class);
|
||||
}
|
||||
|
||||
public Map<UUID, String> getPlayerPluginsTabs(UUID playerUUID) throws SQLException {
|
||||
String serverIDColumn = serverTable + "." + ServerTable.Col.SERVER_ID;
|
||||
String serverUUIDColumn = serverTable + "." + ServerTable.Col.SERVER_UUID + " as s_uuid";
|
||||
String sql = "SELECT " +
|
||||
Col.CONTENT + ", " +
|
||||
serverUUIDColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + serverTable + " on " + serverIDColumn + "=" + Col.SENDER_ID +
|
||||
" WHERE " + Col.INFO_TYPE + "= ?" +
|
||||
" AND " + Col.EXPIRY + "> ?" +
|
||||
" AND " + Col.EXTRA_VARIABLES + "=?";
|
||||
|
||||
return query(new QueryStatement<Map<UUID, String>>(sql, 250) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, CacheInspectPluginsTabRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setLong(2, MiscUtils.getTime());
|
||||
statement.setString(3, playerUUID.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, String> htmlPerUUID = new HashMap<>();
|
||||
while (set.next()) {
|
||||
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
|
||||
String html64 = set.getString(Col.CONTENT.get());
|
||||
|
||||
htmlPerUUID.put(serverUUID, html64);
|
||||
}
|
||||
return htmlPerUUID;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Optional<UUID> getServerPlayerIsOnline(UUID playerUUID) throws SQLException {
|
||||
String serverIDColumn = serverTable + "." + ServerTable.Col.SERVER_ID;
|
||||
@ -279,20 +139,6 @@ public class TransferTable extends Table {
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void storePlayerOnlineOnThisServer(UUID playerUUID) throws SQLException {
|
||||
execute(new ExecStatement(insertStatementNoParts) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms());
|
||||
statement.setString(3, "onlineStatus");
|
||||
statement.setString(4, playerUUID.toString());
|
||||
statement.setString(5, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void storeConfigSettings(String encodedSettingString) throws SQLException {
|
||||
execute(new ExecStatement(insertStatementNoParts) {
|
||||
@Override
|
||||
|
@ -48,8 +48,7 @@ public class NetworkPageContent extends Response {
|
||||
"data-container=\"body\" data-html=\"true\" " +
|
||||
"data-original-title=\"No Servers\" " +
|
||||
"data-content=\"This is displayed when no servers have sent server information to Bungee." +
|
||||
"<br><br>You can try debugging the cause by using /planbungee con & /plan m con" +
|
||||
"<br><br>If MySQL max_packet_size is too small that may cause page transfer to fail.\"" +
|
||||
"<br><br>You can try debugging the cause by using /planbungee con & /plan m con\"" +
|
||||
">help_outline</a></div></div></div>" +
|
||||
"<div class=\"body\">" +
|
||||
"<p>No Servers have sent information to Bungee.</p>" +
|
||||
|
@ -897,29 +897,6 @@ public class SQLiteTest {
|
||||
assertEquals(testString, Base64Util.decode(configSettings.get()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferSplitAndRearrange() throws SQLException {
|
||||
StringBuilder testData = new StringBuilder();
|
||||
for (int i = 0; i < 900000; i++) {
|
||||
testData.append("a");
|
||||
}
|
||||
|
||||
String testString = Base64Util.encode(testData.toString());
|
||||
|
||||
int length = testString.length();
|
||||
System.out.println("Test String Length: " + length);
|
||||
assertTrue(length > 500000);
|
||||
|
||||
System.out.println("Test Parts: " + (int) Math.ceil(length / 500000.0));
|
||||
|
||||
TransferTable transferTable = db.getTransferTable();
|
||||
transferTable.storeServerHtml(TestConstants.SERVER_UUID, testString);
|
||||
|
||||
String result = transferTable.getServerHtml().get(TestConstants.SERVER_UUID);
|
||||
assertNotNull(result);
|
||||
assertEquals(testString, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNetworkGeolocations() throws SQLException {
|
||||
GeoInfoTable geoInfoTable = db.getGeoInfoTable();
|
||||
|
Loading…
Reference in New Issue
Block a user