/** * Checks whether the mapgraph runtime is available. * @return */ public boolean mapgraphRuntimeAvailable() throws Exception { final String repositoryUrl = getSparqlEndpointUrlForNamespaceOrDefault(null /* default namespace */); /** * First reset the runtime */ final ConnectOptions opts = newConnectOptions(repositoryUrl, UUID.randomUUID(), null/* tx */); JettyResponseListener response = null; // Setup the request entity. { opts.addRequestParam(MAPGRAPH, MAPGRAPH_CHECK_RUNTIME_AVAILABLE); opts.method = "POST"; } try { response = doConnect(opts); return response.getStatus()==200 /* HTTP OK */; } finally { if (response != null) response.abort(); } }
/** * Resets the mapgraph runtime for the compute mode. * * @param computeMode the desired compute mode */ public void resetMapgraphRuntime(final ComputeMode computeMode) throws Exception { assertMapgraphRuntimeAvailable(); if (computeMode==null) { throw new IllegalArgumentException("Compute mode must not be null"); } final String repositoryUrl = getSparqlEndpointUrlForNamespaceOrDefault(null /* default namespace */); final ConnectOptions opts = newConnectOptions(repositoryUrl, UUID.randomUUID(), null/* tx */); JettyResponseListener response = null; // Setup the request entity. { opts.addRequestParam(MAPGRAPH, MAPGRAPH_RESET); opts.addRequestParam(COMPUTE_MODE, computeMode.toString()); opts.method = "POST"; } try { checkResponseCode(response = doConnect(opts)); } finally { if (response != null) response.abort(); } }