private static IDataObjectStore OpenStore(ConnectionString connectionString, bool?enableOptimisticLocking = null, string updateGraphUri = null, IEnumerable <string> datasetGraphUris = null, string versionGraphUri = null) { IDataObjectContext context; switch (connectionString.Type) { case ConnectionType.Embedded: context = new EmbeddedDataObjectContext(connectionString); break; #if !SILVERLIGHT && !__MonoCS__ case ConnectionType.Rest: context = new RestDataObjectContext(connectionString); break; #endif case ConnectionType.DotNetRdf: context = new DotNetRdfDataObjectContext(connectionString); break; default: throw new BrightstarClientException("Unable to create valid context with connection string " + connectionString.Value); } return(context.OpenStore(connectionString.StoreName, optimisticLockingEnabled: enableOptimisticLocking.HasValue ? enableOptimisticLocking.Value : connectionString.OptimisticLocking, updateGraph: updateGraphUri, defaultDataSet: datasetGraphUris, versionTrackingGraph: versionGraphUri)); }
public void TestRepeatedSmallUnitsOfWork() { var st = DateTime.UtcNow; // for the embedded stores the context needs to be common. IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + BrightstarDB.Configuration.StoreLocation + "\\")); Assert.IsNotNull(context); var storeId = Guid.NewGuid().ToString(); context.CreateStore(storeId); var tasks = new List <Task>(); for (var i = 0; i < 10; i++) { var t = new Task(() => ExecuteSmallUnitOfWork(context, storeId)); tasks.Add(t); t.Start(); } Task.WaitAll(tasks.ToArray()); var et = DateTime.UtcNow; var duration = et.Subtract(st).TotalMilliseconds; Console.WriteLine(duration); }
private static IDataObjectStore GetDataObjectStore(string storeName) { var context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\")); if (!context.DoesStoreExist(storeName)) { return(context.CreateStore(storeName)); } return(context.OpenStore(storeName)); }
public void TestSpecialCharsInIdentities() { var importDir = Path.Combine(Configuration.StoreLocation, "import"); if (!Directory.Exists(importDir)) { Directory.CreateDirectory(importDir); } var testTarget = new FileInfo(importDir + Path.DirectorySeparatorChar + "persondata_en_subset.nt"); if (!testTarget.Exists) { var testSource = new FileInfo("persondata_en_subset.nt"); if (!testSource.Exists) { Assert.Inconclusive("Could not locate test source file {0}. Test will not run", testSource.FullName); return; } testSource.CopyTo(importDir + Path.DirectorySeparatorChar + "persondata_en_subset.nt"); } var bc = BrightstarService.GetClient("type=http;endpoint=http://localhost:8090/brightstar"); var storeName = Guid.NewGuid().ToString(); bc.CreateStore(storeName); var jobInfo = bc.StartImport(storeName, "persondata_en_subset.nt", null); while (!(jobInfo.JobCompletedOk || jobInfo.JobCompletedWithErrors)) { Thread.Sleep(1000); jobInfo = bc.GetJobInfo(storeName, jobInfo.JobId); } Assert.IsTrue(jobInfo.JobCompletedOk, "Import job failed"); IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\")); var store = context.OpenStore(storeName); var test = store.BindDataObjectsWithSparql("SELECT ?p WHERE {?p a <http://xmlns.com/foaf/0.1/Person>} LIMIT 30").ToList(); Assert.IsNotNull(test); foreach (var testDo in test) { Assert.IsNotNull(testDo); var propValues = testDo.GetPropertyValues("http://xmlns.com/foaf/0.1/name").Cast <string>(); Assert.IsNotNull(propValues); Assert.IsTrue(propValues.Count() > 0); } }
private static IDataObjectStore OpenStore(ConnectionString connectionString, bool?enableOptimisticLocking = null) { IDataObjectContext context; switch (connectionString.Type) { #if !REST_CLIENT case ConnectionType.Embedded: context = new EmbeddedDataObjectContext(connectionString); break; #endif #if !SILVERLIGHT #if !REST_CLIENT case ConnectionType.Http: context = new HttpDataObjectContext(connectionString); break; case ConnectionType.Tcp: context = new NetTcpDataObjectContext(connectionString); break; case ConnectionType.NamedPipe: context = new NamedPipeDataObjectContext(connectionString); break; #endif case ConnectionType.Rest: context = new RestDataObjectContext(connectionString); break; #endif default: throw new BrightstarClientException("Unable to create valid context with connection string " + connectionString.Value); } return(context.OpenStore(connectionString.StoreName, optimisticLockingEnabled: enableOptimisticLocking.HasValue ? enableOptimisticLocking.Value : connectionString.OptimisticLocking)); }