Skip to content

Commit

Permalink
issue # 20 : verify whether we can open index daughter regions before…
Browse files Browse the repository at this point in the history
… opening user regions
  • Loading branch information
chrajeshbabu committed Aug 31, 2013
1 parent a8b6d8f commit 8a494fa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,9 @@ private HRegion getIndexRegion(HRegionServer rs, byte[] startKey, String indexTa
}

@Override
public void postSplit(ObserverContext<RegionCoprocessorEnvironment> e, HRegion l, HRegion r)
public void preSplitAfterPONR(ObserverContext<RegionCoprocessorEnvironment> ctx)
throws IOException {
RegionCoprocessorEnvironment environment = e.getEnvironment();
RegionCoprocessorEnvironment environment = ctx.getEnvironment();
HRegionServer rs = (HRegionServer) environment.getRegionServerServices();
HRegion region = environment.getRegion();
String userTableName = region.getTableDesc().getNameAsString();
Expand All @@ -655,8 +655,9 @@ public void postSplit(ObserverContext<RegionCoprocessorEnvironment> e, HRegion l
PairOfSameType<HRegion> daughters = splitInfo.getDaughters();
if (splitTransaction != null && daughters != null) {
splitTransaction.stepsAfterPONR(rs, rs, daughters);
LOG.info("Daughter regions are opened and split transaction finished for zknodes for index table "
+ indexTableName + " for the region " + region.getRegionInfo());
LOG.info("Daughter regions are opened and split transaction finished"
+ " for zknodes for index table " + indexTableName + " for the region "
+ region.getRegionInfo());
}
} catch (Exception ex) {
String msg =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ boolean postFilterRow(final ObserverContext<RegionCoprocessorEnvironment> ctx,
SplitInfo preSplitBeforePONR(final ObserverContext<RegionCoprocessorEnvironment> ctx,
byte[] splitKey) throws IOException;

/**
* This will be called after PONR step as part of split transaction Calling
* {@link org.apache.hadoop.hbase.coprocessor.ObserverContext#bypass()} has no effect in this
* hook.
* @param ctx
* @throws IOException
*/
void preSplitAfterPONR(final ObserverContext<RegionCoprocessorEnvironment> ctx)
throws IOException;

/**
* This is used to roll back the split related transactions.
* @param ctx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,24 @@ public SplitInfo preSplitBeforePONR(byte[] splitKey) throws IOException {
}
return info;
}

public void preSplitAfterPONR() throws IOException {
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
for (RegionEnvironment env : coprocessors) {
if (env.getInstance() instanceof RegionObserverExt) {
ctx = ObserverContext.createAndPrepare(env, ctx);
try {
((RegionObserverExt) env.getInstance()).preSplitAfterPONR(ctx);
} catch (Throwable e) {
handleCoprocessorThrowable(env, e);
}
if (ctx.shouldComplete()) {
break;
}
}
}
}


public void preRollBack() throws IOException {
boolean result = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ public PairOfSameType<HRegion> execute(final Server server,
final RegionServerServices services)
throws IOException {
PairOfSameType<HRegion> regions = createDaughters(server, services);
if (this.parent.getCoprocessorHost() != null) {
this.parent.getCoprocessorHost().preSplitAfterPONR();
}
stepsAfterPONR(server, services, regions);
return regions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ public SplitInfo preSplitBeforePONR(ObserverContext<RegionCoprocessorEnvironment
return null;
}

@Override
public void preSplitAfterPONR(
ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException {
}

@Override
public void preRollBack(ObserverContext<RegionCoprocessorEnvironment> ctx) throws IOException {
// TODO Auto-generated method stub
Expand Down

0 comments on commit 8a494fa

Please sign in to comment.