Search in sources :

Example 6 with NameStringPair

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();
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) ForeignExceptionDispatcher(org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher) NameStringPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair) ServerName(org.apache.hadoop.hbase.ServerName) ForeignException(org.apache.hadoop.hbase.errorhandling.ForeignException) Procedure(org.apache.hadoop.hbase.procedure.Procedure)

Example 7 with NameStringPair

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();
    }
}
Also used : NameStringPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) JvmPauseMonitor(org.apache.hadoop.hbase.util.JvmPauseMonitor)

Aggregations

NameStringPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair)7 IOException (java.io.IOException)5 InterruptedIOException (java.io.InterruptedIOException)3 ProcedureDescription (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription)3 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)2 MasterNotRunningException (org.apache.hadoop.hbase.MasterNotRunningException)2 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)2 NotServingRegionException (org.apache.hadoop.hbase.NotServingRegionException)2 TableExistsException (org.apache.hadoop.hbase.TableExistsException)2 TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)2 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)2 UnknownRegionException (org.apache.hadoop.hbase.UnknownRegionException)2 ZooKeeperConnectionException (org.apache.hadoop.hbase.ZooKeeperConnectionException)2 TimeoutIOException (org.apache.hadoop.hbase.exceptions.TimeoutIOException)2 FailedLogCloseException (org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException)2 ReplicationException (org.apache.hadoop.hbase.replication.ReplicationException)2 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)2 ExecProcedureRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.ExecProcedureRequest)2