Skip to content

Commit

Permalink
added cluster configuration information to RDF response
Browse files Browse the repository at this point in the history
  • Loading branch information
fasseg committed May 17, 2013
1 parent 96cf287 commit af8659f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
Expand Up @@ -124,14 +124,11 @@ public void testGetRepositoryGraph() throws Exception {
public void testGetDescribeRepositoryRDFJSON() throws Exception {
final HttpGet getObjMethod =
new HttpGet(serverAddress + "");
getObjMethod.addHeader("Accept", "application/n-triples");
getObjMethod.addHeader("Accept", "application/rdf+json");
final HttpResponse response = client.execute(getObjMethod);
assertEquals(200, response.getStatusLine().getStatusCode());
final GraphStore graphStore = TestHelpers.parseTriples(response.getEntity().getContent());
logger.debug("Retrieved repository graph:\n" + graphStore.toString());

assertTrue("expected to find the root node data", graphStore.contains(Node.ANY, Node.ANY, Node.createURI("info:fedora/fedora-system:def/internal#primaryType"), Node.createLiteral("mode:root")));

final String jsonContent = EntityUtils.toString(response.getEntity());
assertTrue("expected to find the cluster size data", jsonContent.contains("info:fedora/fedora-system:def/internal#clusterSize"));
}

@Test
Expand Down
35 changes: 30 additions & 5 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/JcrRdfTools.java
Expand Up @@ -2,6 +2,7 @@

import static org.slf4j.LoggerFactory.getLogger;

import java.util.Map;
import java.util.Set;
import java.util.SortedMap;

Expand All @@ -19,6 +20,7 @@
import org.fcrepo.rdf.GraphSubjects;
import org.fcrepo.services.LowLevelStorageService;
import org.fcrepo.services.RepositoryService;
import org.fcrepo.services.functions.GetClusterConfiguration;
import org.modeshape.jcr.api.JcrConstants;
import org.modeshape.jcr.api.NamespaceRegistry;
import org.slf4j.Logger;
Expand Down Expand Up @@ -164,11 +166,34 @@ private static void addRepositoryMetricsToModel(GraphSubjects factory,
/* 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 */
/* Get the cluster configuration for the RDF response*/
Map<String,String> config = new GetClusterConfiguration().apply(node.getSession().getRepository());

/* TODO: Get and add the Storage policy to the RDF response */

/* add the configuration information */
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterName"),
config.get("clusterName"));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterCacheMode"),
config.get("clusterCacheMode"));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterNodeAddress"),
config.get("clusterNodeAddress"));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterPhysicalAddress"),
config.get("clusterPhysicalAddress"));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterNodeView"),
config.get("clusterNodeView"));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterSize"),
config.get("clusterSize"));
model.add(factory.getGraphSubject(node),
model.createProperty("info:fedora/fedora-system:def/internal#clusterMembers"),
config.get("clusterMembers"));


/* and add the repository metrics to the RDF model */
model.add(factory.getGraphSubject(node),
Expand Down

0 comments on commit af8659f

Please sign in to comment.