| Method from org.apache.hadoop.dfs.DFSClient Detail: |
public void close() throws IOException {
// synchronize in here so that we don't need to change the API
synchronized (this) {
checkOpen();
synchronized (pendingCreates) {
Iterator file_itr = pendingCreates.keySet().iterator();
while (file_itr.hasNext()) {
String name = (String) file_itr.next();
try {
namenode.abandonFileInProgress(name, clientName);
} catch (IOException ie) {
System.err.println("Exception abandoning create lock on " + name);
ie.printStackTrace();
}
}
pendingCreates.clear();
}
this.running = false;
try {
leaseChecker.join();
} catch (InterruptedException ie) {
}
}
}
Close the file system, abadoning all of the leases and files being
created. |
public OutputStream create(UTF8 src,
boolean overwrite) throws IOException {
return create(src, overwrite, defaultReplication, defaultBlockSize, null);
}
Create a new dfs file and return an output stream for writing into it. |
public OutputStream create(UTF8 src,
boolean overwrite,
Progressable progress) throws IOException {
return create(src, overwrite, defaultReplication, defaultBlockSize, null);
}
Create a new dfs file and return an output stream for writing into it
with write-progress reporting. |
public OutputStream create(UTF8 src,
boolean overwrite,
short replication,
long blockSize) throws IOException {
return create(src, overwrite, replication, blockSize, null);
}
Create a new dfs file with the specified block replication
and return an output stream for writing into the file. |
public OutputStream create(UTF8 src,
boolean overwrite,
short replication,
long blockSize,
Progressable progress) throws IOException {
return create(src, overwrite, replication, blockSize, progress,
conf.getInt("io.file.buffer.size", 4096));
}
Create a new dfs file with the specified block replication
with write-progress reporting and return an output stream for writing
into the file. |
public OutputStream create(UTF8 src,
boolean overwrite,
short replication,
long blockSize,
Progressable progress,
int buffersize) throws IOException {
checkOpen();
OutputStream result = new DFSOutputStream(
src, overwrite, replication, blockSize, progress, buffersize);
synchronized (pendingCreates) {
pendingCreates.put(src.toString(), result);
}
return result;
}
Create a new dfs file with the specified block replication
with write-progress reporting and return an output stream for writing
into the file. |
public DatanodeInfo[] datanodeReport() throws IOException {
return namenode.getDatanodeReport();
}
|
public boolean delete(UTF8 src) throws IOException {
checkOpen();
return namenode.delete(src.toString());
}
Make a direct connection to namenode and manipulate structures
there. |
public UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action) throws IOException {
return namenode.distributedUpgradeProgress(action);
}
|
public boolean exists(UTF8 src) throws IOException {
checkOpen();
return namenode.exists(src.toString());
}
|
public void finalizeUpgrade() throws IOException {
namenode.finalizeUpgrade();
}
|
public long getBlockSize(UTF8 f) throws IOException {
try {
return namenode.getBlockSize(f.toString());
} catch (IOException ie) {
LOG.warn("Problem getting block size: " +
StringUtils.stringifyException(ie));
throw ie;
}
}
|
public long getDefaultBlockSize() {
return defaultBlockSize;
}
Get the default block size for this cluster |
public short getDefaultReplication() {
return defaultReplication;
}
|
public DFSFileInfo getFileInfo(UTF8 src) throws IOException {
checkOpen();
return namenode.getFileInfo(src.toString());
}
|
public String[][] getHints(String src,
long start,
long length) throws IOException {
LocatedBlocks blocks = namenode.getBlockLocations(src, start, length);
if (blocks == null) {
return new String[0][];
}
int nrBlocks = blocks.locatedBlockCount();
String[][] hints = new String[nrBlocks][];
int idx = 0;
for (LocatedBlock blk : blocks.getLocatedBlocks()) {
assert idx < nrBlocks : "Incorrect index";
DatanodeInfo[] locations = blk.getLocations();
hints[idx] = new String[locations.length];
for (int hCnt = 0; hCnt < locations.length; hCnt++) {
hints[idx][hCnt] = locations[hCnt].getHostName();
}
idx++;
}
return hints;
}
Get hints about the location of the indicated block(s).
getHints() returns a list of hostnames that store data for
a specific file region. It returns a set of hostnames for
every block within the indicated region.
This function is very useful when writing code that considers
data-placement when performing operations. For example, the
MapReduce system tries to schedule tasks on the same machines
as the data-block the task processes. |
public boolean isDirectory(UTF8 src) throws IOException {
checkOpen();
return namenode.isDir(src.toString());
}
|
public DFSFileInfo[] listPaths(UTF8 src) throws IOException {
checkOpen();
return namenode.getListing(src.toString());
}
|
public void lock(UTF8 src,
boolean exclusive) throws IOException {
long start = System.currentTimeMillis();
boolean hasLock = false;
while (!hasLock) {
hasLock = namenode.obtainLock(src.toString(), clientName, exclusive);
if (!hasLock) {
try {
Thread.sleep(400);
if (System.currentTimeMillis() - start > 5000) {
LOG.info("Waiting to retry lock for " + (System.currentTimeMillis() - start) + " ms.");
Thread.sleep(2000);
}
} catch (InterruptedException ie) {
}
}
}
}
|
public void metaSave(String pathname) throws IOException {
namenode.metaSave(pathname);
}
|
public boolean mkdirs(UTF8 src) throws IOException {
checkOpen();
return namenode.mkdirs(src.toString());
}
|
public DFSClient.DFSInputStream open(UTF8 src) throws IOException {
return open(src, conf.getInt("io.file.buffer.size", 4096));
}
|
public DFSClient.DFSInputStream open(UTF8 src,
int buffersize) throws IOException {
checkOpen();
// Get block info from namenode
return new DFSInputStream(src.toString(), buffersize);
}
Create an input stream that obtains a nodelist from the
namenode, and then reads from all the right places. Creates
inner subclass of InputStream that does the right out-of-band
work. |
public void refreshNodes() throws IOException {
namenode.refreshNodes();
}
|
public void release(UTF8 src) throws IOException {
boolean hasReleased = false;
while (!hasReleased) {
hasReleased = namenode.releaseLock(src.toString(), clientName);
if (!hasReleased) {
LOG.info("Could not release. Retrying...");
try {
Thread.sleep(2000);
} catch (InterruptedException ie) {
}
}
}
}
|
public boolean rename(UTF8 src,
UTF8 dst) throws IOException {
checkOpen();
return namenode.rename(src.toString(), dst.toString());
}
Make a direct connection to namenode and manipulate structures
there. |
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
namenode.reportBadBlocks(blocks);
}
Report corrupt blocks that were discovered by the client. |
void reportChecksumFailure(String file,
LocatedBlock[] lblocks) {
try {
reportBadBlocks(lblocks);
} catch (IOException ie) {
LOG.info("Found corruption while reading " + file
+ ". Error repairing corrupt blocks. Bad blocks remain. "
+ StringUtils.stringifyException(ie));
}
}
|
void reportChecksumFailure(String file,
Block blk,
DatanodeInfo dn) {
DatanodeInfo [] dnArr = { dn };
LocatedBlock [] lblocks = { new LocatedBlock(blk, dnArr) };
reportChecksumFailure(file, lblocks);
}
|
public boolean setReplication(UTF8 src,
short replication) throws IOException {
return namenode.setReplication(src.toString(), replication);
}
Set replication for an existing file. |
public boolean setSafeMode(SafeModeAction action) throws IOException {
return namenode.setSafeMode(action);
}
|
public long totalRawCapacity() throws IOException {
long rawNums[] = namenode.getStats();
return rawNums[0];
}
|
public long totalRawUsed() throws IOException {
long rawNums[] = namenode.getStats();
return rawNums[1];
}
|