parent
c9bd700d31
commit
9170f74887
|
@ -53,6 +53,9 @@ public abstract class Messages {
|
||||||
@SqlUpdate("DELETE FROM messages WHERE " + DESTINATION + " = :destination")
|
@SqlUpdate("DELETE FROM messages WHERE " + DESTINATION + " = :destination")
|
||||||
abstract void clear(@Bind("destination") String destination);
|
abstract void clear(@Bind("destination") String destination);
|
||||||
|
|
||||||
|
@SqlUpdate("VACUUM messages")
|
||||||
|
public abstract void vacuum();
|
||||||
|
|
||||||
public static class MessageMapper implements ResultSetMapper<Pair<Long, OutgoingMessageSignal>> {
|
public static class MessageMapper implements ResultSetMapper<Pair<Long, OutgoingMessageSignal>> {
|
||||||
@Override
|
@Override
|
||||||
public Pair<Long, OutgoingMessageSignal> map(int i, ResultSet resultSet, StatementContext statementContext)
|
public Pair<Long, OutgoingMessageSignal> map(int i, ResultSet resultSet, StatementContext statementContext)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.storage.Accounts;
|
import org.whispersystems.textsecuregcm.storage.Accounts;
|
||||||
import org.whispersystems.textsecuregcm.storage.Keys;
|
import org.whispersystems.textsecuregcm.storage.Keys;
|
||||||
|
import org.whispersystems.textsecuregcm.storage.Messages;
|
||||||
import org.whispersystems.textsecuregcm.storage.PendingAccounts;
|
import org.whispersystems.textsecuregcm.storage.PendingAccounts;
|
||||||
|
|
||||||
import io.dropwizard.cli.ConfiguredCommand;
|
import io.dropwizard.cli.ConfiguredCommand;
|
||||||
|
@ -32,17 +33,25 @@ public class VacuumCommand extends ConfiguredCommand<WhisperServerConfiguration>
|
||||||
WhisperServerConfiguration config)
|
WhisperServerConfiguration config)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
DataSourceFactory dbConfig = config.getDataSourceFactory();
|
DataSourceFactory dbConfig = config.getDataSourceFactory();
|
||||||
DBI dbi = new DBI(dbConfig.getUrl(), dbConfig.getUser(), dbConfig.getPassword());
|
DataSourceFactory messageDbConfig = config.getMessageStoreConfiguration();
|
||||||
|
DBI dbi = new DBI(dbConfig.getUrl(), dbConfig.getUser(), dbConfig.getPassword() );
|
||||||
|
DBI messageDbi = new DBI(messageDbConfig.getUrl(), messageDbConfig.getUser(), messageDbConfig.getPassword());
|
||||||
|
|
||||||
dbi.registerArgumentFactory(new OptionalArgumentFactory(dbConfig.getDriverClass()));
|
dbi.registerArgumentFactory(new OptionalArgumentFactory(dbConfig.getDriverClass()));
|
||||||
dbi.registerContainerFactory(new ImmutableListContainerFactory());
|
dbi.registerContainerFactory(new ImmutableListContainerFactory());
|
||||||
dbi.registerContainerFactory(new ImmutableSetContainerFactory());
|
dbi.registerContainerFactory(new ImmutableSetContainerFactory());
|
||||||
dbi.registerContainerFactory(new OptionalContainerFactory());
|
dbi.registerContainerFactory(new OptionalContainerFactory());
|
||||||
|
|
||||||
|
messageDbi.registerArgumentFactory(new OptionalArgumentFactory(dbConfig.getDriverClass()));
|
||||||
|
messageDbi.registerContainerFactory(new ImmutableListContainerFactory());
|
||||||
|
messageDbi.registerContainerFactory(new ImmutableSetContainerFactory());
|
||||||
|
messageDbi.registerContainerFactory(new OptionalContainerFactory());
|
||||||
|
|
||||||
Accounts accounts = dbi.onDemand(Accounts.class );
|
Accounts accounts = dbi.onDemand(Accounts.class );
|
||||||
Keys keys = dbi.onDemand(Keys.class );
|
Keys keys = dbi.onDemand(Keys.class );
|
||||||
PendingAccounts pendingAccounts = dbi.onDemand(PendingAccounts.class);
|
PendingAccounts pendingAccounts = dbi.onDemand(PendingAccounts.class);
|
||||||
|
Messages messages = dbi.onDemand(Messages.class );
|
||||||
|
|
||||||
logger.warn("Vacuuming accounts...");
|
logger.warn("Vacuuming accounts...");
|
||||||
accounts.vacuum();
|
accounts.vacuum();
|
||||||
|
@ -53,6 +62,9 @@ public class VacuumCommand extends ConfiguredCommand<WhisperServerConfiguration>
|
||||||
logger.warn("Vacuuming keys...");
|
logger.warn("Vacuuming keys...");
|
||||||
keys.vacuum();
|
keys.vacuum();
|
||||||
|
|
||||||
|
logger.warn("Vacuuming messages...");
|
||||||
|
messages.vacuum();
|
||||||
|
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue