Hadoop: avoid case insensitive on windows
This commit is contained in:
@@ -4,7 +4,6 @@ import com.google.common.base.Strings;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -108,9 +107,9 @@ public class FilerClient extends FilerGrpcClient {
|
|||||||
if ("/".equals(path)) {
|
if ("/".equals(path)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
File pathFile = new File(path);
|
String[] dirAndName = SeaweedUtil.toDirAndName(path);
|
||||||
String parent = pathFile.getParent().replace('\\','/');
|
String parent = dirAndName[0];
|
||||||
String name = pathFile.getName();
|
String name = dirAndName[1];
|
||||||
|
|
||||||
mkdirs(parent, mode, uid, gid, userName, groupNames);
|
mkdirs(parent, mode, uid, gid, userName, groupNames);
|
||||||
|
|
||||||
@@ -129,22 +128,22 @@ public class FilerClient extends FilerGrpcClient {
|
|||||||
|
|
||||||
public boolean mv(String oldPath, String newPath) {
|
public boolean mv(String oldPath, String newPath) {
|
||||||
|
|
||||||
File oldPathFile = new File(oldPath);
|
String[] oldDirAndName = SeaweedUtil.toDirAndName(oldPath);
|
||||||
String oldParent = oldPathFile.getParent().replace('\\','/');
|
String oldParent = oldDirAndName[0];
|
||||||
String oldName = oldPathFile.getName();
|
String oldName = oldDirAndName[1];
|
||||||
|
|
||||||
File newPathFile = new File(newPath);
|
String[] newDirAndName = SeaweedUtil.toDirAndName(newPath);
|
||||||
String newParent = newPathFile.getParent().replace('\\','/');
|
String newParent = newDirAndName[0];
|
||||||
String newName = newPathFile.getName();
|
String newName = newDirAndName[1];
|
||||||
|
|
||||||
return atomicRenameEntry(oldParent, oldName, newParent, newName);
|
return atomicRenameEntry(oldParent, oldName, newParent, newName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exists(String path){
|
public boolean exists(String path){
|
||||||
File pathFile = new File(path);
|
String[] dirAndName = SeaweedUtil.toDirAndName(path);
|
||||||
String parent = pathFile.getParent();
|
String parent = dirAndName[0];
|
||||||
String entryName = pathFile.getName();
|
String entryName = dirAndName[1];
|
||||||
if(parent == null) {
|
if(parent == null) {
|
||||||
parent = path;
|
parent = path;
|
||||||
entryName ="";
|
entryName ="";
|
||||||
@@ -155,9 +154,9 @@ public class FilerClient extends FilerGrpcClient {
|
|||||||
|
|
||||||
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
|
public boolean rm(String path, boolean isRecursive, boolean ignoreRecusiveError) {
|
||||||
|
|
||||||
File pathFile = new File(path);
|
String[] dirAndName = SeaweedUtil.toDirAndName(path);
|
||||||
String parent = pathFile.getParent().replace('\\','/');
|
String parent = dirAndName[0];
|
||||||
String name = pathFile.getName();
|
String name = dirAndName[1];
|
||||||
|
|
||||||
return deleteEntry(
|
return deleteEntry(
|
||||||
parent,
|
parent,
|
||||||
@@ -176,9 +175,9 @@ public class FilerClient extends FilerGrpcClient {
|
|||||||
|
|
||||||
public boolean touch(String path, long modifiedTimeSecond, int mode, int uid, int gid, String userName, String[] groupNames) {
|
public boolean touch(String path, long modifiedTimeSecond, int mode, int uid, int gid, String userName, String[] groupNames) {
|
||||||
|
|
||||||
File pathFile = new File(path);
|
String[] dirAndName = SeaweedUtil.toDirAndName(path);
|
||||||
String parent = pathFile.getParent().replace('\\','/');
|
String parent = dirAndName[0];
|
||||||
String name = pathFile.getName();
|
String name = dirAndName[1];
|
||||||
|
|
||||||
FilerProto.Entry entry = lookupEntry(parent, name);
|
FilerProto.Entry entry = lookupEntry(parent, name);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
|||||||
@@ -27,4 +27,17 @@ public class SeaweedUtil {
|
|||||||
public static CloseableHttpClient getClosableHttpClient() {
|
public static CloseableHttpClient getClosableHttpClient() {
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] toDirAndName(String fullpath) {
|
||||||
|
if (fullpath.endsWith("/")) {
|
||||||
|
fullpath = fullpath.substring(0, fullpath.length() - 1);
|
||||||
|
}
|
||||||
|
if (fullpath.length() == 0) {
|
||||||
|
return new String[]{"/", ""};
|
||||||
|
}
|
||||||
|
int sep = fullpath.lastIndexOf("/");
|
||||||
|
String parent = sep == 0 ? "/" : fullpath.substring(0, sep);
|
||||||
|
String name = fullpath.substring(sep + 1);
|
||||||
|
return new String[]{parent, name};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user