X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=c3af217d666f2b9b6c702c364b4e9c3fdb5c507a;hp=e0bd8044d8edac5b62c45ec9e6490d73136632c2;hb=aa83028a17a61b8a2103475fae4624fbfe4c9ca5;hpb=49872c388489260aa2e4ecd42dfda1aaebb8d2db diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e0bd804..c3af217 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -44,24 +44,13 @@ import java.util.logging.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.codahale.metrics.*; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidAlbumFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidImageFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidParentAlbumFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidPostFound; import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidPostReplyFound; -import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent; -import net.pterodactylus.sone.core.event.InsertionDelayChangedEvent; -import net.pterodactylus.sone.core.event.MarkPostKnownEvent; -import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent; -import net.pterodactylus.sone.core.event.MarkSoneKnownEvent; -import net.pterodactylus.sone.core.event.NewPostFoundEvent; -import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent; -import net.pterodactylus.sone.core.event.NewSoneFoundEvent; -import net.pterodactylus.sone.core.event.PostRemovedEvent; -import net.pterodactylus.sone.core.event.PostReplyRemovedEvent; -import net.pterodactylus.sone.core.event.SoneLockedEvent; -import net.pterodactylus.sone.core.event.SoneRemovedEvent; -import net.pterodactylus.sone.core.event.SoneUnlockedEvent; +import net.pterodactylus.sone.core.event.*; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Client; import net.pterodactylus.sone.data.Image; @@ -186,6 +175,8 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, /** The time the configuration was last touched. */ private volatile long lastConfigurationUpdate; + private final MetricRegistry metricRegistry; + /** * Creates a new core. * @@ -203,7 +194,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, * The database */ @Inject - public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database) { + public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database, MetricRegistry metricRegistry) { super("Sone Core"); this.configuration = configuration; this.freenetInterface = freenetInterface; @@ -214,6 +205,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, this.webOfTrustUpdater = webOfTrustUpdater; this.eventBus = eventBus; this.database = database; + this.metricRegistry = metricRegistry; preferences = new Preferences(eventBus); } @@ -235,6 +227,11 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, return debug.get(); } + public void setDebug() { + debug.set(true); + eventBus.post(new DebugActivatedEvent()); + } + /** * Returns the options used by the core. * @@ -625,7 +622,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, sone.setLatestEdition(fromNullable(tryParse(property)).or(0L)); sone.setClient(new Client("Sone", SonePlugin.getPluginVersion())); sone.setKnown(true); - SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, ownIdentity.getId()); + SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, metricRegistry, ownIdentity.getId()); soneInserter.insertionDelayChanged(new InsertionDelayChangedEvent(preferences.getInsertionDelay())); eventBus.register(soneInserter); synchronized (soneInserters) {