http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a5c66de0/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ProcedureFuture.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ProcedureFuture.html b/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ProcedureFuture.html index c10cfbf..a3e2f4a 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ProcedureFuture.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/client/HBaseAdmin.ProcedureFuture.html @@ -3371,7 +3371,7 @@ <span class="sourceLineNo">3363</span> private V result = null;<a name="line.3363"></a> <span class="sourceLineNo">3364</span><a name="line.3364"></a> <span class="sourceLineNo">3365</span> private final HBaseAdmin admin;<a name="line.3365"></a> -<span class="sourceLineNo">3366</span> private final Long procId;<a name="line.3366"></a> +<span class="sourceLineNo">3366</span> protected final Long procId;<a name="line.3366"></a> <span class="sourceLineNo">3367</span><a name="line.3367"></a> <span class="sourceLineNo">3368</span> public ProcedureFuture(final HBaseAdmin admin, final Long procId) {<a name="line.3368"></a> <span class="sourceLineNo">3369</span> this.admin = admin;<a name="line.3369"></a> @@ -3653,653 +3653,651 @@ <span class="sourceLineNo">3645</span> * @return a description of the operation<a name="line.3645"></a> <span class="sourceLineNo">3646</span> */<a name="line.3646"></a> <span class="sourceLineNo">3647</span> protected String getDescription() {<a name="line.3647"></a> -<span class="sourceLineNo">3648</span> return "Operation: " + getOperationType() + ", "<a name="line.3648"></a> -<span class="sourceLineNo">3649</span> + "Table Name: " + tableName.getNameWithNamespaceInclAsString();<a name="line.3649"></a> -<span class="sourceLineNo">3650</span><a name="line.3650"></a> -<span class="sourceLineNo">3651</span> }<a name="line.3651"></a> -<span class="sourceLineNo">3652</span><a name="line.3652"></a> -<span class="sourceLineNo">3653</span> protected abstract class TableWaitForStateCallable implements WaitForStateCallable {<a name="line.3653"></a> -<span class="sourceLineNo">3654</span> @Override<a name="line.3654"></a> -<span class="sourceLineNo">3655</span> public void throwInterruptedException() throws InterruptedIOException {<a name="line.3655"></a> -<span class="sourceLineNo">3656</span> throw new InterruptedIOException("Interrupted while waiting for operation: "<a name="line.3656"></a> -<span class="sourceLineNo">3657</span> + getOperationType() + " on table: " + tableName.getNameWithNamespaceInclAsString());<a name="line.3657"></a> -<span class="sourceLineNo">3658</span> }<a name="line.3658"></a> -<span class="sourceLineNo">3659</span><a name="line.3659"></a> -<span class="sourceLineNo">3660</span> @Override<a name="line.3660"></a> -<span class="sourceLineNo">3661</span> public void throwTimeoutException(long elapsedTime) throws TimeoutException {<a name="line.3661"></a> -<span class="sourceLineNo">3662</span> throw new TimeoutException("The operation: " + getOperationType() + " on table: " +<a name="line.3662"></a> -<span class="sourceLineNo">3663</span> tableName.getNameAsString() + " has not completed after " + elapsedTime + "ms");<a name="line.3663"></a> -<span class="sourceLineNo">3664</span> }<a name="line.3664"></a> -<span class="sourceLineNo">3665</span> }<a name="line.3665"></a> -<span class="sourceLineNo">3666</span><a name="line.3666"></a> -<span class="sourceLineNo">3667</span> @Override<a name="line.3667"></a> -<span class="sourceLineNo">3668</span> protected V postOperationResult(final V result, final long deadlineTs)<a name="line.3668"></a> -<span class="sourceLineNo">3669</span> throws IOException, TimeoutException {<a name="line.3669"></a> -<span class="sourceLineNo">3670</span> LOG.info(getDescription() + " completed");<a name="line.3670"></a> -<span class="sourceLineNo">3671</span> return super.postOperationResult(result, deadlineTs);<a name="line.3671"></a> -<span class="sourceLineNo">3672</span> }<a name="line.3672"></a> -<span class="sourceLineNo">3673</span><a name="line.3673"></a> -<span class="sourceLineNo">3674</span> @Override<a name="line.3674"></a> -<span class="sourceLineNo">3675</span> protected V postOperationFailure(final IOException exception, final long deadlineTs)<a name="line.3675"></a> -<span class="sourceLineNo">3676</span> throws IOException, TimeoutException {<a name="line.3676"></a> -<span class="sourceLineNo">3677</span> LOG.info(getDescription() + " failed with " + exception.getMessage());<a name="line.3677"></a> -<span class="sourceLineNo">3678</span> return super.postOperationFailure(exception, deadlineTs);<a name="line.3678"></a> -<span class="sourceLineNo">3679</span> }<a name="line.3679"></a> -<span class="sourceLineNo">3680</span><a name="line.3680"></a> -<span class="sourceLineNo">3681</span> protected void waitForTableEnabled(final long deadlineTs)<a name="line.3681"></a> -<span class="sourceLineNo">3682</span> throws IOException, TimeoutException {<a name="line.3682"></a> -<span class="sourceLineNo">3683</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3683"></a> -<span class="sourceLineNo">3684</span> @Override<a name="line.3684"></a> -<span class="sourceLineNo">3685</span> public boolean checkState(int tries) throws IOException {<a name="line.3685"></a> -<span class="sourceLineNo">3686</span> try {<a name="line.3686"></a> -<span class="sourceLineNo">3687</span> if (getAdmin().isTableAvailable(tableName)) {<a name="line.3687"></a> -<span class="sourceLineNo">3688</span> return true;<a name="line.3688"></a> -<span class="sourceLineNo">3689</span> }<a name="line.3689"></a> -<span class="sourceLineNo">3690</span> } catch (TableNotFoundException tnfe) {<a name="line.3690"></a> -<span class="sourceLineNo">3691</span> LOG.debug("Table " + tableName.getNameWithNamespaceInclAsString()<a name="line.3691"></a> -<span class="sourceLineNo">3692</span> + " was not enabled, sleeping. tries=" + tries);<a name="line.3692"></a> -<span class="sourceLineNo">3693</span> }<a name="line.3693"></a> -<span class="sourceLineNo">3694</span> return false;<a name="line.3694"></a> -<span class="sourceLineNo">3695</span> }<a name="line.3695"></a> -<span class="sourceLineNo">3696</span> });<a name="line.3696"></a> -<span class="sourceLineNo">3697</span> }<a name="line.3697"></a> -<span class="sourceLineNo">3698</span><a name="line.3698"></a> -<span class="sourceLineNo">3699</span> protected void waitForTableDisabled(final long deadlineTs)<a name="line.3699"></a> -<span class="sourceLineNo">3700</span> throws IOException, TimeoutException {<a name="line.3700"></a> -<span class="sourceLineNo">3701</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3701"></a> -<span class="sourceLineNo">3702</span> @Override<a name="line.3702"></a> -<span class="sourceLineNo">3703</span> public boolean checkState(int tries) throws IOException {<a name="line.3703"></a> -<span class="sourceLineNo">3704</span> return getAdmin().isTableDisabled(tableName);<a name="line.3704"></a> -<span class="sourceLineNo">3705</span> }<a name="line.3705"></a> -<span class="sourceLineNo">3706</span> });<a name="line.3706"></a> -<span class="sourceLineNo">3707</span> }<a name="line.3707"></a> -<span class="sourceLineNo">3708</span><a name="line.3708"></a> -<span class="sourceLineNo">3709</span> protected void waitTableNotFound(final long deadlineTs)<a name="line.3709"></a> -<span class="sourceLineNo">3710</span> throws IOException, TimeoutException {<a name="line.3710"></a> -<span class="sourceLineNo">3711</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3711"></a> -<span class="sourceLineNo">3712</span> @Override<a name="line.3712"></a> -<span class="sourceLineNo">3713</span> public boolean checkState(int tries) throws IOException {<a name="line.3713"></a> -<span class="sourceLineNo">3714</span> return !getAdmin().tableExists(tableName);<a name="line.3714"></a> -<span class="sourceLineNo">3715</span> }<a name="line.3715"></a> -<span class="sourceLineNo">3716</span> });<a name="line.3716"></a> -<span class="sourceLineNo">3717</span> }<a name="line.3717"></a> -<span class="sourceLineNo">3718</span><a name="line.3718"></a> -<span class="sourceLineNo">3719</span> protected void waitForSchemaUpdate(final long deadlineTs)<a name="line.3719"></a> -<span class="sourceLineNo">3720</span> throws IOException, TimeoutException {<a name="line.3720"></a> -<span class="sourceLineNo">3721</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3721"></a> -<span class="sourceLineNo">3722</span> @Override<a name="line.3722"></a> -<span class="sourceLineNo">3723</span> public boolean checkState(int tries) throws IOException {<a name="line.3723"></a> -<span class="sourceLineNo">3724</span> return getAdmin().getAlterStatus(tableName).getFirst() == 0;<a name="line.3724"></a> -<span class="sourceLineNo">3725</span> }<a name="line.3725"></a> -<span class="sourceLineNo">3726</span> });<a name="line.3726"></a> -<span class="sourceLineNo">3727</span> }<a name="line.3727"></a> -<span class="sourceLineNo">3728</span><a name="line.3728"></a> -<span class="sourceLineNo">3729</span> protected void waitForAllRegionsOnline(final long deadlineTs, final byte[][] splitKeys)<a name="line.3729"></a> -<span class="sourceLineNo">3730</span> throws IOException, TimeoutException {<a name="line.3730"></a> -<span class="sourceLineNo">3731</span> final TableDescriptor desc = getTableDescriptor();<a name="line.3731"></a> -<span class="sourceLineNo">3732</span> final AtomicInteger actualRegCount = new AtomicInteger(0);<a name="line.3732"></a> -<span class="sourceLineNo">3733</span> final MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {<a name="line.3733"></a> -<span class="sourceLineNo">3734</span> @Override<a name="line.3734"></a> -<span class="sourceLineNo">3735</span> public boolean visit(Result rowResult) throws IOException {<a name="line.3735"></a> -<span class="sourceLineNo">3736</span> RegionLocations list = MetaTableAccessor.getRegionLocations(rowResult);<a name="line.3736"></a> -<span class="sourceLineNo">3737</span> if (list == null) {<a name="line.3737"></a> -<span class="sourceLineNo">3738</span> LOG.warn("No serialized HRegionInfo in " + rowResult);<a name="line.3738"></a> -<span class="sourceLineNo">3739</span> return true;<a name="line.3739"></a> -<span class="sourceLineNo">3740</span> }<a name="line.3740"></a> -<span class="sourceLineNo">3741</span> HRegionLocation l = list.getRegionLocation();<a name="line.3741"></a> -<span class="sourceLineNo">3742</span> if (l == null) {<a name="line.3742"></a> -<span class="sourceLineNo">3743</span> return true;<a name="line.3743"></a> -<span class="sourceLineNo">3744</span> }<a name="line.3744"></a> -<span class="sourceLineNo">3745</span> if (!l.getRegionInfo().getTable().equals(desc.getTableName())) {<a name="line.3745"></a> -<span class="sourceLineNo">3746</span> return false;<a name="line.3746"></a> -<span class="sourceLineNo">3747</span> }<a name="line.3747"></a> -<span class="sourceLineNo">3748</span> if (l.getRegionInfo().isOffline() || l.getRegionInfo().isSplit()) return true;<a name="line.3748"></a> -<span class="sourceLineNo">3749</span> HRegionLocation[] locations = list.getRegionLocations();<a name="line.3749"></a> -<span class="sourceLineNo">3750</span> for (HRegionLocation location : locations) {<a name="line.3750"></a> -<span class="sourceLineNo">3751</span> if (location == null) continue;<a name="line.3751"></a> -<span class="sourceLineNo">3752</span> ServerName serverName = location.getServerName();<a name="line.3752"></a> -<span class="sourceLineNo">3753</span> // Make sure that regions are assigned to server<a name="line.3753"></a> -<span class="sourceLineNo">3754</span> if (serverName != null && serverName.getHostAndPort() != null) {<a name="line.3754"></a> -<span class="sourceLineNo">3755</span> actualRegCount.incrementAndGet();<a name="line.3755"></a> -<span class="sourceLineNo">3756</span> }<a name="line.3756"></a> -<span class="sourceLineNo">3757</span> }<a name="line.3757"></a> -<span class="sourceLineNo">3758</span> return true;<a name="line.3758"></a> -<span class="sourceLineNo">3759</span> }<a name="line.3759"></a> -<span class="sourceLineNo">3760</span> };<a name="line.3760"></a> -<span class="sourceLineNo">3761</span><a name="line.3761"></a> -<span class="sourceLineNo">3762</span> int tries = 0;<a name="line.3762"></a> -<span class="sourceLineNo">3763</span> int numRegs = (splitKeys == null ? 1 : splitKeys.length + 1) * desc.getRegionReplication();<a name="line.3763"></a> -<span class="sourceLineNo">3764</span> while (EnvironmentEdgeManager.currentTime() < deadlineTs) {<a name="line.3764"></a> -<span class="sourceLineNo">3765</span> actualRegCount.set(0);<a name="line.3765"></a> -<span class="sourceLineNo">3766</span> MetaTableAccessor.scanMetaForTableRegions(getAdmin().getConnection(), visitor,<a name="line.3766"></a> -<span class="sourceLineNo">3767</span> desc.getTableName());<a name="line.3767"></a> -<span class="sourceLineNo">3768</span> if (actualRegCount.get() == numRegs) {<a name="line.3768"></a> -<span class="sourceLineNo">3769</span> // all the regions are online<a name="line.3769"></a> -<span class="sourceLineNo">3770</span> return;<a name="line.3770"></a> -<span class="sourceLineNo">3771</span> }<a name="line.3771"></a> -<span class="sourceLineNo">3772</span><a name="line.3772"></a> -<span class="sourceLineNo">3773</span> try {<a name="line.3773"></a> -<span class="sourceLineNo">3774</span> Thread.sleep(getAdmin().getPauseTime(tries++));<a name="line.3774"></a> -<span class="sourceLineNo">3775</span> } catch (InterruptedException e) {<a name="line.3775"></a> -<span class="sourceLineNo">3776</span> throw new InterruptedIOException("Interrupted when opening" + " regions; "<a name="line.3776"></a> -<span class="sourceLineNo">3777</span> + actualRegCount.get() + " of " + numRegs + " regions processed so far");<a name="line.3777"></a> -<span class="sourceLineNo">3778</span> }<a name="line.3778"></a> -<span class="sourceLineNo">3779</span> }<a name="line.3779"></a> -<span class="sourceLineNo">3780</span> throw new TimeoutException("Only " + actualRegCount.get() + " of " + numRegs<a name="line.3780"></a> -<span class="sourceLineNo">3781</span> + " regions are online; retries exhausted.");<a name="line.3781"></a> -<span class="sourceLineNo">3782</span> }<a name="line.3782"></a> -<span class="sourceLineNo">3783</span> }<a name="line.3783"></a> -<span class="sourceLineNo">3784</span><a name="line.3784"></a> -<span class="sourceLineNo">3785</span> @InterfaceAudience.Private<a name="line.3785"></a> -<span class="sourceLineNo">3786</span> @InterfaceStability.Evolving<a name="line.3786"></a> -<span class="sourceLineNo">3787</span> protected static abstract class NamespaceFuture extends ProcedureFuture<Void> {<a name="line.3787"></a> -<span class="sourceLineNo">3788</span> private final String namespaceName;<a name="line.3788"></a> -<span class="sourceLineNo">3789</span><a name="line.3789"></a> -<span class="sourceLineNo">3790</span> public NamespaceFuture(final HBaseAdmin admin, final String namespaceName, final Long procId) {<a name="line.3790"></a> -<span class="sourceLineNo">3791</span> super(admin, procId);<a name="line.3791"></a> -<span class="sourceLineNo">3792</span> this.namespaceName = namespaceName;<a name="line.3792"></a> -<span class="sourceLineNo">3793</span> }<a name="line.3793"></a> -<span class="sourceLineNo">3794</span><a name="line.3794"></a> -<span class="sourceLineNo">3795</span> /**<a name="line.3795"></a> -<span class="sourceLineNo">3796</span> * @return the namespace name<a name="line.3796"></a> -<span class="sourceLineNo">3797</span> */<a name="line.3797"></a> -<span class="sourceLineNo">3798</span> protected String getNamespaceName() {<a name="line.3798"></a> -<span class="sourceLineNo">3799</span> return namespaceName;<a name="line.3799"></a> -<span class="sourceLineNo">3800</span> }<a name="line.3800"></a> -<span class="sourceLineNo">3801</span><a name="line.3801"></a> -<span class="sourceLineNo">3802</span> /**<a name="line.3802"></a> -<span class="sourceLineNo">3803</span> * @return the operation type like CREATE_NAMESPACE, DELETE_NAMESPACE, etc.<a name="line.3803"></a> -<span class="sourceLineNo">3804</span> */<a name="line.3804"></a> -<span class="sourceLineNo">3805</span> public abstract String getOperationType();<a name="line.3805"></a> -<span class="sourceLineNo">3806</span><a name="line.3806"></a> -<span class="sourceLineNo">3807</span> @Override<a name="line.3807"></a> -<span class="sourceLineNo">3808</span> public String toString() {<a name="line.3808"></a> -<span class="sourceLineNo">3809</span> return "Operation: " + getOperationType() + ", Namespace: " + getNamespaceName();<a name="line.3809"></a> -<span class="sourceLineNo">3810</span> }<a name="line.3810"></a> -<span class="sourceLineNo">3811</span> }<a name="line.3811"></a> -<span class="sourceLineNo">3812</span><a name="line.3812"></a> -<span class="sourceLineNo">3813</span> @InterfaceAudience.Private<a name="line.3813"></a> -<span class="sourceLineNo">3814</span> @InterfaceStability.Evolving<a name="line.3814"></a> -<span class="sourceLineNo">3815</span> private static class ReplicationFuture extends ProcedureFuture<Void> {<a name="line.3815"></a> -<span class="sourceLineNo">3816</span> private final String peerId;<a name="line.3816"></a> -<span class="sourceLineNo">3817</span> private final Supplier<String> getOperation;<a name="line.3817"></a> -<span class="sourceLineNo">3818</span><a name="line.3818"></a> -<span class="sourceLineNo">3819</span> public ReplicationFuture(HBaseAdmin admin, String peerId, Long procId,<a name="line.3819"></a> -<span class="sourceLineNo">3820</span> Supplier<String> getOperation) {<a name="line.3820"></a> -<span class="sourceLineNo">3821</span> super(admin, procId);<a name="line.3821"></a> -<span class="sourceLineNo">3822</span> this.peerId = peerId;<a name="line.3822"></a> -<span class="sourceLineNo">3823</span> this.getOperation = getOperation;<a name="line.3823"></a> -<span class="sourceLineNo">3824</span> }<a name="line.3824"></a> -<span class="sourceLineNo">3825</span><a name="line.3825"></a> -<span class="sourceLineNo">3826</span> @Override<a name="line.3826"></a> -<span class="sourceLineNo">3827</span> public String toString() {<a name="line.3827"></a> -<span class="sourceLineNo">3828</span> return "Operation: " + getOperation.get() + ", peerId: " + peerId;<a name="line.3828"></a> -<span class="sourceLineNo">3829</span> }<a name="line.3829"></a> -<span class="sourceLineNo">3830</span> }<a name="line.3830"></a> -<span class="sourceLineNo">3831</span><a name="line.3831"></a> -<span class="sourceLineNo">3832</span> @Override<a name="line.3832"></a> -<span class="sourceLineNo">3833</span> public List<SecurityCapability> getSecurityCapabilities() throws IOException {<a name="line.3833"></a> -<span class="sourceLineNo">3834</span> try {<a name="line.3834"></a> -<span class="sourceLineNo">3835</span> return executeCallable(new MasterCallable<List<SecurityCapability>>(getConnection(),<a name="line.3835"></a> -<span class="sourceLineNo">3836</span> getRpcControllerFactory()) {<a name="line.3836"></a> -<span class="sourceLineNo">3837</span> @Override<a name="line.3837"></a> -<span class="sourceLineNo">3838</span> protected List<SecurityCapability> rpcCall() throws Exception {<a name="line.3838"></a> -<span class="sourceLineNo">3839</span> SecurityCapabilitiesRequest req = SecurityCapabilitiesRequest.newBuilder().build();<a name="line.3839"></a> -<span class="sourceLineNo">3840</span> return ProtobufUtil.toSecurityCapabilityList(<a name="line.3840"></a> -<span class="sourceLineNo">3841</span> master.getSecurityCapabilities(getRpcController(), req).getCapabilitiesList());<a name="line.3841"></a> -<span class="sourceLineNo">3842</span> }<a name="line.3842"></a> -<span class="sourceLineNo">3843</span> });<a name="line.3843"></a> -<span class="sourceLineNo">3844</span> } catch (IOException e) {<a name="line.3844"></a> -<span class="sourceLineNo">3845</span> if (e instanceof RemoteException) {<a name="line.3845"></a> -<span class="sourceLineNo">3846</span> e = ((RemoteException)e).unwrapRemoteException();<a name="line.3846"></a> -<span class="sourceLineNo">3847</span> }<a name="line.3847"></a> -<span class="sourceLineNo">3848</span> throw e;<a name="line.3848"></a> -<span class="sourceLineNo">3849</span> }<a name="line.3849"></a> -<span class="sourceLineNo">3850</span> }<a name="line.3850"></a> -<span class="sourceLineNo">3851</span><a name="line.3851"></a> -<span class="sourceLineNo">3852</span> @Override<a name="line.3852"></a> -<span class="sourceLineNo">3853</span> public boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException {<a name="line.3853"></a> -<span class="sourceLineNo">3854</span> return splitOrMergeSwitch(enabled, synchronous, MasterSwitchType.SPLIT);<a name="line.3854"></a> -<span class="sourceLineNo">3855</span> }<a name="line.3855"></a> -<span class="sourceLineNo">3856</span><a name="line.3856"></a> -<span class="sourceLineNo">3857</span> @Override<a name="line.3857"></a> -<span class="sourceLineNo">3858</span> public boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException {<a name="line.3858"></a> -<span class="sourceLineNo">3859</span> return splitOrMergeSwitch(enabled, synchronous, MasterSwitchType.MERGE);<a name="line.3859"></a> -<span class="sourceLineNo">3860</span> }<a name="line.3860"></a> -<span class="sourceLineNo">3861</span><a name="line.3861"></a> -<span class="sourceLineNo">3862</span> private boolean splitOrMergeSwitch(boolean enabled, boolean synchronous,<a name="line.3862"></a> -<span class="sourceLineNo">3863</span> MasterSwitchType switchType) throws IOException {<a name="line.3863"></a> -<span class="sourceLineNo">3864</span> return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {<a name="line.3864"></a> -<span class="sourceLineNo">3865</span> @Override<a name="line.3865"></a> -<span class="sourceLineNo">3866</span> protected Boolean rpcCall() throws Exception {<a name="line.3866"></a> -<span class="sourceLineNo">3867</span> MasterProtos.SetSplitOrMergeEnabledResponse response = master.setSplitOrMergeEnabled(<a name="line.3867"></a> -<span class="sourceLineNo">3868</span> getRpcController(),<a name="line.3868"></a> -<span class="sourceLineNo">3869</span> RequestConverter.buildSetSplitOrMergeEnabledRequest(enabled, synchronous, switchType));<a name="line.3869"></a> -<span class="sourceLineNo">3870</span> return response.getPrevValueList().get(0);<a name="line.3870"></a> -<span class="sourceLineNo">3871</span> }<a name="line.3871"></a> -<span class="sourceLineNo">3872</span> });<a name="line.3872"></a> -<span class="sourceLineNo">3873</span> }<a name="line.3873"></a> -<span class="sourceLineNo">3874</span><a name="line.3874"></a> -<span class="sourceLineNo">3875</span> @Override<a name="line.3875"></a> -<span class="sourceLineNo">3876</span> public boolean isSplitEnabled() throws IOException {<a name="line.3876"></a> -<span class="sourceLineNo">3877</span> return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {<a name="line.3877"></a> -<span class="sourceLineNo">3878</span> @Override<a name="line.3878"></a> -<span class="sourceLineNo">3879</span> protected Boolean rpcCall() throws Exception {<a name="line.3879"></a> -<span class="sourceLineNo">3880</span> return master.isSplitOrMergeEnabled(getRpcController(),<a name="line.3880"></a> -<span class="sourceLineNo">3881</span> RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled();<a name="line.3881"></a> -<span class="sourceLineNo">3882</span> }<a name="line.3882"></a> -<span class="sourceLineNo">3883</span> });<a name="line.3883"></a> -<span class="sourceLineNo">3884</span> }<a name="line.3884"></a> -<span class="sourceLineNo">3885</span><a name="line.3885"></a> -<span class="sourceLineNo">3886</span> @Override<a name="line.3886"></a> -<span class="sourceLineNo">3887</span> public boolean isMergeEnabled() throws IOException {<a name="line.3887"></a> -<span class="sourceLineNo">3888</span> return executeCallable(new MasterCallable<Boolean>(getConnection(), getRpcControllerFactory()) {<a name="line.3888"></a> -<span class="sourceLineNo">3889</span> @Override<a name="line.3889"></a> -<span class="sourceLineNo">3890</span> protected Boolean rpcCall() throws Exception {<a name="line.3890"></a> -<span class="sourceLineNo">3891</span> return master.isSplitOrMergeEnabled(getRpcController(),<a name="line.3891"></a> -<span class="sourceLineNo">3892</span> RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled();<a name="line.3892"></a> -<span class="sourceLineNo">3893</span> }<a name="line.3893"></a> -<span class="sourceLineNo">3894</span> });<a name="line.3894"></a> -<span class="sourceLineNo">3895</span> }<a name="line.3895"></a> -<span class="sourceLineNo">3896</span><a name="line.3896"></a> -<span class="sourceLineNo">3897</span> private RpcControllerFactory getRpcControllerFactory() {<a name="line.3897"></a> -<span class="sourceLineNo">3898</span> return this.rpcControllerFactory;<a name="line.3898"></a> -<span class="sourceLineNo">3899</span> }<a name="line.3899"></a> -<span class="sourceLineNo">3900</span><a name="line.3900"></a> -<span class="sourceLineNo">3901</span> @Override<a name="line.3901"></a> -<span class="sourceLineNo">3902</span> public void addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig, boolean enabled)<a name="line.3902"></a> -<span class="sourceLineNo">3903</span> throws IOException {<a name="line.3903"></a> -<span class="sourceLineNo">3904</span> get(addReplicationPeerAsync(peerId, peerConfig, enabled), this.syncWaitTimeout,<a name="line.3904"></a> -<span class="sourceLineNo">3905</span> TimeUnit.MILLISECONDS);<a name="line.3905"></a> -<span class="sourceLineNo">3906</span> }<a name="line.3906"></a> -<span class="sourceLineNo">3907</span><a name="line.3907"></a> -<span class="sourceLineNo">3908</span> @Override<a name="line.3908"></a> -<span class="sourceLineNo">3909</span> public Future<Void> addReplicationPeerAsync(String peerId, ReplicationPeerConfig peerConfig,<a name="line.3909"></a> -<span class="sourceLineNo">3910</span> boolean enabled) throws IOException {<a name="line.3910"></a> -<span class="sourceLineNo">3911</span> AddReplicationPeerResponse response = executeCallable(<a name="line.3911"></a> -<span class="sourceLineNo">3912</span> new MasterCallable<AddReplicationPeerResponse>(getConnection(), getRpcControllerFactory()) {<a name="line.3912"></a> -<span class="sourceLineNo">3913</span> @Override<a name="line.3913"></a> -<span class="sourceLineNo">3914</span> protected AddReplicationPeerResponse rpcCall() throws Exception {<a name="line.3914"></a> -<span class="sourceLineNo">3915</span> return master.addReplicationPeer(getRpcController(),<a name="line.3915"></a> -<span class="sourceLineNo">3916</span> RequestConverter.buildAddReplicationPeerRequest(peerId, peerConfig, enabled));<a name="line.3916"></a> -<span class="sourceLineNo">3917</span> }<a name="line.3917"></a> -<span class="sourceLineNo">3918</span> });<a name="line.3918"></a> -<span class="sourceLineNo">3919</span> return new ReplicationFuture(this, peerId, response.getProcId(), () -> "ADD_REPLICATION_PEER");<a name="line.3919"></a> -<span class="sourceLineNo">3920</span> }<a name="line.3920"></a> -<span class="sourceLineNo">3921</span><a name="line.3921"></a> -<span class="sourceLineNo">3922</span> @Override<a name="line.3922"></a> -<span class="sourceLineNo">3923</span> public void removeReplicationPeer(String peerId) throws IOException {<a name="line.3923"></a> -<span class="sourceLineNo">3924</span> get(removeReplicationPeerAsync(peerId), this.syncWaitTimeout, TimeUnit.MILLISECONDS);<a name="line.3924"></a> -<span class="sourceLineNo">3925</span> }<a name="line.3925"></a> -<span class="sourceLineNo">3926</span><a name="line.3926"></a> -<span class="sourceLineNo">3927</span> @Override<a name="line.3927"></a> -<span class="sourceLineNo">3928</span> public Future<Void> removeReplicationPeerAsync(String peerId) throws IOException {<a name="line.3928"></a> -<span class="sourceLineNo">3929</span> RemoveReplicationPeerResponse response =<a name="line.3929"></a> -<span class="sourceLineNo">3930</span> executeCallable(new MasterCallable<RemoveReplicationPeerResponse>(getConnection(),<a name="line.3930"></a> -<span class="sourceLineNo">3931</span> getRpcControllerFactory()) {<a name="line.3931"></a> -<span class="sourceLineNo">3932</span> @Override<a name="line.3932"></a> -<span class="sourceLineNo">3933</span> protected RemoveReplicationPeerResponse rpcCall() throws Exception {<a name="line.3933"></a> -<span class="sourceLineNo">3934</span> return master.removeReplicationPeer(getRpcController(),<a name="line.3934"></a> -<span class="sourceLineNo">3935</span> RequestConverter.buildRemoveReplicationPeerRequest(peerId));<a name="line.3935"></a> -<span class="sourceLineNo">3936</span> }<a name="line.3936"></a> -<span class="sourceLineNo">3937</span> });<a name="line.3937"></a> -<span class="sourceLineNo">3938</span> return new ReplicationFuture(this, peerId, response.getProcId(),<a name="line.3938"></a> -<span class="sourceLineNo">3939</span> () -> "REMOVE_REPLICATION_PEER");<a name="line.3939"></a> -<span class="sourceLineNo">3940</span> }<a name="line.3940"></a> -<span class="sourceLineNo">3941</span><a name="line.3941"></a> -<span class="sourceLineNo">3942</span> @Override<a name="line.3942"></a> -<span class="sourceLineNo">3943</span> public void enableReplicationPeer(final String peerId) throws IOException {<a name="line.3943"></a> -<span class="sourceLineNo">3944</span> get(enableReplicationPeerAsync(peerId), this.syncWaitTimeout, TimeUnit.MILLISECONDS);<a name="line.3944"></a> -<span class="sourceLineNo">3945</span> }<a name="line.3945"></a> -<span class="sourceLineNo">3946</span><a name="line.3946"></a> -<span class="sourceLineNo">3947</span> @Override<a name="line.3947"></a> -<span class="sourceLineNo">3948</span> public Future<Void> enableReplicationPeerAsync(final String peerId) throws IOException {<a name="line.3948"></a> -<span class="sourceLineNo">3949</span> EnableReplicationPeerResponse response =<a name="line.3949"></a> -<span class="sourceLineNo">3950</span> executeCallable(new MasterCallable<EnableReplicationPeerResponse>(getConnection(),<a name="line.3950"></a> -<span class="sourceLineNo">3951</span> getRpcControllerFactory()) {<a name="line.3951"></a> -<span class="sourceLineNo">3952</span> @Override<a name="line.3952"></a> -<span class="sourceLineNo">3953</span> protected EnableReplicationPeerResponse rpcCall() throws Exception {<a name="line.3953"></a> -<span class="sourceLineNo">3954</span> return master.enableReplicationPeer(getRpcController(),<a name="line.3954"></a> -<span class="sourceLineNo">3955</span> RequestConverter.buildEnableReplicationPeerRequest(peerId));<a name="line.3955"></a> -<span class="sourceLineNo">3956</span> }<a name="line.3956"></a> -<span class="sourceLineNo">3957</span> });<a name="line.3957"></a> -<span class="sourceLineNo">3958</span> return new ReplicationFuture(this, peerId, response.getProcId(),<a name="line.3958"></a> -<span class="sourceLineNo">3959</span> () -> "ENABLE_REPLICATION_PEER");<a name="line.3959"></a> -<span class="sourceLineNo">3960</span> }<a name="line.3960"></a> -<span class="sourceLineNo">3961</span><a name="line.3961"></a> -<span class="sourceLineNo">3962</span> @Override<a name="line.3962"></a> -<span class="sourceLineNo">3963</span> public void disableReplicationPeer(final String peerId) throws IOException {<a name="line.3963"></a> -<span class="sourceLineNo">3964</span> get(disableReplicationPeerAsync(peerId), this.syncWaitTimeout, TimeUnit.MILLISECONDS);<a name="line.3964"></a> -<span class="sourceLineNo">3965</span> }<a name="line.3965"></a> -<span class="sourceLineNo">3966</span><a name="line.3966"></a> -<span class="sourceLineNo">3967</span> @Override<a name="line.3967"></a> -<span class="sourceLineNo">3968</span> public Future<Void> disableReplicationPeerAsync(final String peerId) throws IOException {<a name="line.3968"></a> -<span class="sourceLineNo">3969</span> DisableReplicationPeerResponse response =<a name="line.3969"></a> -<span class="sourceLineNo">3970</span> executeCallable(new MasterCallable<DisableReplicationPeerResponse>(getConnection(),<a name="line.3970"></a> -<span class="sourceLineNo">3971</span> getRpcControllerFactory()) {<a name="line.3971"></a> -<span class="sourceLineNo">3972</span> @Override<a name="line.3972"></a> -<span class="sourceLineNo">3973</span> protected DisableReplicationPeerResponse rpcCall() throws Exception {<a name="line.3973"></a> -<span class="sourceLineNo">3974</span> return master.disableReplicationPeer(getRpcController(),<a name="line.3974"></a> -<span class="sourceLineNo">3975</span> RequestConverter.buildDisableReplicationPeerRequest(peerId));<a name="line.3975"></a> -<span class="sourceLineNo">3976</span> }<a name="line.3976"></a> -<span class="sourceLineNo">3977</span> });<a name="line.3977"></a> -<span class="sourceLineNo">3978</span> return new ReplicationFuture(this, peerId, response.getProcId(),<a name="line.3978"></a> -<span class="sourceLineNo">3979</span> () -> "DISABLE_REPLICATION_PEER");<a name="line.3979"></a> -<span class="sourceLineNo">3980</span> }<a name="line.3980"></a> -<span class="sourceLineNo">3981</span><a name="line.3981"></a> -<span class="sourceLineNo">3982</span> @Override<a name="line.3982"></a> -<span class="sourceLineNo">3983</span> public ReplicationPeerConfig getReplicationPeerConfig(final String peerId) throws IOException {<a name="line.3983"></a> -<span class="sourceLineNo">3984</span> return executeCallable(new MasterCallable<ReplicationPeerConfig>(getConnection(),<a name="line.3984"></a> -<span class="sourceLineNo">3985</span> getRpcControllerFactory()) {<a name="line.3985"></a> -<span class="sourceLineNo">3986</span> @Override<a name="line.3986"></a> -<span class="sourceLineNo">3987</span> protected ReplicationPeerConfig rpcCall() throws Exception {<a name="line.3987"></a> -<span class="sourceLineNo">3988</span> GetReplicationPeerConfigResponse response = master.getReplicationPeerConfig(<a name="line.3988"></a> -<span class="sourceLineNo">3989</span> getRpcController(), RequestConverter.buildGetReplicationPeerConfigRequest(peerId));<a name="line.3989"></a> -<span class="sourceLineNo">3990</span> return ReplicationPeerConfigUtil.convert(response.getPeerConfig());<a name="line.3990"></a> -<span class="sourceLineNo">3991</span> }<a name="line.3991"></a> -<span class="sourceLineNo">3992</span> });<a name="line.3992"></a> -<span class="sourceLineNo">3993</span> }<a name="line.3993"></a> -<span class="sourceLineNo">3994</span><a name="line.3994"></a> -<span class="sourceLineNo">3995</span> @Override<a name="line.3995"></a> -<span class="sourceLineNo">3996</span> public void updateReplicationPeerConfig(final String peerId,<a name="line.3996"></a> -<span class="sourceLineNo">3997</span> final ReplicationPeerConfig peerConfig) throws IOException {<a name="line.3997"></a> -<span class="sourceLineNo">3998</span> get(updateReplicationPeerConfigAsync(peerId, peerConfig), this.syncWaitTimeout,<a name="line.3998"></a> -<span class="sourceLineNo">3999</span> TimeUnit.MILLISECONDS);<a name="line.3999"></a> -<span class="sourceLineNo">4000</span> }<a name="line.4000"></a> -<span class="sourceLineNo">4001</span><a name="line.4001"></a> -<span class="sourceLineNo">4002</span> @Override<a name="line.4002"></a> -<span class="sourceLineNo">4003</span> public Future<Void> updateReplicationPeerConfigAsync(final String peerId,<a name="line.4003"></a> -<span class="sourceLineNo">4004</span> final ReplicationPeerConfig peerConfig) throws IOException {<a name="line.4004"></a> -<span class="sourceLineNo">4005</span> UpdateReplicationPeerConfigResponse response =<a name="line.4005"></a> -<span class="sourceLineNo">4006</span> executeCallable(new MasterCallable<UpdateReplicationPeerConfigResponse>(getConnection(),<a name="line.4006"></a> -<span class="sourceLineNo">4007</span> getRpcControllerFactory()) {<a name="line.4007"></a> -<span class="sourceLineNo">4008</span> @Override<a name="line.4008"></a> -<span class="sourceLineNo">4009</span> protected UpdateReplicationPeerConfigResponse rpcCall() throws Exception {<a name="line.4009"></a> -<span class="sourceLineNo">4010</span> return master.updateReplicationPeerConfig(getRpcController(),<a name="line.4010"></a> -<span class="sourceLineNo">4011</span> RequestConverter.buildUpdateReplicationPeerConfigRequest(peerId, peerConfig));<a name="line.4011"></a> -<span class="sourceLineNo">4012</span> }<a name="line.4012"></a> -<span class="sourceLineNo">4013</span> });<a name="line.4013"></a> -<span class="sourceLineNo">4014</span> return new ReplicationFuture(this, peerId, response.getProcId(),<a name="line.4014"></a> -<span class="sourceLineNo">4015</span> () -> "UPDATE_REPLICATION_PEER_CONFIG");<a name="line.4015"></a> -<span class="sourceLineNo">4016</span> }<a name="line.4016"></a> -<span class="sourceLineNo">4017</span><a name="line.4017"></a> -<span class="sourceLineNo">4018</span> @Override<a name="line.4018"></a> -<span class="sourceLineNo">4019</span> public void transitReplicationPeerSyncReplicationState(String peerId, SyncReplicationState state)<a name="line.4019"></a> -<span class="sourceLineNo">4020</span> throws IOException {<a name="line.4020"></a> -<span class="sourceLineNo">4021</span> get(transitReplicationPeerSyncReplicationStateAsync(peerId, state), this.syncWaitTimeout,<a name="line.4021"></a> -<span class="sourceLineNo">4022</span> TimeUnit.MILLISECONDS);<a name="line.4022"></a> -<span class="sourceLineNo">4023</span> }<a name="line.4023"></a> -<span class="sourceLineNo">4024</span><a name="line.4024"></a> -<span class="sourceLineNo">4025</span> @Override<a name="line.4025"></a> -<span class="sourceLineNo">4026</span> public Future<Void> transitReplicationPeerSyncReplicationStateAsync(String peerId,<a name="line.4026"></a> -<span class="sourceLineNo">4027</span> SyncReplicationState state) throws IOException {<a name="line.4027"></a> -<span class="sourceLineNo">4028</span> TransitReplicationPeerSyncReplicationStateResponse response =<a name="line.4028"></a> -<span class="sourceLineNo">4029</span> executeCallable(new MasterCallable<TransitReplicationPeerSyncReplicationStateResponse>(<a name="line.4029"></a> -<span class="sourceLineNo">4030</span> getConnection(), getRpcControllerFactory()) {<a name="line.4030"></a> -<span class="sourceLineNo">4031</span> @Override<a name="line.4031"></a> -<span class="sourceLineNo">4032</span> protected TransitReplicationPeerSyncReplicationStateResponse rpcCall() throws Exception {<a name="line.4032"></a> -<span class="sourceLineNo">4033</span> return master.transitReplicationPeerSyncReplicationState(getRpcController(),<a name="line.4033"></a> -<span class="sourceLineNo">4034</span> RequestConverter.buildTransitReplicationPeerSyncReplicationStateRequest(peerId,<a name="line.4034"></a> -<span class="sourceLineNo">4035</span> state));<a name="line.4035"></a> -<span class="sourceLineNo">4036</span> }<a name="line.4036"></a> -<span class="sourceLineNo">4037</span> });<a name="line.4037"></a> -<span class="sourceLineNo">4038</span> return new ReplicationFuture(this, peerId, response.getProcId(),<a name="line.4038"></a> -<span class="sourceLineNo">4039</span> () -> "TRANSIT_REPLICATION_PEER_SYNCHRONOUS_REPLICATION_STATE");<a name="line.4039"></a> -<span class="sourceLineNo">4040</span> }<a name="line.4040"></a> -<span class="sourceLineNo">4041</span><a name="line.4041"></a> -<span class="sourceLineNo">4042</span> @Override<a name="line.4042"></a> -<span class="sourceLineNo">4043</span> public void appendReplicationPeerTableCFs(String id,<a name="line.4043"></a> -<span class="sourceLineNo">4044</span> Map<TableName, List<String>> tableCfs)<a name="line.4044"></a> -<span class="sourceLineNo">4045</span> throws ReplicationException, IOException {<a name="line.4045"></a> -<span class="sourceLineNo">4046</span> if (tableCfs == null) {<a name="line.4046"></a> -<span class="sourceLineNo">4047</span> throw new ReplicationException("tableCfs is null");<a name="line.4047"></a> -<span class="sourceLineNo">4048</span> }<a name="line.4048"></a> -<span class="sourceLineNo">4049</span> ReplicationPeerConfig peerConfig = getReplicationPeerConfig(id);<a name="line.4049"></a> -<span class="sourceLineNo">4050</span> ReplicationPeerConfig newPeerConfig =<a name="line.4050"></a> -<span class="sourceLineNo">4051</span> ReplicationPeerConfigUtil.appendTableCFsToReplicationPeerConfig(tableCfs, peerConfig);<a name="line.4051"></a> -<span class="sourceLineNo">4052</span> updateReplicationPeerConfig(id, newPeerConfig);<a name="line.4052"></a> -<span class="sourceLineNo">4053</span> }<a name="line.4053"></a> -<span class="sourceLineNo">4054</span><a name="line.4054"></a> -<span class="sourceLineNo">4055</span> @Override<a name="line.4055"></a> -<span class="sourceLineNo">4056</span> public void removeReplicationPeerTableCFs(String id,<a name="line.4056"></a> -<span class="sourceLineNo">4057</span> Map<TableName, List<String>> tableCfs)<a name="line.4057"></a> -<span class="sourceLineNo">4058</span> throws ReplicationException, IOException {<a name="line.4058"></a> -<span class="sourceLineNo">4059</span> if (tableCfs == null) {<a name="line.4059"></a> -<span class="sourceLineNo">4060</span> throw new ReplicationException("tableCfs is null");<a name="line.4060"></a> -<span class="sourceLineNo">4061</span> }<a name="line.4061"></a> -<span class="sourceLineNo">4062</span> ReplicationPeerConfig peerConfig = getReplicationPeerConfig(id);<a name="line.4062"></a> -<span class="sourceLineNo">4063</span> ReplicationPeerConfig newPeerConfig =<a name="line.4063"></a> -<span class="sourceLineNo">4064</span> ReplicationPeerConfigUtil.removeTableCFsFromReplicationPeerConfig(tableCfs, peerConfig, id);<a name="line.4064"></a> -<span class="sourceLineNo">4065</span> updateReplicationPeerConfig(id, newPeerConfig);<a name="line.4065"></a> -<span class="sourceLineNo">4066</span> }<a name="line.4066"></a> -<span class="sourceLineNo">4067</span><a name="line.4067"></a> -<span class="sourceLineNo">4068</span> @Override<a name="line.4068"></a> -<span class="sourceLineNo">4069</span> public List<ReplicationPeerDescription> listReplicationPeers() throws IOException {<a name="line.4069"></a> -<span class="sourceLineNo">4070</span> return listReplicationPeers((Pattern)null);<a name="line.4070"></a> -<span class="sourceLineNo">4071</span> }<a name="line.4071"></a> -<span class="sourceLineNo">4072</span><a name="line.4072"></a> -<span class="sourceLineNo">4073</span> @Override<a name="line.4073"></a> -<span class="sourceLineNo">4074</span> public List<ReplicationPeerDescription> listReplicationPeers(Pattern pattern)<a name="line.4074"></a> -<span class="sourceLineNo">4075</span> throws IOException {<a name="line.4075"></a> -<span class="sourceLineNo">4076</span> return executeCallable(new MasterCallable<List<ReplicationPeerDescription>>(getConnection(),<a name="line.4076"></a> -<span class="sourceLineNo">4077</span> getRpcControllerFactory()) {<a name="line.4077"></a> -<span class="sourceLineNo">4078</span> @Override<a name="line.4078"></a> -<span class="sourceLineNo">4079</span> protected List<ReplicationPeerDescription> rpcCall() throws Exception {<a name="line.4079"></a> -<span class="sourceLineNo">4080</span> List<ReplicationProtos.ReplicationPeerDescription> peersList = master.listReplicationPeers(<a name="line.4080"></a> -<span class="sourceLineNo">4081</span> getRpcController(), RequestConverter.buildListReplicationPeersRequest(pattern))<a name="line.4081"></a> -<span class="sourceLineNo">4082</span> .getPeerDescList();<a name="line.4082"></a> -<span class="sourceLineNo">4083</span> List<ReplicationPeerDescription> result = new ArrayList<>(peersList.size());<a name="line.4083"></a> -<span class="sourceLineNo">4084</span> for (ReplicationProtos.ReplicationPeerDescription peer : peersList) {<a name="line.4084"></a> -<span class="sourceLineNo">4085</span> result.add(ReplicationPeerConfigUtil.toReplicationPeerDescription(peer));<a name="line.4085"></a> -<span class="sourceLineNo">4086</span> }<a name="line.4086"></a> -<span class="sourceLineNo">4087</span> return result;<a name="line.4087"></a> -<span class="sourceLineNo">4088</span> }<a name="line.4088"></a> -<span class="sourceLineNo">4089</span> });<a name="line.4089"></a> -<span class="sourceLineNo">4090</span> }<a name="line.4090"></a> -<span class="sourceLineNo">4091</span><a name="line.4091"></a> -<span class="sourceLineNo">4092</span> @Override<a name="line.4092"></a> -<span class="sourceLineNo">4093</span> public void decommissionRegionServers(List<ServerName> servers, boolean offload)<a name="line.4093"></a> -<span class="sourceLineNo">4094</span> throws IOException {<a name="line.4094"></a> -<span class="sourceLineNo">4095</span> executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {<a name="line.4095"></a> -<span class="sourceLineNo">4096</span> @Override<a name="line.4096"></a> -<span class="sourceLineNo">4097</span> public Void rpcCall() throws ServiceException {<a name="line.4097"></a> -<span class="sourceLineNo">4098</span> master.decommissionRegionServers(getRpcController(),<a name="line.4098"></a> -<span class="sourceLineNo">4099</span> RequestConverter.buildDecommissionRegionServersRequest(servers, offload));<a name="line.4099"></a> -<span class="sourceLineNo">4100</span> return null;<a name="line.4100"></a> -<span class="sourceLineNo">4101</span> }<a name="line.4101"></a> -<span class="sourceLineNo">4102</span> });<a name="line.4102"></a> -<span class="sourceLineNo">4103</span> }<a name="line.4103"></a> -<span class="sourceLineNo">4104</span><a name="line.4104"></a> -<span class="sourceLineNo">4105</span> @Override<a name="line.4105"></a> -<span class="sourceLineNo">4106</span> public List<ServerName> listDecommissionedRegionServers() throws IOException {<a name="line.4106"></a> -<span class="sourceLineNo">4107</span> return executeCallable(new MasterCallable<List<ServerName>>(getConnection(),<a name="line.4107"></a> -<span class="sourceLineNo">4108</span> getRpcControllerFactory()) {<a name="line.4108"></a> -<span class="sourceLineNo">4109</span> @Override<a name="line.4109"></a> -<span class="sourceLineNo">4110</span> public List<ServerName> rpcCall() throws ServiceException {<a name="line.4110"></a> -<span class="sourceLineNo">4111</span> ListDecommissionedRegionServersRequest req =<a name="line.4111"></a> -<span class="sourceLineNo">4112</span> ListDecommissionedRegionServersRequest.newBuilder().build();<a name="line.4112"></a> -<span class="sourceLineNo">4113</span> List<ServerName> servers = new ArrayList<>();<a name="line.4113"></a> -<span class="sourceLineNo">4114</span> for (HBaseProtos.ServerName server : master<a name="line.4114"></a> -<span class="sourceLineNo">4115</span> .listDecommissionedRegionServers(getRpcController(), req).getServerNameList()) {<a name="line.4115"></a> -<span class="sourceLineNo">4116</span> servers.add(ProtobufUtil.toServerName(server));<a name="line.4116"></a> -<span class="sourceLineNo">4117</span> }<a name="line.4117"></a> -<span class="sourceLineNo">4118</span> return servers;<a name="line.4118"></a> -<span class="sourceLineNo">4119</span> }<a name="line.4119"></a> -<span class="sourceLineNo">4120</span> });<a name="line.4120"></a> -<span class="sourceLineNo">4121</span> }<a name="line.4121"></a> -<span class="sourceLineNo">4122</span><a name="line.4122"></a> -<span class="sourceLineNo">4123</span> @Override<a name="line.4123"></a> -<span class="sourceLineNo">4124</span> public void recommissionRegionServer(ServerName server, List<byte[]> encodedRegionNames)<a name="line.4124"></a> -<span class="sourceLineNo">4125</span> throws IOException {<a name="line.4125"></a> -<span class="sourceLineNo">4126</span> executeCallable(new MasterCallable<Void>(getConnection(), getRpcControllerFactory()) {<a name="line.4126"></a> -<span class="sourceLineNo">4127</span> @Override<a name="line.4127"></a> -<span class="sourceLineNo">4128</span> public Void rpcCall() throws ServiceException {<a name="line.4128"></a> -<span class="sourceLineNo">4129</span> master.recommissionRegionServer(getRpcController(),<a name="line.4129"></a> -<span class="sourceLineNo">4130</span> RequestConverter.buildRecommissionRegionServerRequest(server, encodedRegionNames));<a name="line.4130"></a> -<span class="sourceLineNo">4131</span> return null;<a name="line.4131"></a> -<span class="sourceLineNo">4132</span> }<a name="line.4132"></a> -<span class="sourceLineNo">4133</span> });<a name="line.4133"></a> -<span class="sourceLineNo">4134</span> }<a name="line.4134"></a> -<span class="sourceLineNo">4135</span><a name="line.4135"></a> -<span class="sourceLineNo">4136</span> @Override<a name="line.4136"></a> -<span class="sourceLineNo">4137</span> public List<TableCFs> listReplicatedTableCFs() throws IOException {<a name="line.4137"></a> -<span class="sourceLineNo">4138</span> List<TableCFs> replicatedTableCFs = new ArrayList<>();<a name="line.4138"></a> -<span class="sourceLineNo">4139</span> List<TableDescriptor> tables = listTableDescriptors();<a name="line.4139"></a> -<span class="sourceLineNo">4140</span> tables.forEach(table -> {<a name="line.4140"></a> -<span class="sourceLineNo">4141</span> Map<String, Integer> cfs = new HashMap<>();<a name="line.4141"></a> -<span class="sourceLineNo">4142</span> Stream.of(table.getColumnFamilies())<a name="line.4142"></a> -<span class="sourceLineNo">4143</span> .filter(column -> column.getScope() != HConstants.REPLICATION_SCOPE_LOCAL)<a name="line.4143"></a> -<span class="sourceLineNo">4144</span> .forEach(column -> {<a name="line.4144"></a> -<span class="sourceLineNo">4145</span> cfs.put(column.getNameAsString(), column.getScope());<a name="line.4145"></a> -<span class="sourceLineNo">4146</span> });<a name="line.4146"></a> -<span class="sourceLineNo">4147</span> if (!cfs.isEmpty()) {<a name="line.4147"></a> -<span class="sourceLineNo">4148</span> replicatedTableCFs.add(new TableCFs(table.getTableName(), cfs));<a name="line.4148"></a> -<span class="sourceLineNo">4149</span> }<a name="line.4149"></a> -<span class="sourceLineNo">4150</span> });<a name="line.4150"></a> -<span class="sourceLineNo">4151</span> return replicatedTableCFs;<a name="line.4151"></a> -<span class="sourceLineNo">4152</span> }<a name="line.4152"></a> -<span class="sourceLineNo">4153</span><a name="line.4153"></a> -<span class="sourceLineNo">4154</span> @Override<a name="line.4154"></a> -<span class="sourceLineNo">4155</span> public void enableTableReplication(final TableName tableName) throws IOException {<a name="line.4155"></a> -<span class="sourceLineNo">4156</span> if (tableName == null) {<a name="line.4156"></a> -<span class="sourceLineNo">4157</span> throw new IllegalArgumentException("Table name cannot be null");<a name="line.4157"></a> -<span class="sourceLineNo">4158</span> }<a name="line.4158"></a> -<span class="sourceLineNo">4159</span> if (!tableExists(tableName)) {<a name="line.4159"></a> -<span class="sourceLineNo">4160</span> throw new TableNotFoundException("Table '" + tableName.getNameAsString()<a name="line.4160"></a> -<span class="sourceLineNo">4161</span> + "' does not exists.");<a name="line.4161"></a> -<span class="sourceLineNo">4162</span> }<a name="line.4162"></a> -<span class="sourceLineNo">4163</span> byte[][] splits = getTableSplits(tableName);<a name="line.4163"></a> -<span class="sourceLineNo">4164</span> checkAndSyncTableDescToPeers(tableName, splits);<a name="line.4164"></a> -<span class="sourceLineNo">4165</span> setTableRep(tableName, true);<a name="line.4165"></a> -<span class="sourceLineNo">4166</span> }<a name="line.4166"></a> -<span class="sourceLineNo">4167</span><a name="line.4167"></a> -<span class="sourceLineNo">4168</span> @Override<a name="line.4168"></a> -<span class="sourceLineNo">4169</span> public void disableTableReplication(final TableName tableName) throws IOException {<a name="line.4169"></a> -<span class="sourceLineNo">4170</span> if (tableName == null) {<a name="line.4170"></a> -<span class="sourceLineNo">4171</span> throw new IllegalArgumentException("Table name is null");<a name="line.4171"></a> -<span class="sourceLineNo">4172</span> }<a name="line.4172"></a> -<span class="sourceLineNo">4173</span> if (!tableExists(tableName)) {<a name="line.4173"></a> -<span class="sourceLineNo">4174</span> throw new TableNotFoundException("Table '" + tableName.getNameAsString()<a name="line.4174"></a> -<span class="sourceLineNo">4175</span> + "' does not exists.");<a name="line.4175"></a> -<span class="sourceLineNo">4176</span> }<a name="line.4176"></a> -<span class="sourceLineNo">4177</span> setTableRep(tableName, false);<a name="line.4177"></a> -<span class="sourceLineNo">4178</span> }<a name="line.4178"></a> -<span class="sourceLineNo">4179</span><a name="line.4179"></a> -<span class="sourceLineNo">4180</span> /**<a name="line.4180"></a> -<span class="sourceLineNo">4181</span> * Connect to peer and check the table descriptor on peer:<a name="line.4181"></a> -<span class="sourceLineNo">4182</span> * <ol><a name="line.4182"></a> -<span class="sourceLineNo">4183</span> * <li>Create the same table on peer when not exist.</li><a name="line.4183"></a> -<span class="sourceLineNo">4184</span> * <li>Throw an exception if the table already has replication enabled on any of the column<a name="line.4184"></a> -<span class="sourceLineNo">4185</span> * families.</li><a name="line.4185"></a> -<span class="sourceLineNo">4186</span> * <li>Throw an exception if the table exists on peer cluster but descriptors are not same.</li><a name="line.4186"></a> -<span class="sourceLineNo">4187</span> * </ol><a name="line.4187"></a> -<span class="sourceLineNo">4188</span> * @param tableName name of the table to sync to the peer<a name="line.4188"></a> -<span class="sourceLineNo">4189</span> * @param splits table split keys<a name="line.4189"></a> -<span class="sourceLineNo">4190</span> * @throws IOException<a name="line.4190"></a> -<span class="sourceLineNo">4191</span> */<a name="line.4191"></a> -<span class="sourceLineNo">4192</span> private void checkAndSyncTableDescToPeers(final TableName tableName, final byte[][] splits)<a name="line.4192"></a> -<span class="sourceLineNo">4193</span> throws IOException {<a name="line.4193"></a> -<span class="sourceLineNo">4194</span> List<ReplicationPeerDescription> peers = listReplicationPeers();<a name="line.4194"></a> -<span class="sourceLineNo">4195</span> if (peers == null || peers.size() <= 0) {<a name="line.4195"></a> -<span class="sourceLineNo">4196</span> throw new IllegalArgumentException("Found no peer cluster for replication.");<a name="line.4196"></a> -<span class="sourceLineNo">4197</span> }<a name="line.4197"></a> -<span class="sourceLineNo">4198</span><a name="line.4198"></a> -<span class="sourceLineNo">4199</span> for (ReplicationPeerDescription peerDesc : peers) {<a name="line.4199"></a> -<span class="sourceLineNo">4200</span> if (peerDesc.getPeerConfig().needToReplicate(tableName)) {<a name="line.4200"></a> -<span class="sourceLineNo">4201</span> Configuration peerConf =<a name="line.4201"></a> -<span class="sourceLineNo">4202</span> ReplicationPeerConfigUtil.getPeerClusterConfiguration(this.conf, peerDesc);<a name="line.4202"></a> -<span class="sourceLineNo">4203</span> try (Connection conn = ConnectionFactory.createConnection(peerConf);<a name="line.4203"></a> -<span class="sourceLineNo">4204</span> Admin repHBaseAdmin = conn.getAdmin()) {<a name="line.4204"></a> -<span class="sourceLineNo">4205</span> TableDescriptor tableDesc = getDescriptor(tableName);<a name="line.4205"></a> -<span class="sourceLineNo">4206</span> TableDescriptor peerTableDesc = null;<a name="line.4206"></a> -<span class="sourceLineNo">4207</span> if (!repHBaseAdmin.tableExists(tableName)) {<a name="line.4207"></a> -<span class="sourceLineNo">4208</span> repHBaseAdmin.createTable(tableDesc, splits);<a name="line.4208"></a> -<span class="sourceLineNo">4209</span> } else {<a name="line.4209"></a> -<span class="sourceLineNo">4210</span> peerTableDesc = repHBaseAdmin.getDescriptor(tableName);<a name="line.4210"></a> -<span class="sourceLineNo">4211</span> if (peerTableDesc == null) {<a name="line.4211"></a> -<span class="sourceLineNo">4212</span> throw new IllegalArgumentException("Failed to get table descriptor for table "<a name="line.4212"></a> -<span class="sourceLineNo">4213</span> + tableName.getNameAsString() + " from peer cluster " + peerDesc.getPeerId());<a name="line.4213"></a> -<span class="sourceLineNo">4214</span> }<a name="line.4214"></a> -<span class="sourceLineNo">4215</span> if (TableDescriptor.COMPARATOR_IGNORE_REPLICATION.compare(peerTableDesc,<a name="line.4215"></a> -<span class="sourceLineNo">4216</span> tableDesc) != 0) {<a name="line.4216"></a> -<span class="sourceLineNo">4217</span> throw new IllegalArgumentException("Table " + tableName.getNameAsString()<a name="line.4217"></a> -<span class="sourceLineNo">4218</span> + " exists in peer cluster " + peerDesc.getPeerId()<a name="line.4218"></a> -<span class="sourceLineNo">4219</span> + ", but the table descriptors are not same when compared with source cluster."<a name="line.4219"></a> -<span class="sourceLineNo">4220</span> + " Thus can not enable the table's replication switch.");<a name="line.4220"></a> -<span class="sourceLineNo">4221</span> }<a name="line.4221"></a> -<span class="sourceLineNo">4222</span> }<a name="line.4222"></a> -<span class="sourceLineNo">4223</span> }<a name="line.4223"></a> -<span class="sourceLineNo">4224</span> }<a name="line.4224"></a> -<span class="sourceLineNo">4225</span> }<a name="line.4225"></a> -<span class="sourceLineNo">4226</span> }<a name="line.4226"></a> -<span class="sourceLineNo">4227</span><a name="line.4227"></a> -<span class="sourceLineNo">4228</span> /**<a name="line.4228"></a> -<span class="sourceLineNo">4229</span> * Set the table's replication switch if the table's replication switch is already not set.<a name="line.4229"></a> -<span class="sourceLineNo">4230</span> * @param tableName name of the table<a name="line.4230"></a> -<span class="sourceLineNo">4231</span> * @param enableRep is replication switch enable or disable<a name="line.4231"></a> -<span class="sourceLineNo">4232</span> * @throws IOException if a remote or network exception occurs<a name="line.4232"></a> -<span class="sourceLineNo">4233</span> */<a name="line.4233"></a> -<span class="sourceLineNo">4234</span> private void setTableRep(final TableName tableName, boolean enableRep) throws IOException {<a name="line.4234"></a> -<span class="sourceLineNo">4235</span> TableDescriptor tableDesc = getDescriptor(tableName);<a name="line.4235"></a> -<span class="sourceLineNo">4236</span> if (!tableDesc.matchReplicationScope(enableRep)) {<a name="line.4236"></a> -<span class="sourceLineNo">4237</span> int scope =<a name="line.4237"></a> -<span class="sourceLineNo">4238</span> enableRep ? HConstants.REPLICATION_SCOPE_GLOBAL : HConstants.REPLICATION_SCOPE_LOCAL;<a name="line.4238"></a> -<span class="sourceLineNo">4239</span> modifyTable(TableDescriptorBuilder.newBuilder(tableDesc).setReplicationScope(scope).build());<a name="line.4239"></a> -<span class="sourceLineNo">4240</span> }<a name="line.4240"></a> -<span class="sourceLineNo">4241</span> }<a name="line.4241"></a> -<span class="sourceLineNo">4242</span><a name="line.4242"></a> -<span class="sourceLineNo">4243</span> @Override<a name="line.4243"></a> -<span class="sourceLineNo">4244</span> public void clearCompactionQueues(final ServerName sn, final Set<String> queues)<a name="line.4244"></a> -<span class="sourceLineNo">4245</span> throws IOException, InterruptedException {<a name="line.4245"></a> -<span class="sourceLineNo">4246</span> if (queues == null || queues.size() == 0) {<a name="line.4246"></a> -<span class="sourceLineNo">4247</span> throw new IllegalArgumentException("queues cannot be null or empty");<a name="line.4247"></a> -<span class="sourceLineNo">4248</span> }<a name="line.4248"></a> -<span class="sourceLineNo">4249</span> final AdminService.BlockingInterface admin = this.connection.getAdmin(sn);<a name="line.4249"></a> -<span class="sourceLineNo">4250</span> Callable<Void> callable = new Callable<Void>() {<a name="line.4250"></a> -<span class="sourceLineNo">4251</span> @Override<a name="line.4251"></a> -<span class="sourceLineNo">4252</span> public Void call() throws Exception {<a name="line.4252"></a> -<span class="sourceLineNo">4253</span> // TODO: There is no timeout on this controller. Set one!<a name="line.4253"></a> -<span class="sourceLineNo">4254</span> HBaseRpcController controller = rpcControllerFactory.newController();<a name="line.4254"></a> -<span class="sourceLineNo">4255</span> ClearCompactionQueuesRequest request =<a name="line.4255"></a> -<span class="sourceLineNo">4256</span> RequestConverter.buildClearCompactionQueuesRequest(queues);<a name="line.4256"></a> -<span class="sourceLineNo">4257</span> admin.clearCompactionQueues(controller, request);<a name="line.4257"></a> -<span class="sourceLineNo">4258</span> return null;<a name="line.4258"></a> -<span class="sourceLineNo">4259</span> }<a name="line.4259"></a> -<span class="sourceLineNo">4260</span> };<a name="line.4260"></a> -<span class="sourceLineNo">4261</span> ProtobufUtil.call(callable);<a name="line.4261"></a> -<span class="sourceLineNo">4262</span> }<a name="line.4262"></a> -<span class="sourceLineNo">4263</span><a name="line.4263"></a> -<span class="sourceLineNo">4264</span> @Override<a name="line.4264"></a> -<span class="sourceLineNo">4265</span> public List<ServerName> clearDeadServers(final List<ServerName> servers) throws IOException {<a name="line.4265"></a> -<span class="sourceLineNo">4266</span> if (servers == null || servers.size() == 0) {<a name="line.4266"></a> -<span class="sourceLineNo">4267</span> throw new IllegalArgumentException("servers cannot be null or empty");<a name="line.4267"></a> -<span class="sourceLineNo">4268</span> }<a name="line.4268"></a> -<span class="sourceLineNo">4269</span> return executeCallable(new MasterCallable<List<ServerName>>(getConnection(),<a name="line.4269"></a> -<span class="sourceLineNo">4270</span> getRpcControllerFactory()) {<a name="line.4270"></a> -<span class="sourceLineNo">4271</span> @Override<a name="line.4271"></a> -<span class="sourceLineNo">4272</span> protected List<ServerName> rpcCall() throws Exception {<a name="line.4272"></a> -<span class="sourceLineNo">4273</span> ClearDeadServersRequest req = RequestConverter.buildClearDeadServersRequest(servers);<a name="line.4273"></a> -<span class="sourceLineNo">4274</span> return ProtobufUtil.toServerNameList(<a name="line.4274"></a> -<span class="sourceLineNo">4275</span> master.clearDeadServers(getRpcController(), req).getServerNameList());<a name="line.4275"></a> -<span class="sourceLineNo">4276</span> }<a name="line.4276"></a> -<span class="sourceLineNo">4277</span> });<a name="line.4277"></a> -<span class="sourceLineNo">4278</span> }<a name="line.4278"></a> -<span class="sourceLineNo">4279</span><a name="line.4279"></a> -<span class="sourceLineNo">4280</span> @Override<a name="line.4280"></a> -<span class="sourceLineNo">4281</span> public void cloneTableSchema(final TableName tableName, final TableName newTableName,<a name="line.4281"></a> -<span class="sourceLineNo">4282</span> final boolean preserveSplits) throws IOException {<a name="line.4282"></a> -<span class="sourceLineNo">4283</span> checkTableExists(tableName);<a name="line.4283"></a> -<span class="sourceLineNo">4284</span> if (tableExists(newTableName)) {<a name="line.4284"></a> -<span class="sourceLineNo">4285</span> throw new TableExistsException(newTableName);<a name="line.4285"></a> -<span class="sourceLineNo">4286</span> }<a name="line.4286"></a> -<span class="sourceLineNo">4287</span> TableDescriptor htd = TableDescriptorBuilder.copy(newTableName, getTableDescriptor(tableName));<a name="line.4287"></a> -<span class="sourceLineNo">4288</span> if (preserveSplits) {<a name="line.4288"></a> -<span class="sourceLineNo">4289</span> createTable(htd, getTableSplits(tableName));<a name="line.4289"></a> -<span class="sourceLineNo">4290</span> } else {<a name="line.4290"></a> -<span class="sourceLineNo">4291</span> createTable(htd);<a name="line.4291"></a> -<span class="sourceLineNo">4292</span> }<a name="line.4292"></a> -<span class="sourceLineNo">4293</span> }<a name="line.4293"></a> -<span class="sourceLineNo">4294</span>}<a name="line.4294"></a> +<span class="sourceLineNo">3648</span> return "Operation: " + getOperationType() + ", " + "Table Name: " +<a name="line.3648"></a> +<span class="sourceLineNo">3649</span> tableName.getNameWithNamespaceInclAsString() + ", procId: " + procId;<a name="line.3649"></a> +<span class="sourceLineNo">3650</span> }<a name="line.3650"></a> +<span class="sourceLineNo">3651</span><a name="line.3651"></a> +<span class="sourceLineNo">3652</span> protected abstract class TableWaitForStateCallable implements WaitForStateCallable {<a name="line.3652"></a> +<span class="sourceLineNo">3653</span> @Override<a name="line.3653"></a> +<span class="sourceLineNo">3654</span> public void throwInterruptedException() throws InterruptedIOException {<a name="line.3654"></a> +<span class="sourceLineNo">3655</span> throw new InterruptedIOException("Interrupted while waiting for " + getDescription());<a name="line.3655"></a> +<span class="sourceLineNo">3656</span> }<a name="line.3656"></a> +<span class="sourceLineNo">3657</span><a name="line.3657"></a> +<span class="sourceLineNo">3658</span> @Override<a name="line.3658"></a> +<span class="sourceLineNo">3659</span> public void throwTimeoutException(long elapsedTime) throws TimeoutException {<a name="line.3659"></a> +<span class="sourceLineNo">3660</span> throw new TimeoutException(<a name="line.3660"></a> +<span class="sourceLineNo">3661</span> getDescription() + " has not completed after " + elapsedTime + "ms");<a name="line.3661"></a> +<span class="sourceLineNo">3662</span> }<a name="line.3662"></a> +<span class="sourceLineNo">3663</span> }<a name="line.3663"></a> +<span class="sourceLineNo">3664</span><a name="line.3664"></a> +<span class="sourceLineNo">3665</span> @Override<a name="line.3665"></a> +<span class="sourceLineNo">3666</span> protected V postOperationResult(final V result, final long deadlineTs)<a name="line.3666"></a> +<span class="sourceLineNo">3667</span> throws IOException, TimeoutException {<a name="line.3667"></a> +<span class="sourceLineNo">3668</span> LOG.info(getDescription() + " completed");<a name="line.3668"></a> +<span class="sourceLineNo">3669</span> return super.postOperationResult(result, deadlineTs);<a name="line.3669"></a> +<span class="sourceLineNo">3670</span> }<a name="line.3670"></a> +<span class="sourceLineNo">3671</span><a name="line.3671"></a> +<span class="sourceLineNo">3672</span> @Override<a name="line.3672"></a> +<span class="sourceLineNo">3673</span> protected V postOperationFailure(final IOException exception, final long deadlineTs)<a name="line.3673"></a> +<span class="sourceLineNo">3674</span> throws IOException, TimeoutException {<a name="line.3674"></a> +<span class="sourceLineNo">3675</span> LOG.info(getDescription() + " failed with " + exception.getMessage());<a name="line.3675"></a> +<span class="sourceLineNo">3676</span> return super.postOperationFailure(exception, deadlineTs);<a name="line.3676"></a> +<span class="sourceLineNo">3677</span> }<a name="line.3677"></a> +<span class="sourceLineNo">3678</span><a name="line.3678"></a> +<span class="sourceLineNo">3679</span> protected void waitForTableEnabled(final long deadlineTs)<a name="line.3679"></a> +<span class="sourceLineNo">3680</span> throws IOException, TimeoutException {<a name="line.3680"></a> +<span class="sourceLineNo">3681</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3681"></a> +<span class="sourceLineNo">3682</span> @Override<a name="line.3682"></a> +<span class="sourceLineNo">3683</span> public boolean checkState(int tries) throws IOException {<a name="line.3683"></a> +<span class="sourceLineNo">3684</span> try {<a name="line.3684"></a> +<span class="sourceLineNo">3685</span> if (getAdmin().isTableAvailable(tableName)) {<a name="line.3685"></a> +<span class="sourceLineNo">3686</span> return true;<a name="line.3686"></a> +<span class="sourceLineNo">3687</span> }<a name="line.3687"></a> +<span class="sourceLineNo">3688</span> } catch (TableNotFoundException tnfe) {<a name="line.3688"></a> +<span class="sourceLineNo">3689</span> LOG.debug("Table " + tableName.getNameWithNamespaceInclAsString()<a name="line.3689"></a> +<span class="sourceLineNo">3690</span> + " was not enabled, sleeping. tries=" + tries);<a name="line.3690"></a> +<span class="sourceLineNo">3691</span> }<a name="line.3691"></a> +<span class="sourceLineNo">3692</span> return false;<a name="line.3692"></a> +<span class="sourceLineNo">3693</span> }<a name="line.3693"></a> +<span class="sourceLineNo">3694</span> });<a name="line.3694"></a> +<span class="sourceLineNo">3695</span> }<a name="line.3695"></a> +<span class="sourceLineNo">3696</span><a name="line.3696"></a> +<span class="sourceLineNo">3697</span> protected void waitForTableDisabled(final long deadlineTs)<a name="line.3697"></a> +<span class="sourceLineNo">3698</span> throws IOException, TimeoutException {<a name="line.3698"></a> +<span class="sourceLineNo">3699</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3699"></a> +<span class="sourceLineNo">3700</span> @Override<a name="line.3700"></a> +<span class="sourceLineNo">3701</span> public boolean checkState(int tries) throws IOException {<a name="line.3701"></a> +<span class="sourceLineNo">3702</span> return getAdmin().isTableDisabled(tableName);<a name="line.3702"></a> +<span class="sourceLineNo">3703</span> }<a name="line.3703"></a> +<span class="sourceLineNo">3704</span> });<a name="line.3704"></a> +<span class="sourceLineNo">3705</span> }<a name="line.3705"></a> +<span class="sourceLineNo">3706</span><a name="line.3706"></a> +<span class="sourceLineNo">3707</span> protected void waitTableNotFound(final long deadlineTs)<a name="line.3707"></a> +<span class="sourceLineNo">3708</span> throws IOException, TimeoutException {<a name="line.3708"></a> +<span class="sourceLineNo">3709</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3709"></a> +<span class="sourceLineNo">3710</span> @Override<a name="line.3710"></a> +<span class="sourceLineNo">3711</span> public boolean checkState(int tries) throws IOException {<a name="line.3711"></a> +<span class="sourceLineNo">3712</span> return !getAdmin().tableExists(tableName);<a name="line.3712"></a> +<span class="sourceLineNo">3713</span> }<a name="line.3713"></a> +<span class="sourceLineNo">3714</span> });<a name="line.3714"></a> +<span class="sourceLineNo">3715</span> }<a name="line.3715"></a> +<span class="sourceLineNo">3716</span><a name="line.3716"></a> +<span class="sourceLineNo">3717</span> protected void waitForSchemaUpdate(final long deadlineTs)<a name="line.3717"></a> +<span class="sourceLineNo">3718</span> throws IOException, TimeoutException {<a name="line.3718"></a> +<span class="sourceLineNo">3719</span> waitForState(deadlineTs, new TableWaitForStateCallable() {<a name="line.3719"></a> +<span class="sourceLineNo">3720</span> @Override<a name="line.3720"></a> +<span class="sourceLineNo">3721</span> public boolean checkState(int tries) throws IOException {<a name="line.3721"></a> +<span class="sourceLineNo">3722</span> return getAdmin().getAlterStatus(tableName).getFirst() == 0;<a name="line.3722"></a> +<span class="sourceLineNo">3723</span> }<a name="line.3723"></a> +<span class="sourceLineNo">3724</span> });<a name="line.3724"></a> +<span class="sourceLineNo">3725</span> }<a name="line.3725"></a> +<span class="sourceLineNo">3726</span><a name="line.3726"></a> +<span class="sourceLineNo">3727</span> protected void waitForAllRegionsOnline(final long deadlineTs, final byte[][] splitKeys)<a name="line.3727"></a> +<span class="sourceLineNo">3728</span> throws IOException, TimeoutException {<a name="line.3728"></a> +<span class="sourceLineNo">3729</span> final TableDescriptor desc = getTableDescriptor();<a name="line.3729"></a> +<span class="sourceLineNo">3730</span> final AtomicInteger actualRegCount = new AtomicInteger(0);<a name="line.3730"></a> +<span class="sourceLineNo">3731</span> final MetaTableAccessor.Visitor visitor = new MetaTableAccessor.Visitor() {<a name="line.3731"></a> +<span class="sourceLineNo">3732</span> @Override<a name="line.3732"></a> +<span class="sourceLineNo">3733</span> public boolean visit(Result rowResult) throws IOException {<a name="line.3733"></a> +<span class="sourceLineNo">3734</span> RegionLocations list = MetaTableAccessor.getRegionLocations(rowResult);<a name="line.3734"></a> +<span class="sourceLineNo">3735</span> if (list == null) {<a name="line.3735"></a> +<span class="sourceLineNo">3736</span> LOG.warn("No serialized HRegionInfo in " + rowResult);<a name="line.3736"></a> +<span class="sourceLineNo">3737</span> return true;<a name="line.3737"></a> +<span class="sourceLineNo">3738</span> }<a name="line.3738"></a> +<span class="sourceLineNo">3739</span> HRegionLocation l = list.getRegionLocation();<a name="line.3739"></a> +<span class="sourceLineNo">3740</span> if (l == null) {<a name="line.3740"></a> +<span class="sourceLineNo">3741</span> return true;<a name="line.3741"></a> +<span class="sourceLineNo">3742</span> }<a name="line.3742"></a> +<span class="sourceLineNo">3743</span> if (!l.getRegionInfo().getTable().equals(desc.getTableName())) {<a name="line.3743"></a> +<span class="sourceLineNo">3744</span> return false;<a name="line.3744"></a> +<span class="sourceLineNo">3745</span> }<a name="line.3745"></a> +<span class="sourceLineNo">3746</span> if (l.getRegionInfo().isOffline() || l.getRegionInfo().isSplit()) return true;<a name="line.3746"></a> +<span class="sourceLineNo">3747</span> HRegionLocation[] locations = list.getRegionLocations();<a name="line.3747"></a> +<span class="sourceLineNo">3748</span> for (HRegionLocation location : locations) {<a name="line.3748"></a> +<span class="sourceLineNo">3749</span> if (location == null) continue;<a name="line.3749"></a> +<span class="sourceLineNo">3750</span> ServerName serverName = location.getServerName();<a name="line.3750"></a> +<span class="sourceLineNo">3751</span> // Make sure that regions are assigned to server<a name="line.3751"></a> +<span class="sourceLineNo">3752</span> if (serverName != null && serverName.getHostAndPort() != null) {<a name="line.3752"></a> +<span class="sourceLineNo">3753</span> actualRegCount.incrementAndGet();<a name="line.3753"></a> +<span class="sourceLineNo">3754</span> }<a name="line.3754"></a> +<span class="sourceLineNo">3755</span> }<a name="line.3755"></a> +<span class="sourceLineNo">3756</span> return true;<a name="line.3756"></a> +<span class="sourceLineNo">3757</span> }<a name="line.3757"></a> +<span class="sourceLineNo">3758</span> };<a name="line.3758"></a> +<span class="sourceLineNo">3759</span><a name="line.3759"></a> +<span class="sourceLineNo">3760</span> int tries = 0;<a name="line.3760"></a> +<span class="sourceLineNo">3761</span> int numRegs = (splitKeys == null ? 1 : splitKeys.length + 1) * desc.getRegionReplication();<a name="line.3761"></a> +<span class="sourceLineNo">3762</span> while (EnvironmentEdgeManager.currentTime() < deadlineTs) {<a name="line.3762"></a> +<span class="sourceLineNo">3763</span> actualRegCount.set(0);<a name="line.3763"></a> +<span class="sourceLineNo">3764</span> MetaTableAccessor.scanMetaForTableRegions(getAdmin().getConnection(), visitor,<a name="line.3764"></a> +<span class="sourceLineNo">3765</span> desc.getTableName());<a name="line.3765"></a> +<span class="sourceLineNo">3766</span> if (actualRegCount.get() == numRegs) {<a name="line.3766"></a> +<span class="sourceLineNo">3767</span> // all the regions are online<a name="line.3767"></a> +<span class="sourceLineNo">3768</span> return;<a name="line.3768"></a> +<span class="sourceLineNo">3769</span> }<a name="line.3769"></a> +<span class="sourceLineNo">3770</span><a name="line.3770"></a> +<span class="sourceLineNo">3771</span> try {<a name="line.3771"></a> +<span class="sourceLineNo">3772</span> Thread.sleep(getAdmin().getPauseTime(tries++));<a name="line.3772"></a> +<span class="sourceLineNo">3773</span> } catch (InterruptedException e) {<a name="line.3773"></a> +<span class="sourceLineNo">3774</span> throw new InterruptedIOException("Interrupted when opening" + " regions; "<a name="line.3774"></a> +<span class="sourceLineNo">3775</span> + actualRegCount.get() + " of " + numRegs + " regions processed so far");<a name="line.3775"></a> +<span class="sourceLineNo">3776</span> }<a name="line.3776"></a> +<span class="sourceLineNo">3777</span> }<a name="line.3777"></a> +<span class="sourceLineNo">3778</span> throw new TimeoutException("Only " + actualRegCount.get() + " of " + numRegs<a name="line.3778"></a> +<span class="sourceLineNo">3779</span> + " regions are online; retries exhausted.");<a name="line.3779"></a> +<span class="sourceLineNo">3780</span> }<a name="line.3780"></a> +<span class="sourceLineNo">3781</span> }<a name="line.3781"></a> +<span class="sourceLineNo">3782</span><a name="line.3782"></a> +<span class="sourceLineNo">3783</span> @InterfaceAudience.Private<a name="line.3783"></a> +<span class="sourceLineNo">3784</span> @InterfaceStability.Evolving<a name="line.3784"></a> +<span class="sourceLineNo">3785</span> protected static abstract class NamespaceFuture extends ProcedureFuture<Void> {<a name="line.3785"></a> +<span class="sourceLineNo">3786</span> private final String namespaceName;<a name="line.3786"></a> +<span class="sourceLineNo">3787</span><a name="line.3787"></a> +<span class="sourceLineNo">3788</span> public NamespaceFuture(final HBaseAdmin admin, final String namespaceName, final Long procId) {<a name="line.3788"></a> +<span class="sourceLineNo">3789</span> super(admin, procId);<a name="line.3789"></a> +<span class="sourceLineNo">3790</span> this.namespaceName = namespaceName;<a name="line.3790"></a> +<span class="sourceLineNo">3791</span> }<a name="line.3791"></a> +<span class="sourceLineNo">3792</span><a name="line.3792"></a> +<span class="sourceLineNo">3793</span> /**<a name="line.3793"></a> +<span class="sourceLineNo">3794</span> * @return the namespace name<a name="line.3794"></a> +<span class="sourceLineNo">3795</span> */<a name="line.3795"></a> +<span class="sourceLineNo">3796</span> protected String getNamespaceName() {<a name="line.3796"></a> +<span class="sourceLineNo">3797</span> return namespaceName;<a name="line.3797"></a> +<span class="sourceLineNo">3798</span> }<a name="line.3798"></a> +<span class="sourceLineNo">3799</span><a name="line.3799"></a> +<span class="sourceLineNo">3800</span> /**<a name="line.3800"></a> +<span class="sourceLineNo">3801</span> * @return the operation type like CREATE_NAMESPACE, DELETE_NAMESPACE, etc.<a name="line.3801"></a> +<span class="sourceLineNo">3802</span> */<a name="line.3802"></a> +<span class="sourceLineNo">3803</span> public abstract String getOperationType();<a name="line.3803"></a> +<span class="sourceLineNo">3804</span><a name="line.3804"></a> +<span class="sourceLineNo">3805</span> @Override<a name="line.3805"></a> +<span class="sourceLineNo">3806</span> public String toString() {<a name="line.3806"></a> +<span class="sourceLineNo">3807</span> return "Operation: " + getOperationType() + ", Namespace: " + getNamespaceName();<a name="line.3807"></a> +<span class="sourceLineNo">3808</span> }<a name="line.3808"></a> +<span class="sourceLineNo">3809</span> }<a name="line.3809"></a> +<span class="sourceLineNo">3810</span><a name="line.3810"></a> +<span class="sourceLineNo">3811</span> @InterfaceAudience.Private<a name="line.3811"></a> +<span class="sourceLineNo">3812</span> @InterfaceStability.Evolving<a name="line.3812"></a> +<span class="sourceLineNo">3813</span> private static class ReplicationFuture extends ProcedureFuture<Void> {<a name="line.3813"></a> +<span class="sourceLineNo">3814</span> private final String peerId;<a name="line.3814"></a> +<span class="sourceLineNo">3815</span> private final Supplier<String> getOperation;<a name="line.3815"></a> +<span class="sourceLineNo">3816</span><a name="line.3816"></a> +<span class="sourceLineNo">3817</span> public ReplicationFuture(HBaseAdmin admin, String peerId, Long procId,<a name="line.3817"></a> +<span class="sourceLineNo">3818</span> Supplier<String> getOperation) {<a name="line.3818"></a> +<span class="sourceLineNo">3819</span> super(admin, procId);<a name="line.3819"></a> +<span class="sourceLineNo">3820</span> this.peerId = peerId;<a name="line.3820"></a> +<span class="sourceLineNo">3821</span> this.getOperation = getOperation;<a name="line.3821"></a> +<span class="sourceLineNo">3822</span> }<a name="line.3822"></a> +<span class="sourceLineNo">3823</span><a name="line.3823"></a> +<span class="sourceLineNo">3824</span> @Override<a name="line.3824"></a> +<span class="sourceLineNo">3825</span> public String toString() {<a name="line.3825"></a> +<span class="sourceLineNo">3826</span> return "Operation: " + getOperation.get() + ", peerId: " + peerId;<a name="line.3826"></a> +<span class="sourceLineNo">3827</span> }<a name="line.3827"></a> +<span class="sourceLineNo">3828</span> }<a name="line.3828"></a> +<span class="sourceLineNo">3829</span><a name="line.3829"></a> +<span class="sourceLineNo">3830</span> @Override<a name="line.3830"></a> +<span class="sourceLineNo">3831</span> public List<SecurityCapability> getSecurityCapabilities() throws IOException {<a name="line.3831"></a> +<span class="sourceLineNo">3832</span> try {<a name="line.3832"></a> +<span class="sourceLineNo">3833</span> return executeCallable(new MasterCallable<List<SecurityCapability>>(getConnection(),<a name="line.3833"></a> +<span class="sourceLineNo">3834</span> getRpcControllerFactory()) {<a name="line.3834"></a> +<span class="sourceLineNo">3835</span> @Override<a name="line.3835"></a> +<span class="sourceLineNo">3836</span> protected List<SecurityCapability> rpcCall() throws Exception {<a name="line.3836"></a> +<span class="sourceLineNo">3837</span> SecurityCapabilitiesRequest req = SecurityCapabilitiesRequest.newBuilder().build();<a name="line.3837"></a> +<span class="sourceLineNo">3838</span> return ProtobufUtil.toSecurityCapabilityList(<a name="line.3838"></a> +<span class="sourceLineNo">3839</span> master.getSecurityCapabilities(getRpcController(), req).getCapabilitiesList());<a name="line.3839"></a> +<span class="sourceLineNo">3840</span> }<a name="line.3840"></a> +<span class="sourceLineNo">3841</span> });<a name="line.3841"></a> +<span class="sourceLineNo">3842</span> } catch (IOException e) {<a name="line.3842"></a> +<span class="sourceLineNo">3843</span> if (e instanceof RemoteException) {<a name="line.3843"></a> +<span class="sourceLineNo">3844</span> e = ((RemoteException)e).unwrapRemoteException();<a name="line.3844"></a> +<span class="sourceLineNo">3845</span> }<a name="line.3845"></a> +<span class="sourceLineNo">3846</span> throw e;<a name="line.3846"></a> +<span class="sourceLineNo">3847</span> }<a name="line.3847"></a> +<span class="sourceLineNo">3848</span> }<a name="line.3848"></a> +<span class="sourceLineNo">3849</span><a name="line.3849"></a> +<span class="sourceLineNo">3850</span> @Override<a name="line.3850"></a> +<span class="sourceLineNo">3851</span> public boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException {<a name="line.3851"></a> +<span class="sourceLineNo">3852</span> return splitOrMergeSwitch(enabled, synchronous, MasterSwitchType.SPLIT);<a name="line.3852"></a> +<span class="sourceLineNo">3853</span> }<a name="line.3853"></a> +<span class="sourceLineNo">3854</span><a name="line.3854"></a> +<span class="sourceLineNo">3855</span> @Override<a name="line.3855"></a> +<span class="sourceLineNo">3856</span> pub
<TRUNCATED>