Java Code Examples for org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toServerName()
The following examples show how to use
org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#toServerName() .
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: BackupManifest.java From hbase with Apache License 2.0 | 6 votes |
private static HashMap<TableName, HashMap<String, Long>> loadIncrementalTimestampMap( BackupProtos.BackupImage proto) { List<BackupProtos.TableServerTimestamp> list = proto.getTstMapList(); HashMap<TableName, HashMap<String, Long>> incrTimeRanges = new HashMap<>(); if (list == null || list.size() == 0) { return incrTimeRanges; } for (BackupProtos.TableServerTimestamp tst : list) { TableName tn = ProtobufUtil.toTableName(tst.getTableName()); HashMap<String, Long> map = incrTimeRanges.get(tn); if (map == null) { map = new HashMap<>(); incrTimeRanges.put(tn, map); } List<BackupProtos.ServerTimestamp> listSt = tst.getServerTimestampList(); for (BackupProtos.ServerTimestamp stm : listSt) { ServerName sn = ProtobufUtil.toServerName(stm.getServerName()); map.put(sn.getHostname() + ":" + sn.getPort(), stm.getTimestamp()); } } return incrTimeRanges; }
Example 2
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 6 votes |
@Override public MasterProtos.ScheduleServerCrashProcedureResponse scheduleServerCrashProcedure( RpcController controller, MasterProtos.ScheduleServerCrashProcedureRequest request) throws ServiceException { List<Long> pids = new ArrayList<>(); for (HBaseProtos.ServerName sn: request.getServerNameList()) { ServerName serverName = ProtobufUtil.toServerName(sn); LOG.info("{} schedule ServerCrashProcedure for {}", this.master.getClientIdAuditPrefix(), serverName); if (shouldSubmitSCP(serverName)) { pids.add(this.master.getServerManager().expireServer(serverName, true)); } else { pids.add(Procedure.NO_PROC_ID); } } return MasterProtos.ScheduleServerCrashProcedureResponse.newBuilder().addAllPid(pids).build(); }
Example 3
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 6 votes |
@Override public RecommissionRegionServerResponse recommissionRegionServer(RpcController controller, RecommissionRegionServerRequest request) throws ServiceException { try { master.checkInitialized(); ServerName server = ProtobufUtil.toServerName(request.getServerName()); List<byte[]> encodedRegionNames = request.getRegionList().stream() .map(regionSpecifier -> regionSpecifier.getValue().toByteArray()) .collect(Collectors.toList()); if (master.cpHost != null) { master.cpHost.preRecommissionRegionServer(server, encodedRegionNames); } master.recommissionRegionServer(server, encodedRegionNames); if (master.cpHost != null) { master.cpHost.postRecommissionRegionServer(server, encodedRegionNames); } } catch (IOException io) { throw new ServiceException(io); } return RecommissionRegionServerResponse.newBuilder().build(); }
Example 4
Source File: ServerCrashProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.ServerCrashStateData state = serializer.deserialize(MasterProcedureProtos.ServerCrashStateData.class); this.serverName = ProtobufUtil.toServerName(state.getServerName()); this.carryingMeta = state.hasCarryingMeta()? state.getCarryingMeta(): false; // shouldSplitWAL has a default over in pb so this invocation will always work. this.shouldSplitWal = state.getShouldSplitWal(); int size = state.getRegionsOnCrashedServerCount(); if (size > 0) { this.regionsOnCrashedServer = new ArrayList<>(size); for (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionInfo ri: state.getRegionsOnCrashedServerList()) { this.regionsOnCrashedServer.add(ProtobufUtil.toRegionInfo(ri)); } } updateProgress(false); }
Example 5
Source File: TestMetaWithReplicasBasic.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testZookeeperNodesForReplicas() throws Exception { // Checks all the znodes exist when meta's replicas are enabled ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher(); Configuration conf = TEST_UTIL.getConfiguration(); String baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); String primaryMetaZnode = ZNodePaths.joinZNode(baseZNode, conf.get("zookeeper.znode.metaserver", "meta-region-server")); // check that the data in the znode is parseable (this would also mean the znode exists) byte[] data = ZKUtil.getData(zkw, primaryMetaZnode); ProtobufUtil.toServerName(data); for (int i = 1; i < 3; i++) { String secZnode = ZNodePaths.joinZNode(baseZNode, conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i); String str = zkw.getZNodePaths().getZNodeForReplica(i); assertTrue(str.equals(secZnode)); // check that the data in the znode is parseable (this would also mean the znode exists) data = ZKUtil.getData(zkw, secZnode); ProtobufUtil.toServerName(data); } }
Example 6
Source File: RSRpcServices.java From hbase with Apache License 2.0 | 6 votes |
/** * Close a region on the region server. * * @param controller the RPC controller * @param request the request * @throws ServiceException */ @Override @QosPriority(priority=HConstants.ADMIN_QOS) public CloseRegionResponse closeRegion(final RpcController controller, final CloseRegionRequest request) throws ServiceException { final ServerName sn = (request.hasDestinationServer() ? ProtobufUtil.toServerName(request.getDestinationServer()) : null); try { checkOpen(); throwOnWrongStartCode(request); final String encodedRegionName = ProtobufUtil.getRegionEncodedName(request.getRegion()); requestCount.increment(); if (sn == null) { LOG.info("Close " + encodedRegionName + " without moving"); } else { LOG.info("Close " + encodedRegionName + ", moving to " + sn); } boolean closed = regionServer.closeRegion(encodedRegionName, false, sn); CloseRegionResponse.Builder builder = CloseRegionResponse.newBuilder().setClosed(closed); return builder.build(); } catch (IOException ie) { throw new ServiceException(ie); } }
Example 7
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public ReportRSFatalErrorResponse reportRSFatalError( RpcController controller, ReportRSFatalErrorRequest request) throws ServiceException { String errorText = request.getErrorMessage(); ServerName sn = ProtobufUtil.toServerName(request.getServer()); String msg = sn + " reported a fatal error:\n" + errorText; LOG.warn(msg); master.rsFatals.add(msg); return ReportRSFatalErrorResponse.newBuilder().build(); }
Example 8
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public RegionServerReportResponse regionServerReport(RpcController controller, RegionServerReportRequest request) throws ServiceException { 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); } ClusterStatusProtos.ServerLoad sl = request.getLoad(); ServerName serverName = ProtobufUtil.toServerName(request.getServer()); ServerMetrics oldLoad = master.getServerManager().getLoad(serverName); ServerMetrics newLoad = ServerMetricsBuilder.toServerMetrics(serverName, versionNumber, version, sl); master.getServerManager().regionServerReport(serverName, newLoad); master.getAssignmentManager().reportOnlineRegions(serverName, newLoad.getRegionMetrics().keySet()); if (sl != null && master.metricsMaster != null) { // Up our metrics. master.metricsMaster.incrementRequests( sl.getTotalNumberOfRequests() - (oldLoad != null ? oldLoad.getRequestCount() : 0)); } } catch (IOException ioe) { throw new ServiceException(ioe); } return RegionServerReportResponse.newBuilder().build(); }
Example 9
Source File: SplitWALProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.SplitWALData data = serializer.deserialize(MasterProcedureProtos.SplitWALData.class); walPath = data.getWalPath(); crashedServer = ProtobufUtil.toServerName(data.getCrashedServer()); if (data.hasWorker()) { worker = ProtobufUtil.toServerName(data.getWorker()); } }
Example 10
Source File: SplitWALRemoteProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { MasterProcedureProtos.SplitWALRemoteData data = serializer.deserialize(MasterProcedureProtos.SplitWALRemoteData.class); walPath = data.getWalPath(); targetServer = ProtobufUtil.toServerName(data.getWorker()); crashedServer = ProtobufUtil.toServerName(data.getCrashedServer()); }
Example 11
Source File: RecoverMetaProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); MasterProcedureProtos.RecoverMetaStateData state = serializer.deserialize(MasterProcedureProtos.RecoverMetaStateData.class); this.shouldSplitWal = state.hasShouldSplitWal() && state.getShouldSplitWal(); this.failedMetaServer = state.hasFailedMetaServer() ? ProtobufUtil.toServerName(state.getFailedMetaServer()) : null; this.replicaId = state.hasReplicaId() ? state.getReplicaId() : RegionInfo.DEFAULT_REPLICA_ID; }
Example 12
Source File: CloseRegionProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); CloseRegionProcedureStateData data = serializer.deserialize(CloseRegionProcedureStateData.class); if (data.hasAssignCandidate()) { assignCandidate = ProtobufUtil.toServerName(data.getAssignCandidate()); } }
Example 13
Source File: MoveRegionProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); final MoveRegionStateData state = serializer.deserialize(MoveRegionStateData.class); final RegionInfo regionInfo = getRegion(); // Get it from super class deserialization. final ServerName sourceServer = ProtobufUtil.toServerName(state.getSourceServer()); final ServerName destinationServer = state.hasDestinationServer() ? ProtobufUtil.toServerName(state.getDestinationServer()) : null; this.plan = new RegionPlan(regionInfo, sourceServer, destinationServer); }
Example 14
Source File: RegionRemoteProcedureBase.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { RegionRemoteProcedureBaseStateData data = serializer.deserialize(RegionRemoteProcedureBaseStateData.class); region = ProtobufUtil.toRegionInfo(data.getRegion()); targetServer = ProtobufUtil.toServerName(data.getTargetServer()); state = data.getState(); if (data.hasTransitionCode()) { transitionCode = data.getTransitionCode(); seqId = data.getSeqId(); } }
Example 15
Source File: UnassignProcedure.java From hbase with Apache License 2.0 | 5 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { final UnassignRegionStateData state = serializer.deserialize(UnassignRegionStateData.class); setTransitionState(state.getTransitionState()); setRegionInfo(ProtobufUtil.toRegionInfo(state.getRegionInfo())); this.hostingServer = ProtobufUtil.toServerName(state.getHostingServer()); force = state.getForce(); if (state.hasDestinationServer()) { this.destinationServer = ProtobufUtil.toServerName(state.getDestinationServer()); } removeAfterUnassigning = state.getRemoveAfterUnassigning(); if (state.hasAttempt()) { setAttempt(state.getAttempt()); } }
Example 16
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public ClearDeadServersResponse clearDeadServers(RpcController controller, ClearDeadServersRequest request) throws ServiceException { LOG.debug(master.getClientIdAuditPrefix() + " clear dead region servers."); ClearDeadServersResponse.Builder response = ClearDeadServersResponse.newBuilder(); try { master.checkInitialized(); if (master.cpHost != null) { master.cpHost.preClearDeadServers(); } if (master.getServerManager().areDeadServersInProgress()) { LOG.debug("Some dead server is still under processing, won't clear the dead server list"); response.addAllServerName(request.getServerNameList()); } else { DeadServer deadServer = master.getServerManager().getDeadServers(); Set<Address> clearedServers = new HashSet<>(); for (HBaseProtos.ServerName pbServer : request.getServerNameList()) { ServerName server = ProtobufUtil.toServerName(pbServer); if (!deadServer.removeDeadServer(server)) { response.addServerName(pbServer); } else { clearedServers.add(server.getAddress()); } } master.getRSGroupInfoManager().removeServers(clearedServers); LOG.info("Remove decommissioned servers {} from RSGroup done", clearedServers); } if (master.cpHost != null) { master.cpHost.postClearDeadServers( ProtobufUtil.toServerNameList(request.getServerNameList()), ProtobufUtil.toServerNameList(response.getServerNameList())); } } catch (IOException io) { throw new ServiceException(io); } return response.build(); }
Example 17
Source File: SplitLogTask.java From hbase with Apache License 2.0 | 5 votes |
/** * @return This instance serialized into a byte array * @see #parseFrom(byte[]) */ public byte [] toByteArray() { // First create a pb ServerName. Then create a ByteString w/ the TaskState // bytes in it. Finally create a SplitLogTaskState passing in the two // pbs just created. HBaseProtos.ServerName snpb = ProtobufUtil.toServerName(this.originServer); ZooKeeperProtos.SplitLogTask slts = ZooKeeperProtos.SplitLogTask.newBuilder().setServerName(snpb).setState(this.state).build(); return ProtobufUtil.prependPBMagic(slts.toByteArray()); }
Example 18
Source File: FavoredNodeAssignmentHelper.java From hbase with Apache License 2.0 | 5 votes |
/** * @param favoredNodes The PB'ed bytes of favored nodes * @return the array of {@link ServerName} for the byte array of favored nodes. * @throws IOException */ public static ServerName[] getFavoredNodesList(byte[] favoredNodes) throws IOException { FavoredNodes f = FavoredNodes.parseFrom(favoredNodes); List<HBaseProtos.ServerName> protoNodes = f.getFavoredNodeList(); ServerName[] servers = new ServerName[protoNodes.size()]; int i = 0; for (HBaseProtos.ServerName node : protoNodes) { servers[i++] = ProtobufUtil.toServerName(node); } return servers; }
Example 19
Source File: TestSplitWALManager.java From hbase with Apache License 2.0 | 4 votes |
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { MasterProcedureProtos.SplitWALData data = serializer.deserialize(MasterProcedureProtos.SplitWALData.class); serverName = ProtobufUtil.toServerName(data.getCrashedServer()); }
Example 20
Source File: SplitLogTask.java From hbase with Apache License 2.0 | 4 votes |
SplitLogTask(final ZooKeeperProtos.SplitLogTask slt) { this.originServer = ProtobufUtil.toServerName(slt.getServerName()); this.state = slt.getState(); }