Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D2BF7200C73 for ; Wed, 10 May 2017 16:59:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D135B160BD2; Wed, 10 May 2017 14:59:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4B2CF160BA8 for ; Wed, 10 May 2017 16:59:43 +0200 (CEST) Received: (qmail 23317 invoked by uid 500); 10 May 2017 14:59:42 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 23291 invoked by uid 99); 10 May 2017 14:59:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 May 2017 14:59:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 27E98DFBC8; Wed, 10 May 2017 14:59:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Wed, 10 May 2017 14:59:42 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/51] [partial] hbase-site git commit: Published site at 82d554e3783372cc6b05489452c815b57c06f6cd. archived-at: Wed, 10 May 2017 14:59:46 -0000 Repository: hbase-site Updated Branches: refs/heads/asf-site 8678c699d -> dd7176bfc http://git-wip-us.apache.org/repos/asf/hbase-site/blob/dd7176bf/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html index 17bc96c..1642d61 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/HMaster.InitializationMonitor.html @@ -2317,7 +2317,7 @@ 2309 } 2310 2311 public long restoreSnapshot(final SnapshotDescription snapshotDesc, -2312 final long nonceGroup, final long nonce) throws IOException { +2312 final long nonceGroup, final long nonce, final boolean restoreAcl) throws IOException { 2313 checkInitialized(); 2314 getSnapshotManager().checkSnapshotSupport(); 2315 @@ -2329,1031 +2329,1032 @@ 2321 new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) { 2322 @Override 2323 protected void run() throws IOException { -2324 setProcId(getSnapshotManager().restoreOrCloneSnapshot(snapshotDesc, getNonceKey())); -2325 } -2326 -2327 @Override -2328 protected String getDescription() { -2329 return "RestoreSnapshotProcedure"; -2330 } -2331 }); -2332 } -2333 -2334 @Override -2335 public void checkTableModifiable(final TableName tableName) -2336 throws IOException, TableNotFoundException, TableNotDisabledException { -2337 if (isCatalogTable(tableName)) { -2338 throw new IOException("Can't modify catalog tables"); -2339 } -2340 if (!MetaTableAccessor.tableExists(getConnection(), tableName)) { -2341 throw new TableNotFoundException(tableName); -2342 } -2343 if (!getTableStateManager().isTableState(tableName, TableState.State.DISABLED)) { -2344 throw new TableNotDisabledException(tableName); -2345 } -2346 } -2347 -2348 /** -2349 * @return cluster status -2350 */ -2351 public ClusterStatus getClusterStatus() throws InterruptedIOException { -2352 // Build Set of backup masters from ZK nodes -2353 List<String> backupMasterStrings; -2354 try { -2355 backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper, -2356 this.zooKeeper.znodePaths.backupMasterAddressesZNode); -2357 } catch (KeeperException e) { -2358 LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e); -2359 backupMasterStrings = null; -2360 } -2361 -2362 List<ServerName> backupMasters = null; -2363 if (backupMasterStrings != null && !backupMasterStrings.isEmpty()) { -2364 backupMasters = new ArrayList<>(backupMasterStrings.size()); -2365 for (String s: backupMasterStrings) { -2366 try { -2367 byte [] bytes; -2368 try { -2369 bytes = ZKUtil.getData(this.zooKeeper, ZKUtil.joinZNode( -2370 this.zooKeeper.znodePaths.backupMasterAddressesZNode, s)); -2371 } catch (InterruptedException e) { -2372 throw new InterruptedIOException(); -2373 } -2374 if (bytes != null) { -2375 ServerName sn; -2376 try { -2377 sn = ProtobufUtil.parseServerNameFrom(bytes); -2378 } catch (DeserializationException e) { -2379 LOG.warn("Failed parse, skipping registering backup server", e); -2380 continue; -2381 } -2382 backupMasters.add(sn); -2383 } -2384 } catch (KeeperException e) { -2385 LOG.warn(this.zooKeeper.prefix("Unable to get information about " + -2386 "backup servers"), e); -2387 } -2388 } -2389 Collections.sort(backupMasters, new Comparator<ServerName>() { -2390 @Override -2391 public int compare(ServerName s1, ServerName s2) { -2392 return s1.getServerName().compareTo(s2.getServerName()); -2393 }}); -2394 } -2395 -2396 String clusterId = fileSystemManager != null ? -2397 fileSystemManager.getClusterId().toString() : null; -2398 Set<RegionState> regionsInTransition = assignmentManager != null ? -2399 assignmentManager.getRegionStates().getRegionsInTransition() : null; -2400 String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null; -2401 boolean balancerOn = loadBalancerTracker != null ? -2402 loadBalancerTracker.isBalancerOn() : false; -2403 Map<ServerName, ServerLoad> onlineServers = null; -2404 Set<ServerName> deadServers = null; -2405 if (serverManager != null) { -2406 deadServers = serverManager.getDeadServers().copyServerNames(); -2407 onlineServers = serverManager.getOnlineServers(); -2408 } -2409 return new ClusterStatus(VersionInfo.getVersion(), clusterId, -2410 onlineServers, deadServers, serverName, backupMasters, -2411 regionsInTransition, coprocessors, balancerOn); -2412 } -2413 -2414 /** -2415 * The set of loaded coprocessors is stored in a static set. Since it's -2416 * statically allocated, it does not require that HMaster's cpHost be -2417 * initialized prior to accessing it. -2418 * @return a String representation of the set of names of the loaded coprocessors. -2419 */ -2420 public static String getLoadedCoprocessors() { -2421 return CoprocessorHost.getLoadedCoprocessors().toString(); -2422 } -2423 -2424 /** -2425 * @return timestamp in millis when HMaster was started. -2426 */ -2427 public long getMasterStartTime() { -2428 return startcode; -2429 } -2430 -2431 /** -2432 * @return timestamp in millis when HMaster became the active master. -2433 */ -2434 public long getMasterActiveTime() { -2435 return masterActiveTime; -2436 } -2437 -2438 public int getNumWALFiles() { -2439 return procedureStore != null ? procedureStore.getActiveLogs().size() : 0; -2440 } -2441 -2442 public WALProcedureStore getWalProcedureStore() { -2443 return procedureStore; -2444 } -2445 -2446 public int getRegionServerInfoPort(final ServerName sn) { -2447 RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn); -2448 if (info == null || info.getInfoPort() == 0) { -2449 return conf.getInt(HConstants.REGIONSERVER_INFO_PORT, -2450 HConstants.DEFAULT_REGIONSERVER_INFOPORT); -2451 } -2452 return info.getInfoPort(); -2453 } -2454 -2455 public String getRegionServerVersion(final ServerName sn) { -2456 RegionServerInfo info = this.regionServerTracker.getRegionServerInfo(sn); -2457 if (info != null && info.hasVersionInfo()) { -2458 return info.getVersionInfo().getVersion(); -2459 } -2460 return "Unknown"; -2461 } -2462 -2463 /** -2464 * @return array of coprocessor SimpleNames. -2465 */ -2466 public String[] getMasterCoprocessors() { -2467 Set<String> masterCoprocessors = getMasterCoprocessorHost().getCoprocessors(); -2468 return masterCoprocessors.toArray(new String[masterCoprocessors.size()]); -2469 } -2470 -2471 @Override -2472 public void abort(final String msg, final Throwable t) { -2473 if (isAborted() || isStopped()) { -2474 return; -2475 } -2476 if (cpHost != null) { -2477 // HBASE-4014: dump a list of loaded coprocessors. -2478 LOG.fatal("Master server abort: loaded coprocessors are: " + -2479 getLoadedCoprocessors()); -2480 } -2481 if (t != null) LOG.fatal(msg, t); -2482 try { -2483 stopMaster(); -2484 } catch (IOException e) { -2485 LOG.error("Exception occurred while stopping master", e); -2486 } -2487 } -2488 -2489 @Override -2490 public ZooKeeperWatcher getZooKeeper() { -2491 return zooKeeper; -2492 } -2493 -2494 @Override -2495 public MasterCoprocessorHost getMasterCoprocessorHost() { -2496 return cpHost; -2497 } -2498 -2499 @Override -2500 public MasterQuotaManager getMasterQuotaManager() { -2501 return quotaManager; -2502 } -2503 -2504 @Override -2505 public ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() { -2506 return procedureExecutor; -2507 } -2508 -2509 @Override -2510 public ServerName getServerName() { -2511 return this.serverName; -2512 } -2513 -2514 @Override -2515 public AssignmentManager getAssignmentManager() { -2516 return this.assignmentManager; -2517 } -2518 -2519 @Override -2520 public CatalogJanitor getCatalogJanitor() { -2521 return this.catalogJanitorChore; -2522 } -2523 -2524 public MemoryBoundedLogMessageBuffer getRegionServerFatalLogBuffer() { -2525 return rsFatals; -2526 } -2527 -2528 public void shutdown() throws IOException { -2529 if (cpHost != null) { -2530 cpHost.preShutdown(); -2531 } -2532 -2533 if (this.serverManager != null) { -2534 this.serverManager.shutdownCluster(); -2535 } -2536 if (this.clusterStatusTracker != null){ -2537 try { -2538 this.clusterStatusTracker.setClusterDown(); -2539 } catch (KeeperException e) { -2540 LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e); -2541 } -2542 } -2543 } -2544 -2545 public void stopMaster() throws IOException { -2546 if (cpHost != null) { -2547 cpHost.preStopMaster(); -2548 } -2549 stop("Stopped by " + Thread.currentThread().getName()); -2550 } -2551 -2552 void checkServiceStarted() throws ServerNotRunningYetException { -2553 if (!serviceStarted) { -2554 throw new ServerNotRunningYetException("Server is not running yet"); -2555 } -2556 } -2557 -2558 void checkInitialized() -2559 throws PleaseHoldException, ServerNotRunningYetException, MasterNotRunningException { -2560 checkServiceStarted(); -2561 if (!isInitialized()) throw new PleaseHoldException("Master is initializing"); -2562 if (isStopped()) throw new MasterNotRunningException(); -2563 } -2564 -2565 /** -2566 * Report whether this master is currently the active master or not. -2567 * If not active master, we are parked on ZK waiting to become active. -2568 * -2569 * This method is used for testing. -2570 * -2571 * @return true if active master, false if not. -2572 */ -2573 @Override -2574 public boolean isActiveMaster() { -2575 return activeMaster; -2576 } -2577 -2578 /** -2579 * Report whether this master has completed with its initialization and is -2580 * ready. If ready, the master is also the active master. A standby master -2581 * is never ready. -2582 * -2583 * This method is used for testing. -2584 * -2585 * @return true if master is ready to go, false if not. -2586 */ -2587 @Override -2588 public boolean isInitialized() { -2589 return initialized.isReady(); -2590 } -2591 -2592 /** -2593 * Report whether this master is in maintenance mode. -2594 * -2595 * @return true if master is in maintenanceMode -2596 */ -2597 @Override -2598 public boolean isInMaintenanceMode() { -2599 return maintenanceModeTracker.isInMaintenanceMode(); -2600 } -2601 -2602 @VisibleForTesting -2603 public void setInitialized(boolean isInitialized) { -2604 procedureExecutor.getEnvironment().setEventReady(initialized, isInitialized); -2605 } -2606 -2607 public ProcedureEvent getInitializedEvent() { -2608 return initialized; -2609 } -2610 -2611 /** -2612 * ServerCrashProcessingEnabled is set false before completing assignMeta to prevent processing -2613 * of crashed servers. -2614 * @return true if assignMeta has completed; -2615 */ -2616 @Override -2617 public boolean isServerCrashProcessingEnabled() { -2618 return serverCrashProcessingEnabled.isReady(); -2619 } -2620 -2621 @VisibleForTesting -2622 public void setServerCrashProcessingEnabled(final boolean b) { -2623 procedureExecutor.getEnvironment().setEventReady(serverCrashProcessingEnabled, b); -2624 } -2625 -2626 public ProcedureEvent getServerCrashProcessingEnabledEvent() { -2627 return serverCrashProcessingEnabled; -2628 } -2629 -2630 /** -2631 * Report whether this master has started initialization and is about to do meta region assignment -2632 * @return true if master is in initialization &amp; about to assign hbase:meta regions -2633 */ -2634 public boolean isInitializationStartsMetaRegionAssignment() { -2635 return this.initializationBeforeMetaAssignment; -2636 } -2637 -2638 /** -2639 * Compute the average load across all region servers. -2640 * Currently, this uses a very naive computation - just uses the number of -2641 * regions being served, ignoring stats about number of requests. -2642 * @return the average load -2643 */ -2644 public double getAverageLoad() { -2645 if (this.assignmentManager == null) { -2646 return 0; -2647 } -2648 -2649 RegionStates regionStates = this.assignmentManager.getRegionStates(); -2650 if (regionStates == null) { -2651 return 0; -2652 } -2653 return regionStates.getAverageLoad(); -2654 } -2655 -2656 /* -2657 * @return the count of region split plans executed -2658 */ -2659 public long getSplitPlanCount() { -2660 return splitPlanCount; -2661 } -2662 -2663 /* -2664 * @return the count of region merge plans executed -2665 */ -2666 public long getMergePlanCount() { -2667 return mergePlanCount; -2668 } -2669 -2670 @Override -2671 public boolean registerService(Service instance) { -2672 /* -2673 * No stacking of instances is allowed for a single service name -2674 */ -2675 Descriptors.ServiceDescriptor serviceDesc = instance.getDescriptorForType(); -2676 String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc); -2677 if (coprocessorServiceHandlers.containsKey(serviceName)) { -2678 LOG.error("Coprocessor service "+serviceName+ -2679 " already registered, rejecting request from "+instance -2680 ); -2681 return false; -2682 } -2683 -2684 coprocessorServiceHandlers.put(serviceName, instance); -2685 if (LOG.isDebugEnabled()) { -2686 LOG.debug("Registered master coprocessor service: service="+serviceName); -2687 } -2688 return true; -2689 } -2690 -2691 /** -2692 * Utility for constructing an instance of the passed HMaster class. -2693 * @param masterClass -2694 * @return HMaster instance. -2695 */ -2696 public static HMaster constructMaster(Class<? extends HMaster> masterClass, -2697 final Configuration conf, final CoordinatedStateManager cp) { -2698 try { -2699 Constructor<? extends HMaster> c = -2700 masterClass.getConstructor(Configuration.class, CoordinatedStateManager.class); -2701 return c.newInstance(conf, cp); -2702 } catch(Exception e) { -2703 Throwable error = e; -2704 if (e instanceof InvocationTargetException && -2705 ((InvocationTargetException)e).getTargetException() != null) { -2706 error = ((InvocationTargetException)e).getTargetException(); -2707 } -2708 throw new RuntimeException("Failed construction of Master: " + masterClass.toString() + ". " -2709 , error); -2710 } -2711 } -2712 -2713 /** -2714 * @see org.apache.hadoop.hbase.master.HMasterCommandLine -2715 */ -2716 public static void main(String [] args) { -2717 LOG.info("***** STARTING service '" + HMaster.class.getSimpleName() + "' *****"); -2718 VersionInfo.logVersion(); -2719 new HMasterCommandLine(HMaster.class).doMain(args); -2720 } -2721 -2722 public HFileCleaner getHFileCleaner() { -2723 return this.hfileCleaner; -2724 } -2725 -2726 public LogCleaner getLogCleaner() { -2727 return this.logCleaner; -2728 } -2729 -2730 /** -2731 * @return the underlying snapshot manager -2732 */ -2733 @Override -2734 public SnapshotManager getSnapshotManager() { -2735 return this.snapshotManager; -2736 } -2737 -2738 /** -2739 * @return the underlying MasterProcedureManagerHost -2740 */ -2741 @Override -2742 public MasterProcedureManagerHost getMasterProcedureManagerHost() { -2743 return mpmHost; -2744 } -2745 -2746 @Override -2747 public ClusterSchema getClusterSchema() { -2748 return this.clusterSchemaService; -2749 } -2750 -2751 /** -2752 * Create a new Namespace. -2753 * @param namespaceDescriptor descriptor for new Namespace -2754 * @param nonceGroup Identifier for the source of the request, a client or process. -2755 * @param nonce A unique identifier for this operation from the client or process identified by -2756 * <code>nonceGroup</code> (the source must ensure each operation gets a unique id). -2757 * @return procedure id -2758 */ -2759 long createNamespace(final NamespaceDescriptor namespaceDescriptor, final long nonceGroup, -2760 final long nonce) throws IOException { -2761 checkInitialized(); -2762 -2763 TableName.isLegalNamespaceName(Bytes.toBytes(namespaceDescriptor.getName())); -2764 -2765 return MasterProcedureUtil.submitProcedure( -2766 new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) { -2767 @Override -2768 protected void run() throws IOException { -2769 if (getMaster().getMasterCoprocessorHost().preCreateNamespace(namespaceDescriptor)) { -2770 throw new BypassCoprocessorException(); -2771 } -2772 LOG.info(getClientIdAuditPrefix() + " creating " + namespaceDescriptor); -2773 // Execute the operation synchronously - wait for the operation to complete before -2774 // continuing. -2775 setProcId(getClusterSchema().createNamespace(namespaceDescriptor, getNonceKey())); -2776 getMaster().getMasterCoprocessorHost().postCreateNamespace(namespaceDescriptor); -2777 } -2778 -2779 @Override -2780 protected String getDescription() { -2781 return "CreateNamespaceProcedure"; -2782 } -2783 }); -2784 } -2785 -2786 /** -2787 * Modify an existing Namespace. -2788 * @param nonceGroup Identifier for the source of the request, a client or process. -2789 * @param nonce A unique identifier for this operation from the client or process identified by -2790 * <code>nonceGroup</code> (the source must ensure each operation gets a unique id). -2791 * @return procedure id -2792 */ -2793 long modifyNamespace(final NamespaceDescriptor namespaceDescriptor, final long nonceGroup, -2794 final long nonce) throws IOException { -2795 checkInitialized(); -2796 -2797 TableName.isLegalNamespaceName(Bytes.toBytes(namespaceDescriptor.getName())); -2798 -2799 return MasterProcedureUtil.submitProcedure( -2800 new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) { -2801 @Override -2802 protected void run() throws IOException { -2803 if (getMaster().getMasterCoprocessorHost().preModifyNamespace(namespaceDescriptor)) { -2804 throw new BypassCoprocessorException(); -2805 } -2806 LOG.info(getClientIdAuditPrefix() + " modify " + namespaceDescriptor); -2807 // Execute the operation synchronously - wait for the operation to complete before -2808 // continuing. -2809 setProcId(getClusterSchema().modifyNamespace(namespaceDescriptor, getNonceKey())); -2810 getMaster().getMasterCoprocessorHost().postModifyNamespace(namespaceDescriptor); -2811 } -2812 -2813 @Override -2814 protected String getDescription() { -2815 return "ModifyNamespaceProcedure"; -2816 } -2817 }); -2818 } -2819 -2820 /** -2821 * Delete an existing Namespace. Only empty Namespaces (no tables) can be removed. -2822 * @param nonceGroup Identifier for the source of the request, a client or process. -2823 * @param nonce A unique identifier for this operation from the client or process identified by -2824 * <code>nonceGroup</code> (the source must ensure each operation gets a unique id). -2825 * @return procedure id -2826 */ -2827 long deleteNamespace(final String name, final long nonceGroup, final long nonce) -2828 throws IOException { -2829 checkInitialized(); -2830 -2831 return MasterProcedureUtil.submitProcedure( -2832 new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) { -2833 @Override -2834 protected void run() throws IOException { -2835 if (getMaster().getMasterCoprocessorHost().preDeleteNamespace(name)) { -2836 throw new BypassCoprocessorException(); -2837 } -2838 LOG.info(getClientIdAuditPrefix() + " delete " + name); -2839 // Execute the operation synchronously - wait for the operation to complete before -2840 // continuing. -2841 setProcId(getClusterSchema().deleteNamespace(name, getNonceKey())); -2842 getMaster().getMasterCoprocessorHost().postDeleteNamespace(name); -2843 } -2844 -2845 @Override -2846 protected String getDescription() { -2847 return "DeleteNamespaceProcedure"; -2848 } -2849 }); -2850 } -2851 -2852 /** -2853 * Get a Namespace -2854 * @param name Name of the Namespace -2855 * @return Namespace descriptor for <code>name</code> -2856 */ -2857 NamespaceDescriptor getNamespace(String name) throws IOException { -2858 checkInitialized(); -2859 if (this.cpHost != null) this.cpHost.preGetNamespaceDescriptor(name); -2860 NamespaceDescriptor nsd = this.clusterSchemaService.getNamespace(name); -2861 if (this.cpHost != null) this.cpHost.postGetNamespaceDescriptor(nsd); -2862 return nsd; -2863 } -2864 -2865 /** -2866 * Get all Namespaces -2867 * @return All Namespace descriptors -2868 */ -2869 List<NamespaceDescriptor> getNamespaces() throws IOException { -2870 checkInitialized(); -2871 final List<NamespaceDescriptor> nsds = new ArrayList<>(); -2872 boolean bypass = false; -2873 if (cpHost != null) { -2874 bypass = cpHost.preListNamespaceDescriptors(nsds); -2875 } -2876 if (!bypass) { -2877 nsds.addAll(this.clusterSchemaService.getNamespaces()); -2878 if (this.cpHost != null) this.cpHost.postListNamespaceDescriptors(nsds); -2879 } -2880 return nsds; -2881 } -2882 -2883 @Override -2884 public List<TableName> listTableNamesByNamespace(String name) throws IOException { -2885 checkInitialized(); -2886 return listTableNames(name, null, true); -2887 } -2888 -2889 @Override -2890 public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException { -2891 checkInitialized(); -2892 return listTableDescriptors(name, null, null, true); -2893 } -2894 -2895 @Override -2896 public boolean abortProcedure(final long procId, final boolean mayInterruptIfRunning) -2897 throws IOException { -2898 if (cpHost != null) { -2899 cpHost.preAbortProcedure(this.procedureExecutor, procId); -2900 } -2901 -2902 final boolean result = this.procedureExecutor.abort(procId, mayInterruptIfRunning); -2903 -2904 if (cpHost != null) { -2905 cpHost.postAbortProcedure(); -2906 } -2907 -2908 return result; -2909 } -2910 -2911 @Override -2912 public List<ProcedureInfo> listProcedures() throws IOException { -2913 if (cpHost != null) { -2914 cpHost.preListProcedures(); -2915 } -2916 -2917 final List<ProcedureInfo> procInfoList = this.procedureExecutor.listProcedures(); -2918 -2919 if (cpHost != null) { -2920 cpHost.postListProcedures(procInfoList); -2921 } -2922 -2923 return procInfoList; -2924 } -2925 -2926 private Map<Long, ProcedureInfo> getProcedureInfos() { -2927 final List<ProcedureInfo> list = procedureExecutor.listProcedures(); -2928 final Map<Long, ProcedureInfo> map = new HashMap<>(); -2929 -2930 for (ProcedureInfo procedureInfo : list) { -2931 map.put(procedureInfo.getProcId(), procedureInfo); -2932 } -2933 -2934 return map; -2935 } -2936 -2937 @Override -2938 public List<LockInfo> listLocks() throws IOException { -2939 if (cpHost != null) { -2940 cpHost.preListLocks(); -2941 } -2942 -2943 MasterProcedureScheduler procedureScheduler = procedureExecutor.getEnvironment().getProcedureScheduler(); -2944 -2945 final List<LockInfo> lockInfoList = procedureScheduler.listLocks(); -2946 -2947 if (cpHost != null) { -2948 cpHost.postListLocks(lockInfoList); -2949 } -2950 -2951 return lockInfoList; -2952 } -2953 -2954 /** -2955 * Returns the list of table descriptors that match the specified request -2956 * @param namespace the namespace to query, or null if querying for all -2957 * @param regex The regular expression to match against, or null if querying for all -2958 * @param tableNameList the list of table names, or null if querying for all -2959 * @param includeSysTables False to match only against userspace tables -2960 * @return the list of table descriptors -2961 */ -2962 public List<HTableDescriptor> listTableDescriptors(final String namespace, final String regex, -2963 final List<TableName> tableNameList, final boolean includeSysTables) -2964 throws IOException { -2965 List<HTableDescriptor> htds = new ArrayList<>(); -2966 boolean bypass = cpHost != null? -2967 cpHost.preGetTableDescriptors(tableNameList, htds, regex): false; -2968 if (!bypass) { -2969 htds = getTableDescriptors(htds, namespace, regex, tableNameList, includeSysTables); -2970 if (cpHost != null) { -2971 cpHost.postGetTableDescriptors(tableNameList, htds, regex); -2972 } -2973 } -2974 return htds; -2975 } -2976 -2977 /** -2978 * Returns the list of table names that match the specified request -2979 * @param regex The regular expression to match against, or null if querying for all -2980 * @param namespace the namespace to query, or null if querying for all -2981 * @param includeSysTables False to match only against userspace tables -2982 * @return the list of table names -2983 */ -2984 public List<TableName> listTableNames(final String namespace, final String regex, -2985 final boolean includeSysTables) throws IOException { -2986 List<HTableDescriptor> htds = new ArrayList<>(); -2987 boolean bypass = cpHost != null? cpHost.preGetTableNames(htds, regex): false; -2988 if (!bypass) { -2989 htds = getTableDescriptors(htds, namespace, regex, null, includeSysTables); -2990 if (cpHost != null) cpHost.postGetTableNames(htds, regex); -2991 } -2992 List<TableName> result = new ArrayList<>(htds.size()); -2993 for (HTableDescriptor htd: htds) result.add(htd.getTableName()); -2994 return result; -2995 } -2996 -2997 /** -2998 * @return list of table table descriptors after filtering by regex and whether to include system -2999 * tables, etc. -3000 * @throws IOException -3001 */ -3002 private List<HTableDescriptor> getTableDescriptors(final List<HTableDescriptor> htds, -3003 final String namespace, final String regex, final List<TableName> tableNameList, -3004 final boolean includeSysTables) -3005 throws IOException { -3006 if (tableNameList == null || tableNameList.isEmpty()) { -3007 // request for all TableDescriptors -3008 Collection<HTableDescriptor> allHtds; -3009 if (namespace != null && namespace.length() > 0) { -3010 // Do a check on the namespace existence. Will fail if does not exist. -3011 this.clusterSchemaService.getNamespace(namespace); -3012 allHtds = tableDescriptors.getByNamespace(namespace).values(); -3013 } else { -3014 allHtds = tableDescriptors.getAll().values(); -3015 } -3016 for (HTableDescriptor desc: allHtds) { -3017 if (tableStateManager.isTablePresent(desc.getTableName()) -3018 && (includeSysTables || !desc.getTableName().isSystemTable())) { -3019 htds.add(desc); -3020 } -3021 } -3022 } else { -3023 for (TableName s: tableNameList) { -3024 if (tableStateManager.isTablePresent(s)) { -3025 HTableDescriptor desc = tableDescriptors.get(s); -3026 if (desc != null) { -3027 htds.add(desc); -3028 } -3029 } -3030 } -3031 } -3032 -3033 // Retains only those matched by regular expression. -3034 if (regex != null) filterTablesByRegex(htds, Pattern.compile(regex)); -3035 return htds; -3036 } -3037 -3038 /** -3039 * Removes the table descriptors that don't match the pattern. -3040 * @param descriptors list of table descriptors to filter -3041 * @param pattern the regex to use -3042 */ -3043 private static void filterTablesByRegex(final Collection<HTableDescriptor> descriptors, -3044 final Pattern pattern) { -3045 final String defaultNS = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR; -3046 Iterator<HTableDescriptor> itr = descriptors.iterator(); -3047 while (itr.hasNext()) { -3048 HTableDescriptor htd = itr.next(); -3049 String tableName = htd.getTableName().getNameAsString(); -3050 boolean matched = pattern.matcher(tableName).matches(); -3051 if (!matched && htd.getTableName().getNamespaceAsString().equals(defaultNS)) { -3052 matched = pattern.matcher(defaultNS + TableName.NAMESPACE_DELIM + tableName).matches(); -3053 } -3054 if (!matched) { -3055 itr.remove(); -3056 } -3057 } -3058 } -3059 -3060 @Override -3061 public long getLastMajorCompactionTimestamp(TableName table) throws IOException { -3062 return getClusterStatus().getLastMajorCompactionTsForTable(table); -3063 } -3064 -3065 @Override -3066 public long getLastMajorCompactionTimestampForRegion(byte[] regionName) throws IOException { -3067 return getClusterStatus().getLastMajorCompactionTsForRegion(regionName); -3068 } -3069 -3070 /** -3071 * Gets the mob file compaction state for a specific table. -3072 * Whether all the mob files are selected is known during the compaction execution, but -3073 * the statistic is done just before compaction starts, it is hard to know the compaction -3074 * type at that time, so the rough statistics are chosen for the mob file compaction. Only two -3075 * compaction states are available, CompactionState.MAJOR_AND_MINOR and CompactionState.NONE. -3076 * @param tableName The current table name. -3077 * @return If a given table is in mob file compaction now. -3078 */ -3079 public CompactionState getMobCompactionState(TableName tableName) { -3080 AtomicInteger compactionsCount = mobCompactionStates.get(tableName); -3081 if (compactionsCount != null && compactionsCount.get() != 0) { -3082 return CompactionState.MAJOR_AND_MINOR; -3083 } -3084 return CompactionState.NONE; -3085 } -3086 -3087 public void reportMobCompactionStart(TableName tableName) throws IOException { -3088 IdLock.Entry lockEntry = null; -3089 try { -3090 lockEntry = mobCompactionLock.getLockEntry(tableName.hashCode()); -3091 AtomicInteger compactionsCount = mobCompactionStates.get(tableName); -3092 if (compactionsCount == null) { -3093 compactionsCount = new AtomicInteger(0); -3094 mobCompactionStates.put(tableName, compactionsCount); -3095 } -3096 compactionsCount.incrementAndGet(); -3097 } finally { -3098 if (lockEntry != null) { -3099 mobCompactionLock.releaseLockEntry(lockEntry); -3100 } -3101 } -3102 } -3103 -3104 public void reportMobCompactionEnd(TableName tableName) throws IOException { -3105 IdLock.Entry lockEntry = null; -3106 try { -3107 lockEntry = mobCompactionLock.getLockEntry(tableName.hashCode()); -3108 AtomicInteger compactionsCount = mobCompactionStates.get(tableName); -3109 if (compactionsCount != null) { -3110 int count = compactionsCount.decrementAndGet(); -3111 // remove the entry if the count is 0. -3112 if (count == 0) { -3113 mobCompactionStates.remove(tableName); -3114 } -3115 } -3116 } finally { -3117 if (lockEntry != null) { -3118 mobCompactionLock.releaseLockEntry(lockEntry); -3119 } -3120 } -3121 } -3122 -3123 /** -3124 * Requests mob compaction. -3125 * @param tableName The table the compact. -3126 * @param columns The compacted columns. -3127 * @param allFiles Whether add all mob files into the compaction. -3128 */ -3129 public void requestMobCompaction(TableName tableName, -3130 List<HColumnDescriptor> columns, boolean allFiles) throws IOException { -3131 mobCompactThread.requestMobCompaction(conf, fs, tableName, columns, allFiles); -3132 } -3133 -3134 /** -3135 * Queries the state of the {@link LoadBalancerTracker}. If the balancer is not initialized, -3136 * false is returned. -3137 * -3138 * @return The state of the load balancer, or false if the load balancer isn't defined. -3139 */ -3140 public boolean isBalancerOn() { -3141 if (null == loadBalancerTracker || isInMaintenanceMode()) { -3142 return false; -3143 } -3144 return loadBalancerTracker.isBalancerOn(); -3145 } -3146 -3147 /** -3148 * Queries the state of the {@link RegionNormalizerTracker}. If it's not initialized, -3149 * false is returned. -3150 */ -3151 public boolean isNormalizerOn() { -3152 return (null == regionNormalizerTracker || isInMaintenanceMode()) ? -3153 false: regionNormalizerTracker.isNormalizerOn(); -3154 } -3155 -3156 /** -3157 * Queries the state of the {@link SplitOrMergeTracker}. If it is not initialized, -3158 * false is returned. If switchType is illegal, false will return. -3159 * @param switchType see {@link org.apache.hadoop.hbase.client.MasterSwitchType} -3160 * @return The state of the switch -3161 */ -3162 public boolean isSplitOrMergeEnabled(MasterSwitchType switchType) { -3163 if (null == splitOrMergeTracker || isInMaintenanceMode()) { -3164 return false; -3165 } -3166 return splitOrMergeTracker.isSplitOrMergeEnabled(switchType); -3167 } -3168 -3169 /** -3170 * Fetch the configured {@link LoadBalancer} class name. If none is set, a default is returned. -3171 * -3172 * @return The name of the {@link LoadBalancer} in use. -3173 */ -3174 public String getLoadBalancerClassName() { -3175 return conf.get(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, LoadBalancerFactory -3176 .getDefaultLoadBalancerClass().getName()); -3177 } -3178 -3179 /** -3180 * @return RegionNormalizerTracker instance -3181 */ -3182 public RegionNormalizerTracker getRegionNormalizerTracker() { -3183 return regionNormalizerTracker; -3184 } -3185 -3186 public SplitOrMergeTracker getSplitOrMergeTracker() { -3187 return splitOrMergeTracker; -3188 } -3189 -3190 @Override -3191 public LoadBalancer getLoadBalancer() { -3192 return balancer; -3193 } -3194 -3195 @Override -3196 public FavoredNodesManager getFavoredNodesManager() { -3197 return favoredNodesManager; -3198 } -3199 -3200 @Override -3201 public void addReplicationPeer(String peerId, ReplicationPeerConfig peerConfig) -3202 throws ReplicationException, IOException { -3203 if (cpHost != null) { -3204 cpHost.preAddReplicationPeer(peerId, peerConfig); -3205 } -3206 LOG.info(getClientIdAuditPrefix() + " creating replication peer, id=" + peerId + ", config=" -3207 + peerConfig); -3208 this.replicationManager.addReplicationPeer(peerId, peerConfig); -3209 if (cpHost != null) { -3210 cpHost.postAddReplicationPeer(peerId, peerConfig); -3211 } -3212 } -3213 -3214 @Override -3215 public void removeReplicationPeer(String peerId) throws ReplicationException, IOException { -3216 if (cpHost != null) { -3217 cpHost.preRemoveReplicationPeer(peerId); -3218 } -3219 LOG.info(getClientIdAuditPrefix() + " removing replication peer, id=" + peerId); -3220 this.replicationManager.removeReplicationPeer(peerId); -3221 if (cpHost != null) { -3222 cpHost.postRemoveReplicationPeer(peerId); -3223 } -3224 } -3225 -3226 @Override -3227 public void enableReplicationPeer(String peerId) throws ReplicationException, IOException { -3228 if (cpHos