org.apache.solr.common.cloud

## Class ZkMaintenanceUtils

- java.lang.Object
- - org.apache.solr.common.cloud.ZkMaintenanceUtils

-     public class ZkMaintenanceUtils
      extends Object

  Class to hold ZK upload/download/move common code. With the advent of the upconfig/downconfig/cp/ls/mv commands in bin/solr it made sense to keep the individual transfer methods in a central place, so here it is.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ZkMaintenanceUtils.VISIT_ORDER`
    `static interface` | `ZkMaintenanceUtils.ZkVisitor`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clean(SolrZkClient zkClient, String path)`
    `static String` | `createZkNodeName(String zkRoot, Path root, Path file)`
    `static void` | `downConfig(SolrZkClient zkClient, String confName, Path confPath)`
    `static void` | `downloadFromZK(SolrZkClient zkClient, String zkPath, Path dir)`
    `static String` | `listZnode(SolrZkClient zkClient, String path, Boolean recurse)` Lists a ZNode child and (optionally) the znodes of all the children.
    `static void` | `moveZnode(SolrZkClient zkClient, String src, String dst)`
    `static void` | `traverseZkTree(SolrZkClient zkClient, String path, ZkMaintenanceUtils.VISIT_ORDER visitOrder, ZkMaintenanceUtils.ZkVisitor visitor)` Recursively visit a zk tree rooted at path and apply the given visitor to each path.
    `static void` | `upConfig(SolrZkClient zkClient, Path confPath, String confName)`
    `static void` | `uploadToZK(SolrZkClient zkClient, Path rootPath, String zkPath, Pattern filenameExclusions)`
    `static void` | `zkTransfer(SolrZkClient zkClient, String src, Boolean srcIsZk, String dst, Boolean dstIsZk, Boolean recurse)` Copy between local file system and Zookeeper, or from one Zookeeper node to another, optionally copying recursively.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### listZnode

          public static String listZnode(SolrZkClient zkClient,
                                         String path,
                                         Boolean recurse)
                                  throws org.apache.zookeeper.KeeperException,
                                         InterruptedException,
                                         SolrServerException

      Lists a ZNode child and (optionally) the znodes of all the children. No data is dumped.
      Parameters:
        `path` - The node to remove on Zookeeper
        `recurse` - Whether to remove children.
      Returns:
        an indented list of the znodes suitable for display
      Throws:
        `org.apache.zookeeper.KeeperException` - Could not perform the Zookeeper operation.
        `InterruptedException` - Thread interrupted
        `SolrServerException` - zookeeper node has children and recurse not specified.

    - #### zkTransfer

          public static void zkTransfer(SolrZkClient zkClient,
                                        String src,
                                        Boolean srcIsZk,
                                        String dst,
                                        Boolean dstIsZk,
                                        Boolean recurse)
                                 throws SolrServerException,
                                        org.apache.zookeeper.KeeperException,
                                        InterruptedException,
                                        IOException

      Copy between local file system and Zookeeper, or from one Zookeeper node to another, optionally copying recursively.
      Parameters:
        `src` - Source to copy from. Both src and dst may be Znodes. However, both may NOT be local
        `dst` - The place to copy the files too. Both src and dst may be Znodes. However both may NOT be local
        `recurse` - if the source is a directory, reccursively copy the contents iff this is true.
      Throws:
        `SolrServerException` - Explanatory exception due to bad params, failed operation, etc.
        `org.apache.zookeeper.KeeperException` - Could not perform the Zookeeper operation.
        `InterruptedException` - Thread interrupted
        `IOException`

    - #### moveZnode

          public static void moveZnode(SolrZkClient zkClient,
                                       String src,
                                       String dst)
                                throws SolrServerException,
                                       org.apache.zookeeper.KeeperException,
                                       InterruptedException

      Throws:
        `SolrServerException`
        `org.apache.zookeeper.KeeperException`
        `InterruptedException`

    - #### downConfig

          public static void downConfig(SolrZkClient zkClient,
                                        String confName,
                                        Path confPath)
                                 throws IOException

      Throws:
        `IOException`

    - #### upConfig

          public static void upConfig(SolrZkClient zkClient,
                                      Path confPath,
                                      String confName)
                               throws IOException

      Throws:
        `IOException`

    - #### clean

          public static void clean(SolrZkClient zkClient,
                                   String path)
                            throws InterruptedException,
                                   org.apache.zookeeper.KeeperException

      Throws:
        `InterruptedException`
        `org.apache.zookeeper.KeeperException`

    - #### uploadToZK

          public static void uploadToZK(SolrZkClient zkClient,
                                        Path rootPath,
                                        String zkPath,
                                        Pattern filenameExclusions)
                                 throws IOException

      Throws:
        `IOException`

    - #### downloadFromZK

          public static void downloadFromZK(SolrZkClient zkClient,
                                            String zkPath,
                                            Path dir)
                                     throws IOException

      Throws:
        `IOException`

    - #### traverseZkTree

          public static void traverseZkTree(SolrZkClient zkClient,
                                            String path,
                                            ZkMaintenanceUtils.VISIT_ORDER visitOrder,
                                            ZkMaintenanceUtils.ZkVisitor visitor)
                                     throws InterruptedException,
                                            org.apache.zookeeper.KeeperException

      Recursively visit a zk tree rooted at path and apply the given visitor to each path. Exists as a separate method because some of the logic can get nuanced.
      Parameters:
        `path` - the path to start from
        `visitOrder` - whether to call the visitor at the at the ending or beginning of the run.
        `visitor` - the operation to perform on each path
      Throws:
        `InterruptedException`
        `org.apache.zookeeper.KeeperException`

    - #### createZkNodeName

          public static String createZkNodeName(String zkRoot,
                                                Path root,
                                                Path file)

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.