org.apache.hadoop.hbase.ServerName Java Examples
The following examples show how to use
org.apache.hadoop.hbase.ServerName.
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: TestTableFavoredNodes.java From hbase with Apache License 2.0 | 6 votes |
private void checkIfDaughterInherits2FN(List<ServerName> parentFN, List<ServerName> daughterFN) { assertNotNull(parentFN); assertNotNull(daughterFN); List<ServerName> favoredNodes = Lists.newArrayList(daughterFN); favoredNodes.removeAll(parentFN); /* * With a small cluster its likely some FN might accidentally get shared. Its likely the * 3rd FN the balancer chooses might still belong to the parent in which case favoredNodes * size would be 0. */ assertTrue("Daughter FN:" + daughterFN + " should have inherited 2 FN from parent FN:" + parentFN, favoredNodes.size() <= 1); }
Example #2
Source File: FavoredStochasticBalancer.java From hbase with Apache License 2.0 | 6 votes |
private List<ServerName> getOnlineFavoredNodes(List<ServerName> onlineServers, List<ServerName> serversWithoutStartCodes) { if (serversWithoutStartCodes == null) { return null; } else { List<ServerName> result = Lists.newArrayList(); for (ServerName sn : serversWithoutStartCodes) { for (ServerName online : onlineServers) { if (ServerName.isSameAddress(sn, online)) { result.add(online); } } } return result; } }
Example #3
Source File: TestWALRecoveryCaching.java From phoenix with Apache License 2.0 | 6 votes |
/** * @param cluster * @param indexTable * @param primaryTable * @return * @throws Exception */ private ServerName getSharedServer(MiniHBaseCluster cluster, byte[] indexTable, byte[] primaryTable) throws Exception { Set<ServerName> indexServers = getServersForTable(cluster, indexTable); Set<ServerName> primaryServers = getServersForTable(cluster, primaryTable); Set<ServerName> joinSet = new HashSet<ServerName>(indexServers); joinSet.addAll(primaryServers); // if there is already an overlap, then find it and return it if (joinSet.size() < indexServers.size() + primaryServers.size()) { // find the first overlapping server for (ServerName server : joinSet) { if (indexServers.contains(server) && primaryServers.contains(server)) { return server; } } throw new RuntimeException( "Couldn't find a matching server on which both the primary and index table live, " + "even though they have overlapping server sets"); } return null; }
Example #4
Source File: TestSplitWALManager.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testAcquireAndRelease() throws Exception { List<FakeServerProcedure> testProcedures = new ArrayList<>(); for (int i = 0; i < 4; i++) { testProcedures.add(new FakeServerProcedure( TEST_UTIL.getHBaseCluster().getServerHoldingMeta())); } ServerName server = splitWALManager.acquireSplitWALWorker(testProcedures.get(0)); Assert.assertNotNull(server); Assert.assertNotNull(splitWALManager.acquireSplitWALWorker(testProcedures.get(1))); Assert.assertNotNull(splitWALManager.acquireSplitWALWorker(testProcedures.get(2))); Exception e = null; try { splitWALManager.acquireSplitWALWorker(testProcedures.get(3)); } catch (ProcedureSuspendedException suspendException) { e = suspendException; } Assert.assertNotNull(e); Assert.assertTrue(e instanceof ProcedureSuspendedException); splitWALManager.releaseSplitWALWorker(server, TEST_UTIL.getHBaseCluster().getMaster() .getMasterProcedureExecutor().getEnvironment().getProcedureScheduler()); Assert.assertNotNull(splitWALManager.acquireSplitWALWorker(testProcedures.get(3))); }
Example #5
Source File: MetaTableLocator.java From hbase with Apache License 2.0 | 6 votes |
/** * Wait until the meta region is available and is not in transition. * @param zkw reference to the {@link ZKWatcher} which also contains configuration and constants * @param replicaId the ID of the replica * @param timeout maximum time to wait in millis * @return ServerName or null if we timed out. * @throws InterruptedException if waiting for the socket operation fails */ public static ServerName blockUntilAvailable(final ZKWatcher zkw, int replicaId, final long timeout) throws InterruptedException { if (timeout < 0) { throw new IllegalArgumentException(); } if (zkw == null) { throw new IllegalArgumentException(); } long startTime = System.currentTimeMillis(); ServerName sn = null; while (true) { sn = getMetaRegionLocation(zkw, replicaId); if (sn != null || (System.currentTimeMillis() - startTime) > timeout - HConstants.SOCKET_RETRY_WAIT_MS) { break; } Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS); } return sn; }
Example #6
Source File: TestRegionLocationFinder.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testGetTopBlockLocations() throws Exception { for (int i = 0; i < ServerNum; i++) { HRegionServer server = cluster.getRegionServer(i); for (HRegion region : server.getRegions(tableName)) { List<ServerName> servers = finder.getTopBlockLocations(region .getRegionInfo()); // test table may have empty region if (region.getHDFSBlocksDistribution().getUniqueBlocksTotalWeight() == 0) { continue; } List<String> topHosts = region.getHDFSBlocksDistribution().getTopHosts(); // rs and datanode may have different host in local machine test if (!topHosts.contains(server.getServerName().getHostname())) { continue; } for (int j = 0; j < ServerNum; j++) { ServerName serverName = cluster.getRegionServer(j).getServerName(); assertTrue(servers.contains(serverName)); } } } }
Example #7
Source File: TestStochasticLoadBalancer.java From hbase with Apache License 2.0 | 6 votes |
private ServerMetrics mockServerMetricsWithCpRequests(ServerName server, List<RegionInfo> regionsOnServer, long cpRequestCount) { ServerMetrics serverMetrics = mock(ServerMetrics.class); Map<byte[], RegionMetrics> regionLoadMap = new TreeMap<>(Bytes.BYTES_COMPARATOR); for(RegionInfo info : regionsOnServer){ RegionMetrics rl = mock(RegionMetrics.class); when(rl.getReadRequestCount()).thenReturn(0L); when(rl.getCpRequestCount()).thenReturn(cpRequestCount); when(rl.getWriteRequestCount()).thenReturn(0L); when(rl.getMemStoreSize()).thenReturn(Size.ZERO); when(rl.getStoreFileSize()).thenReturn(Size.ZERO); regionLoadMap.put(info.getRegionName(), rl); } when(serverMetrics.getRegionMetrics()).thenReturn(regionLoadMap); return serverMetrics; }
Example #8
Source File: TestSyncReplicationStandbyKillRS.java From hbase with Apache License 2.0 | 6 votes |
private void waitForRSShutdownToStartAndFinish(JVMClusterUtil.MasterThread activeMaster, ServerName serverName) throws InterruptedException { ServerManager sm = activeMaster.getMaster().getServerManager(); // First wait for it to be in dead list while (!sm.getDeadServers().isDeadServer(serverName)) { LOG.debug("Waiting for [" + serverName + "] to be listed as dead in master"); Thread.sleep(SLEEP_TIME); } LOG.debug("Server [" + serverName + "] marked as dead, waiting for it to " + "finish dead processing"); while (sm.areDeadServersInProgress()) { LOG.debug("Server [" + serverName + "] still being processed, waiting"); Thread.sleep(SLEEP_TIME); } LOG.debug("Server [" + serverName + "] done with server shutdown processing"); }
Example #9
Source File: TestReplicationStatusAfterLagging.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testReplicationStatusAfterLagging() throws Exception { UTIL2.shutdownMiniHBaseCluster(); restartSourceCluster(1); // add some values to cluster 1 for (int i = 0; i < NB_ROWS_IN_BATCH; i++) { Put p = new Put(Bytes.toBytes("row" + i)); p.addColumn(famName, Bytes.toBytes("col1"), Bytes.toBytes("val" + i)); htable1.put(p); } UTIL2.startMiniHBaseCluster(); Thread.sleep(10000); Admin hbaseAdmin = UTIL1.getAdmin(); ServerName serverName = UTIL1.getHBaseCluster().getRegionServer(0).getServerName(); ClusterMetrics metrics = hbaseAdmin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)); List<ReplicationLoadSource> loadSources = metrics.getLiveServerMetrics().get(serverName).getReplicationLoadSourceList(); assertEquals(1, loadSources.size()); ReplicationLoadSource loadSource = loadSources.get(0); assertTrue(loadSource.hasEditsSinceRestart()); assertTrue(loadSource.getTimestampOfLastShippedOp() > 0); assertEquals(0, loadSource.getReplicationLag()); }
Example #10
Source File: HbaseSessions.java From hugegraph with Apache License 2.0 | 6 votes |
public long storeSize(String table) throws IOException { long total = 0; try (Admin admin = this.hbase.getAdmin()) { for (ServerName rs : admin.getRegionServers()) { // NOTE: we can use getLoad() before hbase 2.0 //ServerLoad load = admin.getClusterStatus().getLoad(rs); //total += load.getStorefileSizeMB() * Bytes.MB; //total += load.getMemStoreSizeMB() * Bytes.MB; TableName tableName = TableName.valueOf(this.namespace, table); for (RegionMetrics m : admin.getRegionMetrics(rs, tableName)) { total += m.getStoreFileSize().get(Size.Unit.BYTE); total += m.getMemStoreSize().get(Size.Unit.BYTE); } } } return total; }
Example #11
Source File: CommandAdapter.java From hbase-tools with Apache License 2.0 | 6 votes |
public static List<RegionPlan> makePlan(HBaseAdmin admin, List<RegionPlan> newRegionPlan) throws IOException { // snapshot current region assignment Map<HRegionInfo, ServerName> regionAssignmentMap = createRegionAssignmentMap(admin); // update with new plan for (RegionPlan regionPlan : newRegionPlan) { regionAssignmentMap.put(regionPlan.getRegionInfo(), regionPlan.getDestination()); } Map<ServerName, List<HRegionInfo>> clusterState = initializeRegionMap(admin); for (Map.Entry<HRegionInfo, ServerName> entry : regionAssignmentMap.entrySet()) clusterState.get(entry.getValue()).add(entry.getKey()); StochasticLoadBalancer balancer = new StochasticLoadBalancer(); Configuration conf = admin.getConfiguration(); conf.setFloat("hbase.regions.slop", 0.2f); balancer.setConf(conf); return balancer.balanceCluster(clusterState); }
Example #12
Source File: IndexLoadBalancer.java From phoenix with Apache License 2.0 | 6 votes |
private void savePlan(Map<ServerName, List<HRegionInfo>> bulkPlan) { synchronized (this.colocationInfo) { for (Entry<ServerName, List<HRegionInfo>> e : bulkPlan.entrySet()) { if (LOG.isDebugEnabled()) { LOG.debug("Saving user regions' plans for server " + e.getKey() + '.'); } for (HRegionInfo hri : e.getValue()) { if (!isTableColocated(hri.getTable())) continue; regionOnline(hri, e.getKey()); } if (LOG.isDebugEnabled()) { LOG.debug("Saved user regions' plans for server " + e.getKey() + '.'); } } } }
Example #13
Source File: AssignmentManager.java From hbase with Apache License 2.0 | 6 votes |
/** * Create round-robin assigns. Use on table creation to distribute out regions across cluster. * @return AssignProcedures made out of the passed in <code>hris</code> and a call to the balancer * to populate the assigns with targets chosen using round-robin (default balancer * scheme). If at assign-time, the target chosen is no longer up, thats fine, the * AssignProcedure will ask the balancer for a new target, and so on. */ public TransitRegionStateProcedure[] createRoundRobinAssignProcedures(List<RegionInfo> hris, List<ServerName> serversToExclude) { if (hris.isEmpty()) { return new TransitRegionStateProcedure[0]; } if (serversToExclude != null && this.master.getServerManager().getOnlineServersList().size() == 1) { LOG.debug("Only one region server found and hence going ahead with the assignment"); serversToExclude = null; } try { // Ask the balancer to assign our regions. Pass the regions en masse. The balancer can do // a better job if it has all the assignments in the one lump. Map<ServerName, List<RegionInfo>> assignments = getBalancer().roundRobinAssignment(hris, this.master.getServerManager().createDestinationServersList(serversToExclude)); // Return mid-method! return createAssignProcedures(assignments); } catch (IOException hioe) { LOG.warn("Failed roundRobinAssignment", hioe); } // If an error above, fall-through to this simpler assign. Last resort. return createAssignProcedures(hris); }
Example #14
Source File: DuplicatePacketsCommandAction.java From hbase with Apache License 2.0 | 6 votes |
protected void localPerform() throws IOException { getLogger().info("Starting to execute DuplicatePacketsCommandAction"); ServerName server = PolicyBasedChaosMonkey.selectRandomItem(getCurrentServers()); String hostname = server.getHostname(); try { clusterManager.execSudoWithRetries(hostname, timeout, getCommand(ADD)); Thread.sleep(duration); } catch (InterruptedException e) { getLogger().debug("Failed to run the command for the full duration", e); } finally { clusterManager.execSudoWithRetries(hostname, timeout, getCommand(DELETE)); } getLogger().info("Finished to execute DuplicatePacketsCommandAction"); }
Example #15
Source File: SplitLogManager.java From hbase with Apache License 2.0 | 6 votes |
/** * The caller will block until all the log files of the given region server have been processed - * successfully split or an error is encountered - by an available worker region server. This * method must only be called after the region servers have been brought online. * @param logDirs List of log dirs to split * @throws IOException If there was an error while splitting any log file * @return cumulative size of the logfiles split */ public long splitLogDistributed(final List<Path> logDirs) throws IOException { if (logDirs.isEmpty()) { return 0; } Set<ServerName> serverNames = new HashSet<>(); for (Path logDir : logDirs) { try { ServerName serverName = AbstractFSWALProvider.getServerNameFromWALDirectoryName(logDir); if (serverName != null) { serverNames.add(serverName); } } catch (IllegalArgumentException e) { // ignore invalid format error. LOG.warn("Cannot parse server name from " + logDir); } } return splitLogDistributed(serverNames, logDirs, null); }
Example #16
Source File: BalanceRuleTest.java From hbase-tools with Apache License 2.0 | 6 votes |
private void validateST2(HTable table1) throws IOException { NavigableMap<HRegionInfo, ServerName> regionLocations; List<Map.Entry<HRegionInfo, ServerName>> hRegionInfoList; regionLocations = table1.getRegionLocations(); hRegionInfoList = new ArrayList<>(regionLocations.entrySet()); Map<ServerName, Integer> serverCountMap = new HashMap<>(); for (Map.Entry<HRegionInfo, ServerName> entry : hRegionInfoList) { if (serverCountMap.get(entry.getValue()) == null) { serverCountMap.put(entry.getValue(), 1); } else { serverCountMap.put(entry.getValue(), serverCountMap.get(entry.getValue()) + 1); } } Assert.assertEquals(Math.min(getServerNameList().size(), regionLocations.size()), serverCountMap.size()); int regionCount; regionCount = 0; for (ServerName serverName : getServerNameList()) { List<HRegionInfo> regionInfoList = getRegionInfoList(serverName, Bytes.toString(table1.getTableName())); Assert.assertNotEquals(4, regionInfoList.size()); Assert.assertEquals(2, regionInfoList.size()); regionCount += regionInfoList.size(); } Assert.assertEquals(4, regionCount); }
Example #17
Source File: TestDeadServer.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testSortExtract(){ ManualEnvironmentEdge mee = new ManualEnvironmentEdge(); EnvironmentEdgeManager.injectEdge(mee); mee.setValue(1); DeadServer d = new DeadServer(); d.putIfAbsent(hostname123); mee.incValue(1); d.putIfAbsent(hostname1234); mee.incValue(1); d.putIfAbsent(hostname12345); List<Pair<ServerName, Long>> copy = d.copyDeadServersSince(2L); Assert.assertEquals(2, copy.size()); Assert.assertEquals(hostname1234, copy.get(0).getFirst()); Assert.assertEquals(new Long(2L), copy.get(0).getSecond()); Assert.assertEquals(hostname12345, copy.get(1).getFirst()); Assert.assertEquals(new Long(3L), copy.get(1).getSecond()); EnvironmentEdgeManager.reset(); }
Example #18
Source File: FavoredNodeLoadBalancer.java From hbase with Apache License 2.0 | 6 votes |
private Set<ServerName> getInheritedFNForDaughter(FavoredNodeAssignmentHelper helper, List<ServerName> parentFavoredNodes, Position primary, Position secondary) throws IOException { Set<ServerName> daughterFN = Sets.newLinkedHashSet(); if (parentFavoredNodes.size() >= primary.ordinal()) { daughterFN.add(parentFavoredNodes.get(primary.ordinal())); } if (parentFavoredNodes.size() >= secondary.ordinal()) { daughterFN.add(parentFavoredNodes.get(secondary.ordinal())); } while (daughterFN.size() < FavoredNodeAssignmentHelper.FAVORED_NODES_NUM) { ServerName newNode = helper.generateMissingFavoredNode(Lists.newArrayList(daughterFN)); daughterFN.add(newNode); } return daughterFN; }
Example #19
Source File: TableInfo.java From hbase-tools with Apache License 2.0 | 6 votes |
Set<Integer> getServerIndexes(Args args) { if (indexRSs == null) { indexRSs = new HashSet<>(); if (args.has(Args.OPTION_REGION_SERVER)) { Object arg = args.valueOf(Args.OPTION_REGION_SERVER); if (arg != null) { int i = 0; for (ServerName serverName : serverNameSet) { if (serverName.getServerName().matches((String) arg)) { indexRSs.add(i); } i++; } if (indexRSs.size() == 0) throw new IllegalStateException(arg + " is invalid"); } } } return indexRSs; }
Example #20
Source File: RegionStates.java From hbase with Apache License 2.0 | 5 votes |
public Map<RegionInfo, ServerName> getRegionAssignments() { final HashMap<RegionInfo, ServerName> assignments = new HashMap<RegionInfo, ServerName>(); for (RegionStateNode node: regionsMap.values()) { assignments.put(node.getRegionInfo(), node.getRegionLocation()); } return assignments; }
Example #21
Source File: RegionMover.java From hbase with Apache License 2.0 | 5 votes |
public MoveWithAck(RegionInfo regionInfo, ServerName sourceServer, ServerName targetServer, List<RegionInfo> movedRegions) { this.region = regionInfo; this.targetServer = targetServer; this.movedRegions = movedRegions; this.sourceServer = sourceServer; }
Example #22
Source File: SimpleLoadBalancer.java From hbase with Apache License 2.0 | 5 votes |
/** * Override to invoke {@link #setClusterLoad} before balance, We need clusterLoad of all regions * on every server to achieve overall balanced */ @Override public synchronized List<RegionPlan> balanceCluster(Map<TableName, Map<ServerName, List<RegionInfo>>> loadOfAllTable) { setClusterLoad(loadOfAllTable); return super.balanceCluster(loadOfAllTable); }
Example #23
Source File: TestRequestsPerSecondMetric.java From hbase with Apache License 2.0 | 5 votes |
@Test /** * This test will confirm no negative value in requestsPerSecond metric during any region * transition(close region/remove region/move region). * Firstly, load 2000 random rows for 25 regions and will trigger a metric. * Now, metricCache will have a current read and write requests count. * Next, we disable a table and all of its 25 regions will be closed. * As part of region close, his metric will also be removed from metricCache. * prior to HBASE-23237, we do not remove/reset his metric so we incorrectly compute * (currentRequestCount - lastRequestCount) which result into negative value. * * @throws IOException * @throws InterruptedException */ public void testNoNegativeSignAtRequestsPerSecond() throws IOException, InterruptedException { final TableName TABLENAME = TableName.valueOf("t"); final String FAMILY = "f"; Admin admin = UTIL.getAdmin(); UTIL.createMultiRegionTable(TABLENAME, FAMILY.getBytes(),25); Table table = admin.getConnection().getTable(TABLENAME); ServerName serverName = admin.getRegionServers().iterator().next(); HRegionServer regionServer = UTIL.getMiniHBaseCluster().getRegionServer(serverName); MetricsRegionServerWrapperImpl metricsWrapper = new MetricsRegionServerWrapperImpl(regionServer); MetricsRegionServerWrapperImpl.RegionServerMetricsWrapperRunnable metricsServer = metricsWrapper.new RegionServerMetricsWrapperRunnable(); metricsServer.run(); UTIL.loadRandomRows(table, FAMILY.getBytes(), 1, 2000); Thread.sleep(METRICS_PERIOD); metricsServer.run(); admin.disableTable(TABLENAME); Thread.sleep(METRICS_PERIOD); metricsServer.run(); Assert.assertTrue(metricsWrapper.getRequestsPerSecond() > -1); }
Example #24
Source File: BalanceRuleTest.java From hbase-tools with Apache License 2.0 | 5 votes |
@Test public void testBalanceRR() throws Exception { splitTable("a".getBytes()); splitTable("b".getBytes()); splitTable("c".getBytes()); NavigableMap<HRegionInfo, ServerName> regionLocations; List<Map.Entry<HRegionInfo, ServerName>> hRegionInfoList; try (HTable table = getTable(tableName)) { regionLocations = table.getRegionLocations(); hRegionInfoList = new ArrayList<>(regionLocations.entrySet()); Assert.assertEquals(4, regionLocations.size()); Assert.assertEquals(hRegionInfoList.get(0).getValue(), hRegionInfoList.get(1).getValue()); Assert.assertEquals(hRegionInfoList.get(0).getValue(), hRegionInfoList.get(2).getValue()); Assert.assertEquals(hRegionInfoList.get(0).getValue(), hRegionInfoList.get(3).getValue()); String[] argsParam = {"zookeeper", tableName, "rR", "--force-proceed"}; Args args = new ManagerArgs(argsParam); Assert.assertEquals("zookeeper", args.getZookeeperQuorum()); Balance command = new Balance(admin, args); command.run(); regionLocations = table.getRegionLocations(); hRegionInfoList = new ArrayList<>(regionLocations.entrySet()); Assert.assertNotEquals(hRegionInfoList.get(0).getValue(), hRegionInfoList.get(1).getValue()); Assert.assertNotEquals(hRegionInfoList.get(2).getValue(), hRegionInfoList.get(3).getValue()); } }
Example #25
Source File: SplitRegionScannerIT.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Test public void moveRegionDuringScan() throws SQLException, IOException, InterruptedException { String tableNameStr = sqlUtil.getConglomID(spliceTableWatcherI.toString()); Partition partition = driver.getTableFactory().getTable(tableNameStr); Table htable = ((ClientPartition) partition).unwrapDelegate(); int i = 0; try (Admin admin = connection.getAdmin()) { HRegionLocation regionLocation = getRegionLocation(tableNameStr, admin); Collection<ServerName> allServers = getAllServers(admin); ServerName newServer = getNotIn(allServers, regionLocation.getServerName()); List<Cell> newCells = new ArrayList<>(); Scan scan = new Scan(); SplitRegionScanner srs = new SplitRegionScanner(scan, htable, clock, partition, driver.getConfiguration(), htable.getConfiguration()); while (srs.next(newCells)) { if (i++ == ITERATIONS / 2) { // JL - TODO Now that we are blocking moves, this hangs. // admin.move(regionLocation.getRegionInfo().getEncodedNameAsBytes(), Bytes.toBytes(newServer.getServerName())); } newCells.clear(); } srs.close(); htable.close(); } Assert.assertEquals("Did not return all rows ", ITERATIONS, i); }
Example #26
Source File: ReplicationSinkManager.java From hbase with Apache License 2.0 | 5 votes |
/** * Report a {@code SinkPeer} as being bad (i.e. an attempt to replicate to it * failed). If a single SinkPeer is reported as bad more than * replication.bad.sink.threshold times, it will be removed * from the pool of potential replication targets. * * @param sinkPeer * The SinkPeer that had a failed replication attempt on it */ public synchronized void reportBadSink(SinkPeer sinkPeer) { ServerName serverName = sinkPeer.getServerName(); int badReportCount = (badReportCounts.containsKey(serverName) ? badReportCounts.get(serverName) : 0) + 1; badReportCounts.put(serverName, badReportCount); if (badReportCount > badSinkThreshold) { this.sinks.remove(serverName); if (sinks.isEmpty()) { chooseSinks(); } } }
Example #27
Source File: ProtobufUtil.java From hbase with Apache License 2.0 | 5 votes |
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo rsGroupInfo = new RSGroupInfo(proto.getName()); for (HBaseProtos.ServerName el : proto.getServersList()) { rsGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for (HBaseProtos.TableName pTableName : proto.getTablesList()) { rsGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } proto.getConfigurationList().forEach(pair -> rsGroupInfo.setConfiguration(pair.getName(), pair.getValue())); return rsGroupInfo; }
Example #28
Source File: MasterRegistry.java From hbase with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<ServerName> getActiveMaster() { return this .<GetActiveMasterResponse> call( (c, s, d) -> s.getActiveMaster(c, GetActiveMasterRequest.getDefaultInstance(), d), GetActiveMasterResponse::hasServerName, "getActiveMaster()") .thenApply(this::transformServerName); }
Example #29
Source File: Level.java From hbase-tools with Apache License 2.0 | 5 votes |
public boolean equalsName(String name) { if (name == null) return false; if (level instanceof RegionName) { return ((RegionName) level).name().equals(name); } else if (level instanceof ServerName) { return ((ServerName) level).getServerName().equals(name); } else if (level instanceof TableName) { return ((TableName) level).getTableName().equals(name); } else if (level instanceof String) { return level.equals(name); } else throw new RuntimeException("can not equalsName"); }
Example #30
Source File: TestUpdateConfiguration.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testMasterOnlineConfigChange() throws IOException { LOG.debug("Starting the test {}", name.getMethodName()); replaceHBaseSiteXML(); Admin admin = TEST_UTIL.getAdmin(); ServerName server = TEST_UTIL.getHBaseCluster().getMaster().getServerName(); admin.updateConfiguration(server); Configuration conf = TEST_UTIL.getMiniHBaseCluster().getMaster().getConfiguration(); int custom = conf.getInt("hbase.custom.config", 0); assertEquals(1000, custom); restoreHBaseSiteXML(); }