本文整理汇总了Java中org.apache.hadoop.fs.shell.PathData类的典型用法代码示例。如果您正苦于以下问题:Java PathData类的具体用法?Java PathData怎么用?Java PathData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathData类属于org.apache.hadoop.fs.shell包,在下文中一共展示了PathData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPathRecursable
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Override
protected boolean isPathRecursable(PathData item) throws IOException {
if (item.stat.isDirectory()) {
return true;
}
if (item.stat.isSymlink()) {
PathData linkedItem =
new PathData(item.fs.resolvePath(item.stat.getSymlink()).toString(),
getConf());
if (linkedItem.stat.isDirectory()) {
if (getOptions().isFollowLink()) {
return true;
}
if (getOptions().isFollowArgLink() && (getDepth() == 0)) {
return true;
}
}
}
return false;
}
示例2: processPath
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Override
protected void processPath(PathData item) throws IOException {
//Should we do case insensitive match?
String newOwner = (owner == null || owner.equals(item.stat.getOwner())) ?
null : owner;
String newGroup = (group == null || group.equals(item.stat.getGroup())) ?
null : group;
if (newOwner != null || newGroup != null) {
try {
item.fs.setOwner(item.path, newOwner, newGroup);
} catch (IOException e) {
LOG.debug("Error changing ownership of " + item, e);
throw new IOException(
"changing ownership of '" + item + "': " + e.getMessage());
}
}
}
示例3: testFailFirst
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testFailFirst() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.FAIL);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.PASS);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.FAIL, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例4: testFailSecond
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testFailSecond() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.PASS);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.FAIL);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.FAIL, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例5: testFailBoth
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testFailBoth() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.FAIL);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.FAIL);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.FAIL, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例6: testStopFirst
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testStopFirst() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.STOP);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.PASS);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.STOP, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例7: testStopSecond
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testStopSecond() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.PASS);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.STOP);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.STOP, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例8: testStopFail
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testStopFail() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.STOP);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.FAIL);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.STOP.combine(Result.FAIL), and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例9: testChgrpGroupValidity
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
/**
* Tests valid and invalid group arguments to chgrp.
*/
@Test
public void testChgrpGroupValidity() {
// This test only covers argument parsing, so override to skip processing.
FsCommand chgrp = new FsShellPermissions.Chgrp() {
@Override
protected void processArgument(PathData item) {
}
};
chgrp.setConf(new Configuration());
// The following are valid (no exception expected).
chgrp.run("group", "/path");
// The following are valid only on Windows.
assertValidArgumentsOnWindows(chgrp, "Group With Spaces", "/path");
// The following are invalid (exception expected).
assertIllegalArguments(chgrp, ":gr#oup", "/path");
assertIllegalArguments(chgrp, ":gr%oup", "/path");
}
示例10: testPass
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Test(timeout = 1000)
public void testPass() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.PASS);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.PASS);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.PASS, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
示例11: isAncestor
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
/** Returns true if the target is an ancestor of the source. */
private boolean isAncestor(PathData source, PathData target) {
for (Path parent = source.path; (parent != null) && !parent.isRoot();
parent = parent.getParent()) {
if (parent.equals(target.path)) {
return true;
}
}
return false;
}
示例12: recursePath
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Override
protected void recursePath(PathData item) throws IOException {
if (isStop(item)) {
// this item returned a stop result so don't recurse any further
return;
}
if (getDepth() >= getOptions().getMaxDepth()) {
// reached the maximum depth so don't got any further.
return;
}
if (item.stat.isSymlink() && getOptions().isFollowLink()) {
PathData linkedItem =
new PathData(item.stat.getSymlink().toString(), getConf());
if (isAncestor(item, linkedItem)) {
getOptions().getErr().println(
"Infinite loop ignored: " + item.toString() + " -> "
+ linkedItem.toString());
return;
}
if (linkedItem.exists) {
item = linkedItem;
}
}
if (item.stat.isDirectory()) {
super.recursePath(item);
}
}
示例13: processPath
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Override
protected void processPath(PathData item) throws IOException {
if (getOptions().isDepthFirst()) {
// depth first so leave until post processing
return;
}
applyItem(item);
}
示例14: postProcessPath
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
@Override
protected void postProcessPath(PathData item) throws IOException {
if (!getOptions().isDepthFirst()) {
// not depth first so already processed
return;
}
applyItem(item);
}
示例15: applyItem
import org.apache.hadoop.fs.shell.PathData; //导入依赖的package包/类
private void applyItem(PathData item) throws IOException {
if (getDepth() >= getOptions().getMinDepth()) {
Result result = getRootExpression().apply(item, getDepth());
if (Result.STOP.equals(result)) {
addStop(item);
}
}
}