|
62 | 62 | import org.apache.hadoop.hbase.util.VersionInfo;
|
63 | 63 | import org.slf4j.Logger;
|
64 | 64 |
|
65 |
| -import javax.swing.plaf.synth.Region; |
66 | 65 | import java.io.ByteArrayOutputStream;
|
67 | 66 | import java.io.IOException;
|
68 | 67 | import java.util.*;
|
@@ -2389,27 +2388,65 @@ public void refreshTableEntry(String familyString, boolean hasTestLoad) throws E
|
2389 | 2388 | }
|
2390 | 2389 |
|
2391 | 2390 | public byte[][] getStartKeys() throws IOException {
|
2392 |
| - if (regionLocator == null) { |
2393 |
| - OHRegionLocatorExecutor executor = new OHRegionLocatorExecutor(tableNameString, obTableClient); |
2394 |
| - regionLocator = executor.getRegionLocator(tableNameString); |
| 2391 | + byte[][] startKeys = new byte[0][]; |
| 2392 | + if (ObGlobal.isHBaseAdminSupport()) { |
| 2393 | + // 4.3.5.3 and above, OCP and ODP mode use regionLocator to getStartKeys |
| 2394 | + if (regionLocator == null) { |
| 2395 | + OHRegionLocatorExecutor executor = new OHRegionLocatorExecutor(tableNameString, obTableClient); |
| 2396 | + regionLocator = executor.getRegionLocator(tableNameString); |
| 2397 | + } |
| 2398 | + startKeys = regionLocator.getStartKeys(); |
| 2399 | + } else if (!obTableClient.isOdpMode()) { |
| 2400 | + // before 4.3.5.3 only support in OCP mode |
| 2401 | + try { |
| 2402 | + startKeys = obTableClient.getHBaseTableStartKeys(tableNameString); |
| 2403 | + } catch (Exception e) { |
| 2404 | + throw new IOException("Fail to get start keys of HBase Table: " + tableNameString, e); |
| 2405 | + } |
| 2406 | + } else { |
| 2407 | + throw new IOException("not supported yet in odp mode, only support in ObServer 4.3.5.3 and above"); |
2395 | 2408 | }
|
2396 |
| - return regionLocator.getStartKeys(); |
| 2409 | + |
| 2410 | + return startKeys; |
2397 | 2411 | }
|
2398 | 2412 |
|
2399 | 2413 | public byte[][] getEndKeys() throws IOException {
|
2400 |
| - if (regionLocator == null) { |
2401 |
| - OHRegionLocatorExecutor executor = new OHRegionLocatorExecutor(tableNameString, obTableClient); |
2402 |
| - regionLocator = executor.getRegionLocator(tableNameString); |
| 2414 | + byte[][] endKeys = new byte[0][]; |
| 2415 | + if (ObGlobal.isHBaseAdminSupport()) { |
| 2416 | + // 4.3.5.3 and above, OCP and ODP mode use regionLocator to getEndKeys |
| 2417 | + if (regionLocator == null) { |
| 2418 | + OHRegionLocatorExecutor executor = new OHRegionLocatorExecutor(tableNameString, obTableClient); |
| 2419 | + regionLocator = executor.getRegionLocator(tableNameString); |
| 2420 | + } |
| 2421 | + endKeys = regionLocator.getEndKeys(); |
| 2422 | + } else if (!obTableClient.isOdpMode()) { |
| 2423 | + // before 4.3.5.3 only support in OCP mode |
| 2424 | + try { |
| 2425 | + endKeys = obTableClient.getHBaseTableEndKeys(tableNameString); |
| 2426 | + } catch (Exception e) { |
| 2427 | + throw new IOException("Fail to get start keys of HBase Table: " + tableNameString, e); |
| 2428 | + } |
| 2429 | + } else { |
| 2430 | + throw new IOException("not supported yet in odp mode, only support in ObServer 4.3.5.3 and above"); |
2403 | 2431 | }
|
2404 |
| - return regionLocator.getEndKeys(); |
| 2432 | + |
| 2433 | + return endKeys; |
2405 | 2434 | }
|
2406 | 2435 |
|
2407 | 2436 | public Pair<byte[][], byte[][]> getStartEndKeys() throws IOException {
|
2408 |
| - if (regionLocator == null) { |
2409 |
| - OHRegionLocatorExecutor executor = new OHRegionLocatorExecutor(tableNameString, obTableClient); |
2410 |
| - regionLocator = executor.getRegionLocator(tableNameString); |
| 2437 | + if (ObGlobal.isHBaseAdminSupport()) { |
| 2438 | + // 4.3.5.3 and above, OCP and ODP mode use regionLocator to getStartEndKeys |
| 2439 | + if (regionLocator == null) { |
| 2440 | + OHRegionLocatorExecutor executor = new OHRegionLocatorExecutor(tableNameString, obTableClient); |
| 2441 | + regionLocator = executor.getRegionLocator(tableNameString); |
| 2442 | + } |
| 2443 | + return regionLocator.getStartEndKeys(); |
| 2444 | + } else if (!obTableClient.isOdpMode()) { |
| 2445 | + // before 4.3.5.3 only support in OCP mode |
| 2446 | + return new Pair<>(getStartKeys(), getEndKeys()); |
| 2447 | + } else { |
| 2448 | + throw new IOException("not supported yet in odp mode, only support in ObServer 4.3.5.3 and above"); |
2411 | 2449 | }
|
2412 |
| - return regionLocator.getStartEndKeys(); |
2413 | 2450 | }
|
2414 | 2451 |
|
2415 | 2452 | private BufferedMutator getBufferedMutator() throws IOException {
|
|
0 commit comments