use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair in project hbase by apache.
the class LogRollMasterProcedureManager method execProcedure.
@Override
public void execProcedure(ProcedureDescription desc) throws IOException {
if (!isBackupEnabled()) {
LOG.warn("Backup is not enabled. Check your " + BackupRestoreConstants.BACKUP_ENABLE_KEY + " setting");
return;
}
this.done = false;
// start the process on the RS
ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher(desc.getInstance());
List<ServerName> serverNames = master.getServerManager().getOnlineServersList();
List<String> servers = new ArrayList<String>();
for (ServerName sn : serverNames) {
servers.add(sn.toString());
}
List<NameStringPair> conf = desc.getConfigurationList();
byte[] data = new byte[0];
if (conf.size() > 0) {
// Get backup root path
data = conf.get(0).getValue().getBytes();
}
Procedure proc = coordinator.startProcedure(monitor, desc.getInstance(), data, servers);
if (proc == null) {
String msg = "Failed to submit distributed procedure for '" + desc.getInstance() + "'";
LOG.error(msg);
throw new IOException(msg);
}
try {
// wait for the procedure to complete. A timer thread is kicked off that should cancel this
// if it takes too long.
proc.waitForCompleted();
LOG.info("Done waiting - exec procedure for " + desc.getInstance());
LOG.info("Distributed roll log procedure is successful!");
this.done = true;
} catch (InterruptedException e) {
ForeignException ee = new ForeignException("Interrupted while waiting for roll log procdure to finish", e);
monitor.receive(ee);
Thread.currentThread().interrupt();
} catch (ForeignException e) {
ForeignException ee = new ForeignException("Exception while waiting for roll log procdure to finish", e);
monitor.receive(ee);
}
monitor.rethrowException();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair in project hbase by apache.
the class HRegionServer method handleReportForDutyResponse.
/*
* Run init. Sets up wal and starts up all server threads.
*
* @param c Extra configuration.
*/
protected void handleReportForDutyResponse(final RegionServerStartupResponse c) throws IOException {
try {
boolean updateRootDir = false;
for (NameStringPair e : c.getMapEntriesList()) {
String key = e.getName();
// The hostname the master sees us as.
if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
String hostnameFromMasterPOV = e.getValue();
this.serverName = ServerName.valueOf(hostnameFromMasterPOV, rpcServices.isa.getPort(), this.startcode);
if (shouldUseThisHostnameInstead() && !hostnameFromMasterPOV.equals(useThisHostnameInstead)) {
String msg = "Master passed us a different hostname to use; was=" + this.useThisHostnameInstead + ", but now=" + hostnameFromMasterPOV;
LOG.error(msg);
throw new IOException(msg);
}
if (!shouldUseThisHostnameInstead() && !hostnameFromMasterPOV.equals(rpcServices.isa.getHostName())) {
String msg = "Master passed us a different hostname to use; was=" + rpcServices.isa.getHostName() + ", but now=" + hostnameFromMasterPOV;
LOG.error(msg);
}
continue;
}
String value = e.getValue();
if (key.equals(HConstants.HBASE_DIR)) {
if (value != null && !value.equals(conf.get(HConstants.HBASE_DIR))) {
updateRootDir = true;
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Config from master: " + key + "=" + value);
}
this.conf.set(key, value);
}
// Set our ephemeral znode up in zookeeper now we have a name.
createMyEphemeralNode();
if (updateRootDir) {
// initialize file system by the config fs.defaultFS and hbase.rootdir from master
initializeFileSystem();
}
// config param for task trackers, but we can piggyback off of it.
if (this.conf.get("mapreduce.task.attempt.id") == null) {
this.conf.set("mapreduce.task.attempt.id", "hb_rs_" + this.serverName.toString());
}
// Save it in a file, this will allow to see if we crash
ZNodeClearer.writeMyEphemeralNodeOnDisk(getMyEphemeralNodePath());
this.walFactory = setupWALAndReplication();
// Init in here rather than in constructor after thread name has been set
this.metricsRegionServer = new MetricsRegionServer(new MetricsRegionServerWrapperImpl(this));
this.metricsTable = new MetricsTable(new MetricsTableWrapperAggregateImpl(this));
// Now that we have a metrics source, start the pause monitor
this.pauseMonitor = new JvmPauseMonitor(conf, getMetrics().getMetricsSource());
pauseMonitor.start();
startServiceThreads();
startHeapMemoryManager();
// Call it after starting HeapMemoryManager.
initializeMemStoreChunkPool();
LOG.info("Serving as " + this.serverName + ", RpcServer on " + rpcServices.isa + ", sessionid=0x" + Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()));
// Wake up anyone waiting for this server to online
synchronized (online) {
online.set(true);
online.notifyAll();
}
} catch (Throwable e) {
stop("Failed initialization");
throw convertThrowableToIOE(cleanup(e, "Failed init"), "Region server startup failed");
} finally {
sleeper.skipSleepCycle();
}
}
Aggregations