Пример #1
0
        public virtual void TestGetBlockLocationMetric()
        {
            Path file1_Path = new Path(TestRootDirPath, "file1.dat");

            // When cluster starts first time there are no file  (read,create,open)
            // operations so metric GetBlockLocations should be 0.
            MetricsAsserts.AssertCounter("GetBlockLocations", 0L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            //Perform create file operation
            CreateFile(file1_Path, 100, (short)2);
            UpdateMetrics();
            //Create file does not change numGetBlockLocations metric
            //expect numGetBlockLocations = 0 for previous and current interval
            MetricsAsserts.AssertCounter("GetBlockLocations", 0L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            // Open and read file operation increments GetBlockLocations
            // Perform read file operation on earlier created file
            ReadFile(fs, file1_Path);
            UpdateMetrics();
            // Verify read file operation has incremented numGetBlockLocations by 1
            MetricsAsserts.AssertCounter("GetBlockLocations", 1L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            // opening and reading file  twice will increment numGetBlockLocations by 2
            ReadFile(fs, file1_Path);
            ReadFile(fs, file1_Path);
            UpdateMetrics();
            MetricsAsserts.AssertCounter("GetBlockLocations", 3L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
        }
Пример #2
0
        public virtual void TestDataNodeMetrics()
        {
            Configuration conf = new HdfsConfiguration();

            SimulatedFSDataset.SetFactory(conf);
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).Build();

            try
            {
                FileSystem fs          = cluster.GetFileSystem();
                long       LongFileLen = int.MaxValue + 1L;
                DFSTestUtil.CreateFile(fs, new Path("/tmp.txt"), LongFileLen, (short)1, 1L);
                IList <DataNode> datanodes = cluster.GetDataNodes();
                NUnit.Framework.Assert.AreEqual(datanodes.Count, 1);
                DataNode             datanode = datanodes[0];
                MetricsRecordBuilder rb       = MetricsAsserts.GetMetrics(datanode.GetMetrics().Name());
                MetricsAsserts.AssertCounter("BytesWritten", LongFileLen, rb);
                NUnit.Framework.Assert.IsTrue("Expected non-zero number of incremental block reports"
                                              , MetricsAsserts.GetLongCounter("IncrementalBlockReportsNumOps", rb) > 0);
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Пример #3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestUncacheQuiesces()
        {
            // Create a file
            Path fileName = new Path("/testUncacheQuiesces");
            int  fileLen  = 4096;

            DFSTestUtil.CreateFile(fs, fileName, fileLen, (short)1, unchecked ((int)(0xFDFD)));
            // Cache it
            DistributedFileSystem dfs = cluster.GetFileSystem();

            dfs.AddCachePool(new CachePoolInfo("pool"));
            dfs.AddCacheDirective(new CacheDirectiveInfo.Builder().SetPool("pool").SetPath(fileName
                                                                                           ).SetReplication((short)3).Build());
            GenericTestUtils.WaitFor(new _Supplier_484(), 1000, 30000);
            // Uncache it
            dfs.RemoveCacheDirective(1);
            GenericTestUtils.WaitFor(new _Supplier_495(), 1000, 30000);
            // Make sure that no additional messages were sent
            Sharpen.Thread.Sleep(10000);
            MetricsRecordBuilder dnMetrics = MetricsAsserts.GetMetrics(dn.GetMetrics().Name()
                                                                       );

            MetricsAsserts.AssertCounter("BlocksCached", 1l, dnMetrics);
            MetricsAsserts.AssertCounter("BlocksUncached", 1l, dnMetrics);
        }
Пример #4
0
        /*job*/
        /*map*/
        /*reduce*/
        private void CheckMetrics(int jobsSubmitted, int jobsCompleted, int jobsFailed, int
                                  jobsKilled, int jobsPreparing, int jobsRunning, int mapsLaunched, int mapsCompleted
                                  , int mapsFailed, int mapsKilled, int mapsRunning, int mapsWaiting, int reducesLaunched
                                  , int reducesCompleted, int reducesFailed, int reducesKilled, int reducesRunning
                                  , int reducesWaiting)
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics("MRAppMetrics");

            MetricsAsserts.AssertCounter("JobsSubmitted", jobsSubmitted, rb);
            MetricsAsserts.AssertCounter("JobsCompleted", jobsCompleted, rb);
            MetricsAsserts.AssertCounter("JobsFailed", jobsFailed, rb);
            MetricsAsserts.AssertCounter("JobsKilled", jobsKilled, rb);
            MetricsAsserts.AssertGauge("JobsPreparing", jobsPreparing, rb);
            MetricsAsserts.AssertGauge("JobsRunning", jobsRunning, rb);
            MetricsAsserts.AssertCounter("MapsLaunched", mapsLaunched, rb);
            MetricsAsserts.AssertCounter("MapsCompleted", mapsCompleted, rb);
            MetricsAsserts.AssertCounter("MapsFailed", mapsFailed, rb);
            MetricsAsserts.AssertCounter("MapsKilled", mapsKilled, rb);
            MetricsAsserts.AssertGauge("MapsRunning", mapsRunning, rb);
            MetricsAsserts.AssertGauge("MapsWaiting", mapsWaiting, rb);
            MetricsAsserts.AssertCounter("ReducesLaunched", reducesLaunched, rb);
            MetricsAsserts.AssertCounter("ReducesCompleted", reducesCompleted, rb);
            MetricsAsserts.AssertCounter("ReducesFailed", reducesFailed, rb);
            MetricsAsserts.AssertCounter("ReducesKilled", reducesKilled, rb);
            MetricsAsserts.AssertGauge("ReducesRunning", reducesRunning, rb);
            MetricsAsserts.AssertGauge("ReducesWaiting", reducesWaiting, rb);
        }
Пример #5
0
        /// <exception cref="System.Exception"/>
        public virtual void TestJournal()
        {
            MetricsRecordBuilder metrics = MetricsAsserts.GetMetrics(journal.GetMetricsForTests
                                                                         ().GetName());

            MetricsAsserts.AssertCounter("BatchesWritten", 0L, metrics);
            MetricsAsserts.AssertCounter("BatchesWrittenWhileLagging", 0L, metrics);
            MetricsAsserts.AssertGauge("CurrentLagTxns", 0L, metrics);
            IPCLoggerChannel ch = new IPCLoggerChannel(conf, FakeNsinfo, journalId, jn.GetBoundIpcAddress
                                                           ());

            ch.NewEpoch(1).Get();
            ch.SetEpoch(1);
            ch.StartLogSegment(1, NameNodeLayoutVersion.CurrentLayoutVersion).Get();
            ch.SendEdits(1L, 1, 1, Sharpen.Runtime.GetBytesForString("hello", Charsets.Utf8))
            .Get();
            metrics = MetricsAsserts.GetMetrics(journal.GetMetricsForTests().GetName());
            MetricsAsserts.AssertCounter("BatchesWritten", 1L, metrics);
            MetricsAsserts.AssertCounter("BatchesWrittenWhileLagging", 0L, metrics);
            MetricsAsserts.AssertGauge("CurrentLagTxns", 0L, metrics);
            ch.SetCommittedTxId(100L);
            ch.SendEdits(1L, 2, 1, Sharpen.Runtime.GetBytesForString("goodbye", Charsets.Utf8
                                                                     )).Get();
            metrics = MetricsAsserts.GetMetrics(journal.GetMetricsForTests().GetName());
            MetricsAsserts.AssertCounter("BatchesWritten", 2L, metrics);
            MetricsAsserts.AssertCounter("BatchesWrittenWhileLagging", 1L, metrics);
            MetricsAsserts.AssertGauge("CurrentLagTxns", 98L, metrics);
        }
Пример #6
0
        private void CheckSyncMetric(MiniDFSCluster cluster, int dn, long value)
        {
            DataNode datanode = cluster.GetDataNodes()[dn];

            MetricsAsserts.AssertCounter("FsyncCount", value, MetricsAsserts.GetMetrics(datanode
                                                                                        .GetMetrics().Name()));
        }
        public virtual void TestFinalState()
        {
            StartupProgressTestHelper.SetStartupProgressForFinalState(startupProgress);
            MetricsRecordBuilder builder = MetricsAsserts.GetMetrics(metrics, true);

            NUnit.Framework.Assert.IsTrue(MetricsAsserts.GetLongCounter("ElapsedTime", builder
                                                                        ) >= 0L);
            MetricsAsserts.AssertGauge("PercentComplete", 1.0f, builder);
            MetricsAsserts.AssertCounter("LoadingFsImageCount", 100L, builder);
            NUnit.Framework.Assert.IsTrue(MetricsAsserts.GetLongCounter("LoadingFsImageElapsedTime"
                                                                        , builder) >= 0L);
            MetricsAsserts.AssertCounter("LoadingFsImageTotal", 100L, builder);
            MetricsAsserts.AssertGauge("LoadingFsImagePercentComplete", 1.0f, builder);
            MetricsAsserts.AssertCounter("LoadingEditsCount", 200L, builder);
            NUnit.Framework.Assert.IsTrue(MetricsAsserts.GetLongCounter("LoadingEditsElapsedTime"
                                                                        , builder) >= 0L);
            MetricsAsserts.AssertCounter("LoadingEditsTotal", 200L, builder);
            MetricsAsserts.AssertGauge("LoadingEditsPercentComplete", 1.0f, builder);
            MetricsAsserts.AssertCounter("SavingCheckpointCount", 300L, builder);
            NUnit.Framework.Assert.IsTrue(MetricsAsserts.GetLongCounter("SavingCheckpointElapsedTime"
                                                                        , builder) >= 0L);
            MetricsAsserts.AssertCounter("SavingCheckpointTotal", 300L, builder);
            MetricsAsserts.AssertGauge("SavingCheckpointPercentComplete", 1.0f, builder);
            MetricsAsserts.AssertCounter("SafeModeCount", 400L, builder);
            NUnit.Framework.Assert.IsTrue(MetricsAsserts.GetLongCounter("SafeModeElapsedTime"
                                                                        , builder) >= 0L);
            MetricsAsserts.AssertCounter("SafeModeTotal", 400L, builder);
            MetricsAsserts.AssertGauge("SafeModePercentComplete", 1.0f, builder);
        }
Пример #8
0
        private void CheckMetrics(long hit, long cleared, long updated)
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics("RetryCache." + cacheName);

            MetricsAsserts.AssertCounter("CacheHit", hit, rb);
            MetricsAsserts.AssertCounter("CacheCleared", cleared, rb);
            MetricsAsserts.AssertCounter("CacheUpdated", updated, rb);
        }
Пример #9
0
        public virtual void TestSnapshottableDirs()
        {
            cluster.GetNamesystem().GetSnapshotManager().SetAllowNestedSnapshots(true);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 0, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertCounter("AllowSnapshotOps", 0L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                           ));
            MetricsAsserts.AssertCounter("DisallowSnapshotOps", 0L, MetricsAsserts.GetMetrics
                                             (NnMetrics));
            // Allow snapshots for directories, and check the metrics
            hdfs.AllowSnapshot(sub1);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 1, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertCounter("AllowSnapshotOps", 1L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                           ));
            Path sub2 = new Path(dir, "sub2");
            Path file = new Path(sub2, "file");

            DFSTestUtil.CreateFile(hdfs, file, 1024, Replication, seed);
            hdfs.AllowSnapshot(sub2);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 2, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertCounter("AllowSnapshotOps", 2L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                           ));
            Path subsub1 = new Path(sub1, "sub1sub1");
            Path subfile = new Path(subsub1, "file");

            DFSTestUtil.CreateFile(hdfs, subfile, 1024, Replication, seed);
            hdfs.AllowSnapshot(subsub1);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 3, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertCounter("AllowSnapshotOps", 3L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                           ));
            // Set an already snapshottable directory to snapshottable, should not
            // change the metrics
            hdfs.AllowSnapshot(sub1);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 3, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            // But the number of allowSnapshot operations still increases
            MetricsAsserts.AssertCounter("AllowSnapshotOps", 4L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                           ));
            // Disallow the snapshot for snapshottable directories, then check the
            // metrics again
            hdfs.DisallowSnapshot(sub1);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 2, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsAsserts.AssertCounter("DisallowSnapshotOps", 1L, MetricsAsserts.GetMetrics
                                             (NnMetrics));
            // delete subsub1, snapshottable directories should be 1
            hdfs.Delete(subsub1, true);
            MetricsAsserts.AssertGauge("SnapshottableDirectories", 1, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            // list all the snapshottable directories
            SnapshottableDirectoryStatus[] status = hdfs.GetSnapshottableDirListing();
            NUnit.Framework.Assert.AreEqual(1, status.Length);
            MetricsAsserts.AssertCounter("ListSnapshottableDirOps", 1L, MetricsAsserts.GetMetrics
                                             (NnMetrics));
        }
Пример #10
0
        /// <exception cref="System.IO.IOException"/>
        private void DoRPCs(Configuration conf, bool expectFailure)
        {
            Server server = new RPC.Builder(conf).SetProtocol(typeof(TestRPC.TestProtocol)).SetInstance
                                (new TestRPC.TestImpl()).SetBindAddress(Address).SetPort(0).SetNumHandlers(5).SetVerbose
                                (true).Build();

            server.RefreshServiceAcl(conf, new TestRPC.TestPolicyProvider());
            TestRPC.TestProtocol proxy = null;
            server.Start();
            IPEndPoint addr = NetUtils.GetConnectAddress(server);

            try
            {
                proxy = RPC.GetProxy <TestRPC.TestProtocol>(TestRPC.TestProtocol.versionID, addr,
                                                            conf);
                proxy.Ping();
                if (expectFailure)
                {
                    NUnit.Framework.Assert.Fail("Expect RPC.getProxy to fail with AuthorizationException!"
                                                );
                }
            }
            catch (RemoteException e)
            {
                if (expectFailure)
                {
                    Assert.True(e.UnwrapRemoteException() is AuthorizationException
                                );
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                server.Stop();
                if (proxy != null)
                {
                    RPC.StopProxy(proxy);
                }
                MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(server.rpcMetrics.Name());
                if (expectFailure)
                {
                    MetricsAsserts.AssertCounter("RpcAuthorizationFailures", 1L, rb);
                }
                else
                {
                    MetricsAsserts.AssertCounter("RpcAuthorizationSuccesses", 1L, rb);
                }
                //since we don't have authentication turned ON, we should see
                // 0 for the authentication successes and 0 for failure
                MetricsAsserts.AssertCounter("RpcAuthenticationFailures", 0L, rb);
                MetricsAsserts.AssertCounter("RpcAuthenticationSuccesses", 0L, rb);
            }
        }
Пример #11
0
        public static void CheckApps(MetricsSource source, int submitted, int pending, int
                                     running, int completed, int failed, int killed, bool all)
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(source, all);

            MetricsAsserts.AssertCounter("AppsSubmitted", submitted, rb);
            MetricsAsserts.AssertGauge("AppsPending", pending, rb);
            MetricsAsserts.AssertGauge("AppsRunning", running, rb);
            MetricsAsserts.AssertCounter("AppsCompleted", completed, rb);
            MetricsAsserts.AssertCounter("AppsFailed", failed, rb);
            MetricsAsserts.AssertCounter("AppsKilled", killed, rb);
        }
Пример #12
0
        public virtual void TestSnapshots()
        {
            cluster.GetNamesystem().GetSnapshotManager().SetAllowNestedSnapshots(true);
            MetricsAsserts.AssertGauge("Snapshots", 0, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("CreateSnapshotOps", 0L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            // Create a snapshot for a non-snapshottable directory, thus should not
            // change the metrics
            try
            {
                hdfs.CreateSnapshot(sub1, "s1");
            }
            catch (Exception)
            {
            }
            MetricsAsserts.AssertGauge("Snapshots", 0, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("CreateSnapshotOps", 1L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            // Create snapshot for sub1
            hdfs.AllowSnapshot(sub1);
            hdfs.CreateSnapshot(sub1, "s1");
            MetricsAsserts.AssertGauge("Snapshots", 1, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("CreateSnapshotOps", 2L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            hdfs.CreateSnapshot(sub1, "s2");
            MetricsAsserts.AssertGauge("Snapshots", 2, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("CreateSnapshotOps", 3L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            hdfs.GetSnapshotDiffReport(sub1, "s1", "s2");
            MetricsAsserts.AssertCounter("SnapshotDiffReportOps", 1L, MetricsAsserts.GetMetrics
                                             (NnMetrics));
            // Create snapshot for a directory under sub1
            Path subsub1 = new Path(sub1, "sub1sub1");
            Path subfile = new Path(subsub1, "file");

            DFSTestUtil.CreateFile(hdfs, subfile, 1024, Replication, seed);
            hdfs.AllowSnapshot(subsub1);
            hdfs.CreateSnapshot(subsub1, "s11");
            MetricsAsserts.AssertGauge("Snapshots", 3, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("CreateSnapshotOps", 4L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            // delete snapshot
            hdfs.DeleteSnapshot(sub1, "s2");
            MetricsAsserts.AssertGauge("Snapshots", 2, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("DeleteSnapshotOps", 1L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
            // rename snapshot
            hdfs.RenameSnapshot(sub1, "s1", "NewS1");
            MetricsAsserts.AssertGauge("Snapshots", 2, MetricsAsserts.GetMetrics(NsMetrics));
            MetricsAsserts.AssertCounter("RenameSnapshotOps", 1L, MetricsAsserts.GetMetrics(NnMetrics
                                                                                            ));
        }
Пример #13
0
 public virtual void TestFilesInGetListingOps()
 {
     CreateFile("/tmp1/t1", 3200, (short)3);
     CreateFile("/tmp1/t2", 3200, (short)3);
     CreateFile("/tmp2/t1", 3200, (short)3);
     CreateFile("/tmp2/t2", 3200, (short)3);
     cluster.GetNameNodeRpc().GetListing("/tmp1", HdfsFileStatus.EmptyName, false);
     MetricsAsserts.AssertCounter("FilesInGetListingOps", 2L, MetricsAsserts.GetMetrics
                                      (NnMetrics));
     cluster.GetNameNodeRpc().GetListing("/tmp2", HdfsFileStatus.EmptyName, false);
     MetricsAsserts.AssertCounter("FilesInGetListingOps", 4L, MetricsAsserts.GetMetrics
                                      (NnMetrics));
 }
Пример #14
0
        public virtual void TestMutableRates()
        {
            MetricsRecordBuilder rb       = MetricsAsserts.MockMetricsRecordBuilder();
            MetricsRegistry      registry = new MetricsRegistry("test");
            MutableRates         rates    = new MutableRates(registry);

            rates.Init(typeof(TestMutableMetrics.TestProtocol));
            registry.Snapshot(rb, false);
            MetricsAsserts.AssertCounter("FooNumOps", 0L, rb);
            MetricsAsserts.AssertGauge("FooAvgTime", 0.0, rb);
            MetricsAsserts.AssertCounter("BarNumOps", 0L, rb);
            MetricsAsserts.AssertGauge("BarAvgTime", 0.0, rb);
        }
Пример #15
0
        public virtual void TestRenameMetrics()
        {
            Path src = GetTestPath("src");

            CreateFile(src, 100, (short)1);
            Path target = GetTestPath("target");

            CreateFile(target, 100, (short)1);
            fs.Rename(src, target, Options.Rename.Overwrite);
            UpdateMetrics();
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(NnMetrics);

            MetricsAsserts.AssertCounter("FilesRenamed", 1L, rb);
            MetricsAsserts.AssertCounter("FilesDeleted", 1L, rb);
        }
Пример #16
0
        public virtual void TestSyncAndBlockReportMetric()
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(NnMetrics);

            // We have one sync when the cluster starts up, just opening the journal
            MetricsAsserts.AssertCounter("SyncsNumOps", 1L, rb);
            // Each datanode reports in when the cluster comes up
            MetricsAsserts.AssertCounter("BlockReportNumOps", (long)DatanodeCount * cluster.GetStoragesPerDatanode
                                             (), rb);
            // Sleep for an interval+slop to let the percentiles rollover
            Sharpen.Thread.Sleep((PercentilesInterval + 1) * 1000);
            // Check that the percentiles were updated
            MetricsAsserts.AssertQuantileGauges("Syncs1s", rb);
            MetricsAsserts.AssertQuantileGauges("BlockReport1s", rb);
        }
Пример #17
0
        /// <exception cref="System.IO.IOException"/>
        public static void VerifyLoginMetrics(long success, int failure)
        {
            // Ensure metrics related to kerberos login is updated.
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics("UgiMetrics");

            if (success > 0)
            {
                MetricsAsserts.AssertCounter("LoginSuccessNumOps", success, rb);
                MetricsAsserts.AssertGaugeGt("LoginSuccessAvgTime", 0, rb);
            }
            if (failure > 0)
            {
                MetricsAsserts.AssertCounter("LoginFailureNumPos", failure, rb);
                MetricsAsserts.AssertGaugeGt("LoginFailureAvgTime", 0, rb);
            }
        }
Пример #18
0
        private void CheckMetrics(int launched, int completed, int failed, int killed, int
                                  initing, int running, int allocatedGB, int allocatedContainers, int availableGB
                                  , int allocatedVCores, int availableVCores)
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics("NodeManagerMetrics");

            MetricsAsserts.AssertCounter("ContainersLaunched", launched, rb);
            MetricsAsserts.AssertCounter("ContainersCompleted", completed, rb);
            MetricsAsserts.AssertCounter("ContainersFailed", failed, rb);
            MetricsAsserts.AssertCounter("ContainersKilled", killed, rb);
            MetricsAsserts.AssertGauge("ContainersIniting", initing, rb);
            MetricsAsserts.AssertGauge("ContainersRunning", running, rb);
            MetricsAsserts.AssertGauge("AllocatedGB", allocatedGB, rb);
            MetricsAsserts.AssertGauge("AllocatedVCores", allocatedVCores, rb);
            MetricsAsserts.AssertGauge("AllocatedContainers", allocatedContainers, rb);
            MetricsAsserts.AssertGauge("AvailableGB", availableGB, rb);
            MetricsAsserts.AssertGauge("AvailableVCores", availableVCores, rb);
        }
Пример #19
0
        /// <exception cref="System.Exception"/>
        public virtual void TestTimeoutMetric()
        {
            Configuration              conf    = new HdfsConfiguration();
            Path                       path    = new Path("/test");
            MiniDFSCluster             cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(2).Build();
            IList <FSDataOutputStream> streams = Lists.NewArrayList();

            try
            {
                FSDataOutputStream    @out     = cluster.GetFileSystem().Create(path, (short)2);
                DataNodeFaultInjector injector = Org.Mockito.Mockito.Mock <DataNodeFaultInjector>(
                    );
                Org.Mockito.Mockito.DoThrow(new IOException("mock IOException")).When(injector).WriteBlockAfterFlush
                    ();
                DataNodeFaultInjector.instance = injector;
                streams.AddItem(@out);
                @out.WriteBytes("old gs data\n");
                @out.Hflush();
                /* Test the metric. */
                MetricsRecordBuilder dnMetrics = MetricsAsserts.GetMetrics(cluster.GetDataNodes()
                                                                           [0].GetMetrics().Name());
                MetricsAsserts.AssertCounter("DatanodeNetworkErrors", 1L, dnMetrics);
                /* Test JMX datanode network counts. */
                MBeanServer mbs        = ManagementFactory.GetPlatformMBeanServer();
                ObjectName  mxbeanName = new ObjectName("Hadoop:service=DataNode,name=DataNodeInfo"
                                                        );
                object dnc    = mbs.GetAttribute(mxbeanName, "DatanodeNetworkCounts");
                string allDnc = dnc.ToString();
                NUnit.Framework.Assert.IsTrue("expected to see loopback address", allDnc.IndexOf(
                                                  "127.0.0.1") >= 0);
                NUnit.Framework.Assert.IsTrue("expected to see networkErrors", allDnc.IndexOf("networkErrors"
                                                                                              ) >= 0);
            }
            finally
            {
                IOUtils.Cleanup(Log, Sharpen.Collections.ToArray(streams, new IDisposable[0]));
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
                DataNodeFaultInjector.instance = new DataNodeFaultInjector();
            }
        }
Пример #20
0
        public virtual void TestReceivePacketMetrics()
        {
            Configuration conf     = new HdfsConfiguration();
            int           interval = 1;

            conf.Set(DFSConfigKeys.DfsMetricsPercentilesIntervalsKey, string.Empty + interval
                     );
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).Build();

            try
            {
                cluster.WaitActive();
                DistributedFileSystem fs = cluster.GetFileSystem();
                Path testFile            = new Path("/testFlushNanosMetric.txt");
                FSDataOutputStream fout  = fs.Create(testFile);
                fout.Write(new byte[1]);
                fout.Hsync();
                fout.Close();
                IList <DataNode>     datanodes = cluster.GetDataNodes();
                DataNode             datanode  = datanodes[0];
                MetricsRecordBuilder dnMetrics = MetricsAsserts.GetMetrics(datanode.GetMetrics().
                                                                           Name());
                // Expect two flushes, 1 for the flush that occurs after writing,
                // 1 that occurs on closing the data and metadata files.
                MetricsAsserts.AssertCounter("FlushNanosNumOps", 2L, dnMetrics);
                // Expect two syncs, one from the hsync, one on close.
                MetricsAsserts.AssertCounter("FsyncNanosNumOps", 2L, dnMetrics);
                // Wait for at least 1 rollover
                Sharpen.Thread.Sleep((interval + 1) * 1000);
                // Check the receivePacket percentiles that should be non-zero
                string sec = interval + "s";
                MetricsAsserts.AssertQuantileGauges("FlushNanos" + sec, dnMetrics);
                MetricsAsserts.AssertQuantileGauges("FsyncNanos" + sec, dnMetrics);
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Пример #21
0
        public virtual void TestSendDataPacketMetrics()
        {
            Configuration conf     = new HdfsConfiguration();
            int           interval = 1;

            conf.Set(DFSConfigKeys.DfsMetricsPercentilesIntervalsKey, string.Empty + interval
                     );
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).Build();

            try
            {
                FileSystem fs = cluster.GetFileSystem();
                // Create and read a 1 byte file
                Path tmpfile = new Path("/tmp.txt");
                DFSTestUtil.CreateFile(fs, tmpfile, (long)1, (short)1, 1L);
                DFSTestUtil.ReadFile(fs, tmpfile);
                IList <DataNode> datanodes = cluster.GetDataNodes();
                NUnit.Framework.Assert.AreEqual(datanodes.Count, 1);
                DataNode             datanode = datanodes[0];
                MetricsRecordBuilder rb       = MetricsAsserts.GetMetrics(datanode.GetMetrics().Name());
                // Expect 2 packets, 1 for the 1 byte read, 1 for the empty packet
                // signaling the end of the block
                MetricsAsserts.AssertCounter("SendDataPacketTransferNanosNumOps", (long)2, rb);
                MetricsAsserts.AssertCounter("SendDataPacketBlockedOnNetworkNanosNumOps", (long)2
                                             , rb);
                // Wait for at least 1 rollover
                Sharpen.Thread.Sleep((interval + 1) * 1000);
                // Check that the sendPacket percentiles rolled to non-zero values
                string sec = interval + "s";
                MetricsAsserts.AssertQuantileGauges("SendDataPacketBlockedOnNetworkNanos" + sec,
                                                    rb);
                MetricsAsserts.AssertQuantileGauges("SendDataPacketTransferNanos" + sec, rb);
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Пример #22
0
        public static void CheckResources(MetricsSource source, int allocatedMB, int allocatedCores
                                          , int allocCtnrs, long aggreAllocCtnrs, long aggreReleasedCtnrs, int availableMB
                                          , int availableCores, int pendingMB, int pendingCores, int pendingCtnrs, int reservedMB
                                          , int reservedCores, int reservedCtnrs)
        {
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(source);

            MetricsAsserts.AssertGauge("AllocatedMB", allocatedMB, rb);
            MetricsAsserts.AssertGauge("AllocatedVCores", allocatedCores, rb);
            MetricsAsserts.AssertGauge("AllocatedContainers", allocCtnrs, rb);
            MetricsAsserts.AssertCounter("AggregateContainersAllocated", aggreAllocCtnrs, rb);
            MetricsAsserts.AssertCounter("AggregateContainersReleased", aggreReleasedCtnrs, rb
                                         );
            MetricsAsserts.AssertGauge("AvailableMB", availableMB, rb);
            MetricsAsserts.AssertGauge("AvailableVCores", availableCores, rb);
            MetricsAsserts.AssertGauge("PendingMB", pendingMB, rb);
            MetricsAsserts.AssertGauge("PendingVCores", pendingCores, rb);
            MetricsAsserts.AssertGauge("PendingContainers", pendingCtnrs, rb);
            MetricsAsserts.AssertGauge("ReservedMB", reservedMB, rb);
            MetricsAsserts.AssertGauge("ReservedVCores", reservedCores, rb);
            MetricsAsserts.AssertGauge("ReservedContainers", reservedCtnrs, rb);
        }
        /// <summary>
        /// Verify that the DataNode sends a single incremental block report for all
        /// storages.
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public virtual void TestDataNodeDoesNotSplitReports()
        {
            LocatedBlocks blocks = CreateFileGetBlocks(GenericTestUtils.GetMethodName());

            Assert.AssertThat(cluster.GetDataNodes().Count, IS.Is(1));
            // Remove all blocks from the DataNode.
            foreach (LocatedBlock block in blocks.GetLocatedBlocks())
            {
                dn0.NotifyNamenodeDeletedBlock(block.GetBlock(), block.GetStorageIDs()[0]);
            }
            Log.Info("Triggering report after deleting blocks");
            long ops = MetricsAsserts.GetLongCounter("BlockReceivedAndDeletedOps", MetricsAsserts.GetMetrics
                                                         (NnMetrics));

            // Trigger a report to the NameNode and give it a few seconds.
            DataNodeTestUtils.TriggerBlockReport(dn0);
            Sharpen.Thread.Sleep(5000);
            // Ensure that NameNodeRpcServer.blockReceivedAndDeletes is invoked
            // exactly once after we triggered the report.
            MetricsAsserts.AssertCounter("BlockReceivedAndDeletedOps", ops + 1, MetricsAsserts.GetMetrics
                                             (NnMetrics));
        }
        public virtual void TestInitialState()
        {
            MetricsRecordBuilder builder = MetricsAsserts.GetMetrics(metrics, true);

            MetricsAsserts.AssertCounter("ElapsedTime", 0L, builder);
            MetricsAsserts.AssertGauge("PercentComplete", 0.0f, builder);
            MetricsAsserts.AssertCounter("LoadingFsImageCount", 0L, builder);
            MetricsAsserts.AssertCounter("LoadingFsImageElapsedTime", 0L, builder);
            MetricsAsserts.AssertCounter("LoadingFsImageTotal", 0L, builder);
            MetricsAsserts.AssertGauge("LoadingFsImagePercentComplete", 0.0f, builder);
            MetricsAsserts.AssertCounter("LoadingEditsCount", 0L, builder);
            MetricsAsserts.AssertCounter("LoadingEditsElapsedTime", 0L, builder);
            MetricsAsserts.AssertCounter("LoadingEditsTotal", 0L, builder);
            MetricsAsserts.AssertGauge("LoadingEditsPercentComplete", 0.0f, builder);
            MetricsAsserts.AssertCounter("SavingCheckpointCount", 0L, builder);
            MetricsAsserts.AssertCounter("SavingCheckpointElapsedTime", 0L, builder);
            MetricsAsserts.AssertCounter("SavingCheckpointTotal", 0L, builder);
            MetricsAsserts.AssertGauge("SavingCheckpointPercentComplete", 0.0f, builder);
            MetricsAsserts.AssertCounter("SafeModeCount", 0L, builder);
            MetricsAsserts.AssertCounter("SafeModeElapsedTime", 0L, builder);
            MetricsAsserts.AssertCounter("SafeModeTotal", 0L, builder);
            MetricsAsserts.AssertGauge("SafeModePercentComplete", 0.0f, builder);
        }
Пример #25
0
        public virtual void TestFileAdd()
        {
            // Add files with 100 blocks
            Path file = GetTestPath("testFileAdd");

            CreateFile(file, 3200, (short)3);
            long blockCount    = 32;
            int  blockCapacity = namesystem.GetBlockCapacity();

            UpdateMetrics();
            MetricsAsserts.AssertGauge("BlockCapacity", blockCapacity, MetricsAsserts.GetMetrics
                                           (NsMetrics));
            MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(NnMetrics);

            // File create operations is 1
            // Number of files created is depth of <code>file</code> path
            MetricsAsserts.AssertCounter("CreateFileOps", 1L, rb);
            MetricsAsserts.AssertCounter("FilesCreated", (long)file.Depth(), rb);
            UpdateMetrics();
            long filesTotal = file.Depth() + 1;

            // Add 1 for root
            rb = MetricsAsserts.GetMetrics(NsMetrics);
            MetricsAsserts.AssertGauge("FilesTotal", filesTotal, rb);
            MetricsAsserts.AssertGauge("BlocksTotal", blockCount, rb);
            fs.Delete(file, true);
            filesTotal--;
            // reduce the filecount for deleted file
            rb = WaitForDnMetricValue(NsMetrics, "FilesTotal", filesTotal);
            MetricsAsserts.AssertGauge("BlocksTotal", 0L, rb);
            MetricsAsserts.AssertGauge("PendingDeletionBlocks", 0L, rb);
            rb = MetricsAsserts.GetMetrics(NnMetrics);
            // Delete file operations and number of files deleted must be 1
            MetricsAsserts.AssertCounter("DeleteFileOps", 1L, rb);
            MetricsAsserts.AssertCounter("FilesDeleted", 1L, rb);
        }
Пример #26
0
        /// <summary>Checks a DataNode for correct reporting of failed volumes.</summary>
        /// <param name="dn">DataNode to check</param>
        /// <param name="expectedVolumeFailuresCounter">
        /// metric counter value for
        /// VolumeFailures.  The current implementation actually counts the number
        /// of failed disk checker cycles, which may be different from the length of
        /// expectedFailedVolumes if multiple disks fail in the same disk checker
        /// cycle
        /// </param>
        /// <param name="expectCapacityKnown">
        /// if true, then expect that the capacities of the
        /// volumes were known before the failures, and therefore the lost capacity
        /// can be reported
        /// </param>
        /// <param name="expectedFailedVolumes">expected locations of failed volumes</param>
        /// <exception cref="System.Exception">if there is any failure</exception>
        private void CheckFailuresAtDataNode(DataNode dn, long expectedVolumeFailuresCounter
                                             , bool expectCapacityKnown, params string[] expectedFailedVolumes)
        {
            MetricsAsserts.AssertCounter("VolumeFailures", expectedVolumeFailuresCounter, MetricsAsserts.GetMetrics
                                             (dn.GetMetrics().Name()));
            FsDatasetSpi <object> fsd = dn.GetFSDataset();

            NUnit.Framework.Assert.AreEqual(expectedFailedVolumes.Length, fsd.GetNumFailedVolumes
                                                ());
            Assert.AssertArrayEquals(expectedFailedVolumes, fsd.GetFailedStorageLocations());
            if (expectedFailedVolumes.Length > 0)
            {
                NUnit.Framework.Assert.IsTrue(fsd.GetLastVolumeFailureDate() > 0);
                long expectedCapacityLost = GetExpectedCapacityLost(expectCapacityKnown, expectedFailedVolumes
                                                                    .Length);
                NUnit.Framework.Assert.AreEqual(expectedCapacityLost, fsd.GetEstimatedCapacityLostTotal
                                                    ());
            }
            else
            {
                NUnit.Framework.Assert.AreEqual(0, fsd.GetLastVolumeFailureDate());
                NUnit.Framework.Assert.AreEqual(0, fsd.GetEstimatedCapacityLostTotal());
            }
        }
Пример #27
0
        /// <exception cref="System.IO.IOException"/>
        private void TestCallsInternal(Configuration conf)
        {
            Server server = new RPC.Builder(conf).SetProtocol(typeof(TestRPC.TestProtocol)).SetInstance
                                (new TestRPC.TestImpl()).SetBindAddress(Address).SetPort(0).Build();

            TestRPC.TestProtocol proxy = null;
            try
            {
                server.Start();
                IPEndPoint addr = NetUtils.GetConnectAddress(server);
                proxy = RPC.GetProxy <TestRPC.TestProtocol>(TestRPC.TestProtocol.versionID, addr,
                                                            conf);
                proxy.Ping();
                string stringResult = proxy.Echo("foo");
                Assert.Equal(stringResult, "foo");
                stringResult = proxy.Echo((string)null);
                Assert.Equal(stringResult, null);
                // Check rpcMetrics
                MetricsRecordBuilder rb = MetricsAsserts.GetMetrics(server.rpcMetrics.Name());
                MetricsAsserts.AssertCounter("RpcProcessingTimeNumOps", 3L, rb);
                MetricsAsserts.AssertCounterGt("SentBytes", 0L, rb);
                MetricsAsserts.AssertCounterGt("ReceivedBytes", 0L, rb);
                // Number of calls to echo method should be 2
                rb = MetricsAsserts.GetMetrics(server.rpcDetailedMetrics.Name());
                MetricsAsserts.AssertCounter("EchoNumOps", 2L, rb);
                // Number of calls to ping method should be 1
                MetricsAsserts.AssertCounter("PingNumOps", 1L, rb);
                string[] stringResults = proxy.Echo(new string[] { "foo", "bar" });
                Assert.True(Arrays.Equals(stringResults, new string[] { "foo",
                                                                        "bar" }));
                stringResults = proxy.Echo((string[])null);
                Assert.True(Arrays.Equals(stringResults, null));
                UTF8 utf8Result = (UTF8)proxy.Echo(new UTF8("hello world"));
                Assert.Equal(new UTF8("hello world"), utf8Result);
                utf8Result = (UTF8)proxy.Echo((UTF8)null);
                Assert.Equal(null, utf8Result);
                int intResult = proxy.Add(1, 2);
                Assert.Equal(intResult, 3);
                intResult = proxy.Add(new int[] { 1, 2 });
                Assert.Equal(intResult, 3);
                // Test protobufs
                DescriptorProtos.EnumDescriptorProto sendProto = ((DescriptorProtos.EnumDescriptorProto
                                                                   )DescriptorProtos.EnumDescriptorProto.NewBuilder().SetName("test").Build());
                DescriptorProtos.EnumDescriptorProto retProto = proxy.ExchangeProto(sendProto);
                Assert.Equal(sendProto, retProto);
                NUnit.Framework.Assert.AreNotSame(sendProto, retProto);
                bool caught = false;
                try
                {
                    proxy.Error();
                }
                catch (IOException e)
                {
                    if (Log.IsDebugEnabled())
                    {
                        Log.Debug("Caught " + e);
                    }
                    caught = true;
                }
                Assert.True(caught);
                rb = MetricsAsserts.GetMetrics(server.rpcDetailedMetrics.Name());
                MetricsAsserts.AssertCounter("IOExceptionNumOps", 1L, rb);
                proxy.TestServerGet();
                // create multiple threads and make them do large data transfers
                System.Console.Out.WriteLine("Starting multi-threaded RPC test...");
                server.SetSocketSendBufSize(1024);
                Thread[] threadId = new Thread[numThreads];
                for (int i = 0; i < numThreads; i++)
                {
                    TestRPC.Transactions trans = new TestRPC.Transactions(proxy, datasize);
                    threadId[i] = new Thread(trans, "TransactionThread-" + i);
                    threadId[i].Start();
                }
                // wait for all transactions to get over
                System.Console.Out.WriteLine("Waiting for all threads to finish RPCs...");
                for (int i_1 = 0; i_1 < numThreads; i_1++)
                {
                    try
                    {
                        threadId[i_1].Join();
                    }
                    catch (Exception)
                    {
                        i_1--;
                    }
                }
            }
            finally
            {
                // retry
                server.Stop();
                if (proxy != null)
                {
                    RPC.StopProxy(proxy);
                }
            }
        }