コード例 #1
0
            /// <exception cref="System.IO.IOException"/>
            public virtual int Run(Configuration conf, IList <string> args)
            {
                string name = StringUtils.PopFirstNonOption(args);

                if (name == null)
                {
                    System.Console.Error.WriteLine("You must specify a name when deleting a " + "cache pool."
                                                   );
                    return(1);
                }
                if (!args.IsEmpty())
                {
                    System.Console.Error.Write("Can't understand arguments: " + Joiner.On(" ").Join(args
                                                                                                    ) + "\n");
                    System.Console.Error.WriteLine("Usage is " + GetShortUsage());
                    return(1);
                }
                DistributedFileSystem dfs = AdminHelper.GetDFS(conf);

                try
                {
                    dfs.RemoveCachePool(name);
                }
                catch (IOException e)
                {
                    System.Console.Error.WriteLine(AdminHelper.PrettifyException(e));
                    return(2);
                }
                System.Console.Out.WriteLine("Successfully removed cache pool " + name + ".");
                return(0);
            }
コード例 #2
0
        public virtual void TestQueryAll()
        {
            WebResource r   = Resource();
            MockNM      nm1 = rm.RegisterNode("h1:1234", 5120);
            MockNM      nm2 = rm.RegisterNode("h2:1235", 5121);
            MockNM      nm3 = rm.RegisterNode("h3:1236", 5122);

            rm.SendNodeStarted(nm1);
            rm.SendNodeStarted(nm3);
            rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running);
            rm.NMwaitForState(nm2.GetNodeId(), NodeState.New);
            rm.SendNodeLost(nm3);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").QueryParam
                                          ("states", Joiner.On(',').Join(EnumSet.AllOf <NodeState>())).Accept(MediaType.ApplicationJson
                                                                                                              ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json  = response.GetEntity <JSONObject>();
            JSONObject nodes = json.GetJSONObject("nodes");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.Length()
                                            );
            JSONArray nodeArray = nodes.GetJSONArray("node");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, nodeArray.Length
                                                ());
        }
コード例 #3
0
 public void Joiner_str()
 {
     Assert.AreEqual("a", Joiner.On("-").Join(new string[] { "a" }));
     Assert.AreEqual("a-b", Joiner.On("-").Join(new string[] { "a", "b" }));
     Assert.AreEqual("a-b-c", Joiner.On("-").Join(new string[] { "a", "b", "c" }));
     Assert.AreEqual("a  b  c", Joiner.On("  ").Join(new string[] { "a", "b", "c" }));
 }
コード例 #4
0
        private string FormatMessage(long extraSleepTime, IDictionary <string, JvmPauseMonitor.GcTimes
                                                                       > gcTimesAfterSleep, IDictionary <string, JvmPauseMonitor.GcTimes> gcTimesBeforeSleep
                                     )
        {
            ICollection <string> gcBeanNames = Sets.Intersection(gcTimesAfterSleep.Keys, gcTimesBeforeSleep
                                                                 .Keys);
            IList <string> gcDiffs = Lists.NewArrayList();

            foreach (string name in gcBeanNames)
            {
                JvmPauseMonitor.GcTimes diff = gcTimesAfterSleep[name].Subtract(gcTimesBeforeSleep
                                                                                [name]);
                if (diff.gcCount != 0)
                {
                    gcDiffs.AddItem("GC pool '" + name + "' had collection(s): " + diff.ToString());
                }
            }
            string ret = "Detected pause in JVM or host machine (eg GC): " + "pause of approximately "
                         + extraSleepTime + "ms\n";

            if (gcDiffs.IsEmpty())
            {
                ret += "No GCs detected";
            }
            else
            {
                ret += Joiner.On("\n").Join(gcDiffs);
            }
            return(ret);
        }
コード例 #5
0
        /// <exception cref="System.IO.IOException"/>
        public static FileJournalManager.EditLogFile GetLogFile(FilePath dir, long startTxId
                                                                )
        {
            IList <FileJournalManager.EditLogFile> files = MatchEditLogs(dir);
            IList <FileJournalManager.EditLogFile> ret   = Lists.NewLinkedList();

            foreach (FileJournalManager.EditLogFile elf in files)
            {
                if (elf.GetFirstTxId() == startTxId)
                {
                    ret.AddItem(elf);
                }
            }
            if (ret.IsEmpty())
            {
                // no matches
                return(null);
            }
            else
            {
                if (ret.Count == 1)
                {
                    return(ret[0]);
                }
                else
                {
                    throw new InvalidOperationException("More than one log segment in " + dir + " starting at txid "
                                                        + startTxId + ": " + Joiner.On(", ").Join(ret));
                }
            }
        }
コード例 #6
0
 public _TesterCompressionStrategy_384()
 {
     this.joiner         = Joiner.On("- ");
     this.BlockSize      = 512;
     this.operationBlock = new byte[_T1233992766.BlockSize];
     this.overheadSpace  = _T1233992766.BlockSize / 100 + 12;
 }
コード例 #7
0
        public virtual void TestQueues()
        {
            DatanodeDescriptor  fakeDN      = DFSTestUtil.GetLocalDatanodeDescriptor();
            DatanodeStorage     storage     = new DatanodeStorage("STORAGE_ID");
            DatanodeStorageInfo storageInfo = new DatanodeStorageInfo(fakeDN, storage);

            msgs.EnqueueReportedBlock(storageInfo, block1Gs1, HdfsServerConstants.ReplicaState
                                      .Finalized);
            msgs.EnqueueReportedBlock(storageInfo, block1Gs2, HdfsServerConstants.ReplicaState
                                      .Finalized);
            NUnit.Framework.Assert.AreEqual(2, msgs.Count());
            // Nothing queued yet for block 2
            NUnit.Framework.Assert.IsNull(msgs.TakeBlockQueue(block2Gs1));
            NUnit.Framework.Assert.AreEqual(2, msgs.Count());
            Queue <PendingDataNodeMessages.ReportedBlockInfo> q = msgs.TakeBlockQueue(block1Gs2DifferentInstance
                                                                                      );

            NUnit.Framework.Assert.AreEqual("ReportedBlockInfo [block=blk_1_1, dn=127.0.0.1:50010, reportedState=FINALIZED],"
                                            + "ReportedBlockInfo [block=blk_1_2, dn=127.0.0.1:50010, reportedState=FINALIZED]"
                                            , Joiner.On(",").Join(q));
            NUnit.Framework.Assert.AreEqual(0, msgs.Count());
            // Should be null if we pull again
            NUnit.Framework.Assert.IsNull(msgs.TakeBlockQueue(block1Gs1));
            NUnit.Framework.Assert.AreEqual(0, msgs.Count());
        }
コード例 #8
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void SelectInputStreams(ICollection <EditLogInputStream> streams, long
                                               fromTxnId, bool inProgressOk)
        {
            QuorumCall <AsyncLogger, RemoteEditLogManifest> q = loggers.GetEditLogManifest(fromTxnId
                                                                                           , inProgressOk);
            IDictionary <AsyncLogger, RemoteEditLogManifest> resps = loggers.WaitForWriteQuorum
                                                                         (q, selectInputStreamsTimeoutMs, "selectInputStreams");

            Log.Debug("selectInputStream manifests:\n" + Joiner.On("\n").WithKeyValueSeparator
                          (": ").Join(resps));
            PriorityQueue <EditLogInputStream> allStreams = new PriorityQueue <EditLogInputStream
                                                                               >(64, JournalSet.EditLogInputStreamComparator);

            foreach (KeyValuePair <AsyncLogger, RemoteEditLogManifest> e in resps)
            {
                AsyncLogger           logger   = e.Key;
                RemoteEditLogManifest manifest = e.Value;
                foreach (RemoteEditLog remoteLog in manifest.GetLogs())
                {
                    Uri url = logger.BuildURLToFetchLogs(remoteLog.GetStartTxId());
                    EditLogInputStream elis = EditLogFileInputStream.FromUrl(connectionFactory, url,
                                                                             remoteLog.GetStartTxId(), remoteLog.GetEndTxId(), remoteLog.IsInProgress());
                    allStreams.AddItem(elis);
                }
            }
            JournalSet.ChainAndMakeRedundantStreams(streams, allStreams, fromTxnId);
        }
コード例 #9
0
 public virtual Org.Apache.Hadoop.IO.Compress.CompressDecompressTester <T, E> WithCompressDecompressPair
     (T compressor, E decompressor)
 {
     AddPair(compressor, decompressor, Joiner.On("_").Join(compressor.GetType().GetCanonicalName
                                                               (), decompressor.GetType().GetCanonicalName()));
     return(this);
 }
コード例 #10
0
ファイル: TestPBHelper.cs プロジェクト: orf53975/hadoop.net
        public virtual void TestConvertBlockRecoveryCommand()
        {
            DatanodeInfo di1 = DFSTestUtil.GetLocalDatanodeInfo();
            DatanodeInfo di2 = DFSTestUtil.GetLocalDatanodeInfo();

            DatanodeInfo[] dnInfo = new DatanodeInfo[] { di1, di2 };
            IList <BlockRecoveryCommand.RecoveringBlock> blks = ImmutableList.Of(new BlockRecoveryCommand.RecoveringBlock
                                                                                     (GetExtendedBlock(1), dnInfo, 3), new BlockRecoveryCommand.RecoveringBlock(GetExtendedBlock
                                                                                                                                                                    (2), dnInfo, 3));
            BlockRecoveryCommand cmd = new BlockRecoveryCommand(blks);

            DatanodeProtocolProtos.BlockRecoveryCommandProto proto = PBHelper.Convert(cmd);
            NUnit.Framework.Assert.AreEqual(1, proto.GetBlocks(0).GetBlock().GetB().GetBlockId
                                                ());
            NUnit.Framework.Assert.AreEqual(2, proto.GetBlocks(1).GetBlock().GetB().GetBlockId
                                                ());
            BlockRecoveryCommand cmd2 = PBHelper.Convert(proto);
            IList <BlockRecoveryCommand.RecoveringBlock> cmd2Blks = Lists.NewArrayList(cmd2.GetRecoveringBlocks
                                                                                           ());

            NUnit.Framework.Assert.AreEqual(blks[0].GetBlock(), cmd2Blks[0].GetBlock());
            NUnit.Framework.Assert.AreEqual(blks[1].GetBlock(), cmd2Blks[1].GetBlock());
            NUnit.Framework.Assert.AreEqual(Joiner.On(",").Join(blks), Joiner.On(",").Join(cmd2Blks
                                                                                           ));
            NUnit.Framework.Assert.AreEqual(cmd.ToString(), cmd2.ToString());
        }
コード例 #11
0
 /// <summary>Load configuration from a list of files until the first successful load</summary>
 /// <param name="conf">the configuration object</param>
 /// <param name="files">the list of filenames to try</param>
 /// <returns>the configuration object</returns>
 internal static Org.Apache.Hadoop.Metrics2.Impl.MetricsConfig LoadFirst(string prefix
                                                                         , params string[] fileNames)
 {
     foreach (string fname in fileNames)
     {
         try
         {
             Org.Apache.Commons.Configuration.Configuration cf = new PropertiesConfiguration(fname
                                                                                             ).InterpolatedConfiguration();
             Log.Info("loaded properties from " + fname);
             Log.Debug(ToString(cf));
             Org.Apache.Hadoop.Metrics2.Impl.MetricsConfig mc = new Org.Apache.Hadoop.Metrics2.Impl.MetricsConfig
                                                                    (cf, prefix);
             Log.Debug(mc);
             return(mc);
         }
         catch (ConfigurationException e)
         {
             if (e.Message.StartsWith("Cannot locate configuration"))
             {
                 continue;
             }
             throw new MetricsConfigException(e);
         }
     }
     Log.Warn("Cannot locate configuration: tried " + Joiner.On(",").Join(fileNames));
     // default to an empty configuration
     return(new Org.Apache.Hadoop.Metrics2.Impl.MetricsConfig(new PropertiesConfiguration
                                                                  (), prefix));
 }
コード例 #12
0
        /// <exception cref="System.Exception"/>
        private void DoTestTwoOfThreeNodesDecommissioned(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 two of the nodes (A1, A2)
            IList <DatanodeDescriptor> decomNodes = StartDecommission(0, 1);

            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]));
            NUnit.Framework.Assert.AreEqual("Should have three targets", 3, pipeline.Length);
            bool foundOneOnRackA = false;

            for (int i = 1; i < pipeline.Length; i++)
            {
                DatanodeDescriptor target = pipeline[i].GetDatanodeDescriptor();
                if (rackA.Contains(target))
                {
                    foundOneOnRackA = 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 A. Pipeline: "
                                          + Joiner.On(",").Join(pipeline), foundOneOnRackA);
        }
コード例 #13
0
ファイル: TestQuorumCall.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.Exception"/>
        public virtual void TestQuorums()
        {
            IDictionary <string, SettableFuture <string> > futures = ImmutableMap.Of("f1", SettableFuture
                                                                                     .Create <string>(), "f2", SettableFuture.Create <string>(), "f3", SettableFuture.Create
                                                                                     <string>());
            QuorumCall <string, string> q = QuorumCall.Create(futures);

            NUnit.Framework.Assert.AreEqual(0, q.CountResponses());
            futures["f1"].Set("first future");
            q.WaitFor(1, 0, 0, 100000, "test");
            // wait for 1 response
            q.WaitFor(0, 1, 0, 100000, "test");
            // wait for 1 success
            NUnit.Framework.Assert.AreEqual(1, q.CountResponses());
            futures["f2"].SetException(new Exception("error"));
            NUnit.Framework.Assert.AreEqual(2, q.CountResponses());
            futures["f3"].Set("second future");
            q.WaitFor(3, 0, 100, 100000, "test");
            // wait for 3 responses
            q.WaitFor(0, 2, 100, 100000, "test");
            // 2 successes
            NUnit.Framework.Assert.AreEqual(3, q.CountResponses());
            NUnit.Framework.Assert.AreEqual("f1=first future,f3=second future", Joiner.On(","
                                                                                          ).WithKeyValueSeparator("=").Join(new SortedDictionary <string, string>(q.GetResults
                                                                                                                                                                      ())));
            try
            {
                q.WaitFor(0, 4, 100, 10, "test");
                NUnit.Framework.Assert.Fail("Didn't time out waiting for more responses than came back"
                                            );
            }
            catch (TimeoutException)
            {
            }
        }
コード例 #14
0
        private void PrintReferenceTraceInfo(string op)
        {
            StackTraceElement[] stack = Sharpen.Thread.CurrentThread().GetStackTrace();
            foreach (StackTraceElement ste in stack)
            {
                switch (ste.GetMethodName())
                {
                case "getDfsUsed":
                case "getBlockPoolUsed":
                case "getAvailable":
                case "getVolumeMap":
                {
                    return;
                }

                default:
                {
                    break;
                }
                }
            }
            FsDatasetImpl.Log.Trace("Reference count: " + op + " " + this + ": " + this.reference
                                    .GetReferenceCount());
            FsDatasetImpl.Log.Trace(Joiner.On("\n").Join(Sharpen.Thread.CurrentThread().GetStackTrace
                                                             ()));
        }
コード例 #15
0
        public void TestMap()
        {
            var j = Joiner.On(";").WithKeyValueSeparator(":");

            Assert.AreEqual("", j.Join(new Dictionary <string, string>()));

            var mapWithNulls = new Dictionary <string, string>
            {
                { "a", null },
                { "b", null }
            };

            try
            {
                j.Join(mapWithNulls);
                Assert.Fail();
            }
            catch (NullReferenceException)
            {
            }

            Assert.AreEqual("a:00;b:00", j.UseForNull("00").Join(mapWithNulls));

            var mapInts = new Dictionary <int, int>
            {
                { 1, 2 },
                { 3, 4 },
                { 5, 6 }
            };
            var sb = new StringBuilder();

            j.AppendTo(sb, mapInts);
            Assert.AreEqual("1:2;3:4;5:6", sb.ToString());
        }
コード例 #16
0
        public static string FixRegionCode(Country country, string regionCode)
        {
            if (string.IsNullOrWhiteSpace(regionCode))
            {
                throw new ArgumentNullException(nameof(regionCode));
            }

            var    checkIndex = regionCode.IndexOf('-');
            string code;

            if (checkIndex < 0)
            {
                code = regionCode.ToUpper();
            }
            else if (checkIndex == 0)
            {
                code = regionCode.Substring(1, regionCode.Length - 1);
            }
            else
            {
                var list     = Splitter.On("-").OmitEmptyStrings().TrimResults().SplitToList(regionCode);
                var restList = list.GetRange(1, list.Count - 1);
                code = Joiner.On('-').SkipNulls().Join(restList);
            }

            return($"{EnumsNET.Enums.GetName(country.ToCode()).ToUpper()}-{code.ToUpper()}");
        }
コード例 #17
0
        public void MapToStringWithConverterOuTest()
        {
            var converter = new Int32ToStringConverter();
            var str       = Joiner.On("&").WithKeyValueSeparator("=").Join(OriginalMaterials.IntTypeList, converter);

            str.ShouldBe("1=1&2=2&3=3&4=4&5=5");
        }
コード例 #18
0
        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");
        }
コード例 #19
0
        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");
        }
コード例 #20
0
            public override string ToString()
            {
                StringBuilder sb = new StringBuilder("HostSet(");

                Joiner.On(",").AppendTo(sb, Iterators.Transform(GetEnumerator(), new _Function_226
                                                                    ()));
                return(sb.Append(")").ToString());
            }
コード例 #21
0
        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");
        }
コード例 #22
0
ファイル: KMSAudit.cs プロジェクト: orf53975/hadoop.net
 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);
         }
     }
 }
コード例 #23
0
        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");
        }
コード例 #24
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("BlockRecoveryCommand(\n  ");
            Joiner.On("\n  ").AppendTo(sb, recoveringBlocks);
            sb.Append("\n)");
            return(sb.ToString());
        }
コード例 #25
0
 /// <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);
 }
コード例 #26
0
        /// <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);
        }
コード例 #27
0
        /// <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));
            }
        }
コード例 #28
0
        /// <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));
        }
コード例 #29
0
        /// <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());
            }
        }
コード例 #30
0
ファイル: TestPath.cs プロジェクト: orf53975/hadoop.net
        /// <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));
        }