Java Code Examples for org.apache.hadoop.hbase.client.HBaseAdmin#assign()

The following examples show how to use org.apache.hadoop.hbase.client.HBaseAdmin#assign() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Common.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void move(Args args, HBaseAdmin admin, String tableName, String targetServerName, String encodedRegionName,
    boolean asynchronous)
    throws IOException, InterruptedException {
    int i;
    for (i = 0; i < Constant.TRY_MAX; i++) {
        try {
            admin.move(encodedRegionName.getBytes(), targetServerName.getBytes());
        } catch (java.lang.reflect.UndeclaredThrowableException ignore) {
        }

        if (asynchronous)
            return;

        if (CommandAdapter.isMetaTable(tableName))
            return;

        if (!isTableEnabled(args, admin, tableName))
            throw new IllegalStateException(Constant.MESSAGE_DISABLED_OR_NOT_FOUND_TABLE);

        if (Util.isMoved(admin, tableName, encodedRegionName, targetServerName)) {
            return;
        }

        Thread.sleep(Constant.WAIT_INTERVAL_MS);

        // assign region again
        if (i >= Constant.TRY_MAX / 2)
            admin.assign(encodedRegionName.getBytes());
    }
    if (i >= Constant.TRY_MAX)
        throw new IllegalStateException(Constant.MESSAGE_CANNOT_MOVE + " - "
            + encodedRegionName + " to " + targetServerName);
}
 
Example 2
Source File: Common.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void move(Args args, HBaseAdmin admin, String tableName, String targetServerName, String encodedRegionName,
    boolean asynchronous)
    throws IOException, InterruptedException {
    int i;
    for (i = 0; i < Constant.TRY_MAX; i++) {
        try {
            admin.move(encodedRegionName.getBytes(), targetServerName.getBytes());
        } catch (java.lang.reflect.UndeclaredThrowableException ignore) {
        }

        if (asynchronous)
            return;

        if (CommandAdapter.isMetaTable(tableName))
            return;

        if (!isTableEnabled(args, admin, tableName))
            throw new IllegalStateException(Constant.MESSAGE_DISABLED_OR_NOT_FOUND_TABLE);

        if (Util.isMoved(admin, tableName, encodedRegionName, targetServerName)) {
            return;
        }

        Thread.sleep(Constant.WAIT_INTERVAL_MS);

        // assign region again
        if (i >= Constant.TRY_MAX / 2)
            admin.assign(encodedRegionName.getBytes());
    }
    if (i >= Constant.TRY_MAX)
        throw new IllegalStateException(Constant.MESSAGE_CANNOT_MOVE + " - "
            + encodedRegionName + " to " + targetServerName);
}
 
Example 3
Source File: Common.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void move(Args args, HBaseAdmin admin, String tableName, String targetServerName, String encodedRegionName,
    boolean asynchronous)
    throws IOException, InterruptedException {
    int i;
    for (i = 0; i < Constant.TRY_MAX; i++) {
        try {
            admin.move(encodedRegionName.getBytes(), targetServerName.getBytes());
        } catch (java.lang.reflect.UndeclaredThrowableException ignore) {
        }

        if (asynchronous)
            return;

        if (CommandAdapter.isMetaTable(tableName))
            return;

        if (!isTableEnabled(args, admin, tableName))
            throw new IllegalStateException(Constant.MESSAGE_DISABLED_OR_NOT_FOUND_TABLE);

        if (Util.isMoved(admin, tableName, encodedRegionName, targetServerName)) {
            return;
        }

        Thread.sleep(Constant.WAIT_INTERVAL_MS);

        // assign region again
        if (i >= Constant.TRY_MAX / 2)
            admin.assign(encodedRegionName.getBytes());
    }
    if (i >= Constant.TRY_MAX)
        throw new IllegalStateException(Constant.MESSAGE_CANNOT_MOVE + " - "
            + encodedRegionName + " to " + targetServerName);
}
 
Example 4
Source File: Common.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void move(Args args, HBaseAdmin admin, String tableName, String targetServerName, String encodedRegionName,
    boolean asynchronous)
    throws IOException, InterruptedException {
    int i;
    for (i = 0; i < Constant.TRY_MAX; i++) {
        try {
            admin.move(encodedRegionName.getBytes(), targetServerName.getBytes());
        } catch (java.lang.reflect.UndeclaredThrowableException ignore) {
        }

        if (asynchronous)
            return;

        if (CommandAdapter.isMetaTable(tableName))
            return;

        if (!isTableEnabled(args, admin, tableName))
            throw new IllegalStateException(Constant.MESSAGE_DISABLED_OR_NOT_FOUND_TABLE);

        if (Util.isMoved(admin, tableName, encodedRegionName, targetServerName)) {
            return;
        }

        Thread.sleep(Constant.WAIT_INTERVAL_MS);

        // assign region again
        if (i >= Constant.TRY_MAX / 2)
            admin.assign(encodedRegionName.getBytes());
    }
    if (i >= Constant.TRY_MAX)
        throw new IllegalStateException(Constant.MESSAGE_CANNOT_MOVE + " - "
            + encodedRegionName + " to " + targetServerName);
}
 
Example 5
Source File: Common.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static void move(Args args, HBaseAdmin admin, String tableName, String targetServerName, String encodedRegionName,
    boolean asynchronous)
    throws IOException, InterruptedException {
    int i;
    for (i = 0; i < Constant.TRY_MAX; i++) {
        try {
            admin.move(encodedRegionName.getBytes(), targetServerName.getBytes());
        } catch (java.lang.reflect.UndeclaredThrowableException ignore) {
        }

        if (asynchronous)
            return;

        if (CommandAdapter.isMetaTable(tableName))
            return;

        if (!isTableEnabled(args, admin, tableName))
            throw new IllegalStateException(Constant.MESSAGE_DISABLED_OR_NOT_FOUND_TABLE);

        if (Util.isMoved(admin, tableName, encodedRegionName, targetServerName)) {
            return;
        }

        Thread.sleep(Constant.WAIT_INTERVAL_MS);

        // assign region again
        if (i >= Constant.TRY_MAX / 2)
            admin.assign(encodedRegionName.getBytes());
    }
    if (i >= Constant.TRY_MAX)
        throw new IllegalStateException(Constant.MESSAGE_CANNOT_MOVE + " - "
            + encodedRegionName + " to " + targetServerName);
}