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;
/** The time the configuration was last touched. */
private volatile long lastConfigurationUpdate;
+ private final MetricRegistry metricRegistry;
+
/**
* Creates a new core.
*
* 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;
this.webOfTrustUpdater = webOfTrustUpdater;
this.eventBus = eventBus;
this.database = database;
+ this.metricRegistry = metricRegistry;
preferences = new Preferences(eventBus);
}
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) {
*/
@Subscribe
public void ownIdentityAdded(OwnIdentityAddedEvent ownIdentityAddedEvent) {
- OwnIdentity ownIdentity = ownIdentityAddedEvent.ownIdentity();
+ OwnIdentity ownIdentity = ownIdentityAddedEvent.getOwnIdentity();
logger.log(Level.FINEST, String.format("Adding OwnIdentity: %s", ownIdentity));
if (ownIdentity.hasContext("Sone")) {
addLocalSone(ownIdentity);
*/
@Subscribe
public void ownIdentityRemoved(OwnIdentityRemovedEvent ownIdentityRemovedEvent) {
- OwnIdentity ownIdentity = ownIdentityRemovedEvent.ownIdentity();
+ OwnIdentity ownIdentity = ownIdentityRemovedEvent.getOwnIdentity();
logger.log(Level.FINEST, String.format("Removing OwnIdentity: %s", ownIdentity));
trustedIdentities.removeAll(ownIdentity);
}
*/
@Subscribe
public void identityAdded(IdentityAddedEvent identityAddedEvent) {
- Identity identity = identityAddedEvent.identity();
+ Identity identity = identityAddedEvent.getIdentity();
logger.log(Level.FINEST, String.format("Adding Identity: %s", identity));
- trustedIdentities.put(identityAddedEvent.ownIdentity(), identity);
+ trustedIdentities.put(identityAddedEvent.getOwnIdentity(), identity);
addRemoteSone(identity);
}
*/
@Subscribe
public void identityUpdated(IdentityUpdatedEvent identityUpdatedEvent) {
- Identity identity = identityUpdatedEvent.identity();
+ Identity identity = identityUpdatedEvent.getIdentity();
final Sone sone = getRemoteSone(identity.getId());
if (sone.isLocal()) {
return;
*/
@Subscribe
public void identityRemoved(IdentityRemovedEvent identityRemovedEvent) {
- OwnIdentity ownIdentity = identityRemovedEvent.ownIdentity();
- Identity identity = identityRemovedEvent.identity();
+ OwnIdentity ownIdentity = identityRemovedEvent.getOwnIdentity();
+ Identity identity = identityRemovedEvent.getIdentity();
trustedIdentities.remove(ownIdentity, identity);
for (Entry<OwnIdentity, Collection<Identity>> trustedIdentity : trustedIdentities.asMap().entrySet()) {
if (trustedIdentity.getKey().equals(ownIdentity)) {