/// <exception cref="System.Exception"/> protected override void ServiceInit(Configuration conf) { UserGroupInformation ugi = UserGroupInformation.GetCurrentUser(); UserGroupInformation realUgi = ugi.GetRealUser(); if (realUgi != null) { authUgi = realUgi; doAsUser = ugi.GetShortUserName(); } else { authUgi = ugi; doAsUser = null; } ClientConfig cc = new DefaultClientConfig(); cc.GetClasses().AddItem(typeof(YarnJacksonJaxbJsonProvider)); connConfigurator = NewConnConfigurator(conf); if (UserGroupInformation.IsSecurityEnabled()) { authenticator = new KerberosDelegationTokenAuthenticator(); } else { authenticator = new PseudoDelegationTokenAuthenticator(); } authenticator.SetConnectionConfigurator(connConfigurator); token = new DelegationTokenAuthenticatedURL.Token(); connectionRetry = new TimelineClientImpl.TimelineClientConnectionRetry(conf); client = new Com.Sun.Jersey.Api.Client.Client(new URLConnectionClientHandler(new TimelineClientImpl.TimelineURLConnectionFactory(this)), cc); TimelineClientImpl.TimelineJerseyRetryFilter retryFilter = new TimelineClientImpl.TimelineJerseyRetryFilter (this); client.AddFilter(retryFilter); if (YarnConfiguration.UseHttps(conf)) { resURI = URI.Create(Joiner.Join("https://", conf.Get(YarnConfiguration.TimelineServiceWebappHttpsAddress , YarnConfiguration.DefaultTimelineServiceWebappHttpsAddress), ResourceUriStr)); } else { resURI = URI.Create(Joiner.Join("http://", conf.Get(YarnConfiguration.TimelineServiceWebappAddress , YarnConfiguration.DefaultTimelineServiceWebappAddress), ResourceUriStr)); } Log.Info("Timeline service address: " + resURI); base.ServiceInit(conf); }
/// <exception cref="Sharpen.UnknownHostException"/> public static string GetApplicationWebURLOnJHSWithoutScheme(Configuration conf, ApplicationId appId) { //construct the history url for job string addr = GetJHSWebappURLWithoutScheme(conf); IEnumerator <string> it = AddrSplitter.Split(addr).GetEnumerator(); it.Next(); // ignore the bind host string port = it.Next(); // Use hs address to figure out the host for webapp addr = conf.Get(JHAdminConfig.MrHistoryAddress, JHAdminConfig.DefaultMrHistoryAddress ); string host = AddrSplitter.Split(addr).GetEnumerator().Next(); string hsAddress = Joiner.Join(host, ":", port); IPEndPoint address = NetUtils.CreateSocketAddr(hsAddress, GetDefaultJHSWebappPort (), GetDefaultJHSWebappURLWithoutScheme()); StringBuilder sb = new StringBuilder(); if (address.Address.IsAnyLocalAddress() || address.Address.IsLoopbackAddress()) { sb.Append(Sharpen.Runtime.GetLocalHost().ToString()); } else { sb.Append(address.GetHostName()); } sb.Append(":").Append(address.Port); sb.Append("/jobhistory/job/"); JobID jobId = TypeConverter.FromYarn(appId); sb.Append(jobId.ToString()); return(sb.ToString()); }
public void ShouldJoinNames() { var joiner = new Joiner(); var results = joiner.Join("carlos", "perez"); Approvals.Verify(results); }
public virtual string UniqueName(string name) { lock (this) { UniqueNames.Count c = map[name]; if (c == null) { c = new UniqueNames.Count(name, 0); map[name] = c; return(name); } if (!c.baseName.Equals(name)) { c = new UniqueNames.Count(name, 0); } do { string newName = joiner.Join(name, ++c.value); UniqueNames.Count c2 = map[newName]; if (c2 == null) { map[newName] = c; return(newName); } }while (true); } }
protected internal AppController(Org.Apache.Hadoop.Mapreduce.V2.App.Webapp.App app , Configuration conf, Controller.RequestContext ctx, string title) : base(ctx) { this.app = app; Set(AppId, app.context.GetApplicationID().ToString()); Set(RmWeb, Joiner.Join(MRWebAppUtil.GetYARNWebappScheme(), WebAppUtils.GetResolvedRMWebAppURLWithoutScheme (conf, MRWebAppUtil.GetYARNHttpPolicy()))); }
public void TestNoSpecialNullBehavior() { CheckNoOutput(J, ITERABLE_); CheckResult(J, ITERABLE_1, "1"); CheckResult(J, ITERABLE_12, "1-2"); CheckResult(J, ITERABLE_123, "1-2-3"); try { J.Join(ITERABLE_NULL); Assert.Fail(); } catch (NullReferenceException) { } try { J.Join(ITERABLE_1_NULL_2); Assert.Fail(); } catch (NullReferenceException) { } try { J.Join(ITERABLE_NULL.GetEnumerator()); Assert.Fail(); } catch (NullReferenceException) { } try { J.Join(ITERABLE_1_NULL_2.GetEnumerator()); Assert.Fail(); } catch (NullReferenceException) { } }
public void ShouldWorkNormally() { // Arrange decimal testBaseAmount = 1.5m; decimal testVariantAmount = 0m; var personId = Guid.NewGuid(); var baseResult = GenerateCaseResult(personId, testBaseAmount); var variantResult = GenerateCaseResult(personId, testVariantAmount); // Act var sut = new Joiner(); var result = sut.Join(baseResult, variantResult); // Assert Assert.Single(result); var pcr1 = result.First(x => x.BaseAmount == 1.5m && x.VariantAmount == 0); Assert.NotNull(pcr1); }
static void Main(string[] args) { // Create data var amountOfData = 10; var users = DataGenerator.GetUsers(amountOfData); var departments = DataGenerator.GetDepartments(amountOfData); // Join var joiner = new Joiner(); var result = joiner.Join(users, departments); // Display the result foreach (var userDepartment in result) { Console.WriteLine($"UserId: {userDepartment.UserId}, UserName: {userDepartment.UserName}. " + $"DepartmentId: {userDepartment.DepartmentId}, DepartmentName: {userDepartment.DepartmentName}"); } Console.ReadKey(); }
static void Main(string[] args) { var firstArray = new object[][] { new object[] { 1, "A" }, new object[] { 2, "B" }, new object[] { 3, "C" }, new object[] { 4, "D" }, new object[] { 5, "E" } }; var secondArray = new object[] { 6, 7 }; var joiner = new Joiner(); IEnumerable <IEnumerable <object> > result = joiner.Join(firstArray.ToList(), secondArray.ToList()); //result = new object[] { new object[] { 6, 1, "A" }, // new object[] { 7, 1, "A" }, // new object[] { 6, 2, "B" }, // new object[] { 7, 2, "B" }, // new object[] { 6, 3, "C" }, // new object[] { 7, 3, "C" }, // new object[] { 6, 4, "D" }, // new object[] { 7, 4, "D" }, // new object[] { 6, 5, "E" }, // new object[] { 7, 5, "E" } // }; }
public override void Render() { Puts("Request URI: ", Request().GetRequestURI()); Puts("Query parameters:"); IDictionary <string, string[]> @params = Request().GetParameterMap(); foreach (KeyValuePair <string, string[]> e in @params) { Puts(" ", e.Key, "=", valJoiner.Join(e.Value)); } Puts("More parameters:"); foreach (KeyValuePair <string, string> e_1 in MoreParams()) { Puts(" ", e_1.Key, "=", e_1.Value); } Puts("Path info: ", Request().GetPathInfo()); Puts("Path translated: ", Request().GetPathTranslated()); Puts("Auth type: ", Request().GetAuthType()); Puts("Remote address: " + Request().GetRemoteAddr()); Puts("Remote user: "******"Servlet attributes:"); Enumeration <string> attrNames = Request().GetAttributeNames(); while (attrNames.MoveNext()) { string key = attrNames.Current; Puts(" ", key, "=", Request().GetAttribute(key)); } Puts("Headers:"); Enumeration <string> headerNames = Request().GetHeaderNames(); while (headerNames.MoveNext()) { string key = headerNames.Current; Puts(" ", key, "=", Request().GetHeader(key)); } }
private static void CheckResult(Joiner joiner, IList <string> parts, string expected) { Assert.AreEqual(expected, joiner.Join(parts)); Assert.AreEqual(expected, joiner.Join(parts.GetEnumerator())); }
private static void CheckNoOutput(Joiner joiner, IList <string> parts) { Assert.AreEqual("", joiner.Join(parts)); Assert.AreEqual("", joiner.Join(parts.GetEnumerator())); }
protected String ToSection(IEnumerable <String> sections) { String join = Joiner.Join(sections); return(String.IsNullOrEmpty(join) ? MainSection : join); }
/// <summary>Join on slash and colon (e.g., path args in routing spec)</summary> /// <param name="args">to join</param> /// <returns>args joined with /:</returns> public static string Pajoin(params object[] args) { return(PathArgJoiner.Join(args)); }
/// <summary>Join on underscore</summary> /// <param name="args">to join</param> /// <returns>args joined underscore</returns> public static string _join(params object[] args) { return(Joiner.Join(args)); }
public override void AddContainerRequest(T req) { lock (this) { Preconditions.CheckArgument(req != null, "Resource request can not be null."); ICollection <string> dedupedRacks = new HashSet <string>(); if (req.GetRacks() != null) { Sharpen.Collections.AddAll(dedupedRacks, req.GetRacks()); if (req.GetRacks().Count != dedupedRacks.Count) { Joiner joiner = Joiner.On(','); Log.Warn("ContainerRequest has duplicate racks: " + joiner.Join(req.GetRacks())); } } ICollection <string> inferredRacks = ResolveRacks(req.GetNodes()); inferredRacks.RemoveAll(dedupedRacks); // check that specific and non-specific requests cannot be mixed within a // priority CheckLocalityRelaxationConflict(req.GetPriority(), AnyList, req.GetRelaxLocality( )); // check that specific rack cannot be mixed with specific node within a // priority. If node and its rack are both specified then they must be // in the same request. // For explicitly requested racks, we set locality relaxation to true CheckLocalityRelaxationConflict(req.GetPriority(), dedupedRacks, true); CheckLocalityRelaxationConflict(req.GetPriority(), inferredRacks, req.GetRelaxLocality ()); // check if the node label expression specified is valid CheckNodeLabelExpression(req); if (req.GetNodes() != null) { HashSet <string> dedupedNodes = new HashSet <string>(req.GetNodes()); if (dedupedNodes.Count != req.GetNodes().Count) { Joiner joiner = Joiner.On(','); Log.Warn("ContainerRequest has duplicate nodes: " + joiner.Join(req.GetNodes())); } foreach (string node in dedupedNodes) { AddResourceRequest(req.GetPriority(), node, req.GetCapability(), req, true, req.GetNodeLabelExpression ()); } } foreach (string rack in dedupedRacks) { AddResourceRequest(req.GetPriority(), rack, req.GetCapability(), req, true, req.GetNodeLabelExpression ()); } // Ensure node requests are accompanied by requests for // corresponding rack foreach (string rack_1 in inferredRacks) { AddResourceRequest(req.GetPriority(), rack_1, req.GetCapability(), req, req.GetRelaxLocality (), req.GetNodeLabelExpression()); } // Off-switch AddResourceRequest(req.GetPriority(), ResourceRequest.Any, req.GetCapability(), req , req.GetRelaxLocality(), req.GetNodeLabelExpression()); } }