use of alluxio.stress.worker.UfsIOParameters in project alluxio by Alluxio.
the class ManagerProcessContext method speedTest.
/**
* speed test for ufs.
*
* @param request ufs speed test request
* @return result of the test
*/
public SpeedTestResponse.Payload speedTest(SpeedTestRequest request) {
SpeedTestRequest.Payload req = request.getPayload();
String dataSize = req.getDataSize();
String mountPoint = req.getMountPoint();
String relativePath = req.getPath();
int clusterParallelism = req.getClusterParallelism();
int nodeParallelism = req.getNodeParallelism();
List<String> errors = new ArrayList<>();
MountPointInfo mountInfo = null;
try {
mountInfo = getFileSystem().getMountTable().get(mountPoint);
} catch (IOException | AlluxioException e) {
errors.add("Failed to retrieve mount point information");
errors.add(ValidationUtils.getErrorInfo(e));
}
if (mountInfo == null) {
errors.add("Failed to retrieve mount point information for " + mountPoint);
return SpeedTestResponse.Payload.newBuilder().addAllError(errors).build();
}
if (clusterParallelism > mAlluxioCluster.size()) {
errors.add("Can not set cluster parallelism to be " + clusterParallelism + " which is greater than cluster size " + mAlluxioCluster.size());
return SpeedTestResponse.Payload.newBuilder().addAllError(errors).build();
}
if (relativePath.isEmpty()) {
relativePath = "/";
}
String ufsPath = PathUtils.normalizePath(PathUtils.concatPath(mountInfo.getUfsUri(), relativePath), AlluxioURI.SEPARATOR);
List<String> argList = new ArrayList<>();
String[] args = new String[] { "--io-size", dataSize, "--threads", String.valueOf(nodeParallelism), "--path", ufsPath, "--cluster-limit", String.valueOf(clusterParallelism), "--cluster", "--use-mount-conf" };
Collections.addAll(argList, args);
UfsIOBench bench = getIOBench();
try {
String output = bench.run(argList.toArray(new String[0]));
IOTaskSummary result = (IOTaskSummary) JsonSerializable.fromJson(output);
SpeedTestResponse.Payload.Builder builder = SpeedTestResponse.Payload.newBuilder();
if (result.getErrors() != null) {
builder.addAllError(result.getErrors());
}
if (result.getParameters() != null) {
UfsIOParameters param = result.getParameters();
builder.setParameters(SpeedTestParameter.newBuilder().setDataSize(param.mDataSize).setPath(param.mPath).setThreads(param.mThreads).putAllProperties(param.mConf).build());
}
builder.setReadSpeedStat(convertToProto(result.getReadSpeedStat())).setWriteSpeedStat(convertToProto(result.getWriteSpeedStat()));
return builder.build();
} catch (Exception e) {
errors.add("UfsIOBench failed due to " + ValidationUtils.getErrorInfo(e));
}
return SpeedTestResponse.Payload.newBuilder().addAllError(errors).build();
}
Aggregations