本文整理汇总了C#中Group.Join方法的典型用法代码示例。如果您正苦于以下问题:C# Group.Join方法的具体用法?C# Group.Join怎么用?C# Group.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group.Join方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
IsisSystem.Start();
Group g = new Group("foo");
int myRank = 0;
g.ViewHandlers += (ViewHandler)delegate(View v)
{
IsisSystem.WriteLine("New View: " + v);
myRank = v.GetMyRank();
if (v.members.Length == 3)
go.Release(1);
};
g.Handlers[UPDATE] += (Action<int, int>)delegate(int rank, int n)
{
database.Add(new tuple(n, rank));
IsisSystem.WriteLine("[" + database.Count() + "] New tuple: " + rank + "/" + n);
if (database.Count() == 15)
dbFull.Release(1);
};
g.Handlers[LOOKUP] += (Action<int>)delegate(int arg)
{
IsisSystem.WriteLine("=== Query for arg=" + arg);
List<int> answer = new List<int>();
int index = 0;
foreach (tuple tp in database)
if (index++ % 3 == myRank)
{
IsisSystem.WriteLine("Looking at " + tp.rank + "/" + tp.value);
if (tp.rank == arg)
{
IsisSystem.WriteLine("Including " + tp.rank + "/" + tp.value);
answer.Add(tp.value);
}
}
g.Reply(answer);
};
g.Join();
go.WaitOne();
for (int n = 0; n < 5; n++)
g.OrderedSend(UPDATE, myRank, n);
IsisSystem.WriteLine("Wait until database is full!");
dbFull.WaitOne();
IsisSystem.WriteLine("Database is fully populated!");
if (myRank == 1)
for (int n = 0; n < 3; n++)
{
List<List<int>> results = new List<List<int>>();
g.OrderedQuery(Group.ALL, LOOKUP, n, new Isis.EOLMarker(), results);
IsisSystem.WriteLine("\r\nAnswers for Query rank=" + n);
foreach (List<int> list in results)
foreach (int value in list)
IsisSystem.Write(value + " ");
}
IsisSystem.WaitForever();
}
示例2: Main
static void Main(string[] args)
{
try
{
if (args.Length == 3)
{
int setlocal = int.Parse(args[0]);
int setlocal_ = int.Parse(args[1]);
local.Port = setlocal;
local_.Port = setlocal_;
Console.WriteLine("Local port has been set to " + setlocal + " and " + setlocal_);
bootstrap = args[2];
}
else if (args.Length == 1)
{
bootstrap = args[0];
}
// Set up local UDP communication with web front
string ip = NetSetup();
// TODO: add logic to retrieve oracle information from bootstrap server
// Set up runtime environments
Environment.SetEnvironmentVariable("ISIS_TCP_ONLY", "true");
IsisSystem.Start();
Console.WriteLine("IsisSystem started");
smallGroup = new SmallGroup("Azure Group");
smallGroup.Join();
Console.WriteLine("Azure group joined");
Thread.Sleep(15 * 1000);
IsisSystem.WaitForever();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
示例3: Application_Start
protected void Application_Start(Object sender, EventArgs e)
{
Semaphore sem = new Semaphore(0, 1);
Thread lbFileServerGroupThread = new Thread (delegate()
{
//Start the ISIS System
IsisSystem.Start();
string groupName = "FS1";
string logicalGroupName = "lbalancer-" + groupName;
fileServerGroupList.TryAdd (logicalGroupName, new FileServerGroupObject());
Group lbfsgroup = new Group(logicalGroupName);
lbfsgroup.ViewHandlers += (ViewHandler)delegate(View v)
{
Console.WriteLine("myGroup got a new view event: " + v);
Address [] addList = v.GetLiveMembers();
for(Int32 index = 0; index < addList.Length; index++)
{
Isis.WriteLine ("The Add List Address " + addList[index].ToStringVerboseFormat ());
fileServerGroupList[logicalGroupName].addToFileServerList(addList[index]);
}
Address [] removeList = v.GetFailedMembers();
for(Int32 index = 0; index < removeList.Length; index++)
{
fileServerGroupList[logicalGroupName].removeFromFileServerList(removeList[index]);
}
};
lbfsgroup.Join();
sem.Release();
IsisSystem.WaitForever();
});
lbFileServerGroupThread.Start ();
sem.WaitOne ();
Isis.WriteLine ("Starting Web Service on the LoadBalancer");
new AppHost().Init();
}
示例4: JoinGroup
public static void JoinGroup(Group group)
{
group.Join();
}
示例5: Main
//.........这里部分代码省略.........
Console.WriteLine("entering into Make CheckPoint");
List<KeyValuePair<string, List<KeyValuePair<string, string>>>> database = new List<KeyValuePair<string, List<KeyValuePair<string, string>>>>();
foreach (string key in autoEntity.Keys)
{
database.Add(new KeyValuePair<string, List<KeyValuePair<string, string>>>(key, autoEntity[key].ToList<KeyValuePair<string, string>>()));
}
g.SendChkpt(database);
g.EndOfChkpt();
}
};
//Load checkpoint handler
g.LoadChkpt += (Action<List<KeyValuePair<string, List<KeyValuePair<string, string>>>>>)delegate(List<KeyValuePair<string, List<KeyValuePair<string, string>>>> incoming)
{
Console.WriteLine("entering into load checkpoint");
autoEntity = incoming.ToDictionary(pair => pair.Key, pair => pair.Value.ToDictionary(st => st.Key, st => st.Value));
};
g.Handlers[calculateTime] += (Action<long>)delegate(long time)
{
Console.WriteLine("entering into calculate time");
totalTime.Add(time);
if (totalTime.Count == view.members.Length)
{
timeSem.Release();
}
};
g.Join();
Dataset();
sem.WaitOne();
//100 Independent SET Reuests
#region test case1
//Thread testthread = new Thread(delegate()
//{
// Console.WriteLine("testing case 1");
// int counter = 100;
// List<long> average = new List<long>();
// while (counter > 0)
// {
// Stopwatch sw = new Stopwatch();
// sw.Start();
// g.OrderedSend(SET, entityName[myRank], new List<string>() { "company=company1", "model=model1", "price=price1" });
// sw.Stop();
// average.Add(sw.ElapsedTicks / (Stopwatch.Frequency / (1000L)));
// counter--;
// Thread.Sleep(500);
// }
// long time = (average.Sum());
// g.OrderedSend(calculateTime, time);
// Console.WriteLine("server set time (ms)" + time);
//});
//testthread.Start();
#endregion
//test case: for same entity modify attributes by different server threads
#region test case2
示例6: Isis_Start
//public Dictionary<string, Dictionary<string, string>> entity = new Dictionary<string, Dictionary<string, string>>();
public static void Isis_Start()
{
IsisSystem.Start();
g = new Group("pb476_cs5412");
int myRank = 0;
g.ViewHandlers += (ViewHandler)delegate(View v)
{
IsisSystem.WriteLine("New View: " + v);
myRank = v.GetMyRank();
if (v.members.Length == 5)
go.Release(1);
};
g.Handlers[UPDATE] += (Action<string, string, string>)delegate(string key, string value, string attkey)
{
Dictionary<string, string> attr = new Dictionary<string, string>();
if (value == "null")
{
entity.Remove(key);
}
else if (entity.ContainsKey(key))
{
entity[key] = attr;
attr[key] = attkey;
}
else
{
entity.Add(key, attr);
}
//collection cp = new collection();
CS5412_Service cp = new CS5412_Service();
cp.Set(key, value, attkey);
IsisSystem.WriteLine("New collection: " + key + "/" + value + "/" + attkey);
};
g.Handlers[LOOKUP] += (Action<string>)delegate(string key)
{
Dictionary<string, string> attr = new Dictionary<string, string>();
string result = null;
//attr = entity;
if (entity.ContainsKey(key))
{
result = attr[key];
}
IsisSystem.WriteLine("=== Query for arg=" + key + "Result" + result);
/*List<string> answer = new List<string>();
//foreach (collection tp in database)
if (Get(key) == key)
{
IsisSystem.WriteLine("Including " + Get(key) + "/" + GetType());
answer.Add(Get(key));
}*/
g.Reply(result);
};
g.Join();
IsisSystem.WriteLine("Time elapsed is " + stopwatch.Elapsed);
IsisSystem.WriteLine("Wait until database is full!");
dbFull.WaitOne();
IsisSystem.WriteLine("Database is fully populated!");
}
开发者ID:prashanth08,项目名称:Porting-ISIS2-Cloud-Computing-application-onto-Amazon-EC2-instances-and-achieving-Ordered-Multicast.,代码行数:70,代码来源:CS5412_Service.cs