From fb994264e7342143dcdcc01727b25ea4f47cec71 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Mon, 2 Apr 2018 11:35:01 +0300 Subject: [PATCH] Removed redundant stuff about MySQL page transfer --- .../operation/TransferOperations.java | 19 --- .../sql/operation/SQLTransferOps.java | 55 ------ .../databases/sql/tables/TransferTable.java | 158 +----------------- .../pages/parts/NetworkPageContent.java | 3 +- .../system/database/databases/SQLiteTest.java | 23 --- 5 files changed, 3 insertions(+), 255 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java index d47e487f3..add26f022 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/operation/TransferOperations.java @@ -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 getEncodedPlayerHtml() throws DBException; - - @Deprecated - Map getEncodedNetworkPageContent() throws DBException; - - @Deprecated - Map getEncodedServerHtml() throws DBException; - @Deprecated Optional getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java index 9076f0665..b94a16208 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLTransferOps.java @@ -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 getEncodedPlayerHtml() throws DBException { - try { - return transferTable.getPlayerHtml(); - } catch (SQLException e) { - throw SQLErrorUtil.getExceptionFor(e); - } - } - - @Override - public Map getEncodedNetworkPageContent() throws DBException { - try { - return transferTable.getNetworkPageContent(); - } catch (SQLException e) { - throw SQLErrorUtil.getExceptionFor(e); - } - } - - @Override - public Map getEncodedServerHtml() throws DBException { - try { - return transferTable.getServerHtml(); - } catch (SQLException e) { - throw SQLErrorUtil.getExceptionFor(e); - } - } - @Override public Optional getServerPlayerIsOnlineOn(UUID playerUUID) throws DBException { try { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java index 7e16e2cad..aa9ca928c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TransferTable.java @@ -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 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 getHtmlPerUUIDForCacheRequest(Class c) throws SQLException { - return query(new QueryStatement>(selectStatement, 250) { - @Override - public void prepare(PreparedStatement statement) throws SQLException { - statement.setString(1, c.getSimpleName().toLowerCase()); - statement.setLong(2, MiscUtils.getTime()); - } - - @Override - public Map processResults(ResultSet set) throws SQLException { - Map htmlPerUUID = new HashMap<>(); - Map 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 getPlayerHtml() throws SQLException { - return getHtmlPerUUIDForCacheRequest(CacheInspectPageRequest.class); - } - - public Map getNetworkPageContent() throws SQLException { - return getHtmlPerUUIDForCacheRequest(CacheNetworkPageContentRequest.class); - } - - public Map getServerHtml() throws SQLException { - return getHtmlPerUUIDForCacheRequest(CacheAnalysisPageRequest.class); - } - - public Map 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>(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 processResults(ResultSet set) throws SQLException { - Map 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 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 diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java index c5365a934..e9f5daf43 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java @@ -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." + - "

You can try debugging the cause by using /planbungee con & /plan m con" + - "

If MySQL max_packet_size is too small that may cause page transfer to fail.\"" + + "

You can try debugging the cause by using /planbungee con & /plan m con\"" + ">help_outline" + "
" + "

No Servers have sent information to Bungee.

" + diff --git a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java index dc86f410f..c80c497bc 100644 --- a/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java +++ b/Plan/src/test/java/com/djrapitops/plan/system/database/databases/SQLiteTest.java @@ -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();