Skip to content

Commit

Permalink
added objectssize to rdf response
Browse files Browse the repository at this point in the history
  • Loading branch information
fasseg committed May 17, 2013
1 parent 9daa136 commit 96cf287
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/JcrRdfTools.java
Expand Up @@ -24,6 +24,7 @@
import org.slf4j.Logger;

import com.codahale.metrics.Counter;
import com.codahale.metrics.Timer;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.hp.hpl.jena.datatypes.RDFDatatype;
Expand Down Expand Up @@ -155,17 +156,33 @@ public static Model getJcrPropertiesModel(
return model;
}

/**
* @param factory
* @param node
* @param model
*/
private static void addRepositoryMetricsToModel(GraphSubjects factory,
Node node, Model model) throws RepositoryException{
/* retreive the metrics from the service */
SortedMap<String, Counter> counters = RepositoryService.getMetrics().getCounters();
model.add(factory.getGraphSubject(node),model.createProperty("info:fedora/fedora-system:def/internal#numFixityChecks"), ResourceFactory.createTypedLiteral(counters.get("org.fcrepo.services.LowLevelStorageService.fixity-check-counter").getCount()));
model.add(factory.getGraphSubject(node),model.createProperty("info:fedora/fedora-system:def/internal#numFixityErrors"), ResourceFactory.createTypedLiteral(counters.get("org.fcrepo.services.LowLevelStorageService.fixity-error-counter").getCount()));
model.add(factory.getGraphSubject(node),model.createProperty("info:fedora/fedora-system:def/internal#numFixityRepaired"), ResourceFactory.createTypedLiteral(counters.get("org.fcrepo.services.LowLevelStorageService.fixity-repaired-counter").getCount()));

/* object size is not a counter but a Timer, so fetch that one too */
Timer sizeTimer = RepositoryService.getMetrics().getTimers().get("org.fcrepo.services.RepositoryService.objectSizeCalculation");

/* The following information is not yet available via static services */
/* and I did not want to add some lazy init workaround for non static service calls */
/*, which gets removed later */
/* TODO: Add the Cluster configuration to the RDF response */
/* TODO: Add the Storage policy to the RDF response */

/* and add the repository metrics to the RDF model */
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#numFixityChecks"),
ResourceFactory.createTypedLiteral(counters.get("org.fcrepo.services.LowLevelStorageService.fixity-check-counter").getCount()));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#numFixityErrors"),
ResourceFactory.createTypedLiteral(counters.get("org.fcrepo.services.LowLevelStorageService.fixity-error-counter").getCount()));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#numFixityRepaired"),
ResourceFactory.createTypedLiteral(counters.get("org.fcrepo.services.LowLevelStorageService.fixity-repaired-counter").getCount()));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#objectsSize"),
ResourceFactory.createTypedLiteral(sizeTimer.getCount()));
}

private static void addJcrContentLocationInformationToModel(
Expand Down Expand Up @@ -476,7 +493,5 @@ public static Model getJcrVersionsModel(
}

return model;


}
}

0 comments on commit 96cf287

Please sign in to comment.