本文整理汇总了C#中IServiceAddress类的典型用法代码示例。如果您正苦于以下问题:C# IServiceAddress类的具体用法?C# IServiceAddress怎么用?C# IServiceAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IServiceAddress类属于命名空间,在下文中一共展示了IServiceAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: NetworkClient
public NetworkClient(IServiceAddress managerAddress, IServiceConnector connector, INetworkCache cache)
{
if (!(connector.MessageSerializer is IRpcMessageSerializer) ||
!((IRpcMessageSerializer)connector.MessageSerializer).SupportsMessageStream)
throw new ArgumentException("The connector given has an invalid message serializer for this context (must be a IRPC serializer).");
this.connector = connector;
this.managerAddress = managerAddress;
this.cache = cache;
}
开发者ID:ikvm,项目名称:cloudb,代码行数:10,代码来源:NetworkClient.cs
示例17: AddPath
public void AddPath(IServiceAddress root, string pathName, string pathType)
{
InspectNetwork();
// Check machine is in the schema,
MachineProfile machineProfile = CheckMachineInNetwork(root);
if (!machineProfile.IsRoot)
throw new NetworkAdminException("Machine '" + root + "' is not a root");
// Get the current manager server,
MachineProfile man = ManagerServer;
if (man == null)
throw new NetworkAdminException("No manager server found");
// Check with the root server that the class instantiates,
Message outputStream = new RequestMessage("checkPathType");
outputStream.Arguments.Add(pathType);
Message m = Command(root, ServiceType.Root, outputStream);
if (m.HasError)
throw new NetworkAdminException("Type '" + pathType + "' doesn't instantiate on the root");
IServiceAddress managerServer = man.Address;
// Create a new empty database,
NetworkClient client = new NetworkClient(managerServer, connector);
client.Connect();
DataAddress dataAddress = client.CreateEmptyDatabase();
client.Disconnect();
// Perform the command,
outputStream = new MessageStream(MessageType.Request);
RequestMessage request = new RequestMessage("addPath");
request.Arguments.Add(pathName);
request.Arguments.Add(pathType);
request.Arguments.Add(dataAddress);
((MessageStream)outputStream).AddMessage(request);
request = new RequestMessage("initPath");
request.Arguments.Add(pathName);
((MessageStream)outputStream).AddMessage(request);
Message message = Command(root, ServiceType.Root, outputStream);
if (message.HasError)
throw new NetworkAdminException(message.ErrorMessage);
// Tell the manager server about this path,
outputStream = new RequestMessage("addPathRootMapping");
outputStream.Arguments.Add(pathName);
outputStream.Arguments.Add(root);
message = Command(managerServer, ServiceType.Manager, outputStream);
if (message.HasError)
throw new NetworkAdminException(message.ErrorMessage);
}
开发者ID:yuexiaoyun,项目名称:cloudb,代码行数:55,代码来源:NetworkProfile_Root.cs
示例18: ToBytes
public byte[] ToBytes(IServiceAddress address)
{
TcpServiceAddress tcpAddress = (TcpServiceAddress)address;
int length = tcpAddress.IsIPv4 ? 4 : 16;
byte[] buffer = new byte[length + 2 + 4];
Util.ByteBuffer.WriteInt2((short)length, buffer, 0);
Array.Copy(tcpAddress.Address, 0, buffer, 2, length);
Util.ByteBuffer.WriteInt4(tcpAddress.Port, buffer, length + 2);
return buffer;
}
开发者ID:erpframework,项目名称:cloudb,代码行数:11,代码来源:TcpServiceAddressHandler.cs
示例19: AddRegisteredBlockServer
protected void AddRegisteredBlockServer(long serverGuid, IServiceAddress address)
{
lock (blockServersMap) {
BlockServerInfo blockServer = new BlockServerInfo(serverGuid, address, ServiceStatus.Up);
// Add to the internal map/list
blockServersMap[serverGuid] = blockServer;
blockServers.Add(blockServer);
}
UpdateAddressSpaceEnd();
}
开发者ID:ikvm,项目名称:cloudb,代码行数:11,代码来源:ManagerService.cs
示例20: NetworkTreeSystem
public NetworkTreeSystem(IServiceConnector connector, IServiceAddress[] managerAddresses,
INetworkCache networkCache, ServiceStatusTracker serviceTracker)
{
this.connector = connector;
this.managerAddresses = managerAddresses;
this.networkCache = networkCache;
this.serviceTracker = serviceTracker;
failureFloodControl = new Dictionary<IServiceAddress, DateTime>();
failureFloodControlBidc = new Dictionary<IServiceAddress, DateTime>();
}
开发者ID:erpframework,项目名称:cloudb,代码行数:11,代码来源:NetworkTreeSystem.cs
注:本文中的IServiceAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论