public void MapToStringWithNullKvAndReplaceTest() { var str3 = Joiner.On("&").WithKeyValueSeparator("=").UseForNull("NullKey", "NullValue").Join(OriginalMaterials.IncludeNullKvList); var str4 = Joiner.On("&").WithKeyValueSeparator("=").UseForNull(s => "NullKeyFunc", s => "NullValueFunc").Join(OriginalMaterials.IncludeNullKvList); str3.ShouldBe("a=1&b=2&c=3&d=4&e=5&NullKey=NullValue"); str4.ShouldBe("a=1&b=2&c=3&d=4&e=5&NullKeyFunc=NullValueFunc"); }
public void MapToStringWithEmptyValueAndReplaceTest() { var str51 = Joiner.On("&").WithKeyValueSeparator("=").UseForNull("NullKey", "NullValue").Join(OriginalMaterials.IncludeEmptyValueList); var str61 = Joiner.On("&").WithKeyValueSeparator("=").UseForNull(s => "NullKeyFunc", s => "NullValueFunc").Join(OriginalMaterials.IncludeEmptyValueList); str51.ShouldBe("a=1&b=2&c=3&d=4&e=5&f=NullValue"); str61.ShouldBe("a=1&b=2&c=3&d=4&e=5&f=NullValueFunc"); }
public override string ToString() { StringBuilder sb = new StringBuilder("HostSet("); Joiner.On(",").AppendTo(sb, Iterators.Transform(GetEnumerator(), new _Function_226 ())); return(sb.Append(")").ToString()); }
private AddJoinsReWriter(ISessionFactoryImplementor sessionFactory, QueryModel queryModel) { _sessionFactory = sessionFactory; var joiner = new Joiner(queryModel, AddJoin); _memberExpressionJoinDetector = new MemberExpressionJoinDetector(this, joiner); _whereJoinDetector = new WhereJoinDetector(this, joiner); }
public static FromX From <M>(this Joiner join, Expression <Func <M> > tableModelFunc) { join.DC.Action = ActionEnum.From; var dic = join.DC.EH.FuncTExpression(tableModelFunc)[0]; join.DC.DPH.AddParameter(dic); return(new FromX(join.DC)); }
public void MapToStringWithDefaultKvTest() { var strOu = Joiner.On("&").WithKeyValueSeparator("=").Join(OriginalMaterials.NormalList, "d", "0"); var strJi = Joiner.On("&").WithKeyValueSeparator("=").Join(OriginalMaterials.NormalListJi, "d", "0"); strOu.ShouldBe("a=1&b=2&c=3&d=4&e=5"); strJi.ShouldBe("a=1&b=2&c=3&d=4&e=0"); }
public IActionResult LeaveGameGroup(int id) { Joiner gg = _context.Joiners.SingleOrDefault(a => a.Users_UserId == ( int )HttpContext.Session.GetInt32("UserId") && a.Games_GameId == id); _context.Joiners.Remove(gg); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
private void Op(KMSAudit.OpStatus opStatus, KMS.KMSOp op, string user, string key , string extraMsg) { if (!Strings.IsNullOrEmpty(user) && !Strings.IsNullOrEmpty(key) && (op != null) && AggregateOpsWhitelist.Contains(op)) { string cacheKey = CreateCacheKey(user, key, op); if (opStatus == KMSAudit.OpStatus.Unauthorized) { cache.Invalidate(cacheKey); AuditLog.Info("UNAUTHORIZED[op={}, key={}, user={}] {}", op, key, user, extraMsg); } else { try { KMSAudit.AuditEvent @event = cache.Get(cacheKey, new _Callable_161(key, user, op, extraMsg)); // Log first access (initialized as -1 so // incrementAndGet() == 0 implies first access) if (@event.GetAccessCount().IncrementAndGet() == 0) { @event.GetAccessCount().IncrementAndGet(); LogEvent(@event); } } catch (ExecutionException ex) { throw new RuntimeException(ex); } } } else { IList <string> kvs = new List <string>(); if (op != null) { kvs.AddItem("op=" + op); } if (!Strings.IsNullOrEmpty(key)) { kvs.AddItem("key=" + key); } if (!Strings.IsNullOrEmpty(user)) { kvs.AddItem("user="******"{} {}", opStatus.ToString(), extraMsg); } else { string join = Joiner.On(", ").Join(kvs); AuditLog.Info("{}[{}] {}", opStatus.ToString(), join, extraMsg); } } }
public static FromX From <M>(this Joiner join, Expression <Func <M> > func) { var dic = join.DC.EH.ExpressionHandle(func)[0]; dic.Action = ActionEnum.From; dic.Crud = CrudTypeEnum.Join; join.DC.AddConditions(dic); return(new FromX(join.DC)); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("BlockRecoveryCommand(\n "); Joiner.On("\n ").AppendTo(sb, recoveringBlocks); sb.Append("\n)"); return(sb.ToString()); }
private AddJoinsReWriter(ISessionFactory sessionFactory, QueryModel queryModel) { _sessionFactory = sessionFactory; var joiner = new Joiner(queryModel); _selectJoinDetector = new SelectJoinDetector(this, joiner); _resultOperatorAndOrderByJoinDetector = new ResultOperatorAndOrderByJoinDetector(this, joiner); _whereJoinDetector = new WhereJoinDetector(this, joiner); }
public void TestOnCharOverride() { var onChar = Joiner.On('-'); CheckNoOutput(onChar, ITERABLE_); CheckResult(onChar, ITERABLE_1, "1"); CheckResult(onChar, ITERABLE_12, "1-2"); CheckResult(onChar, ITERABLE_123, "1-2-3"); }
/// <exception cref="System.Exception"/> private int RunTool(params string[] args) { errOutBytes.Reset(); Log.Info("Running: DFSHAAdmin " + Joiner.On(" ").Join(args)); int ret = tool.Run(args); errOutput = new string(errOutBytes.ToByteArray(), Charsets.Utf8); Log.Info("Output:\n" + errOutput); return(ret); }
/// <summary> /// Gets real region's code.<br /> /// 获取真实的地区编码。<br /> /// If <see cref="RegionCode"/> is empty, returns the name of <see cref="CountryCode"/> witch converted from <see cref="Country"/>.<br /> /// 如果地区编码 <see cref="RegionCode"/> 为空,则返回转换自 <see cref="Country"/> 的 <see cref="CountryCode"/> 的名称。<br /> /// <br /> /// If this holiday belongs to the whole nation, returns empty.<br /> /// 如果本节日属于国家级的节日(非地区级别的),则返回空 empty。 /// </summary> /// <returns></returns> public virtual string GetRegionCode() { if (RegionCodes.Any()) { return(Joiner.On(',').Join(RegionCodes)); } return(string.IsNullOrWhiteSpace(RegionCode) ? CountryHelper.GetRegionCode(Country, BelongsToCountry) : RegionCode); }
/// <exception cref="System.Exception"/> public virtual void TestHAUtilClonesDelegationTokens() { Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = GetDelegationToken (fs, "JobTracker"); UserGroupInformation ugi = UserGroupInformation.CreateRemoteUser("test"); URI haUri = new URI("hdfs://my-ha-uri/"); token.SetService(HAUtil.BuildTokenServiceForLogicalUri(haUri, HdfsConstants.HdfsUriScheme )); ugi.AddToken(token); ICollection <IPEndPoint> nnAddrs = new HashSet <IPEndPoint>(); nnAddrs.AddItem(new IPEndPoint("localhost", nn0.GetNameNodeAddress().Port)); nnAddrs.AddItem(new IPEndPoint("localhost", nn1.GetNameNodeAddress().Port)); HAUtil.CloneDelegationTokenForLogicalUri(ugi, haUri, nnAddrs); ICollection <Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> > tokens = ugi .GetTokens(); NUnit.Framework.Assert.AreEqual(3, tokens.Count); Log.Info("Tokens:\n" + Joiner.On("\n").Join(tokens)); DelegationTokenSelector dts = new DelegationTokenSelector(); // check that the token selected for one of the physical IPC addresses // matches the one we received foreach (IPEndPoint addr in nnAddrs) { Text ipcDtService = SecurityUtil.BuildTokenService(addr); Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token2 = dts.SelectToken (ipcDtService, ugi.GetTokens()); NUnit.Framework.Assert.IsNotNull(token2); Assert.AssertArrayEquals(token.GetIdentifier(), token2.GetIdentifier()); Assert.AssertArrayEquals(token.GetPassword(), token2.GetPassword()); } // switch to host-based tokens, shouldn't match existing tokens SecurityUtilTestHelper.SetTokenServiceUseIp(false); foreach (IPEndPoint addr_1 in nnAddrs) { Text ipcDtService = SecurityUtil.BuildTokenService(addr_1); Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token2 = dts.SelectToken (ipcDtService, ugi.GetTokens()); NUnit.Framework.Assert.IsNull(token2); } // reclone the tokens, and see if they match now HAUtil.CloneDelegationTokenForLogicalUri(ugi, haUri, nnAddrs); foreach (IPEndPoint addr_2 in nnAddrs) { Text ipcDtService = SecurityUtil.BuildTokenService(addr_2); Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token2 = dts.SelectToken (ipcDtService, ugi.GetTokens()); NUnit.Framework.Assert.IsNotNull(token2); Assert.AssertArrayEquals(token.GetIdentifier(), token2.GetIdentifier()); Assert.AssertArrayEquals(token.GetPassword(), token2.GetPassword()); } }
/// <summary> /// To<br /> /// 转换 /// </summary> /// <param name="transformer"></param> /// <param name="sequence"></param> /// <param name="joinOnStr"></param> /// <returns></returns> public string To(IStringTransformer transformer, string sequence, string joinOnStr = " ") { if (!_humanizerMode) { var list = _splitter.SplitToList(sequence); var joiner = Joiner.On(joinOnStr); sequence = joiner.Join(list); } return(sequence.Transform(transformer)); }
/// <summary> /// Assert that the given files are not all the same, and in fact that /// they have <code>expectedUniqueHashes</code> unique contents. /// </summary> /// <exception cref="System.Exception"/> public static void AssertFileContentsDifferent(int expectedUniqueHashes, params FilePath [] files) { IDictionary <FilePath, string> md5s = GetFileMD5s(files); if (Sets.NewHashSet(md5s.Values).Count != expectedUniqueHashes) { NUnit.Framework.Assert.Fail("Expected " + expectedUniqueHashes + " different hashes, got:\n " + Joiner.On("\n ").WithKeyValueSeparator("=").Join(md5s)); } }
/// <summary> /// Merge a bunch of Path objects into a sorted semicolon-separated /// path string. /// </summary> public static string MergeStatuses(Path[] paths) { string[] pathStrings = new string[paths.Length]; int i = 0; foreach (Path path in paths) { pathStrings[i++] = path.ToUri().GetPath(); } Arrays.Sort(pathStrings); return(Joiner.On(";").Join(pathStrings)); }
/// <summary> /// To<br /> /// 转换 /// </summary> /// <param name="style"></param> /// <param name="sequence"></param> /// <returns></returns> public string To(Style style, string sequence) { var list = _splitter.SplitToList(sequence); IJoiner joiner; switch (style) { case Style.LOWER_CAMEL: { CaseFormatUtils.LowerCase(list); CaseFormatUtils.UpperCaseEachFirstChar(list); CaseFormatUtils.LowerCaseFirstItemFirstChar(list); joiner = Joiner.On(""); break; } case Style.LOWER_HYPHEN: { CaseFormatUtils.LowerCase(list); joiner = Joiner.On("-"); break; } case Style.LOWER_UNDERSCORE: { CaseFormatUtils.LowerCase(list); joiner = Joiner.On("_"); break; } case Style.UPPER_CAMEL: { CaseFormatUtils.LowerCase(list); CaseFormatUtils.UpperCaseEachFirstChar(list); joiner = Joiner.On(""); break; } case Style.UPPER_UNDERSCORE: { CaseFormatUtils.UpperCase(list); joiner = Joiner.On("_"); break; } default: throw new InvalidOperationException("Invalid operation."); } return(joiner.Join(list)); }
public IActionResult JoinGameGroup(int id) { Game x = _context.Games.Include(a => a.Joiners) .ThenInclude(a => a.User) .SingleOrDefault(a => a.GameId == id); Joiner gg = new Joiner { Users_UserId = ( int )HttpContext.Session.GetInt32("UserId"), Games_GameId = x.GameId }; _context.Joiners.Add(gg); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
/// <summary>Create an event to record unsuccessful completion (killed/failed) of jobs /// </summary> /// <param name="id">Job ID</param> /// <param name="finishTime">Finish time of the job</param> /// <param name="finishedMaps">Number of finished maps</param> /// <param name="finishedReduces">Number of finished reduces</param> /// <param name="status">Status of the job</param> /// <param name="diagnostics">job runtime diagnostics</param> public JobUnsuccessfulCompletionEvent(JobID id, long finishTime, int finishedMaps , int finishedReduces, string status, IEnumerable <string> diagnostics) { datum.SetJobid(new Utf8(id.ToString())); datum.SetFinishTime(finishTime); datum.SetFinishedMaps(finishedMaps); datum.SetFinishedReduces(finishedReduces); datum.SetJobStatus(new Utf8(status)); if (diagnostics == null) { diagnostics = NodiagsList; } datum.SetDiagnostics(new Utf8(Joiner.On('\n').SkipNulls().Join(diagnostics))); }
/// <summary> /// Assert that all of the given paths have the exact same /// contents /// </summary> /// <exception cref="System.Exception"/> public static void AssertFileContentsSame(params FilePath[] files) { if (files.Length < 2) { return; } IDictionary <FilePath, string> md5s = GetFileMD5s(files); if (Sets.NewHashSet(md5s.Values).Count > 1) { NUnit.Framework.Assert.Fail("File contents differed:\n " + Joiner.On("\n ").WithKeyValueSeparator ("=").Join(md5s)); } }
public AsyncBuffer() { #region initialization joiner = new Joiner(); get = joiner.NewSyncMethod <T>(Get); put = joiner.NewAsyncMethod <T>(Put); #endregion (get & put).Do((T t) => { Log.Trace("Match 'get & put': passing " + t + " from Put to Get"); return(t); }); }
public override string ToString() { lock (this) { IDictionary <Quantile, long> data = Snapshot(); if (data == null) { return("[no samples]"); } else { return(Joiner.On("\n").WithKeyValueSeparator(": ").Join(data)); } } }
public UpdateServiceHelper(Joiner joiner, Grouper grouper, TimeService timeService, IJsonDataService tripService, IJsonDataService busStopService, IJsonDataService busLineService, IJsonDataService expeditionService, IJsonDataService stopInTripService, BusStopModelService busStopModelService, IDocumentStoreRepository documentStoreRepository) { _joiner = joiner; _grouper = grouper; _timeService = timeService; _tripService = tripService; _busStopService = busStopService; _busLineService = busLineService; _expeditionService = expeditionService; _stopInTripService = stopInTripService; _busStopModelService = busStopModelService; _documentStoreRepository = documentStoreRepository; }
/// <exception cref="System.Exception"/> private void DoTestOneOfTwoRacksDecommissioned(int testIndex) { // Block originally on A1, A2, B1 IList <DatanodeStorageInfo> origStorages = GetStorages(0, 1, 3); IList <DatanodeDescriptor> origNodes = GetNodes(origStorages); BlockInfoContiguous blockInfo = AddBlockOnNodes(testIndex, origNodes); // Decommission all of the nodes in rack A IList <DatanodeDescriptor> decomNodes = StartDecommission(0, 1, 2); DatanodeStorageInfo[] pipeline = ScheduleSingleReplication(blockInfo); NUnit.Framework.Assert.IsTrue("Source of replication should be one of the nodes the block " + "was on. Was: " + pipeline[0], origStorages.Contains(pipeline[0])); // Only up to two nodes can be picked per rack when there are two racks. NUnit.Framework.Assert.AreEqual("Should have two targets", 2, pipeline.Length); bool foundOneOnRackB = false; for (int i = 1; i < pipeline.Length; i++) { DatanodeDescriptor target = pipeline[i].GetDatanodeDescriptor(); if (rackB.Contains(target)) { foundOneOnRackB = true; } NUnit.Framework.Assert.IsFalse(decomNodes.Contains(target)); NUnit.Framework.Assert.IsFalse(origNodes.Contains(target)); } NUnit.Framework.Assert.IsTrue("Should have at least one target on rack B. Pipeline: " + Joiner.On(",").Join(pipeline), foundOneOnRackB); // Mark the block as received on the target nodes in the pipeline FulfillPipeline(blockInfo, pipeline); // the block is still under-replicated. Add a new node. This should allow // the third off-rack replica. DatanodeDescriptor rackCNode = DFSTestUtil.GetDatanodeDescriptor("7.7.7.7", "/rackC" ); rackCNode.UpdateStorage(new DatanodeStorage(DatanodeStorage.GenerateUuid())); AddNodes(ImmutableList.Of(rackCNode)); try { DatanodeStorageInfo[] pipeline2 = ScheduleSingleReplication(blockInfo); NUnit.Framework.Assert.AreEqual(2, pipeline2.Length); NUnit.Framework.Assert.AreEqual(rackCNode, pipeline2[1].GetDatanodeDescriptor()); } finally { RemoveNode(rackCNode); } }
/// <summary> /// /// </summary> /// <param name="left"></param> /// <param name="right"></param> /// <param name="joiner"></param> public JoinFWindow(FWindowable <TLeft> left, FWindowable <TRight> right, Joiner joiner) : base(left, right, left.Size, left.Period, left.Offset, left.Duration) { Invariant.IsTrue(right.Offset == left.Offset, "Left offset must match to right offset"); Invariant.IsTrue(right.Period % left.Period == 0, "Right period must be a multiple of left period"); Invariant.IsTrue(right.Size == left.Size, "Left size must match to right size"); Invariant.IsTrue(right.Period == right.Duration, "Right: period and duration must be same"); Invariant.IsTrue(left.Period == left.Duration, "Left: period and duration must be same"); _joiner = joiner; _Payload = new FSubWindow <TResult>(Length); _Sync = Left.Sync as FSubWindow <long>; _Other = Left.Other as FSubWindow <long>; _BV = new BVFSubWindow(Length); }
public async Task <IActionResult> Join() { var curUser = await _userManager.GetUserAsync(User); var joined = _context.Joiners.Where(x => x.UserId == curUser.Id).FirstOrDefault(); if (joined == null) { Joiner newJoin = new Joiner(); newJoin.UserId = curUser.Id; await _context.Joiners.AddAsync(newJoin); await _context.SaveChangesAsync(); } return(Ok()); }
public virtual void TestSharedDirIsAutomaticallyMarkedRequired() { URI foo = new URI("file:/foo"); URI bar = new URI("file:/bar"); Configuration conf = new Configuration(); conf.Set(DFSConfigKeys.DfsNamenodeEditsDirKey, Joiner.On(",").Join(foo, bar)); conf.Set(DFSConfigKeys.DfsNamenodeEditsDirRequiredKey, foo.ToString()); NUnit.Framework.Assert.IsFalse(FSNamesystem.GetRequiredNamespaceEditsDirs(conf).Contains (bar)); conf.Set(DFSConfigKeys.DfsNamenodeSharedEditsDirKey, bar.ToString()); ICollection <URI> requiredEditsDirs = FSNamesystem.GetRequiredNamespaceEditsDirs(conf ); NUnit.Framework.Assert.IsTrue(Joiner.On(",").Join(requiredEditsDirs) + " does not contain " + bar, requiredEditsDirs.Contains(bar)); }
public virtual void TestRefreshNamenodes() { // Start cluster with a single NN and DN Configuration conf = new Configuration(); MiniDFSCluster cluster = null; try { MiniDFSNNTopology topology = new MiniDFSNNTopology().AddNameservice(new MiniDFSNNTopology.NSConf ("ns1").AddNN(new MiniDFSNNTopology.NNConf(null).SetIpcPort(nnPort1))).SetFederation (true); cluster = new MiniDFSCluster.Builder(conf).NnTopology(topology).Build(); DataNode dn = cluster.GetDataNodes()[0]; NUnit.Framework.Assert.AreEqual(1, dn.GetAllBpOs().Length); cluster.AddNameNode(conf, nnPort2); NUnit.Framework.Assert.AreEqual(2, dn.GetAllBpOs().Length); cluster.AddNameNode(conf, nnPort3); NUnit.Framework.Assert.AreEqual(3, dn.GetAllBpOs().Length); cluster.AddNameNode(conf, nnPort4); // Ensure a BPOfferService in the datanodes corresponds to // a namenode in the cluster ICollection <IPEndPoint> nnAddrsFromCluster = Sets.NewHashSet(); for (int i = 0; i < 4; i++) { NUnit.Framework.Assert.IsTrue(nnAddrsFromCluster.AddItem(cluster.GetNameNode(i).GetNameNodeAddress ())); } ICollection <IPEndPoint> nnAddrsFromDN = Sets.NewHashSet(); foreach (BPOfferService bpos in dn.GetAllBpOs()) { foreach (BPServiceActor bpsa in bpos.GetBPServiceActors()) { NUnit.Framework.Assert.IsTrue(nnAddrsFromDN.AddItem(bpsa.GetNNSocketAddress())); } } NUnit.Framework.Assert.AreEqual(string.Empty, Joiner.On(",").Join(Sets.SymmetricDifference (nnAddrsFromCluster, nnAddrsFromDN))); } finally { if (cluster != null) { cluster.Shutdown(); } } }