You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by Kun Ren <re...@gmail.com> on 2016/05/20 19:05:28 UTC

cp and mv

Hi Genius,

Currently I debugged the cp and mv operations, for example:
(1) ./bin/hdfs dfs -cp input/a.xml input/b.xml
(2)./bin/hdfs dfs -mv input/a.xml input/b.xml

My understanding is that for operation cp, it will create a new file b.xml,
and will copy the content of a.xml to b.xml; For mv operations, it will
create b.xml and copy the content of a.xml to b.xml, and delete the a.xml.

However, when I debug the code, i found that both operations will finally
go through the create() method in NameNodeRpcServer.java, but I didn't see
any calls to copy and delete function,  could you please point out to me
where I can debug and see the full logic of the cp and mv operations.
Thanks a lot.

Re: cp and mv

Posted by Kun Ren <re...@gmail.com>.
Make sense, Thanks a lot, Mingliang.  Another quick question:  why there is
a shell command that can copy a HDFS file to another  HDFS file, but there
is no API that can do this, the API only support copying file from local to
HDFS, so that I should call multiple APIs to implement this, is that
correct?  Thanks.

On Fri, May 20, 2016 at 5:44 PM, Mingliang Liu <ml...@hortonworks.com> wrote:

> Kun,
>
> I think you need to be ware of the difference between client and server
> side logic. Perhaps you’re more interested in the client side in this case.
> The commands are generally running in the shell, and
> org.apache.hadoop.fs.shell package is a good place to start. Specially,
> have a look at CommandWithDestination.java.
>
> Ciao,
>
> L
>
> On May 20, 2016, at 12:05 PM, Kun Ren <re...@gmail.com> wrote:
>
> Hi Genius,
>
> Currently I debugged the cp and mv operations, for example:
> (1) ./bin/hdfs dfs -cp input/a.xml input/b.xml
> (2)./bin/hdfs dfs -mv input/a.xml input/b.xml
>
> My understanding is that for operation cp, it will create a new file b.xml,
> and will copy the content of a.xml to b.xml; For mv operations, it will
> create b.xml and copy the content of a.xml to b.xml, and delete the a.xml.
>
> However, when I debug the code, i found that both operations will finally
> go through the create() method in NameNodeRpcServer.java, but I didn't see
> any calls to copy and delete function,  could you please point out to me
> where I can debug and see the full logic of the cp and mv operations.
> Thanks a lot.
>
>
>

Re: cp and mv

Posted by Mingliang Liu <ml...@hortonworks.com>.
Kun,

I think you need to be ware of the difference between client and server side logic. Perhaps you’re more interested in the client side in this case. The commands are generally running in the shell, and org.apache.hadoop.fs.shell package is a good place to start. Specially, have a look at CommandWithDestination.java.

Ciao,

L

On May 20, 2016, at 12:05 PM, Kun Ren <re...@gmail.com>> wrote:

Hi Genius,

Currently I debugged the cp and mv operations, for example:
(1) ./bin/hdfs dfs -cp input/a.xml input/b.xml
(2)./bin/hdfs dfs -mv input/a.xml input/b.xml

My understanding is that for operation cp, it will create a new file b.xml,
and will copy the content of a.xml to b.xml; For mv operations, it will
create b.xml and copy the content of a.xml to b.xml, and delete the a.xml.

However, when I debug the code, i found that both operations will finally
go through the create() method in NameNodeRpcServer.java, but I didn't see
any calls to copy and delete function,  could you please point out to me
where I can debug and see the full logic of the cp and mv operations.
Thanks a lot.