HBASE-18367 Reduce ProcedureInfo usage

Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
Balazs Meszaros 2017-07-12 10:02:49 +02:00 committed by Michael Stack
parent 9e230dc321
commit 45bd493b33
34 changed files with 325 additions and 299 deletions

View File

@ -466,6 +466,10 @@ public abstract class Procedure<TEnvironment> implements Comparable<Procedure<TE
return rootProcId;
}
public String getProcName() {
return toStringClass();
}
public NonceKey getNonceKey() {
return nonceKey;
}
@ -625,7 +629,7 @@ public abstract class Procedure<TEnvironment> implements Comparable<Procedure<TE
/**
* @return true if the procedure is in a RUNNABLE state.
*/
protected synchronized boolean isRunnable() {
public synchronized boolean isRunnable() {
return state == ProcedureState.RUNNABLE;
}
@ -677,7 +681,7 @@ public abstract class Procedure<TEnvironment> implements Comparable<Procedure<TE
}
@InterfaceAudience.Private
protected synchronized ProcedureState getState() {
public synchronized ProcedureState getState() {
return state;
}

View File

@ -22,12 +22,15 @@ import org.apache.hadoop.hbase.shaded.com.google.common.annotations.VisibleForTe
import org.apache.hadoop.hbase.shaded.com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@ -43,7 +46,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.exceptions.IllegalArgumentIOException;
@ -57,7 +59,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.Procedu
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.NonceKey;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Threads;
/**
@ -111,6 +112,37 @@ public class ProcedureExecutor<TEnvironment> {
void procedureFinished(long procId);
}
private static class CompletedProcedureRetainer {
private final Procedure<?> procedure;
private long clientAckTime;
public CompletedProcedureRetainer(Procedure<?> procedure) {
this.procedure = procedure;
clientAckTime = -1;
}
public Procedure<?> getProcedure() {
return procedure;
}
public boolean hasClientAckTime() {
return clientAckTime != -1;
}
public long getClientAckTime() {
return clientAckTime;
}
public void setClientAckTime(long clientAckTime) {
this.clientAckTime = clientAckTime;
}
public boolean isExpired(long now, long evictTtl, long evictAckTtl) {
return (hasClientAckTime() && (now - getClientAckTime()) >= evictAckTtl) ||
(now - procedure.getLastUpdate()) >= evictTtl;
}
}
/**
* Internal cleaner that removes the completed procedure results after a TTL.
* NOTE: This is a special case handled in timeoutLoop().
@ -144,13 +176,13 @@ public class ProcedureExecutor<TEnvironment> {
private static final String BATCH_SIZE_CONF_KEY = "hbase.procedure.cleaner.evict.batch.size";
private static final int DEFAULT_BATCH_SIZE = 32;
private final Map<Long, ProcedureInfo> completed;
private final Map<Long, CompletedProcedureRetainer> completed;
private final Map<NonceKey, Long> nonceKeysToProcIdsMap;
private final ProcedureStore store;
private Configuration conf;
public CompletedProcedureCleaner(final Configuration conf, final ProcedureStore store,
final Map<Long, ProcedureInfo> completedMap,
final Map<Long, CompletedProcedureRetainer> completedMap,
final Map<NonceKey, Long> nonceKeysToProcIdsMap) {
// set the timeout interval that triggers the periodic-procedure
super(conf.getInt(CLEANER_INTERVAL_CONF_KEY, DEFAULT_CLEANER_INTERVAL));
@ -177,17 +209,17 @@ public class ProcedureExecutor<TEnvironment> {
int batchCount = 0;
final long now = EnvironmentEdgeManager.currentTime();
final Iterator<Map.Entry<Long, ProcedureInfo>> it = completed.entrySet().iterator();
final Iterator<Map.Entry<Long, CompletedProcedureRetainer>> it = completed.entrySet().iterator();
final boolean debugEnabled = LOG.isDebugEnabled();
while (it.hasNext() && store.isRunning()) {
final Map.Entry<Long, ProcedureInfo> entry = it.next();
final ProcedureInfo procInfo = entry.getValue();
final Map.Entry<Long, CompletedProcedureRetainer> entry = it.next();
final CompletedProcedureRetainer retainer = entry.getValue();
final Procedure<?> proc = retainer.getProcedure();
// TODO: Select TTL based on Procedure type
if ((procInfo.hasClientAckTime() && (now - procInfo.getClientAckTime()) >= evictAckTtl) ||
(now - procInfo.getLastUpdate()) >= evictTtl) {
if (retainer.isExpired(now, evictTtl, evictAckTtl)) {
if (debugEnabled) {
LOG.debug("Evict completed " + procInfo);
LOG.debug("Evict completed " + proc);
}
batchIds[batchCount++] = entry.getKey();
if (batchCount == batchIds.length) {
@ -196,7 +228,7 @@ public class ProcedureExecutor<TEnvironment> {
}
it.remove();
final NonceKey nonceKey = procInfo.getNonceKey();
final NonceKey nonceKey = proc.getNonceKey();
if (nonceKey != null) {
nonceKeysToProcIdsMap.remove(nonceKey);
}
@ -213,7 +245,7 @@ public class ProcedureExecutor<TEnvironment> {
* Once a Root-Procedure completes (success or failure), the result will be added to this map.
* The user of ProcedureExecutor should call getResult(procId) to get the result.
*/
private final ConcurrentHashMap<Long, ProcedureInfo> completed = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Long, CompletedProcedureRetainer> completed = new ConcurrentHashMap<>();
/**
* Map the the procId returned by submitProcedure(), the Root-ProcID, to the RootProcedureState.
@ -296,7 +328,7 @@ public class ProcedureExecutor<TEnvironment> {
public void handleCorrupted(ProcedureIterator procIter) throws IOException {
int corruptedCount = 0;
while (procIter.hasNext()) {
ProcedureInfo proc = procIter.nextAsProcedureInfo();
Procedure<?> proc = procIter.next();
LOG.error("Corrupt " + proc);
corruptedCount++;
}
@ -314,22 +346,17 @@ public class ProcedureExecutor<TEnvironment> {
// 1. Build the rollback stack
int runnablesCount = 0;
while (procIter.hasNext()) {
final NonceKey nonceKey;
final long procId;
boolean finished = procIter.isNextFinished();
Procedure proc = procIter.next();
NonceKey nonceKey = proc.getNonceKey();
long procId = proc.getProcId();
if (procIter.isNextFinished()) {
ProcedureInfo proc = procIter.nextAsProcedureInfo();
nonceKey = proc.getNonceKey();
procId = proc.getProcId();
completed.put(proc.getProcId(), proc);
if (finished) {
completed.put(proc.getProcId(), new CompletedProcedureRetainer(proc));
if (debugEnabled) {
LOG.debug("Completed " + proc);
}
} else {
Procedure proc = procIter.nextAsProcedure();
nonceKey = proc.getNonceKey();
procId = proc.getProcId();
if (!proc.hasParent()) {
assert !proc.isFinished() : "unexpected finished procedure";
rollbackStack.put(proc.getProcId(), new RootProcedureState());
@ -360,7 +387,7 @@ public class ProcedureExecutor<TEnvironment> {
continue;
}
Procedure proc = procIter.nextAsProcedure();
Procedure proc = procIter.next();
assert !(proc.isFinished() && !proc.hasParent()) : "unexpected completed proc=" + proc;
if (debugEnabled) {
@ -723,6 +750,49 @@ public class ProcedureExecutor<TEnvironment> {
}
}
private static class FailedProcedure<TEnvironment> extends Procedure<TEnvironment> {
private String procName;
public FailedProcedure(NonceKey nonceKey, String procName, User owner,
IOException exception) {
this.procName = procName;
setNonceKey(nonceKey);
setOwner(owner);
setFailure(Objects.toString(exception.getMessage(), ""), exception);
}
@Override
public String getProcName() {
return procName;
}
@Override
protected Procedure<TEnvironment>[] execute(TEnvironment env)
throws ProcedureYieldException, ProcedureSuspendedException,
InterruptedException {
throw new UnsupportedOperationException();
}
@Override
protected void rollback(TEnvironment env)
throws IOException, InterruptedException {
throw new UnsupportedOperationException();
}
@Override
protected boolean abort(TEnvironment env) {
throw new UnsupportedOperationException();
}
@Override
protected void serializeStateData(OutputStream stream) throws IOException {
}
@Override
protected void deserializeStateData(InputStream stream) throws IOException {
}
}
/**
* If the failure failed before submitting it, we may want to give back the
* same error to the requests with the same nonceKey.
@ -739,12 +809,8 @@ public class ProcedureExecutor<TEnvironment> {
final Long procId = nonceKeysToProcIdsMap.get(nonceKey);
if (procId == null || completed.containsKey(procId)) return;
final long currentTime = EnvironmentEdgeManager.currentTime();
final ProcedureInfo result = new ProcedureInfo(procId.longValue(),
procName, procOwner != null ? procOwner.getShortName() : null,
ProcedureUtil.convertToProcedureState(ProcedureState.ROLLEDBACK),
-1, nonceKey, exception, currentTime, currentTime, null);
completed.putIfAbsent(procId, result);
Procedure proc = new FailedProcedure(nonceKey, procName, procOwner, exception);
completed.putIfAbsent(procId, new CompletedProcedureRetainer(proc));
}
// ==========================================================================
@ -893,8 +959,13 @@ public class ProcedureExecutor<TEnvironment> {
return null;
}
public ProcedureInfo getResult(final long procId) {
return completed.get(procId);
public Procedure getResult(final long procId) {
CompletedProcedureRetainer retainer = completed.get(procId);
if (retainer == null) {
return null;
} else {
return retainer.getProcedure();
}
}
/**
@ -926,8 +997,8 @@ public class ProcedureExecutor<TEnvironment> {
* @param procId the ID of the procedure to remove
*/
public void removeResult(final long procId) {
final ProcedureInfo result = completed.get(procId);
if (result == null) {
CompletedProcedureRetainer retainer = completed.get(procId);
if (retainer == null) {
assert !procedures.containsKey(procId) : "procId=" + procId + " is still running";
if (LOG.isDebugEnabled()) {
LOG.debug("procId=" + procId + " already removed by the cleaner.");
@ -936,20 +1007,17 @@ public class ProcedureExecutor<TEnvironment> {
}
// The CompletedProcedureCleaner will take care of deletion, once the TTL is expired.
result.setClientAckTime(EnvironmentEdgeManager.currentTime());
retainer.setClientAckTime(EnvironmentEdgeManager.currentTime());
}
public Pair<ProcedureInfo, Procedure> getResultOrProcedure(final long procId) {
ProcedureInfo result = completed.get(procId);
Procedure proc = null;
if (result == null) {
proc = procedures.get(procId);
if (proc == null) {
result = completed.get(procId);
public Procedure getResultOrProcedure(final long procId) {
CompletedProcedureRetainer retainer = completed.get(procId);
if (retainer == null) {
return procedures.get(procId);
} else {
return retainer.getProcedure();
}
}
return new Pair(result, proc);
}
/**
* Check if the user is this procedure's owner
@ -961,35 +1029,34 @@ public class ProcedureExecutor<TEnvironment> {
public boolean isProcedureOwner(final long procId, final User user) {
if (user == null) return false;
final Procedure proc = procedures.get(procId);
if (proc != null) {
return proc.getOwner().equals(user.getShortName());
final Procedure runningProc = procedures.get(procId);
if (runningProc != null) {
return runningProc.getOwner().equals(user.getShortName());
}
final CompletedProcedureRetainer retainer = completed.get(procId);
if (retainer != null) {
return retainer.getProcedure().getOwner().equals(user.getShortName());
}
final ProcedureInfo procInfo = completed.get(procId);
if (procInfo == null) {
// Procedure either does not exist or has already completed and got cleaned up.
// At this time, we cannot check the owner of the procedure
return false;
}
return ProcedureInfo.isProcedureOwner(procInfo, user);
}
/**
* List procedures.
* @return the procedures in a list
*/
public List<ProcedureInfo> listProcedures() {
final List<ProcedureInfo> procedureLists = new ArrayList<>(procedures.size() + completed.size());
for (Map.Entry<Long, Procedure> p: procedures.entrySet()) {
procedureLists.add(ProcedureUtil.convertToProcedureInfo(p.getValue()));
}
for (Map.Entry<Long, ProcedureInfo> e: completed.entrySet()) {
public List<Procedure> listProcedures() {
final List<Procedure> procedureLists = new ArrayList<>(procedures.size() + completed.size());
procedureLists.addAll(procedures.values());
// Note: The procedure could show up twice in the list with different state, as
// it could complete after we walk through procedures list and insert into
// procedureList - it is ok, as we will use the information in the ProcedureInfo
// to figure it out; to prevent this would increase the complexity of the logic.
procedureLists.add(e.getValue());
for (CompletedProcedureRetainer retainer: completed.values()) {
procedureLists.add(retainer.getProcedure());
}
return procedureLists;
}
@ -1595,13 +1662,14 @@ public class ProcedureExecutor<TEnvironment> {
// call the procedure completion cleanup handler
execCompletionCleanup(proc);
CompletedProcedureRetainer retainer = new CompletedProcedureRetainer(proc);
// update the executor internal state maps
final ProcedureInfo procInfo = ProcedureUtil.convertToProcedureInfo(proc, proc.getNonceKey());
if (!proc.shouldWaitClientAck(getEnvironment())) {
procInfo.setClientAckTime(0);
retainer.setClientAckTime(0);
}
completed.put(procInfo.getProcId(), procInfo);
completed.put(proc.getProcId(), retainer);
rollbackStack.remove(proc.getProcId());
procedures.remove(proc.getProcId());

View File

@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.procedure2.store;
import java.io.IOException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.procedure2.Procedure;
@ -82,12 +81,7 @@ public interface ProcedureStore {
* @throws IOException if there was an error fetching/deserializing the procedure
* @return the next procedure in the iteration.
*/
Procedure nextAsProcedure() throws IOException;
/**
* @return the next procedure in the iteration as ProcedureInfo.
*/
ProcedureInfo nextAsProcedureInfo();
Procedure next() throws IOException;
}
/**

View File

@ -25,7 +25,6 @@ import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.procedure2.Procedure;
@ -362,10 +361,6 @@ public class ProcedureWALFormatReader {
return procedure;
}
public ProcedureInfo convertToInfo() {
return ProcedureUtil.convertToProcedureInfo(proto);
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
@ -410,22 +405,13 @@ public class ProcedureWALFormatReader {
}
@Override
public Procedure nextAsProcedure() throws IOException {
public Procedure next() throws IOException {
try {
return current.convert();
} finally {
current = current.replayNext;
}
}
@Override
public ProcedureInfo nextAsProcedureInfo() {
try {
return current.convertToInfo();
} finally {
current = current.replayNext;
}
}
}
private static class WalProcedureMap {

View File

@ -35,7 +35,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.exceptions.IllegalArgumentIOException;
import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
import org.apache.hadoop.hbase.io.util.StreamUtils;
@ -259,45 +258,45 @@ public class ProcedureTestingUtility {
public static <TEnv> void assertProcNotFailed(ProcedureExecutor<TEnv> procExecutor,
long procId) {
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
assertTrue("expected procedure result", result != null);
assertProcNotFailed(result);
}
public static void assertProcNotFailed(final ProcedureInfo result) {
public static void assertProcNotFailed(final Procedure<?> result) {
assertFalse("found exception: " + result.getException(), result.isFailed());
}
public static <TEnv> Throwable assertProcFailed(final ProcedureExecutor<TEnv> procExecutor,
final long procId) {
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
assertTrue("expected procedure result", result != null);
return assertProcFailed(result);
}
public static Throwable assertProcFailed(final ProcedureInfo result) {
public static Throwable assertProcFailed(final Procedure<?> result) {
assertEquals(true, result.isFailed());
LOG.info("procId=" + result.getProcId() + " exception: " + result.getException().getMessage());
return getExceptionCause(result);
}
public static void assertIsAbortException(final ProcedureInfo result) {
public static void assertIsAbortException(final Procedure<?> result) {
Throwable cause = assertProcFailed(result);
assertTrue("expected abort exception, got "+ cause, cause instanceof ProcedureAbortedException);
}
public static void assertIsTimeoutException(final ProcedureInfo result) {
public static void assertIsTimeoutException(final Procedure<?> result) {
Throwable cause = assertProcFailed(result);
assertTrue("expected TimeoutIOException, got " + cause, cause instanceof TimeoutIOException);
}
public static void assertIsIllegalArgumentException(final ProcedureInfo result) {
public static void assertIsIllegalArgumentException(final Procedure<?> result) {
Throwable cause = assertProcFailed(result);
assertTrue("expected IllegalArgumentIOException, got " + cause,
cause instanceof IllegalArgumentIOException);
}
public static Throwable getExceptionCause(final ProcedureInfo procInfo) {
public static Throwable getExceptionCause(final Procedure<?> procInfo) {
assert procInfo.isFailed();
Throwable cause = procInfo.getException().getCause();
return cause == null ? procInfo.getException() : cause;
@ -447,7 +446,7 @@ public class ProcedureTestingUtility {
public static class LoadCounter implements ProcedureStore.ProcedureLoader {
private final ArrayList<Procedure> corrupted = new ArrayList<>();
private final ArrayList<ProcedureInfo> completed = new ArrayList<>();
private final ArrayList<Procedure> completed = new ArrayList<>();
private final ArrayList<Procedure> runnable = new ArrayList<>();
private Set<Long> procIds;
@ -485,7 +484,7 @@ public class ProcedureTestingUtility {
return runnable.size();
}
public ArrayList<ProcedureInfo> getCompleted() {
public ArrayList<Procedure> getCompleted() {
return completed;
}
@ -524,12 +523,12 @@ public class ProcedureTestingUtility {
while (procIter.hasNext()) {
long procId;
if (procIter.isNextFinished()) {
ProcedureInfo proc = procIter.nextAsProcedureInfo();
Procedure<?> proc = procIter.next();
procId = proc.getProcId();
LOG.debug("loading completed procId=" + procId + ": " + proc);
completed.add(proc);
} else {
Procedure proc = procIter.nextAsProcedure();
Procedure proc = procIter.next();
procId = proc.getProcId();
LOG.debug("loading runnable procId=" + procId + ": " + proc);
runnable.add(proc);
@ -543,7 +542,7 @@ public class ProcedureTestingUtility {
@Override
public void handleCorrupted(ProcedureIterator procIter) throws IOException {
while (procIter.hasNext()) {
Procedure proc = procIter.nextAsProcedure();
Procedure proc = procIter.next();
LOG.debug("corrupted procId=" + proc.getProcId() + ": " + proc);
corrupted.add(proc);
}

View File

@ -25,7 +25,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -35,7 +34,6 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@Category({MasterTests.class, SmallTests.class})
@ -138,7 +136,7 @@ public class TestChildProcedures {
private void assertProcFailed(long procId) {
assertTrue("expected completed proc", procExecutor.isFinished(procId));
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
assertEquals(true, result.isFailed());
LOG.info(result.getException().getMessage());
}
@ -146,6 +144,7 @@ public class TestChildProcedures {
public static class TestRootProcedure extends SequentialProcedure<TestProcEnv> {
public TestRootProcedure() {}
@Override
public Procedure[] execute(TestProcEnv env) {
if (env.toggleKillBeforeStoreUpdate) {
ProcedureTestingUtility.toggleKillBeforeStoreUpdate(procExecutor);
@ -153,6 +152,7 @@ public class TestChildProcedures {
return new Procedure[] { new TestChildProcedure(), new TestChildProcedure() };
}
@Override
public void rollback(TestProcEnv env) {
}
@ -165,6 +165,7 @@ public class TestChildProcedures {
public static class TestChildProcedure extends SequentialProcedure<TestProcEnv> {
public TestChildProcedure() {}
@Override
public Procedure[] execute(TestProcEnv env) {
if (env.toggleKillBeforeStoreUpdate) {
ProcedureTestingUtility.toggleKillBeforeStoreUpdate(procExecutor);
@ -175,6 +176,7 @@ public class TestChildProcedures {
return null;
}
@Override
public void rollback(TestProcEnv env) {
}

View File

@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureState;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@ -138,7 +137,7 @@ public class TestProcedureExecution {
// subProc1 has a "null" subprocedure which is catched as InvalidArgument
// failed state with 2 execute and 2 rollback
LOG.info(state);
ProcedureInfo result = procExecutor.getResult(rootId);
Procedure<?> result = procExecutor.getResult(rootId);
assertTrue(state.toString(), result.isFailed());
ProcedureTestingUtility.assertIsIllegalArgumentException(result);
@ -159,7 +158,7 @@ public class TestProcedureExecution {
// successful state, with 3 execute
LOG.info(state);
ProcedureInfo result = procExecutor.getResult(rootId);
Procedure<?> result = procExecutor.getResult(rootId);
ProcedureTestingUtility.assertProcNotFailed(result);
assertEquals(state.toString(), 3, state.size());
}
@ -175,7 +174,7 @@ public class TestProcedureExecution {
// the 3rd proc fail, rollback after 2 successful execution
LOG.info(state);
ProcedureInfo result = procExecutor.getResult(rootId);
Procedure<?> result = procExecutor.getResult(rootId);
assertTrue(state.toString(), result.isFailed());
LOG.info(result.getException().getMessage());
Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
@ -219,7 +218,7 @@ public class TestProcedureExecution {
public void testRollbackRetriableFailure() {
long procId = ProcedureTestingUtility.submitAndWait(procExecutor, new TestFaultyRollback());
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
assertTrue("expected a failure", result.isFailed());
LOG.info(result.getException().getMessage());
Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
@ -303,7 +302,7 @@ public class TestProcedureExecution {
long execTime = EnvironmentEdgeManager.currentTime() - startTime;
LOG.info(state);
assertTrue("we didn't wait enough execTime=" + execTime, execTime >= PROC_TIMEOUT_MSEC);
ProcedureInfo result = procExecutor.getResult(rootId);
Procedure<?> result = procExecutor.getResult(rootId);
assertTrue(state.toString(), result.isFailed());
ProcedureTestingUtility.assertIsTimeoutException(result);
assertEquals(state.toString(), 2, state.size());
@ -318,7 +317,7 @@ public class TestProcedureExecution {
proc.setTimeout(2500);
long rootId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);
LOG.info(state);
ProcedureInfo result = procExecutor.getResult(rootId);
Procedure<?> result = procExecutor.getResult(rootId);
assertTrue(state.toString(), result.isFailed());
ProcedureTestingUtility.assertIsTimeoutException(result);
assertEquals(state.toString(), 4, state.size());

View File

@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -44,7 +43,6 @@ import org.junit.experimental.categories.Category;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@Category({MasterTests.class, SmallTests.class})
public class TestProcedureNonce {
@ -105,7 +103,7 @@ public class TestProcedureNonce {
// we should get back the old procId
assertEquals(procId, procExecutor.registerNonce(nonceKey));
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
}
@ -140,7 +138,7 @@ public class TestProcedureNonce {
// we should get back the old procId
assertEquals(procId, procExecutor.registerNonce(nonceKey));
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
}
@ -157,7 +155,7 @@ public class TestProcedureNonce {
new IOException("test failure"));
final long procId = procExecutor.registerNonce(nonceKey);
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcFailed(result);
}

View File

@ -30,7 +30,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -198,7 +197,7 @@ public class TestProcedureRecovery {
long restartTs = EnvironmentEdgeManager.currentTime();
restart();
waitProcedure(procId);
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
assertTrue(result.getLastUpdate() > restartTs);
ProcedureTestingUtility.assertProcNotFailed(result);
assertEquals(1, Bytes.toInt(result.getResult()));
@ -237,7 +236,7 @@ public class TestProcedureRecovery {
assertTrue(procExecutor.isRunning());
// The procedure is completed
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
}
@ -284,7 +283,7 @@ public class TestProcedureRecovery {
waitProcedure(procId);
// The procedure is completed
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertIsAbortException(result);
}
@ -402,7 +401,7 @@ public class TestProcedureRecovery {
long procId = procExecutor.submitProcedure(new TestStateMachineProcedure(true));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExecutor, procId);
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
assertEquals(19, Bytes.toInt(result.getResult()));
assertEquals(4, procExecutor.getLastProcId());
@ -441,7 +440,7 @@ public class TestProcedureRecovery {
assertTrue(procExecutor.isRunning());
// The procedure is completed
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertProcNotFailed(result);
assertEquals(26, Bytes.toInt(result.getResult()));
}
@ -495,7 +494,7 @@ public class TestProcedureRecovery {
assertTrue(procExecutor.isRunning());
// The procedure is completed
ProcedureInfo result = procExecutor.getResult(procId);
Procedure<?> result = procExecutor.getResult(procId);
ProcedureTestingUtility.assertIsAbortException(result);
}

View File

@ -31,8 +31,6 @@ import org.apache.commons.cli.Option;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtility;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure;
import org.apache.hadoop.hbase.procedure2.store.ProcedureStore;
@ -82,18 +80,14 @@ public class ProcedureWALLoaderPerformanceEvaluation extends AbstractHBaseTool {
@Override
public void load(ProcedureIterator procIter) throws IOException {
while (procIter.hasNext()) {
if (procIter.isNextFinished()) {
ProcedureInfo proc = procIter.nextAsProcedureInfo();
} else {
Procedure proc = procIter.nextAsProcedure();
}
procIter.next();
}
}
@Override
public void handleCorrupted(ProcedureIterator procIter) throws IOException {
while (procIter.hasNext()) {
Procedure proc = procIter.nextAsProcedure();
procIter.next();
}
}
}

View File

@ -604,9 +604,9 @@ public class TestWALProcedureStore {
@Override
public void load(ProcedureIterator procIter) throws IOException {
assertTrue(procIter.hasNext());
assertEquals(1, procIter.nextAsProcedureInfo().getProcId());
assertEquals(1, procIter.next().getProcId());
assertTrue(procIter.hasNext());
assertEquals(2, procIter.nextAsProcedureInfo().getProcId());
assertEquals(2, procIter.next().getProcId());
assertFalse(procIter.hasNext());
}
@ -660,16 +660,16 @@ public class TestWALProcedureStore {
@Override
public void load(ProcedureIterator procIter) throws IOException {
assertTrue(procIter.hasNext());
assertEquals(4, procIter.nextAsProcedureInfo().getProcId());
assertEquals(4, procIter.next().getProcId());
// TODO: This will be multiple call once we do fast-start
//assertFalse(procIter.hasNext());
assertTrue(procIter.hasNext());
assertEquals(1, procIter.nextAsProcedureInfo().getProcId());
assertEquals(1, procIter.next().getProcId());
assertTrue(procIter.hasNext());
assertEquals(2, procIter.nextAsProcedureInfo().getProcId());
assertEquals(2, procIter.next().getProcId());
assertTrue(procIter.hasNext());
assertEquals(3, procIter.nextAsProcedureInfo().getProcId());
assertEquals(3, procIter.next().getProcId());
assertFalse(procIter.hasNext());
}

View File

@ -47,7 +47,6 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.MetaTableAccessor.DefaultVisitorBase;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
@ -68,6 +67,7 @@ import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.master.ServerListener;
import org.apache.hadoop.hbase.master.TableStateManager;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.protobuf.ProtobufMagic;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos;
@ -762,9 +762,10 @@ class RSGroupInfoManagerImpl implements RSGroupInfoManager {
if(tries <= 0) {
throw new IOException("Failed to create group table in a given time.");
} else {
ProcedureInfo result = masterServices.getMasterProcedureExecutor().getResult(procId);
Procedure<?> result = masterServices.getMasterProcedureExecutor().getResult(procId);
if (result != null && result.isFailed()) {
throw new IOException("Failed to create group table. " + result.getExceptionFullMessage());
throw new IOException("Failed to create group table. " +
result.getException().unwrapRemoteIOException());
}
}
}

View File

@ -133,8 +133,10 @@ import org.apache.hadoop.hbase.monitoring.TaskMonitor;
import org.apache.hadoop.hbase.procedure.MasterProcedureManagerHost;
import org.apache.hadoop.hbase.procedure.flush.MasterFlushTableProcedureManager;
import org.apache.hadoop.hbase.procedure2.LockInfo;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureEvent;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
import org.apache.hadoop.hbase.quotas.MasterQuotaManager;
import org.apache.hadoop.hbase.quotas.MasterSpaceQuotaObserver;
@ -2525,6 +2527,7 @@ public class HMaster extends HRegionServer implements MasterServices {
return info.getInfoPort();
}
@Override
public String getRegionServerVersion(final ServerName sn) {
RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn);
if (info != null && info.hasVersionInfo()) {
@ -2993,7 +2996,13 @@ public class HMaster extends HRegionServer implements MasterServices {
cpHost.preListProcedures();
}
final List<ProcedureInfo> procInfoList = this.procedureExecutor.listProcedures();
final List<Procedure> procList = this.procedureExecutor.listProcedures();
final List<ProcedureInfo> procInfoList = new ArrayList<>(procList.size());
for (Procedure proc : procList) {
ProcedureInfo procInfo = ProcedureUtil.convertToProcedureInfo(proc);
procInfoList.add(procInfo);
}
if (cpHost != null) {
cpHost.postListProcedures(procInfoList);
@ -3002,17 +3011,6 @@ public class HMaster extends HRegionServer implements MasterServices {
return procInfoList;
}
private Map<Long, ProcedureInfo> getProcedureInfos() {
final List<ProcedureInfo> list = procedureExecutor.listProcedures();
final Map<Long, ProcedureInfo> map = new HashMap<>();
for (ProcedureInfo procedureInfo : list) {
map.put(procedureInfo.getProcId(), procedureInfo);
}
return map;
}
@Override
public List<LockInfo> listLocks() throws IOException {
if (cpHost != null) {

View File

@ -43,7 +43,6 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.UnknownRegionException;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.MasterSwitchType;
import org.apache.hadoop.hbase.client.TableState;
import org.apache.hadoop.hbase.client.VersionInfoUtil;
@ -132,7 +131,6 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProto
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionSpaceUseReportResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest;
@ -1013,28 +1011,33 @@ public class MasterRpcServices extends RSRpcServices
master.checkInitialized();
GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder();
Pair<ProcedureInfo, Procedure> v = master.getMasterProcedureExecutor()
Procedure<?> result = master.getMasterProcedureExecutor()
.getResultOrProcedure(request.getProcId());
if (v.getFirst() != null) {
ProcedureInfo result = v.getFirst();
if (result == null) {
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
} else {
boolean remove = false;
if (result.isFinished() || result.isFailed()) {
builder.setState(GetProcedureResultResponse.State.FINISHED);
remove = true;
} else {
builder.setState(GetProcedureResultResponse.State.RUNNING);
}
builder.setSubmittedTime(result.getSubmittedTime());
builder.setLastUpdate(result.getLastUpdate());
if (result.isFailed()) {
builder.setException(ForeignExceptionUtil.toProtoForeignException(result.getException()));
IOException exception = result.getException().unwrapRemoteIOException();
builder.setException(ForeignExceptionUtil.toProtoForeignException(exception));
}
if (result.hasResultData()) {
builder.setResult(UnsafeByteOperations.unsafeWrap(result.getResult()));
byte[] resultData = result.getResult();
if (resultData != null) {
builder.setResult(UnsafeByteOperations.unsafeWrap(resultData));
}
if (remove) {
master.getMasterProcedureExecutor().removeResult(request.getProcId());
} else {
Procedure<?> proc = v.getSecond();
if (proc == null) {
builder.setState(GetProcedureResultResponse.State.NOT_FOUND);
} else {
builder.setState(GetProcedureResultResponse.State.RUNNING);
builder.setSubmittedTime(proc.getSubmittedTime());
builder.setLastUpdate(proc.getLastUpdate());
}
}
return builder.build();

View File

@ -32,7 +32,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CoordinatedStateException;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
@ -147,11 +146,11 @@ public final class ProcedureSyncWait {
}
);
ProcedureInfo result = procExec.getResult(procId);
Procedure result = procExec.getResult(procId);
if (result != null) {
if (result.isFailed()) {
if (result.hasException()) {
// If the procedure fails, we should always have an exception captured. Throw it.
throw result.getException();
throw result.getException().unwrapRemoteIOException();
}
return result.getResult();
} else {

View File

@ -31,6 +31,7 @@
import="org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv"
import="org.apache.hadoop.hbase.ProcedureInfo"
import="org.apache.hadoop.hbase.procedure2.LockInfo"
import="org.apache.hadoop.hbase.procedure2.Procedure"
import="org.apache.hadoop.hbase.procedure2.ProcedureExecutor"
import="org.apache.hadoop.hbase.procedure2.store.wal.ProcedureWALFile"
import="org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore"
@ -47,11 +48,11 @@
long millisFromLastRoll = walStore.getMillisFromLastRoll();
ArrayList<ProcedureWALFile> procedureWALFiles = walStore.getActiveLogs();
Set<ProcedureWALFile> corruptedWALFiles = walStore.getCorruptedLogs();
List<ProcedureInfo> procedures = procExecutor.listProcedures();
Collections.sort(procedures, new Comparator<ProcedureInfo>() {
List<Procedure> procedures = procExecutor.listProcedures();
Collections.sort(procedures, new Comparator<Procedure>() {
@Override
public int compare(ProcedureInfo lhs, ProcedureInfo rhs) {
long cmp = lhs.getParentId() - rhs.getParentId();
public int compare(Procedure lhs, Procedure rhs) {
long cmp = lhs.getParentProcId() - rhs.getParentProcId();
cmp = cmp != 0 ? cmp : lhs.getProcId() - rhs.getProcId();
return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
}
@ -118,16 +119,16 @@
<th>Last Update</th>
<th>Errors</th>
</tr>
<% for (ProcedureInfo procInfo : procedures) { %>
<% for (Procedure<?> proc : procedures) { %>
<tr>
<td><%= procInfo.getProcId() %></td>
<td><%= procInfo.hasParentId() ? procInfo.getParentId() : "" %></td>
<td><%= escapeXml(procInfo.getProcState().toString()) %></td>
<td><%= escapeXml(procInfo.getProcOwner()) %></td>
<td><%= escapeXml(procInfo.getProcName()) %></td>
<td><%= new Date(procInfo.getSubmittedTime()) %></td>
<td><%= new Date(procInfo.getLastUpdate()) %></td>
<td><%= escapeXml(procInfo.isFailed() ? procInfo.getException().getMessage() : "") %></td>
<td><%= proc.getProcId() %></td>
<td><%= proc.hasParent() ? proc.getParentProcId() : "" %></td>
<td><%= escapeXml(proc.getState().toString()) %></td>
<td><%= escapeXml(proc.getOwner()) %></td>
<td><%= escapeXml(proc.getProcName()) %></td>
<td><%= new Date(proc.getSubmittedTime()) %></td>
<td><%= new Date(proc.getLastUpdate()) %></td>
<td><%= escapeXml(proc.isFailed() ? proc.getException().unwrapRemoteIOException().getMessage() : "") %></td>
</tr>
<% } %>
</table>

View File

@ -24,7 +24,6 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.master.MasterServices;
import org.apache.hadoop.hbase.master.locking.LockProcedure;
@ -95,8 +94,7 @@ public class TestLockManager {
@After
public void tearDown() throws Exception {
for (ProcedureInfo procInfo : getMasterProcedureExecutor().listProcedures()) {
Procedure proc = getMasterProcedureExecutor().getProcedure(procInfo.getProcId());
for (Procedure<?> proc : getMasterProcedureExecutor().listProcedures()) {
if (proc instanceof LockProcedure) {
((LockProcedure) proc).unlock(getMasterProcedureExecutor().getEnvironment());
ProcedureTestingUtility.waitProcedure(getMasterProcedureExecutor(), proc);

View File

@ -26,7 +26,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.locking.LockServiceClient;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureConstants;
@ -39,7 +38,6 @@ import org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException;
import org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.*;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Pair;
import org.hamcrest.core.IsInstanceOf;
import org.hamcrest.core.StringStartsWith;
import org.junit.rules.TestRule;
@ -132,10 +130,8 @@ public class TestLockProcedure {
public void tearDown() throws Exception {
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);
// Kill all running procedures.
for (ProcedureInfo procInfo : procExec.listProcedures()) {
Procedure proc = procExec.getProcedure(procInfo.getProcId());
if (proc == null) continue;
procExec.abort(procInfo.getProcId());
for (Procedure<?> proc : procExec.listProcedures()) {
procExec.abort(proc.getProcId());
ProcedureTestingUtility.waitProcedure(procExec, proc);
}
assertEquals(0, procExec.getEnvironment().getProcedureScheduler().size());
@ -440,8 +436,8 @@ public class TestLockProcedure {
}
assertEquals(true, procExec.isRunning());
ProcedureTestingUtility.waitProcedure(procExec, lockProc.getProcId());
Pair<ProcedureInfo, Procedure> result = procExec.getResultOrProcedure(lockProc.getProcId());
assertTrue(result.getFirst() != null && !result.getFirst().isFailed());
Procedure<?> result = procExec.getResultOrProcedure(lockProc.getProcId());
assertTrue(result != null && !result.isFailed());
ProcedureTestingUtility.assertProcNotFailed(procExec, lockProc.getProcId());
}
}

View File

@ -25,8 +25,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -100,9 +100,9 @@ public class TestAddColumnFamilyProcedure extends TestTableDDLProcedureBase {
ProcedureTestingUtility.waitProcedure(procExec, procId2);
// Second add should fail with InvalidFamilyOperationException
ProcedureInfo result = procExec.getResult(procId2);
Procedure<?> result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Add failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Add failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
@ -116,7 +116,7 @@ public class TestAddColumnFamilyProcedure extends TestTableDDLProcedureBase {
// Second add should fail with InvalidFamilyOperationException
result = procExec.getResult(procId3);
assertTrue(result.isFailed());
LOG.debug("Add failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Add failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}

View File

@ -26,17 +26,14 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.SnapshotDescription;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.client.SnapshotDescription;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.CloneSnapshotState;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -125,9 +122,9 @@ public class TestCloneSnapshotProcedure extends TestTableDDLProcedureBase {
long procId = ProcedureTestingUtility.submitAndWait(
procExec, new CloneSnapshotProcedure(procExec.getEnvironment(), htd, snapshotDesc));
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Clone snapshot failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Clone snapshot failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof TableExistsException);
}

View File

@ -31,8 +31,8 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceExistException;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -112,9 +112,9 @@ public class TestCreateNamespaceProcedure {
ProcedureTestingUtility.waitProcedure(procExec, procId2);
// Second create should fail with NamespaceExistException
ProcedureInfo result = procExec.getResult(procId2);
Procedure<?> result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Create namespace failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException);
}
@ -129,9 +129,9 @@ public class TestCreateNamespaceProcedure {
new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Create namespace failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException);
}
@ -150,9 +150,9 @@ public class TestCreateNamespaceProcedure {
new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Create namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}
@ -170,9 +170,9 @@ public class TestCreateNamespaceProcedure {
new CreateNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Create namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}

View File

@ -23,9 +23,9 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -85,7 +85,7 @@ public class TestCreateTableProcedure extends TestTableDDLProcedureBase {
long procId =
ProcedureTestingUtility.submitAndWait(procExec,
new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
final ProcedureInfo result = procExec.getResult(procId);
final Procedure<?> result = procExec.getResult(procId);
assertEquals(true, result.isFailed());
Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
assertTrue("expected DoNotRetryIOException, got " + cause,

View File

@ -25,8 +25,8 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -98,9 +98,9 @@ public class TestDeleteColumnFamilyProcedure extends TestTableDDLProcedureBase {
ProcedureTestingUtility.waitProcedure(procExec, procId2);
// Second delete should fail with InvalidFamilyOperationException
ProcedureInfo result = procExec.getResult(procId2);
Procedure<?> result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Delete online failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete online failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
@ -113,7 +113,7 @@ public class TestDeleteColumnFamilyProcedure extends TestTableDDLProcedureBase {
// Expect fail with InvalidFamilyOperationException
result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Delete offline failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete offline failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}
@ -133,9 +133,9 @@ public class TestDeleteColumnFamilyProcedure extends TestTableDDLProcedureBase {
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId1);
ProcedureInfo result = procExec.getResult(procId1);
Procedure<?> result = procExec.getResult(procId1);
assertTrue(result.isFailed());
LOG.debug("Delete failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}

View File

@ -31,9 +31,9 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -117,9 +117,9 @@ public class TestDeleteNamespaceProcedure {
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
// Expect fail with NamespaceNotFoundException
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete namespace failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException);
}
@ -133,9 +133,9 @@ public class TestDeleteNamespaceProcedure {
new DeleteNamespaceProcedure(procExec.getEnvironment(), namespaceName));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}
@ -153,9 +153,9 @@ public class TestDeleteNamespaceProcedure {
new DeleteNamespaceProcedure(procExec.getEnvironment(), namespaceName));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}

View File

@ -18,14 +18,16 @@
package org.apache.hadoop.hbase.master.procedure;
import static org.junit.Assert.assertTrue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -37,8 +39,6 @@ import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import static org.junit.Assert.assertTrue;
@Category({MasterTests.class, MediumTests.class})
public class TestDeleteTableProcedure extends TestTableDDLProcedureBase {
private static final Log LOG = LogFactory.getLog(TestDeleteTableProcedure.class);
@ -95,9 +95,9 @@ public class TestDeleteTableProcedure extends TestTableDDLProcedureBase {
MasterProcedureTestingUtility.validateTableDeletion(getMaster(), tableName);
// Second delete should fail with TableNotFound
ProcedureInfo result = procExec.getResult(procId2);
Procedure<?> result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Delete failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Delete failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException);
}

View File

@ -23,9 +23,9 @@ import static org.junit.Assert.assertTrue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotEnabledException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -82,9 +82,9 @@ public class TestDisableTableProcedure extends TestTableDDLProcedureBase {
procExec.getEnvironment(), tableName, false));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId2);
ProcedureInfo result = procExec.getResult(procId2);
Procedure<?> result = procExec.getResult(procId2);
assertTrue(result.isFailed());
LOG.debug("Disable failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Disable failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotEnabledException);

View File

@ -23,9 +23,9 @@ import static org.junit.Assert.assertTrue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -74,9 +74,9 @@ public class TestEnableTableProcedure extends TestTableDDLProcedureBase {
new EnableTableProcedure(procExec.getEnvironment(), tableName, false));
ProcedureTestingUtility.waitProcedure(procExec, procId1);
ProcedureInfo result = procExec.getResult(procId1);
Procedure<?> result = procExec.getResult(procId1);
assertTrue(result.isFailed());
LOG.debug("Enable failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Enable failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException);

View File

@ -24,8 +24,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -95,9 +95,9 @@ public class TestModifyColumnFamilyProcedure extends TestTableDDLProcedureBase {
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId1);
ProcedureInfo result = procExec.getResult(procId1);
Procedure<?> result = procExec.getResult(procId1);
assertTrue(result.isFailed());
LOG.debug("Modify failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Modify failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}

View File

@ -19,7 +19,9 @@
package org.apache.hadoop.hbase.master.procedure;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -28,8 +30,8 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -138,9 +140,9 @@ public class TestModifyNamespaceProcedure {
ProcedureTestingUtility.waitProcedure(procExec, procId);
// Expect fail with NamespaceNotFoundException
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("modify namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("modify namespace failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException);
}
@ -162,9 +164,9 @@ public class TestModifyNamespaceProcedure {
new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Modify namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Modify namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}
@ -185,9 +187,9 @@ public class TestModifyNamespaceProcedure {
new ModifyNamespaceProcedure(procExec.getEnvironment(), nsd));
// Wait the completion
ProcedureTestingUtility.waitProcedure(procExec, procId);
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Modify namespace failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Modify namespace failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}

View File

@ -27,8 +27,8 @@ import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -173,7 +173,7 @@ public class TestModifyTableProcedure extends TestTableDDLProcedureBase {
long procId3 =
ProcedureTestingUtility.submitAndWait(procExec,
new ModifyTableProcedure(procExec.getEnvironment(), htd3));
final ProcedureInfo result = procExec.getResult(procId3);
final Procedure<?> result = procExec.getResult(procId3);
assertEquals(true, result.isFailed());
Throwable cause = ProcedureTestingUtility.getExceptionCause(result);
assertTrue("expected DoNotRetryIOException, got " + cause,

View File

@ -31,9 +31,8 @@ import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.ProcedureState;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -48,8 +47,6 @@ import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import static org.junit.Assert.*;
@Category({MasterTests.class, MediumTests.class})
public class TestProcedureAdmin {
private static final Log LOG = LogFactory.getLog(TestProcedureAdmin.class);
@ -209,15 +206,15 @@ public class TestProcedureAdmin {
// Wait for one step to complete
ProcedureTestingUtility.waitProcedure(procExec, procId);
List<ProcedureInfo> listProcedures = procExec.listProcedures();
List<Procedure> listProcedures = procExec.listProcedures();
assertTrue(listProcedures.size() >= 1);
boolean found = false;
for (ProcedureInfo procInfo: listProcedures) {
if (procInfo.getProcId() == procId) {
assertTrue(procInfo.getProcState() == ProcedureState.RUNNABLE);
for (Procedure proc: listProcedures) {
if (proc.getProcId() == procId) {
assertTrue(proc.isRunnable());
found = true;
} else {
assertTrue(procInfo.getProcState() == ProcedureState.SUCCESS);
assertTrue(proc.isSuccess());
}
}
assertTrue(found);
@ -227,8 +224,8 @@ public class TestProcedureAdmin {
ProcedureTestingUtility.waitNoProcedureRunning(procExec);
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);
listProcedures = procExec.listProcedures();
for (ProcedureInfo procInfo: listProcedures) {
assertTrue(procInfo.getProcState() == ProcedureState.SUCCESS);
for (Procedure proc: listProcedures) {
assertTrue(proc.isSuccess());
}
}

View File

@ -31,17 +31,15 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.client.SnapshotDescription;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProcedureProtos.RestoreSnapshotState;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos;
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -55,11 +53,6 @@ import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@Category({MasterTests.class, MediumTests.class})
public class TestRestoreSnapshotProcedure extends TestTableDDLProcedureBase {
private static final Log LOG = LogFactory.getLog(TestRestoreSnapshotProcedure.class);
@ -173,9 +166,9 @@ public class TestRestoreSnapshotProcedure extends TestTableDDLProcedureBase {
long procId = ProcedureTestingUtility.submitAndWait(
procExec, new RestoreSnapshotProcedure(procExec.getEnvironment(), newHTD, snapshot));
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Restore snapshot failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Restore snapshot failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException);
}
@ -190,9 +183,9 @@ public class TestRestoreSnapshotProcedure extends TestTableDDLProcedureBase {
long procId = ProcedureTestingUtility.submitAndWait(
procExec,
new RestoreSnapshotProcedure(procExec.getEnvironment(), snapshotHTD, snapshot));
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Restore snapshot failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Restore snapshot failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException);
} finally {

View File

@ -25,10 +25,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.CategoryBasedTimeout;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility;
import org.apache.hadoop.hbase.testclassification.MasterTests;
@ -40,9 +40,6 @@ import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@Category({MasterTests.class, MediumTests.class})
public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
private static final Log LOG = LogFactory.getLog(TestTruncateTableProcedure.class);
@ -61,9 +58,9 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
new TruncateTableProcedure(procExec.getEnvironment(), tableName, true));
// Second delete should fail with TableNotFound
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Truncate failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Truncate failed with exception: " + result.getException());
assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException);
}
@ -78,9 +75,9 @@ public class TestTruncateTableProcedure extends TestTableDDLProcedureBase {
new TruncateTableProcedure(procExec.getEnvironment(), tableName, false));
// Second delete should fail with TableNotDisabled
ProcedureInfo result = procExec.getResult(procId);
Procedure<?> result = procExec.getResult(procId);
assertTrue(result.isFailed());
LOG.debug("Truncate failed with exception: " + result.getExceptionFullMessage());
LOG.debug("Truncate failed with exception: " + result.getException());
assertTrue(
ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException);
}

View File

@ -101,6 +101,7 @@ import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
import org.apache.hadoop.hbase.master.procedure.TableProcedureInterface;
import org.apache.hadoop.hbase.procedure2.Procedure;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.procedure2.ProcedureUtil;
import org.apache.hadoop.hbase.procedure2.ProcedureYieldException;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
@ -633,18 +634,18 @@ public class TestAccessController extends SecureTestUtil {
TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
Procedure proc = new TestTableDDLProcedure(procExec.getEnvironment(), tableName);
proc.setOwner(USER_OWNER);
final long procId = procExec.submitProcedure(proc);
final List<ProcedureInfo> procInfoList = procExec.listProcedures();
procExec.submitProcedure(proc);
final List<Procedure> procList = procExec.listProcedures();
AccessTestAction listProceduresAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
List<ProcedureInfo> procInfoListClone = new ArrayList<>(procInfoList.size());
for(ProcedureInfo pi : procInfoList) {
procInfoListClone.add(pi.clone());
List<ProcedureInfo> procInfoList = new ArrayList<>(procList.size());
for(Procedure p : procList) {
procInfoList.add(ProcedureUtil.convertToProcedureInfo(p));
}
ACCESS_CONTROLLER
.postListProcedures(ObserverContext.createAndPrepare(CP_ENV, null), procInfoListClone);
.postListProcedures(ObserverContext.createAndPrepare(CP_ENV, null), procInfoList);
return null;
}
};