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


C# SortedSet.headSet方法代码示例

本文整理汇总了C#中SortedSet.headSet方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.headSet方法的具体用法?C# SortedSet.headSet怎么用?C# SortedSet.headSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortedSet的用法示例。


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

示例1: execute

			/// <summary>
			/// the command that is run and retried for actually
			/// obtaining the lock
			/// </summary>
			/// <returns> if the command was successful or not </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean execute() throws org.apache.zookeeper.KeeperException, InterruptedException
			public virtual bool execute()
			{
				do
				{
					if (string.ReferenceEquals(outerInstance.id, null))
					{
						long sessionId = outerInstance.zookeeper.SessionId;
						string prefix = "x-" + sessionId + "-";
						// lets try look up the current ID if we failed 
						// in the middle of creating the znode
						findPrefixInChildren(prefix, outerInstance.zookeeper, outerInstance.dir);
						outerInstance.idName = new ZNodeName(outerInstance.id);
					}
					if (!string.ReferenceEquals(outerInstance.id, null))
					{
						IList<string> names = outerInstance.zookeeper.getChildren(outerInstance.dir, false);
						if (names.Count == 0)
						{
							LOG.warn("No children in: " + outerInstance.dir + " when we've just " + "created one! Lets recreate it...");
							// lets force the recreation of the id
							outerInstance.id = null;
						}
						else
						{
							// lets sort them explicitly (though they do seem to come back in order ususally :)
							SortedSet<ZNodeName> sortedNames = new SortedSet<ZNodeName>();
							foreach (string name in names)
							{
								sortedNames.Add(new ZNodeName(outerInstance.dir + "/" + name));
							}
							outerInstance.ownerId = sortedNames.Min.Name;
							SortedSet<ZNodeName> lessThanMe = sortedNames.headSet(outerInstance.idName);
							if (lessThanMe.Count > 0)
							{
								ZNodeName lastChildName = lessThanMe.Max;
								outerInstance.lastChildId = lastChildName.Name;
								if (LOG.DebugEnabled)
								{
									LOG.debug("watching less than me node: " + outerInstance.lastChildId);
								}
								Stat stat = outerInstance.zookeeper.exists(outerInstance.lastChildId, new LockWatcher(outerInstance));
								if (stat != null)
								{
									return false;
								}
								else
								{
									LOG.warn("Could not find the" + " stats for less than me: " + lastChildName.Name);
								}
							}
							else
							{
								if (outerInstance.Owner)
								{
									if (outerInstance.callback != null)
									{
										outerInstance.callback.lockAcquired();
									}
									return true;
								}
							}
						}
					}
				} while (string.ReferenceEquals(outerInstance.id, null));
				return false;
			}
开发者ID:,项目名称:,代码行数:73,代码来源:


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