Ejemplo n.º 1
0
        public override int Run(string[] remainingArguments)
        {
            string file_id = remainingArguments [0];

            if (_dryrun)
            {
                Console.WriteLine("fdfsclient download {0} --output {1} {2}", OptionsToString(), _destFileName, file_id);
                return(0);
            }

            ConnectionManager.Initialize(_trackers);
            string groupName = null;
            string fileName  = null;

            SplitGroupNameAndFileName(file_id, out groupName, out fileName);

            StorageNode[] nodes = FastDFSClient.QueryStorageNodesForFile(groupName, fileName);
            if (nodes == null)
            {
                throw new FDFSException(string.Format("Group {0} not found.", groupName));
            }

            StorageNode node = SelectStorageNode(nodes, fileName, _timeout);

            if (node == null)
            {
                throw new FDFSException("node not available");
            }
            DoDownload(node, fileName, _destFileName);
            return(0);
        }
Ejemplo n.º 2
0
        public override int Run(string[] remainingArguments)
        {
            string file_id = remainingArguments [0];

            if (_dryrun)
            {
                Console.WriteLine("fdfsclient query {0} {1}", OptionsToString(), file_id);
                return(0);
            }
            ConnectionManager.Initialize(_trackers);

            string groupName = null;
            string fileName  = null;

            SplitGroupNameAndFileName(file_id, out groupName, out fileName);

            StorageNode[] nodes = FastDFSClient.QueryStorageNodesForFile(groupName, fileName);
            if (nodes == null)
            {
                throw new FDFSException(string.Format("Group {0} not found.", groupName));
            }

            foreach (StorageNode node in nodes)
            {
                Console.WriteLine("Group:{0}\nServer:{1}\n", node.GroupName, node.EndPoint.ToString());
                if (FileExistsOnStorageNode(node, fileName))
                {
                    Console.WriteLine("file exists.");
                }
                else
                {
                    Console.WriteLine("file doesn't exist.");
                }
            }
            return(0);
        }