static ServerCoreManager() { UpdateLock = new object(); ServerCores = new Dictionary<string, ServerCore>(); QueryCache = Configuration.QueryCache; PersistenceType = Configuration.PersistenceType; }
/// <summary> /// Creates a new store. /// </summary> /// <param name="storeName">The name of the store to create</param> /// <param name="namespaceMappings">A collection of prefix to URI mappings to enable CURIEs to be used for resource addresses instead of full URIs</param> /// <param name="optimisticLockingEnabled">A boolean flag indicating if optimistic locking should be enabled</param> /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param> /// <returns>The newly created data object store</returns> public IDataObjectStore CreateStore(string storeName, Dictionary<string, string> namespaceMappings, bool? optimisticLockingEnabled = null, PersistenceType? persistenceType = null) { Client.CreateStore(storeName, persistenceType.HasValue ? persistenceType.Value : Configuration.PersistenceType); return new RestDataObjectStore( _connectionString, storeName, namespaceMappings, optimisticLockingEnabled.HasValue ? optimisticLockingEnabled.Value : _optimisticLockingEnabled); }
public string CreateStore(string storeName, PersistenceType persistenceType) { Logging.LogInfo("Create Store"); var store = _storeManager.CreateStore(Path.Combine(_baseLocation, storeName), persistenceType, true); store.Close(); Logging.LogInfo("Store id is {0}", storeName); return storeName; }
/// <summary> /// Create a new store with a specific persistence type for the main store indexes /// </summary> /// <param name="storeName">The name of the store to be created</param> /// <param name="persistenceType">The type of persistence to use for the main store indexes</param> public void CreateStore(string storeName, PersistenceType persistenceType) { if (persistenceType == PersistenceType.Rewrite) { throw new NotSupportedException("The rewrite store type is not currently supported by BrightstarDB on Azure"); } BrightstarCluster.Instance.CreateStore(storeName); }
public ServerCore(string baseLocation, ICache queryCache, PersistenceType persistenceType) { Logging.LogInfo("ServerCore Initialised {0}", baseLocation); _baseLocation = baseLocation; _stores = new Dictionary<string, StoreWorker>(); var configuration = new StoreConfiguration {PersistenceType = persistenceType}; _storeManager = StoreManagerFactory.GetStoreManager(configuration); _queryCache = queryCache; }
/// <summary> /// Creates a new store. /// </summary> /// <param name="storeName">The name of the store to create</param> /// <param name="namespaceMappings">A collection of prefix to URI mappings to enable CURIEs to be used for resource addresses instead of full URIs</param> /// <param name="optimisticLockingEnabled">A boolean flag indicating if optimistic locking should be enabled</param> /// <returns>The newly created data object store</returns> public IDataObjectStore CreateStore(string storeName, Dictionary<string, string> namespaceMappings = null, bool? optimisticLockingEnabled = new bool?(), PersistenceType? persistenceType = null) { // For now persistenceType is ignored, and the store is always an append-only store to match the way the block provider works _client.CreateStore(storeName); return new BrightstarClusterDataObjectStore(storeName, namespaceMappings, optimisticLockingEnabled.HasValue ? optimisticLockingEnabled.Value : _optimisticLockingEnabled); }
public static IPageStore OpenPageStore(string fileName, bool readOnly, PersistenceType persistenceType = PersistenceType.AppendOnly, ulong txnId = 1UL, BrightstarProfiler profiler = null) { using (profiler.Step("Open Page Store")) { if (persistenceType == PersistenceType.AppendOnly) { return new AppendOnlyFilePageStore(PersistenceManager, fileName, 4096, readOnly, false); } return new BinaryFilePageStore(PersistenceManager, fileName, 4096, readOnly, txnId); } }
public ServerCore(string baseLocation, ICache queryCache, PersistenceType persistenceType, bool enableTransactionLoggingOnNewStores) { Logging.LogInfo("ServerCore Initialised {0}", baseLocation); _baseLocation = baseLocation; _stores = new Dictionary<string, StoreWorker>(); var configuration = StoreConfiguration.DefaultStoreConfiguration.Clone() as StoreConfiguration; configuration.PersistenceType = persistenceType; _storeManager = StoreManagerFactory.GetStoreManager(configuration); _queryCache = queryCache; _enableTransactionLogging = enableTransactionLoggingOnNewStores; }
public CreateStoreRequestObject(string storeName, PersistenceType? persistenceType) { StoreName = storeName; if (persistenceType.HasValue) { PersistenceType = (int) persistenceType; } else { PersistenceType = -1; } }
public IStore CreateStore(string storeLocation, PersistenceType storePersistenceType, bool readOnly, bool withTransactionLogging) { Logging.LogInfo("Create Store {0} with persistence type {1}", storeLocation, storePersistenceType); if (_persistenceManager.DirectoryExists(storeLocation)) { throw new StoreManagerException(storeLocation, "Store already exists"); } _persistenceManager.CreateDirectory(storeLocation); var dataFilePath = Path.Combine(storeLocation, DataFileName); _persistenceManager.CreateFile(dataFilePath); var resourceFilePath = Path.Combine(storeLocation, ResourceFileName); _persistenceManager.CreateFile(resourceFilePath); var targetStoreConfiguration = _storeConfiguration.Clone() as StoreConfiguration; targetStoreConfiguration.PersistenceType = storePersistenceType; MasterFile.Create(_persistenceManager, storeLocation, targetStoreConfiguration, Guid.NewGuid()); IPageStore dataPageStore = null; switch (storePersistenceType) { case PersistenceType.AppendOnly: dataPageStore = new AppendOnlyFilePageStore(_persistenceManager, dataFilePath, PageSize, false, _storeConfiguration.DisableBackgroundWrites); break; case PersistenceType.Rewrite: dataPageStore = new BinaryFilePageStore(_persistenceManager, dataFilePath, PageSize, false, 0, 1, _storeConfiguration.DisableBackgroundWrites); break; } IPageStore resourcePageStore = new AppendOnlyFilePageStore(_persistenceManager, resourceFilePath, PageSize, false, _storeConfiguration.DisableBackgroundWrites); var resourceTable = new ResourceTable(resourcePageStore); using (var store = new Store(storeLocation, dataPageStore, resourceTable)) { store.Commit(Guid.Empty); } if (withTransactionLogging) { _persistenceManager.CreateFile(Path.Combine(storeLocation, "transactionheaders.bs")); _persistenceManager.CreateFile(Path.Combine(storeLocation, "transactions.bs")); } Logging.LogInfo("Store created at {0}", storeLocation); return(OpenStore(storeLocation, readOnly)); }
private void DrawListItems(Rect rect, int index, bool isActive, bool isFocused) { float spacing = 2; float persistTogWidth = 20; float delBtnWidth = 20; string entryKey = currentGroup[index]; BlackboardVariable entryValue = bb.EditorGetDict()[entryKey]; string textInKeyField = EditorGUI.DelayedTextField( new Rect(rect.x, rect.y, (rect.width - spacing - persistTogWidth - spacing - delBtnWidth) / 2, EditorGUIUtility.singleLineHeight), entryKey); BlackboardVariable objectInValueField = (BlackboardVariable)EditorGUI.ObjectField( new Rect(rect.x + (rect.width - spacing - persistTogWidth - spacing - delBtnWidth) / 2 + spacing, rect.y, (rect.width - spacing - persistTogWidth - spacing - delBtnWidth) / 2, EditorGUIUtility.singleLineHeight), entryValue, typeof(BlackboardVariable), false); PersistenceType persistenceType = PersistenceType.NeverPersist; if (entryValue != null) { persistenceType = (PersistenceType)EditorGUI.EnumPopup( new Rect(rect.x + rect.width - persistTogWidth - delBtnWidth, rect.y, persistTogWidth, EditorGUIUtility.singleLineHeight), entryValue.persistenceType); } bool deletebutton = GUI.Button(new Rect(rect.x + rect.width - delBtnWidth, rect.y, delBtnWidth, EditorGUIUtility.singleLineHeight), "X", deleteButtonStyle); if (entryKey != textInKeyField) { RenameEntry(entryKey, textInKeyField); } if (entryValue != objectInValueField) { UpdateEntryValue(entryKey, objectInValueField); } if (entryValue != null && entryValue.persistenceType != persistenceType) { Undo.RecordObject(entryValue, "Set blackboard variable's persistence type"); entryValue.persistenceType = persistenceType; EditorUtility.SetDirty(entryValue); } if (deletebutton) { RemoveEntry(entryKey); } }
public void TestLoadAndQuery25K(PersistenceType persistenceType) { var storeName = MakeStoreName("TestLoadAndQuery10K", persistenceType); const int personCount = 25000; var hugosCount = personCount/TestDataLists.Firstnames.Count; // Estimated number of instances with name 'HUGO' we will generate using (var doStore = CreateStore(storeName, persistenceType)) { using (var context = new MyEntityContext(doStore)) { var last10 = new IFoafPerson[10]; for (int i = 0; i < personCount; i++) { // Create an entity with properties set var person = context.FoafPersons.Create(); person.Name = TestDataLists.Firstnames[i%TestDataLists.Firstnames.Count]; person.Organisation = TestDataLists.Organizations[i%TestDataLists.Organizations.Count]; foreach (var friend in last10.Where(friend => friend != null)) { person.Knows.Add(friend); } last10[i%10] = person; } context.SaveChanges(); // Attempt a query using the same store handle var hugos = context.FoafPersons.Where(p => p.Name.Equals("HUGO")).ToList(); Assert.IsTrue(hugos.Count >= hugosCount, "Expected at least {0} foafPerson instances returned with name HUGO", hugosCount); hugosCount = hugos.Count; // Acual number may be one higher depending on where the iteration leaves off. } } // Try query with a new store context using (var doStore = OpenStore(storeName)) { using (var context = new MyEntityContext(doStore)) { var hugos = context.FoafPersons.Where(p => p.Name.Equals("HUGO")).ToList(); Assert.AreEqual(hugosCount, hugos.Count, "Expected count of HUGOs to be unchanged when querying from a second context instance"); } } // Try query with a completely new client session BrightstarDB.Client.BrightstarService.Shutdown(); using (var doStore = OpenStore(storeName)) { using (var context = new MyEntityContext(doStore)) { var hugos = context.FoafPersons.Where(p => p.Name.Equals("HUGO")).ToList(); Assert.AreEqual(hugosCount, hugos.Count, "Expected count of HUGOs to be unchanged when querying from a third context instance"); } } }
public ServerCore(string baseLocation, ICache queryCache, PersistenceType persistenceType, bool enableTransactionLoggingOnNewStores) { Logging.LogInfo("ServerCore Initialised {0}", baseLocation); _baseLocation = baseLocation; _stores = new Dictionary <string, StoreWorker>(); var configuration = new StoreConfiguration { PersistenceType = persistenceType }; _storeManager = StoreManagerFactory.GetStoreManager(configuration); _queryCache = queryCache; _enableTransactionLogging = enableTransactionLoggingOnNewStores; }
internal void LoadInternal(NativeMethods.CREDENTIAL credential) { Username = credential.UserName; if (credential.CredentialBlobSize > 0) { Password = Marshal.PtrToStringUni(credential.CredentialBlob, credential.CredentialBlobSize / 2); } Target = credential.TargetName; Type = (CredentialType)credential.Type; PersistenceType = (PersistenceType)credential.Persist; Description = credential.Comment; LastWriteTimeUtc = DateTime.FromFileTimeUtc(credential.LastWritten); }
/// <summary> /// A preference that is stored in the cloud. Automatically added to the <see cref="DataManager"/>. /// </summary> /// <param name="key">A unique identifier used to identify this particular value.</param> /// <param name="type">The method of conflict resolution to be used in case of a data conflict. Can happen if the data is altered by a different device.</param> /// <param name="value">The starting value for this preference.</param> /// <param name="defaultValue">The value the preference will be set to if it is ever reset.</param> /// <param name="valueLoader"><c>delegate</c> used to get the preference.</param> /// <param name="valueSetter"><c>delegate</c> used to set the preference.</param> protected PersistentValue(string key, PersistenceType type, T value, T defaultValue, ValueLoaderDelegate valueLoader, ValueSetterDelegate valueSetter) { Key = key; Value = value; PersistenceType = type; DefaultValue = defaultValue; ValueLoader = valueLoader; ValueSetter = valueSetter; DataManager.CloudPrefs[key] = this; DataManager.InitDataManager(); Load(); }
private async Task <byte[]> GetPersistedBytesAsync(PersistenceType persistenceType, IEnumerable <IPersistenceStrategy> strategies) { foreach (var strategy in strategies) { var bytes = await strategy.RetrieveAsync(persistenceType); if (bytes != null && bytes.Length > 0) { return(bytes); } } return(null); }
/// <summary> /// Creates a new store. /// </summary> /// <param name="storeName">Name of the store to create.</param> /// <param name="optimisticLockingEnabled">Optional parameter to override the default optimistic locking setting for the context</param> /// <param name="namespaceMappings">Namespace mappings that can be used by CURIE's.</param> /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param> /// <returns>A new store instance.</returns> public IDataObjectStore CreateStore(string storeName, Dictionary<string, string> namespaceMappings = null, bool? optimisticLockingEnabled = null, PersistenceType? persistenceType = null) { if (namespaceMappings == null) { namespaceMappings = new Dictionary<string, string>(); } namespaceMappings["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; namespaceMappings["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#"; _serverCore.CreateStore(storeName, persistenceType.HasValue ? persistenceType.Value : Configuration.PersistenceType); return new EmbeddedDataObjectStore(_serverCore, storeName, namespaceMappings, optimisticLockingEnabled.HasValue ? optimisticLockingEnabled.Value : _optimisticLockingEnabled); }
public static IPersistens <Users> GetPersistency(PersistenceType peristenceType) { switch (peristenceType) { // File case PersistenceType.File: return(new FilePersistence()); // Database case PersistenceType.Database: return(new DBPersistence()); default: return(new FilePersistence()); } }
public static IPersistence GetPersistency(PersistenceType peristenceType) { switch (peristenceType) { case PersistenceType.Simple: return(new SimplePersistence()); // File case PersistenceType.File: return(new FilePersistence()); // Database case PersistenceType.Database: return(new SamkørselPersistence()); default: return(new SimplePersistence()); } }
/// <summary> /// Ensures that a specified <see cref="bool"/> exists in the local <see cref="GameData"/>. /// </summary> /// <param name="key">Must be a unique identifier for this specific value.</param> /// <param name="persistenceType"> /// The persistence type to use in case of a data conflict. /// <see cref="PersistenceType.Latest"/> will always prefer the newest data. /// <see cref="PersistenceType.Highest"/> will prefer <c>true</c>. /// <see cref="PersistenceType.Lowest"/> will prefer <c>false</c>. /// </param> /// <param name="value">The initial value for this <see cref="bool"/>.</param> public static void InitializeBool(string key, PersistenceType persistenceType, bool value) { if (!s_localGameData.SyncableItems.ContainsKey(key)) { var metaData = new SyncableItemMetaData( DataType.Bool, persistenceType); var syncableItem = new SyncableItem( value.ToString(), metaData); CreateItem(key, syncableItem); } }
/// <summary> /// Ensures that a specified <see cref="decimal"/> exists in the local <see cref="GameData"/>. /// </summary> /// <param name="key">Must be a unique identifier for this specific value.</param> /// <param name="persistenceType"> /// The persistence type to use in case of a data conflict. /// <see cref="PersistenceType.Latest"/> will always prefer the newest data. /// <see cref="PersistenceType.Highest"/> will prefer the highest value. /// <see cref="PersistenceType.Lowest"/> will prefer the lowest value. /// </param> /// <param name="value">The initial value for this <see cref="decimal"/>.</param> public static void InitializeDecimal(string key, PersistenceType persistenceType, decimal value) { if (!s_localGameData.SyncableItems.ContainsKey(key)) { var metaData = new SyncableItemMetaData( DataType.Decimal, persistenceType); var syncableItem = new SyncableItem( value.ToString(CultureInfo.InvariantCulture), metaData); CreateItem(key, syncableItem); } }
public void TestExecuteTransaction(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestExecuteTransaction", persistenceType); client.CreateStore(storeName, persistenceType); // Test a simple addition of triples var insertData = new StringBuilder(); insertData.AppendLine(@"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/name> ""Alice""."); insertData.AppendLine( @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/mbox> ""*****@*****.**""."); var job = client.ExecuteTransaction(storeName, new UpdateTransactionData { InsertData = insertData.ToString() }); AssertJobSuccessful(client, storeName, job); // Test an update with a precondition which is met const string tripleToDelete = @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/mbox> ""*****@*****.**""."; const string tripleToInsert = @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/mbox_sha1sum> ""FAKESHA1"""; job = client.ExecuteTransaction(storeName, new UpdateTransactionData { ExistencePreconditions = tripleToDelete, DeletePatterns = tripleToDelete, InsertData = tripleToInsert }); AssertJobSuccessful(client, storeName, job); // Test an update with a precondition which is not met job = client.ExecuteTransaction(storeName, new UpdateTransactionData { ExistencePreconditions = tripleToDelete, DeletePatterns = tripleToDelete, InsertData = tripleToInsert }); while (!(job.JobCompletedOk || job.JobCompletedWithErrors)) { Task.Delay(3).Wait(); job = client.GetJobInfo(storeName, job.JobId); } Assert.IsTrue(job.JobCompletedWithErrors); }
public IStore CreateStore(string storeLocation, PersistenceType storePersistenceType, bool readOnly, bool withTransactionLogging) { Logging.LogInfo("Create Store {0} with persistence type {1}", storeLocation, storePersistenceType); if (_persistenceManager.DirectoryExists(storeLocation)) { throw new StoreManagerException(storeLocation, "Store already exists"); } _persistenceManager.CreateDirectory(storeLocation); var dataFilePath = Path.Combine(storeLocation, DataFileName); _persistenceManager.CreateFile(dataFilePath); var resourceFilePath = Path.Combine(storeLocation, ResourceFileName); _persistenceManager.CreateFile(resourceFilePath); var targetStoreConfiguration = _storeConfiguration.Clone() as StoreConfiguration; targetStoreConfiguration.PersistenceType = storePersistenceType; MasterFile.Create(_persistenceManager, storeLocation, targetStoreConfiguration, Guid.NewGuid()); IPageStore dataPageStore = null; switch (storePersistenceType) { case PersistenceType.AppendOnly: dataPageStore = new AppendOnlyFilePageStore(_persistenceManager, dataFilePath, PageSize, false, _storeConfiguration.DisableBackgroundWrites); break; case PersistenceType.Rewrite: dataPageStore = new BinaryFilePageStore(_persistenceManager, dataFilePath, PageSize, false, 0, 1, _storeConfiguration.DisableBackgroundWrites); break; } IPageStore resourcePageStore = new AppendOnlyFilePageStore(_persistenceManager, resourceFilePath, PageSize, false, _storeConfiguration.DisableBackgroundWrites); var resourceTable = new ResourceTable(resourcePageStore); using (var store = new Store(storeLocation, dataPageStore, resourceTable)) { store.Commit(Guid.Empty); store.Close(); } if (withTransactionLogging) { _persistenceManager.CreateFile(Path.Combine(storeLocation, "transactionheaders.bs")); _persistenceManager.CreateFile(Path.Combine(storeLocation, "transactions.bs")); } Logging.LogInfo("Store created at {0}", storeLocation); return OpenStore(storeLocation, readOnly); }
public static BasePersistenceHelper CreateInstence(PersistenceType type = PersistenceType.ADO, DatabaseType dbType = DatabaseType.SqlServer) { if (type == PersistenceType.ADO) { return(CreateADOInstence(dbType)); } else if (type == PersistenceType.NHibernate) { return(new NHibernateHelper()); } else if (type == PersistenceType.EntityFarmwork) { return(new EntityFarmworkHelper()); } return(null); }
private static string GetPersistenceTypeString(PersistenceType type) { switch (type) { case PersistenceType.Latest: return("PersistenceType.Latest"); case PersistenceType.Highest: return("PersistenceType.Highest"); case PersistenceType.Lowest: return("PersistenceType.Lowest"); default: throw new ArgumentOutOfRangeException("type", type, null); } }
/** * Generic Load - read athe PersistenceData from the Json file */ public static T LoadObject <T>(PersistenceType type) where T : class { //string filePath = Application.persistentDataPath + "/playerInfo.json"; if (File.Exists(filePath)) { try { using (Stream stream = File.OpenRead(filePath)) { String jsonString = File.ReadAllText(filePath); JsonData jsonData = JsonMapper.ToObject(jsonString); return(jsonData["Item"] as T); } } catch (Exception e) { Debug.Log(e.Message); } } return(null); }
public static IPageStore CreateEmptyPageStore(string fileName, PersistenceType persistenceType = PersistenceType.AppendOnly, BrightstarProfiler profiler = null) { using (profiler.Step("Create Empty Page Store")) { using (profiler.Step("Delete Existing")) { if (PersistenceManager.FileExists(fileName)) PersistenceManager.DeleteFile(fileName); //if (File.Exists(fileName)) File.Delete(fileName); } using (profiler.Step("Create New Page Store")) { if (persistenceType == PersistenceType.AppendOnly) { return new AppendOnlyFilePageStore(PersistenceManager, fileName, 4096, false, false); } return new BinaryFilePageStore(PersistenceManager, fileName, 4096, false, 1); } } }
public void TestExecuteTransaction(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestExecuteTransaction", persistenceType); client.CreateStore(storeName, persistenceType); // Test a simple addition of triples var insertData = new StringBuilder(); insertData.AppendLine(@"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/name> ""Alice""."); insertData.AppendLine( @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/mbox> ""*****@*****.**""."); var job = client.ExecuteTransaction(storeName, new UpdateTransactionData {InsertData = insertData.ToString()}); AssertJobSuccessful(client, storeName, job); // Test an update with a precondition which is met const string tripleToDelete = @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/mbox> ""*****@*****.**""."; const string tripleToInsert = @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/mbox_sha1sum> ""FAKESHA1"""; job = client.ExecuteTransaction(storeName, new UpdateTransactionData { ExistencePreconditions = tripleToDelete, DeletePatterns = tripleToDelete, InsertData = tripleToInsert }); AssertJobSuccessful(client, storeName, job); // Test an update with a precondition which is not met job = client.ExecuteTransaction(storeName, new UpdateTransactionData { ExistencePreconditions = tripleToDelete, DeletePatterns = tripleToDelete, InsertData = tripleToInsert }); while (!(job.JobCompletedOk || job.JobCompletedWithErrors)) { Task.Delay(3).Wait(); job = client.GetJobInfo(storeName, job.JobId); } Assert.IsTrue(job.JobCompletedWithErrors); }
private void BuildAndScan(IPageStore pageStore, string pageStoreName, PersistenceType persistenceType, int keyCount) { var config = new BPlusTreeConfiguration(8, 64, pageStore.PageSize); var builder = new BPlusTreeBuilder(pageStore, config); var treeRoot = builder.Build(1, _testOrderedValues.Take(keyCount)); var treeBeforeSave = new BPlusTree(pageStore, treeRoot); treeBeforeSave.Save(1, null); //ValidateScan(treeBeforeSave.Scan(null), keyCount, pageStoreName + " before save"); pageStore.Commit(1, null); pageStore.Close(); using(var ps = TestUtils.OpenPageStore(pageStoreName, true, persistenceType, 1)) { var tree = new BPlusTree(ps, treeRoot); tree.DumpStructure(); ValidateScan(tree.Scan(null), keyCount, pageStoreName + " after save"); ValidateSearch(tree, keyCount, pageStoreName + "after save"); } }
/// <summary> /// Used to set a <see cref="string"/> that will be stored in the cloud. PersistenceType.Latest will be used in case of data conflict. /// </summary> /// <param name="key">Must be a unique identifier for this specific value.</param> /// <param name="value">The value for this <see cref="string"/>.</param> /// <param name="persistenceType">The persistence type to use in case of a data conflict (ignored if value has been set before).</param> public static void SetString(string key, string value, PersistenceType persistenceType) { if (!s_localGameData.SyncableItems.ContainsKey(key)) { var metaData = new SyncableItemMetaData(DataType.String, persistenceType); var syncableItem = new SyncableItem(value, metaData); s_localGameData.SyncableItems.Add(key, syncableItem); IsLocalDataDirty = true; } if (s_localGameData.SyncableItems[key].Metadata.DataType == DataType.String) { s_localGameData.SyncableItems[key].ValueString = value; IsLocalDataDirty = true; } else { throw new UnexpectedCollectionElementTypeException(key, typeof(string)); } }
/// <summary> /// Used to set a <see cref="decimal"/> that will be stored in the cloud. /// </summary> /// <param name="key">Must be a unique identifier for this specific value.</param> /// <param name="value">The value for this <see cref="decimal"/>.</param> /// <param name="persistenceType">The persistence type to use in case of a data conflict (ignored if value has been set before).</param> public static void SetDecimal(string key, decimal value, PersistenceType persistenceType) { if (!s_localGameData.SyncableItems.ContainsKey(key)) { var metaData = new SyncableItemMetaData(DataType.Decimal, persistenceType); var syncableItem = new SyncableItem(value.ToString(CultureInfo.InvariantCulture), metaData); s_localGameData.SyncableItems.Add(key, syncableItem); IsLocalDataDirty = true; } if (s_localGameData.SyncableItems[key].Metadata.DataType == DataType.Decimal) { s_localGameData.SyncableItems[key].ValueString = value.ToString(CultureInfo.InvariantCulture); IsLocalDataDirty = true; } else { throw new UnexpectedCollectionElementTypeException(key, typeof(decimal)); } }
public void TestRdfImportExport(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestRdfImportExport", persistenceType); var importPath = Path.Combine(TestConfiguration.StoreLocation, "import"); TestHelper.CopyFile("TestData\\simple.txt", importPath, "simple.txt"); client.CreateStore(storeName, persistenceType); // RDF import var job = client.StartImport(storeName, "simple.txt"); AssertJobSuccessful(client, storeName, job); // RDF export job = client.StartExport(storeName, "simple.export.nt"); AssertJobSuccessful(client, storeName, job); var exportFilePath = Path.Combine(importPath, "simple.export.nt"); Assert.IsTrue(_pm.FileExists(exportFilePath)); }
/// <summary> /// Create a new store with a specific persistence type for the main indexes /// </summary> /// <param name="storeName">The name of the store to create.</param> /// <param name="persistenceType">The type of persistence to use for the main store indexes</param> /// <exception cref="ArgumentNullException">Raised if <paramref name="storeName"/> is NULL</exception> /// <exception cref="ArgumentException">Raised if <paramref name="storeName"/> is an empty string or does not match the allowed regular expression production for store names.</exception> /// <remarks>See <see cref="Constants.StoreNameRegex"/> for the regular expression used to validate store names.</remarks> public void CreateStore(string storeName, PersistenceType persistenceType) { try { if (storeName == null) throw new ArgumentNullException("storeName", Strings.BrightstarServiceClient_StoreNameMustNotBeNull); if (String.IsNullOrEmpty(storeName)) throw new ArgumentException(Strings.BrightstarServiceClient_StoreNameMustNotBeEmptyString, "storeName"); if (!System.Text.RegularExpressions.Regex.IsMatch(storeName, Constants.StoreNameRegex)) { throw new ArgumentException(Strings.BrightstarServiceClient_InvalidStoreName, "storeName"); } _serverCore.CreateStore(storeName, persistenceType); } catch (Exception ex) { Logging.LogError(BrightstarEventId.ServerCoreException, "Error Creating Store {0}", storeName); throw new BrightstarClientException("Error creating store " + storeName + ". " + ex.Message, ex); } }
/// <summary> /// Create a new store with a specific persistence type /// </summary> /// <param name="storeName"></param> /// <param name="persistenceType"></param> public void CreateStoreWithPersistenceType(string storeName, PersistenceType persistenceType) { try { if (String.IsNullOrEmpty(storeName)) { throw new BrightstarClientException("Store name cannot be NULL or an empty string."); } if (!Regex.IsMatch(storeName, Constants.StoreNameRegex)) { throw new BrightstarClientException(Strings.BrightstarServiceClient_InvalidStoreName); } ServerCore.CreateStore(storeName, persistenceType); Logging.LogInfo("Created store {0} with persistence type {1}", storeName, persistenceType); } catch (Exception ex) { Logging.LogError(BrightstarDB.BrightstarEventId.ServerCoreException, "Error Creating Store {0}", storeName); throw new BrightstarClientException("Error creating store " + storeName + ". " + ex.Message, ex); } }
/** * Retrieve the data from a JsonData and create an Item list with the info */ private static List <Item> GetItemFromJsonData(JsonData jsonData) { PersistenceType type = PersistenceType.itens; Item item = null; List <Item> itens = new List <Item>(); for (int i = 0; i < jsonData[type.ToString()].Count; i++) { item = new Item(); item.id = Convert.ToInt32(jsonData[type.ToString()][i]["id"].ToString()); item.name = jsonData[type.ToString()][i]["name"].ToString(); item.description = jsonData[type.ToString()][i]["description"].ToString(); item.amount = Convert.ToInt32(jsonData[type.ToString()][i]["amount"].ToString()); item.spritePos = Convert.ToInt32(jsonData[type.ToString()][i]["spritePos"].ToString()); int x = Convert.ToInt32(jsonData[type.ToString()][i]["coords"][0].ToString()); int y = Convert.ToInt32(jsonData[type.ToString()][i]["coords"][1].ToString()); item.coords = new int[] { x, y }; itens.Add(item); } return(itens); }
private void BuildAndScan(IPageStore pageStore, string pageStoreName, PersistenceType persistenceType, int keyCount) { var config = new BPlusTreeConfiguration(8, 64, pageStore.PageSize); var builder = new BPlusTreeBuilder(pageStore, config); var treeRoot = builder.Build(1, _testOrderedValues.Take(keyCount)); var treeBeforeSave = new BPlusTree(pageStore, treeRoot); treeBeforeSave.Save(1, null); //ValidateScan(treeBeforeSave.Scan(null), keyCount, pageStoreName + " before save"); pageStore.Commit(1, null); pageStore.Close(); using (var ps = TestUtils.OpenPageStore(pageStoreName, true, persistenceType, 1)) { var tree = new BPlusTree(ps, treeRoot); tree.DumpStructure(); ValidateScan(tree.Scan(null), keyCount, pageStoreName + " after save"); ValidateSearch(tree, keyCount, pageStoreName + "after save"); } }
public void TestRdfImportExport(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestRdfImportExport", persistenceType); var importPath = Path.Combine(TestConfiguration.StoreLocation, "import"); TestHelper.CopyFile("TestData\\simple.txt", importPath, "simple.txt"); client.CreateStore(storeName, persistenceType); // RDF import var job = client.StartImport(storeName, "simple.txt"); AssertJobSuccessful(client, storeName, job); // RDF export job = client.StartExport(storeName, "simple.export.nt"); AssertJobSuccessful(client, storeName, job); var exportFilePath = Path.Combine(importPath, "simple.export.nt"); Assert.IsTrue(_pm.FileExists(exportFilePath)); }
public static IPageStore CreateEmptyPageStore(string fileName, PersistenceType persistenceType = PersistenceType.AppendOnly, BrightstarProfiler profiler = null) { using (profiler.Step("Create Empty Page Store")) { using (profiler.Step("Delete Existing")) { if (PersistenceManager.FileExists(fileName)) { PersistenceManager.DeleteFile(fileName); } //if (File.Exists(fileName)) File.Delete(fileName); } using (profiler.Step("Create New Page Store")) { if (persistenceType == PersistenceType.AppendOnly) { return(new AppendOnlyFilePageStore(PersistenceManager, fileName, 4096, false, false)); } return(new BinaryFilePageStore(PersistenceManager, fileName, 4096, false, 1)); } } }
public void TestCreateStore(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestCreateStore", persistenceType); var storePath = Path.Combine(TestConfiguration.StoreLocation, storeName); var dataPath = Path.Combine(storePath, "data.bs"); client.CreateStore(storeName, persistenceType); Assert.IsTrue(client.DoesStoreExist(storeName)); Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation)); Assert.IsTrue(_pm.DirectoryExists(storePath)); Assert.IsTrue(_pm.FileExists(dataPath)); client.DeleteStore(storeName); Task.Delay(1000).Wait(); // Wait to allow store to shutdown Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation)); Assert.IsFalse(_pm.FileExists(dataPath), "Expected data file to be deleted, but it was still found at {0}", dataPath); Assert.IsFalse(_pm.DirectoryExists(storePath), "Expected store directory to be deleted, but it was still found at {0}", storePath); Assert.IsFalse(client.DoesStoreExist(storeName), "Expected client to report that store not longer exists after deletion"); }
public void TestQuery(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestQuery", persistenceType); client.CreateStore(storeName, persistenceType); var insertData = new StringBuilder(); insertData.AppendLine(@"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/name> ""Alice""."); insertData.AppendLine( @"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.org/people/bob> ."); insertData.AppendLine(@"<http://example.org/people/alice> <http://xmlns.com/foaf/0.1/knows> <http://example.org/people/carol> ."); insertData.AppendLine(@"<http://example.org/people/bob> <http://xmlns.com/foaf/0.1/name> ""Bob"" ."); insertData.AppendLine(@"<http://example.org/people/carol> <http://xmlns.com/foaf/0.1/name> ""Carol"" ."); var job = client.ExecuteTransaction(storeName, new UpdateTransactionData { InsertData = insertData.ToString() }); AssertJobSuccessful(client, storeName, job); const string query = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?p ?n WHERE { <http://example.org/people/alice> foaf:knows ?p . ?p foaf:name ?n }"; var resultStream = client.ExecuteQuery(storeName, query); var doc = XDocument.Load(resultStream); Assert.IsNotNull(doc.Root); var rows = doc.SparqlResultRows().ToList(); Assert.AreEqual(2, rows.Count); foreach (var row in rows) { Assert.IsNotNull(row.GetColumnValue("p")); Assert.IsNotNull(row.GetColumnValue("n")); } }
public void TestCreateStore(PersistenceType persistenceType) { var client = GetEmbeddedClient(); var storeName = MakeStoreName("TestCreateStore", persistenceType); var storePath = Path.Combine(TestConfiguration.StoreLocation, storeName); var dataPath = Path.Combine(storePath, "data.bs"); client.CreateStore(storeName, persistenceType); Assert.IsTrue(client.DoesStoreExist(storeName)); Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation)); Assert.IsTrue(_pm.DirectoryExists(storePath)); Assert.IsTrue(_pm.FileExists(dataPath)); client.DeleteStore(storeName); Task.Delay(1000).Wait(); // Wait to allow store to shutdown Assert.IsTrue(_pm.DirectoryExists(TestConfiguration.StoreLocation)); Assert.IsFalse(_pm.FileExists(dataPath), "Expected data file to be deleted, but it was still found at {0}", dataPath); Assert.IsFalse(_pm.DirectoryExists(storePath), "Expected store directory to be deleted, but it was still found at {0}", storePath); Assert.IsFalse(client.DoesStoreExist(storeName), "Expected client to report that store not longer exists after deletion"); }
public virtual IPersistenceEngine GetPersistenceEngine(PersistenceType persistenceType) { if (persistenceType == PersistenceType.Default) { return(DefaultPersistenceEngine); } else if (persistenceType == PersistenceType.ObjectDocument) { return(ObjectDocumentPersistenceEngine); } else if (persistenceType == PersistenceType.ObjectObject) { return(ObjectObjectPersistenceEngine); } else if (persistenceType == PersistenceType.ObjectRelational) { return(ObjectRelationalPersistenceEngine); } else if (persistenceType == PersistenceType.ObjectService) { return(ObjectServicePersistenceEngine); } return(null); }
internal void CreateSnapshot(string destinationStoreName, PersistenceType persistenceType, ulong commitPointId) { _storeManager.CreateSnapshot(_storeLocation, Path.Combine(_baseLocation, destinationStoreName), persistenceType, commitPointId); }
public Guid CreateSnapshot(string sourceStoreName, string targetStoreName, PersistenceType persistenceType, ulong sourceCommitPointId) { var storeWorker = GetStoreWorker(sourceStoreName); return storeWorker.QueueSnapshotJob(targetStoreName, persistenceType, sourceCommitPointId); }
/// <summary> /// Queues a job to create a snapshot of a store /// </summary> /// <param name="storeName">The name of the store to take a snapshot of</param> /// <param name="targetStoreName">The name of the store to be created to receive the snapshot</param> /// <param name="persistenceType">The type of persistence to use for the target store</param> /// <param name="sourceCommitPoint">OPTIONAL: the commit point in the source store to take a snapshot from</param> /// <param name="label">Optional user-friendly label for the job.</param> /// <returns>A <see cref="IJobInfo"/> instance for tracking the current status of the job.</returns> public IJobInfo CreateSnapshot(string storeName, string targetStoreName, PersistenceType persistenceType, ICommitPointInfo sourceCommitPoint = null, string label = null) { try { var jobId = _serverCore.CreateSnapshot(storeName, targetStoreName, persistenceType, sourceCommitPoint == null ? StoreConstants.NullUlong : sourceCommitPoint.Id, label); return GetJobInfo(storeName, jobId.ToString()); } catch (Exception ex) { Logging.LogError(BrightstarEventId.ServerCoreException, "Error queuing snapshot job for store {0}", storeName); throw new BrightstarClientException( "Error queuing snapshot job for store " + storeName + ". " + ex.Message, ex); } }
private void TestBuildSingleLeafNode(IPageStore pageStore, string pageStoreName, PersistenceType persistenceType) { BuildAndScan(pageStore, pageStoreName, persistenceType, 20); }
/// <summary> /// Used to store <see cref="long"/>s in the cloud. /// </summary> /// <param name="key">A unique identifier used to identify this particular value.</param> /// <param name="persistenceType"> /// The method of conflict resolution to be used in case of a data conflict. Can happen if the data is altered by a different device. /// <see cref="PersistenceType.Latest"/> will prefer the latest (newest) value. /// <see cref="PersistenceType.Highest"/> will prefer the highest value. /// <see cref="PersistenceType.Lowest"/> will prefer the lowest value. /// </param> /// <param name="value">The starting value for this <see cref="long"/>.</param> /// <param name="defaultValue">The value the <see cref="long"/> will be set to if it is ever reset.</param> public CloudLong(string key, PersistenceType persistenceType, long value, long defaultValue) : base(key, persistenceType, value, defaultValue, DataManager.GetLong, DataManager.SetLong) { DataManager.InitializeLong(key, persistenceType, value); Load(); }
static void Main(string[] args) { // // TODO: Add code to start application here // #if (!(DEBUG)) try { #endif if (args.Length != 2) { Console.WriteLine("usage: OperaCopy <source> <dest>"); Console.WriteLine("supported types: TLG, TSR, RWC, RWD, XML"); Console.WriteLine("TLG -------- input"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone), true, true)); Console.WriteLine("TLB = TLG, full base track info; TLS = TLG, geometrical base track info only."); Console.WriteLine("TLG -------- output"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone), false, true)); Console.WriteLine("AI -------- output"); Console.WriteLine("Alignment Ignore sections of TLG files translated to text files"); Console.WriteLine("BI -------- output"); Console.WriteLine("BaseTrack Index sections of TLG files translated to text files"); Console.WriteLine("DBMI -------- output"); Console.WriteLine("DB MicroTrack Index sections of TLG files translated to text files"); Console.WriteLine("TSR -------- input"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.TotalScan.Volume), true, true)); Console.WriteLine("TSR -------- output"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.TotalScan.Volume), false, true)); Console.WriteLine("RWC -------- input"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.Scanning.Plate.IO.OPERA.RawData.Catalog), true, true)); Console.WriteLine("RWC -------- output"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.Scanning.Plate.IO.OPERA.RawData.Catalog), false, true)); Console.WriteLine("RWD -------- input"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.Scanning.Plate.IO.OPERA.RawData.Fragment), true, true)); Console.WriteLine("RWD -------- output"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.Scanning.Plate.IO.OPERA.RawData.Fragment), false, true)); Console.WriteLine("XML -------- input"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.OperaDb.ComputingInfrastructure.ProgramSettings), true, true)); Console.WriteLine("XML -------- output"); Console.WriteLine(SySal.OperaPersistence.Help(typeof(SySal.OperaDb.ComputingInfrastructure.ProgramSettings), false, true)); return; } PersistenceType T = GetType(args[0]); PersistenceType Q = GetType(args[1]); if (T != Q && !(Q == PersistenceType.TLG && (T == PersistenceType.TLB || T == PersistenceType.TLS))) { throw new Exception("Input and output persistence supports must be of the same type."); } switch (T) { case PersistenceType.TLG: if (args[1].ToLower().EndsWith(".bi")) { SySal.Scanning.Plate.IO.OPERA.LinkedZone.BaseTrackIndex bi = (SySal.Scanning.Plate.IO.OPERA.LinkedZone.BaseTrackIndex)SySal.OperaPersistence.Restore(args[0], typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone.BaseTrackIndex)); System.IO.StreamWriter wr = new System.IO.StreamWriter(args[1]); wr.Write("Index"); foreach (int ix in bi.Ids) { wr.WriteLine(); wr.Write(ix); } wr.Flush(); wr.Close(); } else if (args[1].ToLower().EndsWith(".ai")) { SySal.Scanning.Plate.IO.OPERA.LinkedZone.BaseTrackIgnoreAlignment ai = (SySal.Scanning.Plate.IO.OPERA.LinkedZone.BaseTrackIgnoreAlignment)SySal.OperaPersistence.Restore(args[0], typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone.BaseTrackIgnoreAlignment)); System.IO.StreamWriter wr = new System.IO.StreamWriter(args[1]); wr.Write("Index"); foreach (int ix in ai.Ids) { wr.WriteLine(); wr.Write(ix); } wr.Flush(); wr.Close(); } else if (args[1].ToLower().EndsWith(".dbmi")) { SySal.OperaDb.Scanning.DBMIPMicroTrackIndex dbmi = (SySal.OperaDb.Scanning.DBMIPMicroTrackIndex)SySal.OperaPersistence.Restore(args[0], typeof(SySal.OperaDb.Scanning.DBMIPMicroTrackIndex)); System.IO.StreamWriter wr = new System.IO.StreamWriter(args[1]); wr.Write("IdZone\tSide\tId"); foreach (SySal.OperaDb.TotalScan.DBMIPMicroTrackIndex tx in dbmi.TopTracksIndex) { wr.WriteLine(); wr.Write(tx.ZoneId + "\t" + tx.Side + "\t" + tx.Id); } foreach (SySal.OperaDb.TotalScan.DBMIPMicroTrackIndex tx in dbmi.BottomTracksIndex) { wr.WriteLine(); wr.Write(tx.ZoneId + "\t" + tx.Side + "\t" + tx.Id); } wr.Flush(); wr.Close(); } else { SySal.OperaPersistence.LinkedZoneDetailLevel = SySal.OperaDb.Scanning.LinkedZone.DetailLevel.Full; Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.Scanning.Plate.IO.OPERA.LinkedZone)SySal.OperaPersistence.Restore(args[0], typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone)))); } break; case PersistenceType.TLB: SySal.OperaPersistence.LinkedZoneDetailLevel = SySal.OperaDb.Scanning.LinkedZone.DetailLevel.BaseFull; Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.Scanning.Plate.IO.OPERA.LinkedZone)SySal.OperaPersistence.Restore((args[0].Substring(0, args[0].Length - 1) + 'G'), typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone)))); break; case PersistenceType.TLS: SySal.OperaPersistence.LinkedZoneDetailLevel = SySal.OperaDb.Scanning.LinkedZone.DetailLevel.BaseGeom; Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.Scanning.Plate.IO.OPERA.LinkedZone)SySal.OperaPersistence.Restore((args[0].Substring(0, args[0].Length - 1) + 'G'), typeof(SySal.Scanning.Plate.IO.OPERA.LinkedZone)))); break; case PersistenceType.TSR: Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.TotalScan.Volume)SySal.OperaPersistence.Restore(args[0], typeof(SySal.TotalScan.Volume)))); break; case PersistenceType.RWC: Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.Scanning.Plate.IO.OPERA.RawData.Catalog)SySal.OperaPersistence.Restore(args[0], typeof(SySal.Scanning.Plate.IO.OPERA.RawData.Catalog)))); break; case PersistenceType.RWD: Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.Scanning.Plate.IO.OPERA.RawData.Fragment)SySal.OperaPersistence.Restore(args[0], typeof(SySal.Scanning.Plate.IO.OPERA.RawData.Fragment)))); break; case PersistenceType.XML: Console.WriteLine(SySal.OperaPersistence.Persist(args[1], (SySal.OperaDb.ComputingInfrastructure.ProgramSettings)SySal.OperaPersistence.Restore(args[0], typeof(SySal.OperaDb.ComputingInfrastructure.ProgramSettings)))); break; } #if (!(DEBUG)) } catch (Exception x) { Console.Error.WriteLine(x); } #endif }
public SnapshotJob(Guid jobId, string label, StoreWorker storeWorker, string destinationStoreName, PersistenceType persistenceType, ulong sourceCommitPointId) : base(jobId, label, storeWorker) { _destinationStoreName = destinationStoreName; _sourceCommitPointId = sourceCommitPointId; _persistenceType = persistenceType; }
/// <summary> /// Creates a new store. /// </summary> /// <param name="storeName">The name of the store to create</param> /// <param name="namespaceMappings">A collection of prefix to URI mappings to enable CURIEs to be used for resource addresses instead of full URIs</param> /// <param name="optimisticLockingEnabled">A boolean flag indicating if optimistic locking should be enabled</param> /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param> /// <param name="updateGraph">OPTIONAL: The URI identifier of the graph to be updated with any new triples created by operations on the store. If /// not defined, the default graph in the store will be updated.</param> /// <param name="versionTrackingGraph">OPTIONAL: The URI identifier of the graph that contains version number statements for data objects. /// If not defined, the <paramref name="updateGraph"/> will be used.</param> /// <returns>The newly created data object store</returns> /// <remarks>When creating a new store through this API the default data set used for queries will be automatically set to the single update graph specified by the /// <paramref name="updateGraph"/> parameter (or the default graph if the parameter is ommitted).</remarks> /// <exception cref="BrightstarClientException">raised if the store creation failed on the server</exception> /// <exception cref="BrightstarInternalException">raised if the underlying DotNetRDF storage server implementation raises an exception during this operation. /// The underlying server exception will be contained in the InnerException property of the BrightstarInternalException.</exception> public override IDataObjectStore CreateStore(string storeName, Dictionary<string, string> namespaceMappings = null, bool? optimisticLockingEnabled = null, PersistenceType? persistenceType = null, string updateGraph = null, string versionTrackingGraph = null) { if (!_createSupported) throw new NotSupportedException(Strings.DotNetRdf_UnsupportedByServer); try { var storeTemplate = _storageServer.GetDefaultTemplate(storeName); if (_storageServer.CreateStore(storeTemplate)) { return OpenStore(storeName, namespaceMappings, optimisticLockingEnabled, updateGraph, null, versionTrackingGraph); } throw new BrightstarClientException(Strings.DotNetRdf_StoreCreationFailed); } catch (BrightstarException) { throw; } catch (Exception e) { throw new BrightstarInternalException(Strings.DotNetRdf_ErrorFromUnderlyingServer, e); } }
internal void LoadInternal(NativeMethods.CREDENTIAL credential) { Username = credential.UserName; if (credential.CredentialBlobSize > 0) { Password = Marshal.PtrToStringUni(credential.CredentialBlob, credential.CredentialBlobSize / 2); } Target = credential.TargetName; Type = (CredentialType)credential.Type; PersistenceType = (PersistenceType)credential.Persist; Description = credential.Comment; LastWriteTimeUtc = DateTime.FromFileTimeUtc(credential.LastWritten); }
/// <summary> /// Creates a new store. /// </summary> /// <param name="storeName">The name of the store to create</param> /// <param name="namespaceMappings">A collection of prefix to URI mappings to enable CURIEs to be used for resource addresses instead of full URIs</param> /// <param name="optimisticLockingEnabled">A boolean flag indicating if optimistic locking should be enabled</param> /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param> /// <param name="updateGraph">OPTIONAL: The URI identifier of the graph to be updated with any new triples created by operations on the store. If /// not defined, the default graph in the store will be updated.</param> /// <param name="versionTrackingGraph">OPTIONAL: The URI identifier of the graph that contains version number statements for data objects. /// If not defined, the <paramref name="updateGraph"/> will be used.</param> /// <returns>The newly created data object store</returns> public IDataObjectStore CreateStore(string storeName, Dictionary<string, string> namespaceMappings, bool? optimisticLockingEnabled = null, PersistenceType? persistenceType = null, string updateGraph = null, string versionTrackingGraph = null) { Client.CreateStore(storeName, persistenceType.HasValue ? persistenceType.Value : Configuration.PersistenceType); if (String.IsNullOrEmpty(updateGraph)) updateGraph = Constants.DefaultGraphUri; if (String.IsNullOrEmpty(versionTrackingGraph)) versionTrackingGraph = updateGraph; return new RestDataObjectStore( _connectionString, storeName, namespaceMappings, optimisticLockingEnabled.HasValue ? optimisticLockingEnabled.Value : _optimisticLockingEnabled, updateGraph, new string[] {updateGraph}, versionTrackingGraph); }
public void TestCollectionUpdatedByInverseProperty(PersistenceType persistenceType) { var storeName = MakeStoreName("TestCollectionUpdatedByInverseProperty", persistenceType); using (var dataObjectStore = CreateStore(storeName, persistenceType)) { using (var context = new MyEntityContext(dataObjectStore)) { var dept = new Department {Name = "Research"}; context.Departments.Add(dept); // Attach before property is set var alice = new Person {Name = "Alice"}; context.Persons.Add(alice); alice.Department = dept; Assert.AreEqual(1, dept.Persons.Count); // Attach after property set var bob = new Person {Name = "Bob", Department = dept}; context.Persons.Add(bob); Assert.AreEqual(2, dept.Persons.Count); // Attach after property set by explicit call var charlie = new Person {Name = "Charlie"}; charlie.Department = dept; context.Persons.Add(charlie); Assert.AreEqual(3, dept.Persons.Count); // Not attached before checking inverse property var dave = new Person {Name = "Dave", Department = dept}; Assert.AreEqual(3, dept.Persons.Count); context.Persons.Add(dave); Assert.AreEqual(4, dept.Persons.Count); context.SaveChanges(); Assert.AreEqual(4, dept.Persons.Count); context.DeleteObject(bob); Assert.AreEqual(3, dept.Persons.Count); context.SaveChanges(); Assert.AreEqual(3, dept.Persons.Count); } } }
public IJobInfo CreateSnapshot(string storeName, string targetStoreName, PersistenceType persistenceType, ICommitPointInfo sourceCommitPoint = null) { ValidateStoreName(storeName); ValidateStoreName(targetStoreName); try { if (sourceCommitPoint == null) { return new JobInfoWrapper(_service.CreateSnapshot(storeName, targetStoreName, persistenceType, null)); } return new JobInfoWrapper(_service.CreateSnapshot(storeName, targetStoreName, persistenceType, new CommitPointInfo { Id = sourceCommitPoint.Id, StoreName = sourceCommitPoint.StoreName, CommitTime = sourceCommitPoint.CommitTime, JobId = sourceCommitPoint.JobId })); } catch (FaultException<ExceptionDetail> fault) { throw new BrightstarClientException(fault); } }
/// <summary> /// Used to store <see cref="uint"/>s in the cloud. /// </summary> /// <param name="key">A unique identifier used to identify this particular value.</param> /// <param name="persistenceType"> /// The method of conflict resolution to be used in case of a data conflict. Can happen if the data is altered by a different device. /// <see cref="PersistenceType.Latest"/> will prefer the latest (newest) value. /// <see cref="PersistenceType.Highest"/> will prefer the highest value. /// <see cref="PersistenceType.Lowest"/> will prefer the lowest value. /// If you use <see cref="PersistenceType.Lowest"/> and don't set <paramref name="value"/>, the <see cref="uint"/> will always be <c>0u</c>. /// </param> /// <param name="value">The starting value for this <see cref="uint"/>.</param> /// <param name="defaultValue">The value the <see cref="uint"/> will be set to if it is ever reset.</param> public CloudUInt(string key, PersistenceType persistenceType, uint value, uint defaultValue) : base(key, persistenceType, value, defaultValue, DataManager.GetUInt, DataManager.SetUInt) { DataManager.InitializeUInt(key, persistenceType, value); Load(); }
public void CreateStore(string storeName, PersistenceType persistenceType) { ValidateStoreName(storeName); _service.CreateStore(storeName); // TODO: Pass through persistence type }
private void TestBuildSingleLeafNode(IPageStore pageStore, string pageStoreName, PersistenceType persistenceType) { BuildAndScan(pageStore, pageStoreName, persistenceType, 20); }
public void CreateStoreWithPersistenceType(string storeName, PersistenceType persistenceType) { throw new NotImplementedException(); }
public SnapshotJob(Guid jobId, string label, StoreWorker storeWorker, string destinationStoreName, PersistenceType persistenceType, ulong sourceCommitPointId) : base(jobId, label, storeWorker) { _destinationStoreName = destinationStoreName; _sourceCommitPointId = sourceCommitPointId; _persistenceType = persistenceType; }
/// <summary> /// Creates a new store. /// </summary> /// <param name="storeName">The name of the store to create</param> /// <param name="namespaceMappings">A collection of prefix to URI mappings to enable CURIEs to be used for resource addresses instead of full URIs</param> /// <param name="optimisticLockingEnabled">A boolean flag indicating if optimistic locking should be enabled</param> /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param> /// <param name="updateGraph">OPTIONAL: The URI identifier of the graph to be updated with any new triples created by operations on the store. If /// not defined, the default graph in the store will be updated.</param> /// <param name="versionTrackingGraph">OPTIONAL: The URI identifier of the graph that contains version number statements for data objects. /// If not defined, the <paramref name="updateGraph"/> will be used.</param> /// <returns>The newly created data object store</returns> /// <remarks>When creating a new store through this API the default data set used for queries will be automatically set to the single update graph specified by the /// <paramref name="updateGraph"/> parameter (or the default graph if the parameter is ommitted).</remarks> public override IDataObjectStore CreateStore(string storeName, Dictionary<string, string> namespaceMappings = null, bool? optimisticLockingEnabled = null, PersistenceType? persistenceType = null, string updateGraph = null, string versionTrackingGraph = null) { throw new NotSupportedException(); }