@Override protected RSRpcServices createRpcServices() throws IOException { return new MasterRpcServices(this); }
/** * @return Subset of configuration to pass initializing regionservers: e.g. * the filesystem to use and root directory to use. */ private RegionServerStartupResponse.Builder createConfigurationSubset() { RegionServerStartupResponse.Builder resp = addConfig( RegionServerStartupResponse.newBuilder(), HConstants.HBASE_DIR); resp = addConfig(resp, "fs.defaultFS"); return addConfig(resp, "hbase.master.info.port"); }
@SuppressWarnings("unchecked") @Before public void setup() { masterServices = mock(MasterRpcServices.class); when(masterServices.hasAccessControlServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.hasVisibilityLabelsServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.checkCoprocessorWithService( any(List.class), any(Class.class))).thenCallRealMethod(); }
@Override public SetBalancerRunningResponse setBalancerRunning(RpcController c, SetBalancerRunningRequest req) throws ServiceException { try { master.checkInitialized(); boolean prevValue = (req.getSynchronous())? synchronousBalanceSwitch(req.getOn()) : master.balanceSwitch(req.getOn()); return SetBalancerRunningResponse.newBuilder().setPrevBalanceValue(prevValue).build(); } catch (IOException ioe) { throw new ServiceException(ioe); } }
if (master.cpHost != null && hasAccessControlServiceCoprocessor(master.cpHost)) { if (AccessChecker.isAuthorizationSupported(master.getConfiguration())) { capabilities.add(SecurityCapabilitiesResponse.Capability.AUTHORIZATION); if (master.cpHost != null && hasVisibilityLabelsServiceCoprocessor(master.cpHost)) { if (VisibilityController.isCellAuthorizationSupported(master.getConfiguration())) { capabilities.add(SecurityCapabilitiesResponse.Capability.CELL_VISIBILITY);
/** * Determines if there is a MasterCoprocessor deployed which implements * {@link org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService.Interface}. */ boolean hasVisibilityLabelsServiceCoprocessor(MasterCoprocessorHost cpHost) { return checkCoprocessorWithService( cpHost.findCoprocessors(MasterCoprocessor.class), VisibilityLabelsService.Interface.class); }
boolean synchronousBalanceSwitch(final boolean b) throws IOException { return switchBalancer(b, BalanceSwitchMode.SYNC); }
boolean splitEnabled = true, mergeEnabled = true; try { splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null, RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled(); } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) { mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null, RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled(); } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) {
@Override public RegionServerStartupResponse regionServerStartup(RpcController controller, RegionServerStartupRequest request) throws ServiceException { // Register with server manager try { master.checkServiceStarted(); int versionNumber = 0; String version = "0.0.0"; VersionInfo versionInfo = VersionInfoUtil.getCurrentClientVersionInfo(); if (versionInfo != null) { version = versionInfo.getVersion(); versionNumber = VersionInfoUtil.getVersionNumber(versionInfo); } InetAddress ia = master.getRemoteInetAddress(request.getPort(), request.getServerStartCode()); // if regionserver passed hostname to use, // then use it instead of doing a reverse DNS lookup ServerName rs = master.getServerManager().regionServerStartup(request, versionNumber, version, ia); // Send back some config info RegionServerStartupResponse.Builder resp = createConfigurationSubset(); NameStringPair.Builder entry = NameStringPair.newBuilder() .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER).setValue(rs.getHostname()); resp.addMapEntries(entry.build()); return resp.build(); } catch (IOException ioe) { throw new ServiceException(ioe); } }
UTIL.startMiniCluster(2); UTIL.getMiniHBaseCluster().getMaster().getMasterRpcServices().synchronousBalanceSwitch(false); LOG.info("\n\nCreating tables"); for (TableName TABLE : TABLES) {
/** * Determines if there is a MasterCoprocessor deployed which implements * {@link org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService.Interface}. */ boolean hasAccessControlServiceCoprocessor(MasterCoprocessorHost cpHost) { return checkCoprocessorWithService( cpHost.findCoprocessors(MasterCoprocessor.class), AccessControlService.Interface.class); }
public boolean balanceSwitch(final boolean b) throws IOException { return getMasterRpcServices().switchBalancer(b, BalanceSwitchMode.ASYNC); }
when(masterRpcServices.isSplitOrMergeEnabled(any(), any())).thenReturn( IsSplitOrMergeEnabledResponse.newBuilder().setEnabled(true).build());
@Override public RegionServerStartupResponse regionServerStartup( RpcController controller, RegionServerStartupRequest request) throws ServiceException { // Register with server manager try { master.checkServiceStarted(); InetAddress ia = master.getRemoteInetAddress( request.getPort(), request.getServerStartCode()); // if regionserver passed hostname to use, // then use it instead of doing a reverse DNS lookup ServerName rs = master.serverManager.regionServerStartup(request, ia); // Send back some config info RegionServerStartupResponse.Builder resp = createConfigurationSubset(); NameStringPair.Builder entry = NameStringPair.newBuilder() .setName(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER) .setValue(rs.getHostname()); resp.addMapEntries(entry.build()); return resp.build(); } catch (IOException ioe) { throw new ServiceException(ioe); } }
@SuppressWarnings("unchecked") @Before public void setup() { masterServices = mock(MasterRpcServices.class); when(masterServices.hasAccessControlServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.hasVisibilityLabelsServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.checkCoprocessorWithService( any(List.class), any(Class.class))).thenCallRealMethod(); }
@Override public SetBalancerRunningResponse setBalancerRunning(RpcController c, SetBalancerRunningRequest req) throws ServiceException { try { master.checkInitialized(); boolean prevValue = (req.getSynchronous())? synchronousBalanceSwitch(req.getOn()) : master.balanceSwitch(req.getOn()); return SetBalancerRunningResponse.newBuilder().setPrevBalanceValue(prevValue).build(); } catch (IOException ioe) { throw new ServiceException(ioe); } }
@Test public void testVisibilityLabelServices() { MasterCoprocessor defaultImpl = new VisibilityController(); MasterCoprocessor customImpl = new MockVisibilityController(); MasterCoprocessor unrelatedImpl = new JMXListener(); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(defaultImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(customImpl), VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.emptyList(), VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( null, VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.singletonList(unrelatedImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, customImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, defaultImpl), VisibilityLabelsService.Interface.class)); } }
boolean synchronousBalanceSwitch(final boolean b) throws IOException { return switchBalancer(b, BalanceSwitchMode.SYNC); }
when(masterRpcServices.isSplitOrMergeEnabled(any(), any())).thenReturn( IsSplitOrMergeEnabledResponse.newBuilder().setEnabled(true).build());
/** * @return Subset of configuration to pass initializing regionservers: e.g. * the filesystem to use and root directory to use. */ private RegionServerStartupResponse.Builder createConfigurationSubset() { RegionServerStartupResponse.Builder resp = addConfig( RegionServerStartupResponse.newBuilder(), HConstants.HBASE_DIR); resp = addConfig(resp, "fs.defaultFS"); return addConfig(resp, "hbase.master.info.port"); }