/** * Constructor that simply specifies an endpoint. This class will internally * allocate a {@link RemoteRepositoryManager} that is scoped to the life * cycle of this class. The allocated {@link RemoteRepositoryManager} will be * closed when this {@link BigdataSailRemoteRepository} is closed. * <p> * Note: This constructor pattern is NOT flyweight. * * @param sparqlEndpointURL * The SPARQL end point URL */ @Deprecated // This is broken because the sparqlEndpointURL is not the serviceURL and that is what the RRM expects/needs. public BigdataSailRemoteRepository(final String sparqlEndpointURL) { if (sparqlEndpointURL == null) throw new IllegalArgumentException(); /* * Allocate a RemoteRepositoryManager. This is NOT a flyweight operation. * */ this.our_mgr = new RemoteRepositoryManager(sparqlEndpointURL, false/*useLBS*/); this.remoteRepository = our_mgr.getRepositoryForURL(sparqlEndpointURL); }
/** * {@inheritDoc} * <p> * Ensure resource is closed. * * @see AutoCloseable * @see <a href="http://trac.bigdata.com/ticket/1207" > Memory leak in * CI? </a> */ @Override protected void finalize() throws Throwable { close(); super.finalize(); }
/** * Create a new KB instance. * * @param namespace * The namespace of the KB instance. * @param properties * The configuration properties for that KB instance. * * @throws Exception * * @see <a href="http://trac.bigdata.com/ticket/1257"> createRepository() * does not set the namespace on the Properties</a> */ public void createRepository(final String namespace, final Properties properties) throws Exception { createRepository(namespace, properties, UUID.randomUUID()); }
/** * Obtain a flyweight {@link RemoteRepository} for a data set managed by the * remote service. * * @param namespace * The name of the data set (its bigdata namespace). * * @return An interface which may be used to talk to that data set. */ public RemoteRepository getRepositoryForNamespace(final String namespace) { return getRepositoryForURL(getRepositoryBaseURLForNamespace(namespace) + "/sparql"); }
/** * Destroy a KB instance. * * @param namespace * The namespace of the KB instance. * @param uuid * The {@link UUID} to be assigned to the request.a * * @throws Exception */ public void deleteRepository(final String namespace, final UUID uuid) throws Exception { final ConnectOptions opts = newConnectOptions(getRepositoryBaseURLForNamespace(namespace), uuid, null/* txId */); opts.method = "DELETE"; JettyResponseListener response = null; try { checkResponseCode(response = doConnect(opts)); } finally { if (response != null) response.abort(); } }
public static void main(String[] args) throws Exception { final RemoteRepositoryManager repositoryManager = new RemoteRepositoryManager(serviceURL, false /*useLBS*/); repositoryManager.createRepository(namespace, properties); log.info(String.format("Create namespace %s done", namespace)); repositoryManager.getRepositoryForNamespace(namespace).add(new AddOp(is, RDFFormat.forMIMEType("application/x-turtle-RDR"))); } finally { is.close(); final RemoteRepository r = repositoryManager.getRepositoryForNamespace(namespace); final IPreparedTupleQuery query = r.prepareTupleQuery("SELECT ?age ?src WHERE {?bob foaf:name \"Bob\" . <<?bob foaf:age ?age>> dc:source ?src .}"); final TupleQueryResult result = query.evaluate(); repositoryManager.close();
final RemoteRepositoryManager mgr = new RemoteRepositoryManager( "localhost:" + Config.BLAZEGRAPH_HTTP_PORT /* serviceURLIsIngored */); final BigdataSailRemoteRepository repo = mgr.getRepositoryForURL( sparqlEndpointURL).getBigdataSailRemoteRepository(); mgr.close();
m_mgr.getRepositoryProperties(namespace); log.warn("Got properties for " + namespace); m_mgr.getRepositoryProperties(namespace2); fail("Should not exist: " + namespace2); } catch (HttpException ex) { m_mgr.createRepository(namespace2, properties); final Properties p = m_mgr.getRepositoryProperties(namespace2); assertNotNull(p); m_mgr.createRepository(namespace2, properties); p = m_mgr.getRepositoryProperties(ns); } catch (Throwable t) { log.warn("Couldn't get properties for " + ns, t); // to help see failure in log! final RemoteRepository tmp = m_mgr.getRepositoryForNamespace(ns); m_mgr.deleteRepository(ns); m_mgr.getRepositoryProperties(ns);
boolean found = true; try { final Properties p = m_mgr.getRepositoryProperties(ns); assert p != null; found = true; p.setProperty(RemoteRepositoryManager.OPTION_CREATE_KB_NAMESPACE, ns); m_mgr.createRepository(ns, p); return m_mgr.getRepositoryForNamespace(ns);
public Void call() throws Exception { rmgr.getRepositoryDescriptions(uuid); return null; }
repo = new RemoteRepositoryManager( serviceURL, client, executor); final IObjectManager om = new NanoSparqlObjectManager(repo.getRepositoryForDefaultNamespace(), namespace); repo.close();
private void loadStatements(final String namespace, final int nstatements) throws Exception { final Collection<Statement> stmts = new ArrayList<>(nstatements); for (int i = 0; i < nstatements; i++) { stmts.add(generateTriple()); } log.warn(String.format("Loading package into %s namespace...", namespace)); m_mgr.getRepositoryForNamespace(namespace).add(new RemoteRepository.AddOp(stmts)); log.warn(String.format("Loading package into %s namespace done", namespace)); }
m_repo = new RemoteRepositoryManager(m_serviceURL, m_httpClient, getSail().getIndexManager().getExecutorService());
public GlobalSecurityValidator(final RemoteRepositoryManager m_repo) throws Exception { GraphQueryResult repoDescription = m_repo.getRepositoryDescriptions(); Set<String> namespaces = new HashSet<String>(); while (repoDescription.hasNext()) { RemoteRepository repo = m_repo.getRepositoryForNamespace(namespace);
m_mgr.getRepositoryProperties(randomNS); fail("Should not exist: " + randomNS); } catch (HttpException ex) { loaderProps.setProperty("fileOrDirs", dataURL); m_mgr.doDataLoader(loaderProps); RemoteRepository repo = m_mgr.getRepositoryForNamespace(randomNS); final Properties p = m_mgr.getRepositoryProperties(randomNS); assertNotNull(p);
/** * Connect to a SPARQL end point (GET or POST query only). * * @param opts * The connection options. * * @return The connection. */ private JettyResponseListener doConnect(final ConnectOptions opts) throws Exception { return mgr.doConnect(opts); }
throws Exception { assertMapgraphRuntimeAvailable(); getSparqlEndpointUrlForNamespaceOrDefault(namespace); newConnectOptions(repositoryUrl, UUID.randomUUID(), null/* tx */); checkResponseCode(response = doConnect(opts));
m_repo = new RemoteRepositoryManager(m_serviceURL, m_client, m_indexManager.getExecutorService()); om = new NanoSparqlObjectManager(m_repo.getRepositoryForDefaultNamespace(), m_namespace);
/** * * Prepare configuration properties for a new KB instance. * * @param namespace * The namespace of the KB instance. * @param properties * The configuration properties for that KB instance. * * @return The effective configuration properties for that named data set. * * @throws Exception */ public Properties getPreparedProperties(final String namespace, final Properties properties) throws Exception { return getPreparedProperties(namespace, properties, UUID.randomUUID()); }
/** * 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(); } }