Java Code Examples for org.apache.hadoop.hbase.ServerName#getStartcode()
The following examples show how to use
org.apache.hadoop.hbase.ServerName#getStartcode() .
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: AbstractFSWALProvider.java From hbase with Apache License 2.0 | 6 votes |
/** * This function returns region server name from a log file name which is in one of the following * formats: * <ul> * <li>hdfs://<name node>/hbase/.logs/<server name>-splitting/...</li> * <li>hdfs://<name node>/hbase/.logs/<server name>/...</li> * </ul> * @return null if the passed in logFile isn't a valid WAL file path */ public static ServerName getServerNameFromWALDirectoryName(Path logFile) { String logDirName = logFile.getParent().getName(); // We were passed the directory and not a file in it. if (logDirName.equals(HConstants.HREGION_LOGDIR_NAME)) { logDirName = logFile.getName(); } ServerName serverName = null; if (logDirName.endsWith(SPLITTING_EXT)) { logDirName = logDirName.substring(0, logDirName.length() - SPLITTING_EXT.length()); } try { serverName = ServerName.parseServerName(logDirName); } catch (IllegalArgumentException | IllegalStateException ex) { serverName = null; LOG.warn("Cannot parse a server name from path=" + logFile + "; " + ex.getMessage()); } if (serverName != null && serverName.getStartcode() < 0) { LOG.warn("Invalid log file path=" + logFile); serverName = null; } return serverName; }
Example 2
Source File: MockMasterServices.java From hbase with Apache License 2.0 | 6 votes |
/** * Call this restart method only after running MockMasterServices#start() * The RSs can be differentiated by the port number, see * ServerName in MockMasterServices#start() method above. * Restart of region server will have new startcode in server name * * @param serverName Server name to be restarted */ public void restartRegionServer(ServerName serverName) throws IOException { List<ServerName> onlineServers = serverManager.getOnlineServersList(); long startCode = -1; for (ServerName s : onlineServers) { if (s.getAddress().equals(serverName.getAddress())) { startCode = s.getStartcode() + 1; break; } } if (startCode == -1) { return; } ServerName sn = ServerName.valueOf(serverName.getAddress().toString(), startCode); serverManager.regionServerReport(sn, ServerMetricsBuilder.of(sn)); }
Example 3
Source File: ProtobufUtil.java From hbase with Apache License 2.0 | 6 votes |
/** * Convert a ServerName to a protocol buffer ServerName * * @param serverName the ServerName to convert * @return the converted protocol buffer ServerName * @see #toServerName(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ServerName) */ public static HBaseProtos.ServerName toServerName(final ServerName serverName) { if (serverName == null) { return null; } HBaseProtos.ServerName.Builder builder = HBaseProtos.ServerName.newBuilder(); builder.setHostName(serverName.getHostname()); if (serverName.getPort() >= 0) { builder.setPort(serverName.getPort()); } if (serverName.getStartcode() >= 0) { builder.setStartCode(serverName.getStartcode()); } return builder.build(); }
Example 4
Source File: ClusterStatusListener.java From hbase with Apache License 2.0 | 6 votes |
/** * Check if we know if a server is dead. * * @param sn the server name to check. * @return true if we know for sure that the server is dead, false otherwise. */ public boolean isDeadServer(ServerName sn) { if (sn.getStartcode() <= 0) { return false; } for (ServerName dead : deadServers) { if (dead.getStartcode() >= sn.getStartcode() && dead.getPort() == sn.getPort() && dead.getHostname().equals(sn.getHostname())) { return true; } } return false; }
Example 5
Source File: ServerManager.java From hbase with Apache License 2.0 | 5 votes |
/** * Check is a server of same host and port already exists, * if not, or the existed one got a smaller start code, record it. * * @param serverName the server to check and record * @param sl the server load on the server * @return true if the server is recorded, otherwise, false */ boolean checkAndRecordNewServer(final ServerName serverName, final ServerMetrics sl) { ServerName existingServer = null; synchronized (this.onlineServers) { existingServer = findServerWithSameHostnamePortWithLock(serverName); if (existingServer != null && (existingServer.getStartcode() > serverName.getStartcode())) { LOG.info("Server serverName=" + serverName + " rejected; we already have " + existingServer.toString() + " registered with same hostname and port"); return false; } recordNewServerWithLock(serverName, sl); } // Tell our listeners that a server was added if (!this.listeners.isEmpty()) { for (ServerListener listener : this.listeners) { listener.serverAdded(serverName); } } // Note that we assume that same ts means same server, and don't expire in that case. // TODO: ts can theoretically collide due to clock shifts, so this is a bit hacky. if (existingServer != null && (existingServer.getStartcode() < serverName.getStartcode())) { LOG.info("Triggering server recovery; existingServer " + existingServer + " looks stale, new server:" + serverName); expireServer(existingServer); } return true; }
Example 6
Source File: StartcodeAgnosticServerName.java From hbase with Apache License 2.0 | 4 votes |
public static StartcodeAgnosticServerName valueOf(final ServerName serverName) { return new StartcodeAgnosticServerName(serverName.getHostname(), serverName.getPort(), serverName.getStartcode()); }
Example 7
Source File: RegionMovedException.java From hbase with Apache License 2.0 | 4 votes |
public RegionMovedException(ServerName serverName, long locationSeqNum) { this.hostname = serverName.getHostname(); this.port = serverName.getPort(); this.startCode = serverName.getStartcode(); this.locationSeqNum = locationSeqNum; }