当前位置: 首页>>代码示例>>C#>>正文


C# IServiceAddress类代码示例

本文整理汇总了C#中IServiceAddress的典型用法代码示例。如果您正苦于以下问题:C# IServiceAddress类的具体用法?C# IServiceAddress怎么用?C# IServiceAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IServiceAddress类属于命名空间,在下文中一共展示了IServiceAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StopRole

        private CommandResultCode StopRole(NetworkContext context, string role, IServiceAddress address)
        {
            Out.WriteLine("Stopping role " + role + " on " + address);

            MachineProfile p = context.Network.GetMachineProfile(address);
            if (p == null) {
                Out.WriteLine("Error: Machine was not found in the network schema.");
                return CommandResultCode.ExecutionFailed;
            }

            // Here we have some rules,
            // 1. The manager can not be relieved until all block and root servers have
            //    been.

            MachineProfile currentManager = context.Network.ManagerServer;
            MachineProfile[] currentRoots = context.Network.RootServers;
            MachineProfile[] currentBlocks = context.Network.BlockServers;
            if (role.Equals("manager")) {
                if (currentRoots.Length > 0 ||
                    currentBlocks.Length > 0) {
                    Error.WriteLine("Error: Can not relieve manager role when there are existing block and root assignments.");
                    return CommandResultCode.ExecutionFailed;
                }
            }

            // Check that the machine is performing the role,
            bool isPerforming = false;
            if (role.Equals("block")) {
                isPerforming = p.IsBlock;
            } else if (role.Equals("manager")) {
                isPerforming = p.IsManager;
            } else if (role.Equals("root")) {
                isPerforming = p.IsRoot;
            } else {
                Error.WriteLine("Unknown role " + role);
                return CommandResultCode.SyntaxError;
            }

            if (!isPerforming) {
                Error.WriteLine("Error: The machine is not assigned to the " + role + " role.");
                return CommandResultCode.ExecutionFailed;
            }

            // Perform the assignment,
            if (role.Equals("block")) {
                context.Network.DeregisterBlock(address);
                context.Network.StopService(address, ServiceType.Block);
            } else if (role.Equals("manager")) {
                context.Network.StopService(address, ServiceType.Manager);
            } else if (role.Equals("root")) {
                context.Network.DeregisterRoot(address);
                context.Network.StopService(address, ServiceType.Root);
            } else {
                Error.WriteLine("Unknown role " + role);
                return CommandResultCode.SyntaxError;
            }

            Out.WriteLine("done.");
            return CommandResultCode.Success;
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:60,代码来源:StopCommand.cs

示例2: ServiceStatusEventArgs

 internal ServiceStatusEventArgs(IServiceAddress serviceAddress, ServiceType serviceType, ServiceStatus oldStatus, ServiceStatus newStatus)
 {
     this.serviceAddress = serviceAddress;
     this.serviceType = serviceType;
     this.oldStatus = oldStatus;
     this.newStatus = newStatus;
 }
开发者ID:erpframework,项目名称:cloudb,代码行数:7,代码来源:ServiceStatusEventArgs.cs

示例3: ReportServiceDownClientReport

        public void ReportServiceDownClientReport(IServiceAddress address, ServiceType type)
        {
            if (log.IsInterestedIn(LogLevel.Information))
                log.Info(string.Format("reportServiceDownClientReport {0} {1}", address, type));

            ReportServiceDown(address, type, ServiceStatus.DownClientReport);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:7,代码来源:ServiceStatusTracker.cs

示例4: FileSystemRootService

        public FileSystemRootService(IServiceConnector connector, IServiceAddress address, string path)
            : base(connector, address)
        {
            this.path = path;

            pathInitializationQueue = new List<string>(64);
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:7,代码来源:FileSystemRootService.cs

示例5: GetCacheForManager

 public static INetworkCache GetCacheForManager(IServiceAddress[] managers)
 {
     lock (ServiceCacheMap) {
         INetworkCache picked = null;
         int pickedCount = 0;
         for (int i = 0; i < managers.Length; ++i) {
             INetworkCache g;
             if (ServiceCacheMap.TryGetValue(managers[i], out g)) {
                 picked = g;
                 ++pickedCount;
             }
         }
         if (picked == null) {
             picked = CreateDefaultCacheFor(managers);
             for (int i = 0; i < managers.Length; ++i) {
                 ServiceCacheMap[managers[i]] = picked;
             }
         } else if (pickedCount != managers.Length) {
             for (int i = 0; i < managers.Length; ++i) {
                 ServiceCacheMap[managers[i]] = picked;
             }
         }
         return picked;
     }
 }
开发者ID:erpframework,项目名称:cloudb,代码行数:25,代码来源:MachineState.cs

示例6: AddValueToPath

        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);
            }
        }
开发者ID:erpframework,项目名称:cloudb,代码行数:26,代码来源:NetworkContext.cs

示例7: GetServiceTracker

 public static ServiceStatusTracker GetServiceTracker(IServiceAddress[] managers, IServiceConnector connector)
 {
     lock (TrackerCacheMap) {
         ServiceStatusTracker picked = null;
         int pickedCount = 0;
         for (int i = 0; i < managers.Length; ++i) {
             ServiceStatusTracker g;
             if (TrackerCacheMap.TryGetValue(managers[i], out g)) {
                 picked = g;
                 ++pickedCount;
             }
         }
         if (picked == null) {
             picked = new ServiceStatusTracker(connector);
             for (int i = 0; i < managers.Length; ++i) {
                 TrackerCacheMap[managers[i]] = picked;
             }
         } else if (pickedCount != managers.Length) {
             for (int i = 0; i < managers.Length; ++i) {
                 TrackerCacheMap[managers[i]] = picked;
             }
         }
         return picked;
     }
 }
开发者ID:erpframework,项目名称:cloudb,代码行数:25,代码来源:MachineState.cs

示例8: FileSystemManagerService

 public FileSystemManagerService(IServiceConnector connector, string basePath, 
     string dbPath, IServiceAddress address)
     : base(connector, address)
 {
     this.basePath = basePath;
     this.dbPath = dbPath;
 }
开发者ID:ikvm,项目名称:cloudb,代码行数:7,代码来源:FileSystemManagerService.cs

示例9: AddRegisteredRootServer

 protected void AddRegisteredRootServer(IServiceAddress address)
 {
     lock (rootServers) {
         // Add to the internal map/list
         rootServers.Add(new RootServerInfo(address, ServiceStatus.Up));
     }
 }
开发者ID:ikvm,项目名称:cloudb,代码行数:7,代码来源:ManagerService.cs

示例10: InvalidOperationException

        IMessageProcessor IServiceConnector.Connect(IServiceAddress address, ServiceType type)
        {
            if (!connected) {
                if (!OnConnect(address, type)) {
                    logger.Warning(this, "Unable to connect to '" + address + "' after check.");
                    return null;
                }

                try {
                    processor = Connect(address, type);
                } catch (Exception e) {
                    logger.Error(this, "Error while connecting.", e);
                    throw;
                }

                connected = true;

                if (processor == null) {
                    logger.Error(this, "It was not possible to obtain a valid message processor for the connection.");

                    connected = false;
                    throw new InvalidOperationException("Was not able to connect.");
                }

                OnConnected(address, type);

                logger.Info(this, "Connected to '" + address + "'.");
            }

            return processor;
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:31,代码来源:ServiceConnector.cs

示例11: StartRole

        private CommandResultCode StartRole(NetworkContext context, string role, IServiceAddress address)
        {
            Out.WriteLine("Starting role " + role + " on " + address);

            MachineProfile p = context.Network.GetMachineProfile(address);
            if (p == null) {
                Error.WriteLine("Error: Machine was not found in the network schema.");
                return CommandResultCode.ExecutionFailed;
            }

            // Here we have some rules,
            // 1. There must be a manager service assigned before block and roots can be
            //    assigned.
            // 2. Only one manager server can exist.

            MachineProfile current_manager = context.Network.ManagerServer;
            if (!role.Equals("manager") && current_manager == null) {
                Error.WriteLine("Error: Can not assign block or root role when no manager is available on the network.");
                return CommandResultCode.ExecutionFailed;
            } else if (role.Equals("manager") && current_manager != null) {
                Out.WriteLine("Error: Can not assign manager because manager role already assigned.");
                return CommandResultCode.ExecutionFailed;
            }

            // Check if the machine already performing the role,
            bool already_doing_it = false;
            if (role.Equals("block")) {
                already_doing_it = p.IsBlock;
            } else if (role.Equals("manager")) {
                already_doing_it = p.IsManager;
            } else if (role.Equals("root")) {
                already_doing_it = p.IsRoot;
            } else {
                Error.WriteLine("Unknown role " + role);
                return CommandResultCode.SyntaxError;
            }

            if (already_doing_it) {
                Error.WriteLine("Error: The machine is already assigned to the " + role + " role.");
                return CommandResultCode.ExecutionFailed;
            }

            // Perform the assignment,
            if (role.Equals("block")) {
                context.Network.StartService(address, ServiceType.Block);
                context.Network.RegisterBlock(address);
            } else if (role.Equals("manager")) {
                context.Network.StartService(address, ServiceType.Manager);
            } else if (role.Equals("root")) {
                context.Network.StartService(address, ServiceType.Root);
                context.Network.RegisterRoot(address);
            } else {
                Error.WriteLine("Unknown role " + role);
                return CommandResultCode.SyntaxError;
            }

            Out.WriteLine("done.");
            return CommandResultCode.Success;
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:59,代码来源:StartCommand.cs

示例12: NetworkClient

 public NetworkClient(IServiceAddress[] managerAddresses, IServiceConnector connector, INetworkCache lnc)
 {
     this.connector = connector;
     this.managerAddresses = managerAddresses;
     this.localNetworkCache = lnc;
     // Default values,
     MaxTransactionNodeCacheHeapSize = 14*1024*1024;
 }
开发者ID:erpframework,项目名称:cloudb,代码行数:8,代码来源:NetworkClient.cs

示例13: Set

        public void Set(String path, IServiceAddress rootAddress)
        {
            string rootAddrStr = null;
            if (rootAddress != null)
                rootAddrStr = rootAddress.ToString();

            dictionary.SetValue(path, rootAddrStr);
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:8,代码来源:PathRootTable.cs

示例14: SetCache

        public static void SetCache(IServiceAddress manager, INetworkCache cache)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");

            lock (serviceCacheMap) {
                serviceCacheMap[manager] = cache;
            }
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:9,代码来源:ManagerCacheState.cs

示例15: AdminService

        public AdminService(IServiceAddress address, IServiceConnector connector, IServiceFactory serviceFactory)
        {
            if (serviceFactory == null)
                throw new ArgumentNullException("serviceFactory");

            this.serviceFactory = serviceFactory;
            this.address = address;
            this.connector = connector;
            analytics = new Analytics();
        }
开发者ID:ikvm,项目名称:cloudb,代码行数:10,代码来源:AdminService.cs


注:本文中的IServiceAddress类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。