Java Code Examples for org.apache.hadoop.hbase.ServerName#getServerName()
The following examples show how to use
org.apache.hadoop.hbase.ServerName#getServerName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptyAsync() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--force-proceed", "--move-async", "--skip-export"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // verify assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 2
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptySkipExport() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 with export boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--skip-export", "--force-proceed"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // check empty assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 3
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptyAsync() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--force-proceed", "--move-async", "--skip-export"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // verify assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 4
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptySkipExport() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 with export boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--skip-export", "--force-proceed"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // check empty assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 5
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptyAsync() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--force-proceed", "--move-async", "--skip-export"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // verify assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 6
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptySkipExport() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 with export boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--skip-export", "--force-proceed"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // check empty assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 7
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptyAsync() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--force-proceed", "--move-async", "--skip-export"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // verify assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 8
Source File: AssignEmptyTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testEmptySkipExport() throws Exception { ArrayList<ServerName> serverNameList; List<HRegionInfo> regionInfoList; // move all regions to rs1 splitTable("a".getBytes()); splitTable("b".getBytes()); serverNameList = getServerNameList(); ServerName rs1 = serverNameList.get(0); regionInfoList = getRegionInfoList(tableName); assertEquals(3, regionInfoList.size()); for (HRegionInfo hRegionInfo : regionInfoList) move(hRegionInfo, rs1); assertEquals(regionInfoList.size(), getRegionInfoList(rs1, tableName).size()); // empty rs1 with export boolean balancerRunning = false; try { balancerRunning = admin.setBalancerRunning(false, true); String[] argsParam = {"zookeeper", "empty", rs1.getServerName(), "--skip-export", "--force-proceed"}; Args args = new ManagerArgs(argsParam); Assign command = new Assign(admin, args); command.run(); // check empty assertEquals(0, getRegionInfoList(rs1, tableName).size()); } finally { if (balancerRunning) admin.setBalancerRunning(true, true); } }
Example 9
Source File: MetricsMasterWrapperImpl.java From hbase with Apache License 2.0 | 5 votes |
@Override public String getServerName() { ServerName serverName = master.getServerName(); if (serverName == null) { return ""; } return serverName.getServerName(); }
Example 10
Source File: MetricsRegionServerWrapperImpl.java From hbase with Apache License 2.0 | 5 votes |
@Override public String getServerName() { ServerName serverName = regionServer.getServerName(); if (serverName == null) { return ""; } return serverName.getServerName(); }
Example 11
Source File: MetricsConnection.java From hbase with Apache License 2.0 | 5 votes |
@Override public void updateRegionStats(ServerName serverName, byte[] regionName, RegionLoadStats stats) { String name = serverName.getServerName() + "," + Bytes.toStringBinary(regionName); ConcurrentMap<byte[], RegionStats> rsStats = computeIfAbsent(serverStats, serverName, () -> new ConcurrentSkipListMap<>(Bytes.BYTES_COMPARATOR)); RegionStats regionStats = computeIfAbsent(rsStats, regionName, () -> new RegionStats(this.registry, name)); regionStats.update(stats); }
Example 12
Source File: AbstractRpcClient.java From hbase with Apache License 2.0 | 5 votes |
InetSocketAddress createAddr(ServerName sn) throws UnknownHostException { InetSocketAddress addr = new InetSocketAddress(sn.getHostname(), sn.getPort()); if (addr.isUnresolved()) { throw new UnknownHostException("can not resolve " + sn.getServerName()); } return addr; }
Example 13
Source File: ClientPushbackTestBase.java From hbase with Apache License 2.0 | 4 votes |
@Test public void testClientTracksServerPushback() throws Exception { HRegionServer rs = UTIL.getHBaseCluster().getRegionServer(0); Region region = rs.getRegions(tableName).get(0); LOG.debug("Writing some data to " + tableName); // write some data Put p = new Put(Bytes.toBytes("row")); p.addColumn(family, qualifier, Bytes.toBytes("value1")); mutate(p); // get the current load on RS. Hopefully memstore isn't flushed since we wrote the the data int load = (int) ((region.getMemStoreHeapSize() * 100) / flushSizeBytes); LOG.debug("Done writing some data to " + tableName); // get the stats for the region hosting our table ClientBackoffPolicy backoffPolicy = getBackoffPolicy(); assertTrue("Backoff policy is not correctly configured", backoffPolicy instanceof ExponentialClientBackoffPolicy); ServerStatisticTracker stats = getStatisticsTracker(); assertNotNull("No stats configured for the client!", stats); // get the names so we can query the stats ServerName server = rs.getServerName(); byte[] regionName = region.getRegionInfo().getRegionName(); // check to see we found some load on the memstore ServerStatistics serverStats = stats.getStats(server); ServerStatistics.RegionStatistics regionStats = serverStats.getStatsForRegion(regionName); assertEquals("We did not find some load on the memstore", load, regionStats.getMemStoreLoadPercent()); // check that the load reported produces a nonzero delay long backoffTime = backoffPolicy.getBackoffTime(server, regionName, serverStats); assertNotEquals("Reported load does not produce a backoff", 0, backoffTime); LOG.debug("Backoff calculated for " + region.getRegionInfo().getRegionNameAsString() + " @ " + server + " is " + backoffTime); CountDownLatch latch = new CountDownLatch(1); AtomicLong endTime = new AtomicLong(); long startTime = EnvironmentEdgeManager.currentTime(); mutate(p, endTime, latch); // Currently the ExponentialClientBackoffPolicy under these test conditions // produces a backoffTime of 151 milliseconds. This is long enough so the // wait and related checks below are reasonable. Revisit if the backoff // time reported by above debug logging has significantly deviated. MetricsConnection metrics = getConnectionMetrics(); String name = server.getServerName() + "," + Bytes.toStringBinary(regionName); MetricsConnection.RegionStats rsStats = metrics.serverStats.get(server).get(regionName); assertEquals(name, rsStats.name); assertEquals(rsStats.heapOccupancyHist.getSnapshot().getMean(), (double) regionStats.getHeapOccupancyPercent(), 0.1); assertEquals(rsStats.memstoreLoadHist.getSnapshot().getMean(), (double) regionStats.getMemStoreLoadPercent(), 0.1); MetricsConnection.RunnerStats runnerStats = metrics.runnerStats; assertEquals(1, runnerStats.delayRunners.getCount()); assertEquals(1, runnerStats.normalRunners.getCount()); assertEquals("", runnerStats.delayIntevalHist.getSnapshot().getMean(), (double) backoffTime, 0.1); latch.await(backoffTime * 2, TimeUnit.MILLISECONDS); assertNotEquals("AsyncProcess did not submit the work time", 0, endTime.get()); assertTrue("AsyncProcess did not delay long enough", endTime.get() - startTime >= backoffTime); }
Example 14
Source File: AsyncBatchRpcRetryingCaller.java From hbase with Apache License 2.0 | 4 votes |
private String getExtraContextForError(ServerName serverName) { return serverName != null ? serverName.getServerName() : ""; }