mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-28 02:54:20 +01:00
Periodic DBCommit task. Removed remaints of KillData victimID
This commit is contained in:
parent
8e2e710f98
commit
af63e3cb92
@ -22,6 +22,7 @@ public class DBCommitProcessor extends Processor<Database> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() {
|
public void process() {
|
||||||
|
// TODO Prevent Commit during batch operations.
|
||||||
try {
|
try {
|
||||||
object.commit();
|
object.commit();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package main.java.com.djrapitops.plan.data.listeners;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
|
import main.java.com.djrapitops.plan.data.handling.DBCommitProcessor;
|
||||||
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Periodically commits changes to the SQLite Database.
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class PeriodicDBCommitTask extends AbsRunnable {
|
||||||
|
|
||||||
|
private Plan plugin;
|
||||||
|
|
||||||
|
public PeriodicDBCommitTask(Plan plugin) {
|
||||||
|
super("PeriodicDBCommitTask");
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Database db = plugin.getDB();
|
||||||
|
if ("mysql".equals(db.getConfigName())) {
|
||||||
|
this.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plugin.addToProcessQueue(new DBCommitProcessor(db));
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
package test.java.main.java.com.djrapitops.plan.data;
|
package test.java.main.java.com.djrapitops.plan.data;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.data.KillData;
|
import main.java.com.djrapitops.plan.data.KillData;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -17,20 +18,27 @@ import static org.junit.Assert.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class KillDataTest {
|
public class KillDataTest {
|
||||||
|
|
||||||
|
private KillData test;
|
||||||
|
private UUID testUUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public KillDataTest() {
|
public KillDataTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
testUUID = UUID.fromString("71cfb6f0-c3ef-4954-8abe-13fa07afc340");
|
||||||
|
test = new KillData(testUUID, "TestWeapon", 100L);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetVictim() {
|
public void testGetVictim() {
|
||||||
UUID uuid = UUID.fromString("71cfb6f0-c3ef-4954-8abe-13fa07afc340");
|
assertEquals(test.getVictim(), testUUID);
|
||||||
KillData k = new KillData(uuid, 1, "TestWeapon", 100L);
|
|
||||||
assertEquals(k.getVictim(), uuid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,9 +46,7 @@ public class KillDataTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetDate() {
|
public void testGetDate() {
|
||||||
UUID uuid = UUID.fromString("71cfb6f0-c3ef-4954-8abe-13fa07afc340");
|
assertEquals(test.getDate(), 100L);
|
||||||
KillData k = new KillData(uuid, 1, "TestWeapon", 100L);
|
|
||||||
assertEquals(k.getDate(), 100L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,19 +54,6 @@ public class KillDataTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetWeapon() {
|
public void testGetWeapon() {
|
||||||
UUID uuid = UUID.fromString("71cfb6f0-c3ef-4954-8abe-13fa07afc340");
|
assertEquals(test.getWeapon(), "TestWeapon");
|
||||||
KillData k = new KillData(uuid, 1, "TestWeapon", 100L);
|
|
||||||
assertEquals(k.getWeapon(), "TestWeapon");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetVictimUserID() {
|
|
||||||
UUID uuid = UUID.fromString("71cfb6f0-c3ef-4954-8abe-13fa07afc340");
|
|
||||||
KillData k = new KillData(uuid, 1, "TestWeapon", 100L);
|
|
||||||
assertEquals(k.getVictimUserID(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,14 @@ public class DatabaseCommitTest {
|
|||||||
assertTrue("Errors were caught.", rows == rowsAgain);
|
assertTrue("Errors were caught.", rows == rowsAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoExceptionWhenCommitEmpty() throws SQLException {
|
||||||
|
db.init();
|
||||||
|
db.commit();
|
||||||
|
db.commit();
|
||||||
|
db.commit();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommitToDBFile() throws SQLException {
|
public void testCommitToDBFile() throws SQLException {
|
||||||
db.init();
|
db.init();
|
||||||
|
Loading…
Reference in New Issue
Block a user