public StatisticsViewModel GetStatistics(Store store) { var client = BrightstarService.GetClient(ConnectionString); var stats = client.GetStatistics(store.Location); return(stats == null ? null : new StatisticsViewModel(stats)); }
public XDocument ExecuteQuery(Store store, string sparqlQueryString, CommitPointViewModel targetCommitPoint) { var client = BrightstarService.GetClient(_connectionString); try { if (targetCommitPoint == null) { using (var resultsStream = client.ExecuteQuery(store.Location, sparqlQueryString)) { XDocument result = XDocument.Load(resultsStream); return(result); } } var commitPoint = client.GetCommitPoint(store.Location, targetCommitPoint.CommitTime); if (commitPoint == null) { throw new Exception("Could not retrieve specified commit point from store."); } using (var resultsStream = client.ExecuteQuery(commitPoint, sparqlQueryString)) { XDocument result = XDocument.Load(resultsStream); return(result); } } catch (BrightstarClientException brightstarClientException) { ExtractSyntaxError(brightstarClientException.InnerException); throw new SparqlQueryException(brightstarClientException); } catch (Exception ex) { throw new SparqlQueryException(ex); } }
public void TestSyncWithEmptyStoreUpdate() { // Create an initial store for sync var client = BrightstarService.GetClient("type=embedded;storesDirectory=c:\\brightstar\\coreA"); client.CreateStore("TestStore3"); _coreA.Start(10001); _coreB.Start(10002); _clusterManager.Start(); WaitForState(_coreB, CoreState.RunningSlave, 5000); Assert.IsTrue(Directory.Exists("c:\\brightstar\\coreB\\TestStore3")); _coreA.ProcessTransaction( new ClusterUpdateTransaction { StoreId = "TestStore3", Inserts = "<http://brightstardb.com/foo> <http://brightstardb.com/property> <http://brightstardb.com/value> ." }); Thread.Sleep(500); var results = _coreB.ProcessQuery("TestStore3", "SELECT * WHERE {<http://brightstardb.com/foo> ?s ?p }"); XDocument newResultsDoc = XDocument.Parse(results); Assert.AreEqual(1, newResultsDoc.SparqlResultRows().Count()); }
/// <summary> /// Initialize is called before any other methods. The base implementation /// creates a client connection using the provided connection string and /// initializes a new store using the name returned by <see cref="MakeStoreName"/>. /// </summary> /// <param name="connectionString">The connection string to use</param> /// <param name="testScale">The scale parameter passed to the test framework</param> public virtual void Initialize(string connectionString, int testScale) { Service = BrightstarService.GetClient(connectionString); StoreName = MakeStoreName(); Service.CreateStore(StoreName); TestScale = testScale; }
public void TestCannotInitializeBrightstarClientWithDnrConnection() { var configFilePath = Path.GetFullPath(Configuration.DataLocation + "dataObjectStoreConfig.ttl"); var connectionString = "type=dotNetRdf;configuration=" + configFilePath + ";storeName=example"; BrightstarService.GetClient(connectionString); }
private XDocument ExecuteQuery(string query) { var client = BrightstarService.GetClient(_connectionString); var ret = XDocument.Load(client.ExecuteQuery(_storeName, query)); return(ret); }
public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobCompletedOk) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionSuccess); } else if (_transactionJob.JobCompletedWithErrors) { ValidationMessages.Clear(); ValidationMessages.Add(Strings.TransactionFailed); ValidationMessages.Add(_transactionJob.ExtractJobErrorMessage(true)); Messenger.Default.Send( new ShowDialogMessage("Transaction failed", "Transaction failed with status: " + _transactionJob.StatusMessage, MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new JobMonitorDelegate(this.CheckJobStatus)); } }
/// <summary> /// Initializes a new instance of the <see cref="TripleStore"/> class. /// </summary> /// <param name="storeDirectory"> Directory where the store will be located</param> /// <param name="storeName">Name of the store</param> /// <param name="clearStore">True if the store needs to be cleared when opened</param> public TripleStore(string storeDirectory, string storeName = null, bool clearStore = false) { Contract.Requires <ArgumentNullException>(storeDirectory != null, "Store directory cannot be null."); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(storeDirectory), "Store directory cannot be empty."); this.storeDirectory = storeDirectory; this.storeName = storeName ?? DefaultStoreName; this.client = BrightstarService.GetClient(this.ConnectionString); if (this.client.DoesStoreExist(this.storeName)) { // clear store if necessary if (clearStore) { this.ClearStore(); } } else { // create store if does not exists Logger.Info("Creating triple store {0} at {1}", this.storeName, this.storeDirectory); this.client.CreateStore(this.storeName); } }
public void CheckJobStatus() { try { var client = BrightstarService.GetClient(Store.Source.ConnectionString); var inProgress = QueuedJobs.Where(j => !j.Completed).ToList(); if (inProgress.Any()) { foreach (var job in inProgress) { job.RefreshStatus(client, Store.Location); } Thread.Sleep(1000); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(this.CheckJobStatus)); } else { _monitorStarted = false; } } catch (Exception) { ProgressText = "Error retrieving job status information from server. This may indicate a networking problem or that the server has stopped running."; } }
public void TestPreloadMultipleStores() { var client = BrightstarService.GetClient("type=embedded;storesDirectory=" + Path.GetFullPath("preload_test")); var dataPartitionB = Path.GetFullPath(Path.Combine("preload_test", "storeB", "data.bs")); var dataPartitionC = Path.GetFullPath(Path.Combine("preload_test", "storeC", "data.bs")); client.CreateStore("storeB", PersistenceType.AppendOnly); client.CreateStore("storeC", PersistenceType.AppendOnly); Assert.That(PageCache.Instance.Lookup(dataPartitionB, 1ul), Is.Not.Null); Assert.That(PageCache.Instance.Lookup(dataPartitionC, 1ul), Is.Not.Null); BrightstarService.Shutdown(); PageCache.Instance.Clear(); Assert.That(PageCache.Instance.Lookup(dataPartitionB, 1ul), Is.Null); Assert.That(PageCache.Instance.Lookup(dataPartitionC, 1ul), Is.Null); client = BrightstarService.GetClient("type=embedded;storesDirectory=" + Path.GetFullPath("preload_test"), new EmbeddedServiceConfiguration( new PageCachePreloadConfiguration { Enabled = true, DefaultCacheRatio = 1.0m } )); // Preload runs in the background so give it a bit of time Thread.Sleep(1000); Assert.That(PageCache.Instance.Lookup(dataPartitionB, 1ul), Is.Not.Null); Assert.That(PageCache.Instance.Lookup(dataPartitionC, 1ul), Is.Not.Null); }
public static BrightstarBootstrapper GetBootstrapper(ServiceArgs serviceArgs) { try { var configuration = System.Configuration.ConfigurationManager.GetSection("brightstarService") as BrightstarServiceConfiguration ?? new BrightstarServiceConfiguration(); // Connection string specified on the command line overrides the one in the app config file. if (serviceArgs.ConnectionString != null) { configuration.ConnectionString = serviceArgs.ConnectionString; } var service = BrightstarService.GetClient(configuration.ConnectionString); return(new BrightstarBootstrapper(service, configuration.StorePermissionsProvider, configuration.SystemPermissionsProvider, serviceArgs.RootPath)); } catch (Exception ex) { throw new BootstrapperException("Error initializing BrightstarDB server: " + ex.Message, ex); } }
public void TestBulkLoad24M() { var testTarget = new FileInfo(_importDirPath + Path.DirectorySeparatorChar + "BSBM_24M.nt"); if (!testTarget.Exists) { var testSource = new FileInfo("BSBM_24M.nt"); if (!testSource.Exists) { Assert.Inconclusive("Could not locate test source file {0}. Test will not run", testSource.FullName); return; } testSource.CopyTo(_importDirPath + Path.DirectorySeparatorChar + "BSBM_24M.nt"); } var timer = new Stopwatch(); timer.Start(); var bc = BrightstarService.GetClient("type=http;endpoint=http://localhost:8090/brightstar"); var storeName = Guid.NewGuid().ToString(); bc.CreateStore(storeName); var jobInfo = bc.StartImport(storeName, "BSBM_24M.nt", null); while (!jobInfo.JobCompletedOk) { Thread.Sleep(3000); jobInfo = bc.GetJobInfo(storeName, jobInfo.JobId); } timer.Stop(); Console.WriteLine("24M triples imported in {0} ms", timer.ElapsedMilliseconds); }
public void TestMapToRdfDataTypeDate() { var storeName = "foaf_" + Guid.NewGuid().ToString(); var embeddedClient = BrightstarService.GetClient("type=embedded;storesDirectory=c:\\brightstar;"); embeddedClient.CreateStore(storeName); //add rdf data for a person var triples = new StringBuilder(); triples.AppendLine(@"<http://www.networkedplanet.com/people/j.williams> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> ."); triples.AppendLine(@"<http://www.networkedplanet.com/people/j.williams> <http://xmlns.com/foaf/0.1/name> ""Jen Williams"" ."); triples.AppendLine(@"<http://www.networkedplanet.com/people/j.williams> <http://dbpedia.org/ontology/birthDate> ""1921-11-28""^^<http://www.w3.org/2001/XMLSchema#date> ."); embeddedClient.ExecuteTransaction(storeName, null, null, triples.ToString(), true); //check EF can access all properties var context = new MyEntityContext(string.Format(@"type=embedded;storesDirectory=c:\\brightstar;storeName={0}", storeName)); Assert.IsNotNull(context.FoafPersons); Assert.AreEqual(1, context.FoafPersons.Count()); var person = context.FoafPersons.FirstOrDefault(); Assert.IsNotNull(person); Assert.IsNotNull(person.Id); Assert.AreEqual("j.williams", person.Id); Assert.IsNotNull(person.Name); Assert.AreEqual("Jen Williams", person.Name); Assert.IsNotNull(person.BirthDate); }
public ActionResult Update(string storename) { if (Request.HttpMethod.ToLower().Equals("post") && Request.ContentType.Equals("application/sparql-update")) { try { string update; using (var streamReader = new StreamReader(Request.InputStream)) { update = streamReader.ReadToEnd(); if (string.IsNullOrEmpty(update)) { throw new HttpException(400, "No update expression in request body"); } } var client = BrightstarService.GetClient(); var jobInfo = client.ExecuteUpdate(storename, update); if (!jobInfo.JobCompletedOk) { throw new HttpException(500, "Unable to complete update job " + jobInfo.StatusMessage); } return(new HttpStatusCodeResult(200)); } catch (Exception ex) { throw new HttpException(500, "Unable to complete update job " + ex.Message, ex); } } throw new HttpException(400, "Missing parameters or incorrect request format"); }
private void CRMForm_Load(object sender, EventArgs e) { // Initialise license and stores directory location Configuration.Register(); //create a unique store name var storeName = "CRM_Ontology"; //connection string to the BrightstarDB service string connectionString = string.Format(@"Type=embedded;storesDirectory={0};StoreName={1};", Configuration.StoresDirectory, storeName); dataContext = new CRMOntologyContext(connectionString); client = BrightstarService.GetClient(connectionString); //getPredicates XDocument xDoc = dataContext.ExecuteQuery("SELECT DISTINCT ?predicate WHERE { ?x ?predicate ?y.}"); foreach (var sparqlResultRow in xDoc.SparqlResultRows()) { string result = sparqlResultRow.GetColumnValue("predicate").ToString(); //beautify if (result.IndexOf(URI) >= 0) { treeViewOntology.Nodes[0].Nodes[0].Nodes.Add(result, result.Replace(URI + "/", "").Replace("#", "")); treeViewOntology.Nodes[0].Nodes[1].Nodes.Add(result, result.Replace(URI + "/", "").Replace("#", "")); } } }
public void TestDeleteFromGraph() { var storeName = "TestDeleteFromGraph_" + DateTime.Now.Ticks; var client = BrightstarService.GetClient("type=embedded;storesDirectory=C:\\brightstar"); client.CreateStore(storeName); client.ExecuteTransaction(storeName, null, null, @"<http://np.com/s> <http://np.com/p> <http://np.com/o2> <http://np.com/g1> . <http://np.com/s> <http://np.com/p> <http://np.com/o> . "); var result = client.ExecuteQuery(storeName, "SELECT ?o FROM <http://np.com/g1> WHERE { <http://np.com/s> <http://np.com/p> ?o }"); Assert.IsNotNull(result); XDocument resultDoc = XDocument.Load(result); Assert.AreEqual(1, resultDoc.SparqlResultRows().Count()); var resultRow = resultDoc.SparqlResultRows().First(); Assert.AreEqual(new Uri("http://np.com/o2"), resultRow.GetColumnValue("o")); client.ExecuteTransaction(storeName, @"<http://np.com/s> <http://np.com/p> <http://np.com/o2> <http://np.com/g1> .", @"<http://np.com/s> <http://np.com/p> <http://np.com/o2> <http://np.com/g1> .", null); result = client.ExecuteQuery(storeName, "SELECT ?o FROM <http://np.com/g1> WHERE { <http://np.com/s> <http://np.com/p> ?o }"); Assert.IsNotNull(result); resultDoc = XDocument.Load(result); Assert.AreEqual(0, resultDoc.SparqlResultRows().Count()); }
public void TestNetTcpBindingClient() { var client = BrightstarService.GetClient("type=tcp;endpoint=net.tcp://localhost:8095/brightstar"); var stores = client.ListStores(); Assert.IsNotNull(stores); }
public void CreateStore(Store store) { var client = BrightstarService.GetClient(_connectionString); client.CreateStore(store.Location); Stores.Add(store); }
public void TestBasicHttpBindingClient() { var client = BrightstarService.GetClient("type=http;endpoint=http://localhost:8090/brightstar"); var stores = client.ListStores(); Assert.IsNotNull(stores); }
public void TestNamedPipeBindingClient() { var client = BrightstarService.GetClient("type=namedPipe;endpoint=net.pipe://localhost/brightstar"); var stores = client.ListStores(); Assert.IsNotNull(stores); }
private void EnsureStore() { var client = BrightstarService.GetClient("type=embedded;storesDirectory=stores"); if (!client.DoesStoreExist("SparqlPerformance")) { Console.WriteLine("Creating performance test store."); client.CreateStore("SparqlPerformance", PersistenceType.AppendOnly); var importPath = Path.Combine("stores", "import"); if (!Directory.Exists(importPath)) { Directory.CreateDirectory(importPath); } var dataPath = Path.GetFullPath(Path.Combine("..", "..", "..", "BrightstarDB.Tests", "data", "bsbm_1M.nt")); File.Copy(dataPath, Path.Combine(importPath, "bsbm_1M.nt")); var importJob = client.StartImport("SparqlPerformance", "bsbm_1M.nt"); while (!(importJob.JobCompletedOk || importJob.JobCompletedWithErrors)) { Thread.Sleep(2000); importJob = client.GetJobInfo("SparqlPerformance", importJob.JobId); Console.WriteLine(importJob.StatusMessage); } if (importJob.JobCompletedWithErrors) { throw new Exception( String.Format( "Import job failed. Testing cannot proceed. Last job message: {0}. Job exception trace: {1}", importJob.StatusMessage, importJob.ExceptionInfo)); } } }
public void TestSimpleJoinQuery() { var sparqlQuery = @"PREFIX bsbm: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/> SELECT ?review WHERE { ?review bsbm:reviewFor ?product . ?product bsbm:productFeature <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature2330> . } LIMIT 3"; // Warm-up var client = BrightstarService.GetClient("type=embedded;storesDirectory=stores"); for (int i = 0; i < 5; i++) { client.ExecuteQuery("SparqlPerformance", sparqlQuery); } // Profile var profiler = new BrightstarProfiler("SimpleJoinQuery"); for (int i = 0; i < 100; i++) { using (profiler.Step("ExecuteQuery")) { client.ExecuteQuery("SparqlPerformance", sparqlQuery); } } Console.WriteLine(profiler.GetLogString()); }
public void CheckJobStatus() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.GetJobInfo(Store.Location, _transactionJob.JobId); if (_transactionJob.JobPending) { ProgressText = "Job is currently queued for processing."; } if (_transactionJob.JobStarted) { ProgressText = "Job is running"; } if (_transactionJob.JobCompletedOk) { ProgressText = "Job completed successfully"; Messenger.Default.Send(new ShowDialogMessage( Strings.ExportCompletedDialogTitle, String.Format(Strings.ExportCompletedDialogMsg, Store.Location), MessageBoxImage.Information, MessageBoxButton.OK), "MainWindow"); } else if (_transactionJob.JobCompletedWithErrors) { ProgressText = String.IsNullOrEmpty(_transactionJob.StatusMessage) ? "Export job failed. No further details provided by the server." : String.Format("Export job failed. Server reports : '{0}'", _transactionJob.StatusMessage); Messenger.Default.Send(new ShowDialogMessage(Strings.ImportFailedDialogTitle, String.Format(Strings.ImportFailedDialogMsg, Store.Location), MessageBoxImage.Error, MessageBoxButton.OK), "MainWindow"); } else { _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(this.CheckJobStatus)); } }
private void WithClient(Action <IBrightstarService> action) { if (RequiresAuthentication) { if (!HaveCredentials()) { MessengerInstance.Send(new AuthenticationRequiredMessage("This operation requires your username and password.", (dialogResult, username, password) => { if (dialogResult.HasValue && dialogResult.Value) { _userName = username; _password = password; } else { // Ensure we make a connection with no credentials _password = null; } })); action(MakeConnection()); } action(MakeConnection()); } else { action(BrightstarService.GetClient(ConnectionString)); } }
public IEnumerable <CommitPointViewModel> GetCommitPoints(Store store, DateTime latest, DateTime earliest, int skip, int take) { var client = BrightstarService.GetClient(ConnectionString); return (client.GetCommitPoints(store.Location, latest, earliest, skip, take).Select( x => new CommitPointViewModel(x))); }
private void StartRemoteImport() { var client = BrightstarService.GetClient(Store.Source.ConnectionString); _transactionJob = client.StartImport(Store.Location, ImportFileName); _dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new TransactionViewModel.JobMonitorDelegate(CheckJobStatus)); }
public SparqlUpdateTests() { #if WINDOWS_PHONE _client = BrightstarService.GetEmbeddedClient("brightstar"); #else _client = BrightstarService.GetClient("type=embedded;storesDirectory=c:\\brightstar"); #endif }
public SingleThreadStressTest(ConnectionString connectionString) : base(connectionString) { _client = BrightstarService.GetClient(connectionString); _storeName = connectionString.StoreName; _importJobs = new List <string>(); _queryTimes = new ConcurrentQueue <Tuple <long, int> >(); _queryTasks = new List <Task>(); }
private IBrightstarService NewRdfClient() { var connectionString = String.Format("type=embedded;storesDirectory={0};storeName={1}", TestStoreLocation, _storeName); return(BrightstarService.GetClient(connectionString)); }
/// <summary> /// Create a new bootstrapper from the specified configuration and root path configuration /// </summary> /// <param name="configuration">The service configuration</param> /// <param name="rootPath">The root path</param> public BrightstarBootstrapper(BrightstarServiceConfiguration configuration, string rootPath = null) : this(BrightstarService.GetClient(configuration.ConnectionString), configuration.AuthenticationProviders, configuration.StorePermissionsProvider, configuration.SystemPermissionsProvider, rootPath) { }