@Test public void parseMountInfoInvalidOutput() throws Exception { UnixMountInfo info = ShellUtils.parseMountInfo("invalid output"); assertFalse(info.getDeviceSpec().isPresent()); assertFalse(info.getMountPoint().isPresent()); assertFalse(info.getFsType().isPresent()); assertFalse(info.getOptions().getSize().isPresent()); }
public static UnixMountInfo parseMountInfo(String line) { UnixMountInfo.Builder builder = new UnixMountInfo.Builder(); Matcher matcher = Pattern.compile(".* (type \\w+ ).*").matcher(line); String lineWithoutType; if (matcher.matches()) { String match = matcher.group(1); builder.setFsType(match.replace("type", "").trim()); lineWithoutType = line.replace(match, ""); } else { lineWithoutType = line; } matcher = Pattern.compile("(.*) on (.*) \\((.*)\\)").matcher(lineWithoutType); if (!matcher.matches()) { LOG.warn("Unable to parse output of '{}': {}", MOUNT_COMMAND, line); return builder.build(); } builder.setDeviceSpec(matcher.group(1)); builder.setMountPoint(matcher.group(2)); builder.setOptions(parseUnixMountOptions(matcher.group(3))); return builder.build(); }
ShellUtils { public static UnixMountInfo parseMountInfo(String line) { UnixMountInfo.Builder builder = new UnixMountInfo.Builder(); Matcher matcher = Pattern.compile(".* (type \\w+ ).*").matcher(line); String lineWithoutType; if (matcher.matches()) { String match = matcher.group(1); builder.setFsType(match.replace("type", "").trim()); lineWithoutType = line.replace(match, ""); } else { lineWithoutType = line; } matcher = Pattern.compile("(.*) on (.*) \\((.*)\\)").matcher(lineWithoutType); if (!matcher.matches()) { LOG.warn("Unable to parse output of '{}': {}", MOUNT_COMMAND, line); return builder.build(); } builder.setDeviceSpec(matcher.group(1)); builder.setMountPoint(matcher.group(2)); builder.setOptions(parseUnixMountOptions(matcher.group(3))); return builder.build(); } }
ShellUtils { public static UnixMountInfo parseMountInfo(String line) { UnixMountInfo.Builder builder = new UnixMountInfo.Builder(); Matcher matcher = Pattern.compile(".* (type \\w+ ).*").matcher(line); String lineWithoutType; if (matcher.matches()) { String match = matcher.group(1); builder.setFsType(match.replace("type", "").trim()); lineWithoutType = line.replace(match, ""); } else { lineWithoutType = line; } matcher = Pattern.compile("(.*) on (.*) \\((.*)\\)").matcher(lineWithoutType); if (!matcher.matches()) { LOG.warn("Unable to parse output of '{}': {}", MOUNT_COMMAND, line); return builder.build(); } builder.setDeviceSpec(matcher.group(1)); builder.setMountPoint(matcher.group(2)); builder.setOptions(parseUnixMountOptions(matcher.group(3))); return builder.build(); } private  ShellUtils(); }
ShellUtils { public static UnixMountInfo parseMountInfo(String line) { UnixMountInfo.Builder builder = new UnixMountInfo.Builder(); Matcher matcher = Pattern.compile(".* (type \\w+ ).*").matcher(line); String lineWithoutType; if (matcher.matches()) { String match = matcher.group(1); builder.setFsType(match.replace("type", "").trim()); lineWithoutType = line.replace(match, ""); } else { lineWithoutType = line; } matcher = Pattern.compile("(.*) on (.*) \\((.*)\\)").matcher(lineWithoutType); if (!matcher.matches()) { LOG.warn("Unable to parse output of '{}': {}", MOUNT_COMMAND, line); return builder.build(); } builder.setDeviceSpec(matcher.group(1)); builder.setMountPoint(matcher.group(2)); builder.setOptions(parseUnixMountOptions(matcher.group(3))); return builder.build(); } private  ShellUtils(); static String[] getGroupsForUserCommand(final String user); static String[] getSetPermissionCommand(String perm, String filePath); static List<UnixMountInfo> getUnixMountInfo(); static UnixMountInfo parseMountInfo(String line); static boolean isMountingPoint(String path, String[] fsTypes); static boolean isAlluxioRunning(String className); static String execCommand(String... cmd); static CommandReturn execCommandWithOutput(String... cmd); static CommandReturn sshExecCommandWithOutput(String hostname, String... cmd); static CommandReturn scpCommandWithOutput(
          String hostname, String fromFile, String toFile, boolean isDir); static CommandReturn execCmdWithBackup(ShellCommand cmd, ShellCommand backupCmd); }
ShellUtils { public static UnixMountInfo parseMountInfo(String line) { UnixMountInfo.Builder builder = new UnixMountInfo.Builder(); Matcher matcher = Pattern.compile(".* (type \\w+ ).*").matcher(line); String lineWithoutType; if (matcher.matches()) { String match = matcher.group(1); builder.setFsType(match.replace("type", "").trim()); lineWithoutType = line.replace(match, ""); } else { lineWithoutType = line; } matcher = Pattern.compile("(.*) on (.*) \\((.*)\\)").matcher(lineWithoutType); if (!matcher.matches()) { LOG.warn("Unable to parse output of '{}': {}", MOUNT_COMMAND, line); return builder.build(); } builder.setDeviceSpec(matcher.group(1)); builder.setMountPoint(matcher.group(2)); builder.setOptions(parseUnixMountOptions(matcher.group(3))); return builder.build(); } private  ShellUtils(); static String[] getGroupsForUserCommand(final String user); static String[] getSetPermissionCommand(String perm, String filePath); static List<UnixMountInfo> getUnixMountInfo(); static UnixMountInfo parseMountInfo(String line); static boolean isMountingPoint(String path, String[] fsTypes); static boolean isAlluxioRunning(String className); static String execCommand(String... cmd); static CommandReturn execCommandWithOutput(String... cmd); static CommandReturn sshExecCommandWithOutput(String hostname, String... cmd); static CommandReturn scpCommandWithOutput(
          String hostname, String fromFile, String toFile, boolean isDir); static CommandReturn execCmdWithBackup(ShellCommand cmd, ShellCommand backupCmd); static final String COMMON_SSH_OPTS; static final String SET_PERMISSION_COMMAND; static final String MOUNT_COMMAND; static final String TOKEN_SEPARATOR_REGEX; }