public void AddValueToPath(string path, string tableName, string key, string value) { if (!BasePathWrapper.IsSupported) { throw new ApplicationException("Base path is not supported."); } MachineProfile[] managers = netProfile.GetManagerServers(); if (managers.Length == 0) { throw new ApplicationException(); } IServiceAddress[] managerAddresses = new IServiceAddress[managers.Length]; for (int i = 0; i < managers.Length; i++) { managerAddresses[i] = managers[i].ServiceAddress; } NetworkClient client = new NetworkClient(managerAddresses, netProfile.Connector); BasePathWrapper wrapper = new BasePathWrapper(); object session = wrapper.CreateDbSession(client, path); using (IDisposable transaction = wrapper.CreateDbTransaction(session) as IDisposable) { if (!wrapper.TableExists(transaction, tableName)) { throw new ApplicationException(); } wrapper.Insert(transaction, tableName, key, value); wrapper.Commit(transaction); } }
public void StartManager() { MachineProfile machine = NetworkProfile.GetMachineProfile(LocalAddress); Assert.IsNotNull(machine); Assert.IsEmpty(NetworkProfile.GetManagerServers()); Assert.IsFalse(machine.IsManager); NetworkProfile.StartService(LocalAddress, ServiceType.Manager); NetworkProfile.RegisterManager(LocalAddress); NetworkProfile.Refresh(); machine = NetworkProfile.GetMachineProfile(LocalAddress); Assert.IsNotNull(machine); Assert.IsNotNull(NetworkProfile.GetManagerServers()); Assert.IsTrue(machine.IsManager); }