Search in sources :

Example 6 with Procedure

use of org.apache.hadoop.hbase.procedure.Procedure 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<>();
    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 = Bytes.toBytes(conf.get(0).getValue());
    }
    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)

Aggregations

Procedure (org.apache.hadoop.hbase.procedure.Procedure)6 ForeignException (org.apache.hadoop.hbase.errorhandling.ForeignException)5 ServerName (org.apache.hadoop.hbase.ServerName)4 HashSet (java.util.HashSet)3 HBaseSnapshotException (org.apache.hadoop.hbase.snapshot.HBaseSnapshotException)3 IOException (java.io.IOException)2 TableName (org.apache.hadoop.hbase.TableName)2 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)2 ForeignExceptionDispatcher (org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher)2 ArrayList (java.util.ArrayList)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 MasterCoprocessorHost (org.apache.hadoop.hbase.master.MasterCoprocessorHost)1 SnapshotSentinel (org.apache.hadoop.hbase.master.SnapshotSentinel)1 CloneSnapshotProcedure (org.apache.hadoop.hbase.master.procedure.CloneSnapshotProcedure)1 RestoreSnapshotProcedure (org.apache.hadoop.hbase.master.procedure.RestoreSnapshotProcedure)1 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)1 NameStringPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair)1 UnknownSnapshotException (org.apache.hadoop.hbase.snapshot.UnknownSnapshotException)1 Pair (org.apache.hadoop.hbase.util.Pair)1