@Override public void getMountTable(GetMountTablePRequest request, StreamObserver<GetMountTablePResponse> responseObserver) { RpcUtils.call(LOG, (RpcUtils.RpcCallableThrowsIOException<GetMountTablePResponse>) () -> { Map<String, MountPointInfo> mountTableWire = mFileSystemMaster.getMountTable(); Map<String, alluxio.grpc.MountPointInfo> mountTableProto = new HashMap<>(); for (Map.Entry<String, MountPointInfo> entry : mountTableWire.entrySet()) { mountTableProto.put(entry.getKey(), GrpcUtils.toProto(entry.getValue())); } return GetMountTablePResponse.newBuilder().putAllMountPoints(mountTableProto).build(); }, "GetMountTable", "", responseObserver); }
@Override public Map<String, alluxio.wire.MountPointInfo> getMountTable() throws AlluxioStatusException { return retryRPC(() -> { Map<String, alluxio.wire.MountPointInfo> mountTableWire = new HashMap<>(); for (Map.Entry<String, alluxio.grpc.MountPointInfo> entry : mClient .getMountTable(GetMountTablePRequest.newBuilder().build()).getMountPointsMap() .entrySet()) { mountTableWire.put(entry.getKey(), GrpcUtils.fromProto(entry.getValue())); } return mountTableWire; }, "GetMountTable"); }
private void apply(AddMountPointEntry entry) { MountInfo mountInfo = new MountInfo(new AlluxioURI(entry.getAlluxioPath()), new AlluxioURI(entry.getUfsPath()), entry.getMountId(), GrpcUtils.fromMountEntry(entry)); mMountTable.put(entry.getAlluxioPath(), mountInfo); }
@Override public boolean exists(AlluxioURI path, ExistsPOptions options) throws InvalidPathException, IOException, AlluxioException { checkUri(path); FileSystemMasterClient masterClient = mFsContext.acquireMasterClient(); try { // TODO(calvin): Make this more efficient masterClient.getStatus(path, GrpcUtils.toGetStatusOptions(options)); return true; } catch (NotFoundException e) { return false; } catch (InvalidArgumentException e) { // The server will throw this when a prefix of the path is a file. // TODO(andrew): Change the server so that a prefix being a file means the path does not exist return false; } catch (UnavailableException e) { throw e; } catch (AlluxioStatusException e) { throw e.toAlluxioException(); } finally { mFsContext.releaseMasterClient(masterClient); } }
/** * @param fsCommand wire type * @return proto representation of given wire type */ public static alluxio.grpc.FileSystemCommand toProto(FileSystemCommand fsCommand) { return alluxio.grpc.FileSystemCommand.newBuilder() .setCommandType(toProto(fsCommand.getCommandType())) .setCommandOptions(FileSystemCommandOptions.newBuilder() .setPersistOptions(PersistCommandOptions.newBuilder().addAllPersistFiles( fsCommand.getCommandOptions().getPersistOptions().getFilesToPersist().stream() .map(GrpcUtils::toProto).collect(Collectors.toList())))) .build(); }
@Override public List<WorkerInfo> getWorkerReport(final GetWorkerReportOptions options) throws IOException { return retryRPC(() -> { List<WorkerInfo> result = new ArrayList<>(); for (alluxio.grpc.WorkerInfo workerInfo : mClient.getWorkerReport(options.toProto()) .getWorkerInfosList()) { result.add(GrpcUtils.fromProto(workerInfo)); } return result; }); }
/** * Converts wire type to proto type. * * @param blockInfo the wire type to convert * @return the converted proto type */ public static alluxio.grpc.BlockInfo toProto(BlockInfo blockInfo) { List<alluxio.grpc.BlockLocation> locations = new ArrayList<>(); for (BlockLocation location : blockInfo.getLocations()) { locations.add(toProto(location)); } return alluxio.grpc.BlockInfo.newBuilder().setBlockId(blockInfo.getBlockId()) .setLength(blockInfo.getLength()).addAllLocations(locations).build(); }
@Override public List<WorkerInfo> getWorkerInfoList() throws IOException { return retryRPC(() -> { List<WorkerInfo> result = new ArrayList<>(); for (alluxio.grpc.WorkerInfo workerInfo : mClient .getWorkerInfoList(GetWorkerInfoListPOptions.getDefaultInstance()) .getWorkerInfosList()) { result.add(GrpcUtils.fromProto(workerInfo)); } return result; }); }
/** * Gets all configuration properties filtered by the specified scope. * * @param conf the configuration to use * @param scope the scope to filter by * @return the properties */ public static List<ConfigProperty> getConfiguration(AlluxioConfiguration conf, Scope scope) { ConfigurationValueOptions useRawDisplayValue = ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(true); List<ConfigProperty> configs = new ArrayList<>(); List<PropertyKey> selectedKeys = conf.keySet().stream() .filter(key -> GrpcUtils.contains(key.getScope(), scope)) .filter(key -> key.isValid(key.getName())) .collect(toList()); for (PropertyKey key : selectedKeys) { ConfigProperty.Builder configProp = ConfigProperty.newBuilder().setName(key.getName()) .setSource(conf.getSource(key).toString()); if (conf.isSet(key)) { configProp.setValue(conf.get(key, useRawDisplayValue)); } configs.add(configProp.build()); } return configs; }
public Long call() { return mClient.registerJobWorker(RegisterJobWorkerPRequest.newBuilder() .setWorkerNetAddress(GrpcUtils.toProto(address)).build()).getId(); } });
@Override public List<URIStatus> listStatus(final AlluxioURI path, final ListStatusPOptions options) throws AlluxioStatusException { return retryRPC(() -> { List<URIStatus> result = new ArrayList<>(); for (alluxio.grpc.FileInfo fileInfo : mClient.listStatus(ListStatusPRequest.newBuilder() .setPath(path.getPath()).setOptions(options).build()) .getFileInfosList()) { result.add(new URIStatus(GrpcUtils.fromProto(fileInfo))); } return result; }, "ListStatus"); }
if (!GrpcUtils.contains(key.getScope(), Scope.CLIENT)) {
/** * @param defaultAcl the default access control list to convert * @return the proto representation of default acl object */ public static PAcl toProto(DefaultAccessControlList defaultAcl) { PAcl.Builder pAcl = PAcl.newBuilder(toProto((AccessControlList) defaultAcl)); pAcl.setIsDefault(true); pAcl.setIsDefaultEmpty(defaultAcl.isEmpty()); return pAcl.build(); }
/** * @param fileId the id of the file for which to get the {@link FileInfo} * @return the file info for the given file id */ public FileInfo getFileInfo(final long fileId) throws IOException { return retryRPC(() -> GrpcUtils.fromProto(mClient .getFileInfo(GetFileInfoPRequest.newBuilder().setFileId(fileId).build()).getFileInfo())); }