You can use the oddly named ZkStateReader.readConfigName(String Collection)
to get this information. We should add this information to the cluster
status API.

On Mon, Apr 13, 2015 at 6:58 PM, Shai Erera <[email protected]> wrote:

> Hi
>
> I was looking for some API (Java or REST) for retrieving the configuration
> name with which a collection was created. It doesn't appear as part of the
> cluster status information, nor is part of the DocCollection class.
>
> I eventually wrote this code:
>
>   /** Returns a collection's configuration name, or {@code null} if the
> collection doesn't exist. */
>   public static String getCollectionConfigName(ZkStateReader
> zkStateReader, String collection) {
>     try {
>       final String collectionZkNode = ZkStateReader.COLLECTIONS_ZKNODE +
> "/" + collection;
>       final byte[] data =
> zkStateReader.getZkClient().getData(collectionZkNode, null, null, true);
>       final ZkNodeProps nodeProps = ZkNodeProps.load(data);
>       final String collectionConfigName =
> nodeProps.getStr(ZkStateReader.CONFIGNAME_PROP);
>       return collectionConfigName;
>     } catch (NoNodeException e) {
>       return null;
>     } catch (KeeperException | InterruptedException e) {
>       throw Throwables.propagate(e);
>     }
>   }
>
> This works but feels "hacky" as none of this is documented anywhere. So if
> anyone is aware of an existing class/method which does that, even if it's
> not truly "public API", I'd appreciate a pointer.
>
> Also, would it make sense to add this information to DocCollection, e.g.
> docCollection.getConfigName()?
>
> Shai
>



-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to