Search in sources :

Example 6 with DFSClient

use of org.apache.hadoop.hdfs.DFSClient in project hadoop by apache.

the class TestRetryCacheWithHA method testAddCacheDirectiveInfo.

@Test(timeout = 60000)
public void testAddCacheDirectiveInfo() throws Exception {
    DFSClient client = genClientWithDummyHandler();
    AtMostOnceOp op = new AddCacheDirectiveInfoOp(client, new CacheDirectiveInfo.Builder().setPool("pool").setPath(new Path("/path")).build());
    testClientRetryWithFailover(op);
}
Also used : DFSClient(org.apache.hadoop.hdfs.DFSClient) Path(org.apache.hadoop.fs.Path) Test(org.junit.Test)

Example 7 with DFSClient

use of org.apache.hadoop.hdfs.DFSClient in project hadoop by apache.

the class TestDisallowModifyROSnapshot method testCreate.

@Test(timeout = 60000, expected = SnapshotAccessControlException.class)
public void testCreate() throws Exception {
    @SuppressWarnings("deprecation") DFSClient dfsclient = new DFSClient(conf);
    dfsclient.create(objInSnapshot.toString(), true);
}
Also used : DFSClient(org.apache.hadoop.hdfs.DFSClient) Test(org.junit.Test)

Example 8 with DFSClient

use of org.apache.hadoop.hdfs.DFSClient in project hadoop by apache.

the class TestDisallowModifyROSnapshot method testCreateSymlink.

@Test(timeout = 60000, expected = SnapshotAccessControlException.class)
public void testCreateSymlink() throws Exception {
    @SuppressWarnings("deprecation") DFSClient dfsclient = new DFSClient(conf);
    dfsclient.createSymlink(sub2.toString(), "/TestSnapshot/sub1/.snapshot", false);
}
Also used : DFSClient(org.apache.hadoop.hdfs.DFSClient) Test(org.junit.Test)

Example 9 with DFSClient

use of org.apache.hadoop.hdfs.DFSClient in project hadoop by apache.

the class LeaseRenewer method renew.

private void renew() throws IOException {
    final List<DFSClient> copies;
    synchronized (this) {
        copies = new ArrayList<>(dfsclients);
    }
    //sort the client names for finding out repeated names.
    Collections.sort(copies, new Comparator<DFSClient>() {

        @Override
        public int compare(final DFSClient left, final DFSClient right) {
            return left.getClientName().compareTo(right.getClientName());
        }
    });
    String previousName = "";
    for (final DFSClient c : copies) {
        //skip if current client name is the same as the previous name.
        if (!c.getClientName().equals(previousName)) {
            if (!c.renewLease()) {
                LOG.debug("Did not renew lease for client {}", c);
                continue;
            }
            previousName = c.getClientName();
            LOG.debug("Lease renewed for client {}", previousName);
        }
    }
}
Also used : DFSClient(org.apache.hadoop.hdfs.DFSClient)

Example 10 with DFSClient

use of org.apache.hadoop.hdfs.DFSClient in project hadoop by apache.

the class LeaseRenewer method addClient.

/** Add a client. */
private synchronized void addClient(final DFSClient dfsc) {
    for (DFSClient c : dfsclients) {
        if (c == dfsc) {
            //client already exists, nothing to do.
            return;
        }
    }
    //client not found, add it
    dfsclients.add(dfsc);
    //update renewal time
    final int hdfsTimeout = dfsc.getConf().getHdfsTimeout();
    if (hdfsTimeout > 0) {
        final long half = hdfsTimeout / 2;
        if (half < renewal) {
            this.renewal = half;
        }
    }
}
Also used : DFSClient(org.apache.hadoop.hdfs.DFSClient)

Aggregations

DFSClient (org.apache.hadoop.hdfs.DFSClient)107 Test (org.junit.Test)58 IOException (java.io.IOException)39 Nfs3FileAttributes (org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes)27 FileHandle (org.apache.hadoop.nfs.nfs3.FileHandle)26 Path (org.apache.hadoop.fs.Path)20 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)19 VisibleForTesting (com.google.common.annotations.VisibleForTesting)18 Configuration (org.apache.hadoop.conf.Configuration)17 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)15 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)14 InetSocketAddress (java.net.InetSocketAddress)13 FileSystem (org.apache.hadoop.fs.FileSystem)12 NfsConfiguration (org.apache.hadoop.hdfs.nfs.conf.NfsConfiguration)12 FsPermission (org.apache.hadoop.fs.permission.FsPermission)10 HdfsDataOutputStream (org.apache.hadoop.hdfs.client.HdfsDataOutputStream)10 ArrayList (java.util.ArrayList)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 LocatedBlock (org.apache.hadoop.hdfs.protocol.LocatedBlock)8 ShellBasedIdMapping (org.apache.hadoop.security.ShellBasedIdMapping)8