Example #1
0
        private static async Task uploadFileToZk(SolrZkClient zkClient, string zkNode, string file, Regex filenameExclusions)
        {
            var fielName = Path.GetFileName(file);

            if (filenameExclusions != null && filenameExclusions.Match(fielName ?? throw new InvalidOperationException("File name is empty")).Success)
            {
                //TODO: Log here
                //log.info("uploadToZK skipping '{}' due to filenameExclusions '{}'", filename, filenameExclusions);
                return;
            }
            try
            {
                // if the path exists (and presumably we're uploading data to it) just set its data
                if (Path.GetFileName(file).Equals(ZKNODE_DATA_FILE) && (await zkClient.exists(zkNode, true)))
                {
                    await zkClient.setData(zkNode, file, true);
                }
                else
                {
                    //Can't work async because it will try to create same path
                    zkClient.makePath(zkNode, file, false, true).Wait();
                }
            }
            catch (KeeperException ex)
            {
                throw new Exception("Error uploading file " + file + " to zookeeper path " + zkNode, SolrZkClient.checkInterrupted(ex));
            }
        }
Example #2
0
 // Insure that all the nodes in one path match the nodes in the other as a safety check before removing
 // the source in a 'mv' command.
 private static async Task checkAllZnodesThere(SolrZkClient zkClient, string src, string dst)
 {
     foreach (var node in await zkClient.getChildren(src, null, true))
     {
         if (await zkClient.exists(dst + "/" + node, true) == false)
         {
             throw new Exception("mv command did not move node " + dst + "/" + node + " source left intact");
         }
         await checkAllZnodesThere(zkClient, src + "/" + node, dst + "/" + node);
     }
 }
Example #3
0
 public async void EnsureExists(string path, byte[] data, CreateMode createMode, SolrZkClient zkClient, int skipPathParts)
 {
     if (await zkClient.exists(path, true))
     {
         return;
     }
     try
     {
         await zkClient.makePath(path, data, createMode, null, true, true, skipPathParts);
     }
     catch (KeeperException.NodeExistsException ex)
     {
         // it's okay if another beats us creating the node
     }
 }
Example #4
0
 /// <summary>
 /// Check whether a config exists in Zookeeper
 /// </summary>
 /// <param name="configName">The config to check existance on</param>
 /// <returns>Whether the config exists or not</returns>
 /// <exception cref="IOException">If an I/O error occurs</exception>
 public async Task <bool> configExists(string configName)
 {
     try
     {
         return(await zkClient.exists(ConfigsZKnode + "/" + configName, true));
     }
     catch (Exception ex)
     {
         if (ex is KeeperException || ex is ThreadInterruptedException)
         {
             throw new IOException("Error checking whether config exists", SolrZkClient.checkInterrupted(ex));
         }
         throw;
     }
 }
Example #5
0
        public static async Task <bool> isEphemeral(SolrZkClient zkClient, string zkPath)
        {
            var znodeStat = await zkClient.exists(zkPath, null, true);

            return(znodeStat.getEphemeralOwner() != 0);
        }