/** * Factory method for {@link FileSystemMasterClient}. * * @param conf master client configuration * @return a new {@link FileSystemMasterClient} instance */ public static FileSystemMasterClient create(MasterClientContext conf) { return new RetryHandlingFileSystemMasterClient(conf); } }
@Override public void rename(final AlluxioURI src, final AlluxioURI dst) throws AlluxioStatusException { rename(src, dst, RenamePOptions.getDefaultInstance()); }
@Override public synchronized List<SyncPointInfo> getSyncPathList() throws AlluxioStatusException { return retryRPC(() -> mClient.getSyncPathList(GetSyncPathListPRequest.getDefaultInstance()) .getSyncPathsList().stream().map(x -> alluxio.wire.SyncPointInfo.fromProto(x)) .collect(Collectors.toList()), "GetSyncPathList"); }
@Override protected Map<String, Command> loadCommands() { ClientContext ctx = ClientContext.create(mConfiguration); MasterClientContext masterConfig = MasterClientContext.newBuilder(ctx).build(); Context context = new Context( new RetryHandlingFileSystemMasterClient(masterConfig), new RetryHandlingBlockMasterClient(masterConfig), new RetryHandlingMetaMasterClient(masterConfig), System.out ); return CommandUtils.loadCommands(FileSystemAdminShell.class.getPackage().getName(), new Class[] {Context.class, AlluxioConfiguration.class}, new Object[] {context, mConfiguration}); } }
@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"); }
/** * @return clients for communicating with the cluster */ public synchronized Clients getClients() { Preconditions.checkState(mState == State.STARTED, "must be in the started state to create a meta master client, but state was %s", mState); MasterClientContext config = MasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())) .setMasterInquireClient(getMasterInquireClient()).build(); return new Clients(getFileSystemClient(), new RetryHandlingFileSystemMasterClient(config), new RetryHandlingMetaMasterClient(config), new RetryHandlingBlockMasterClient(config)); }
@Override public void setAcl(AlluxioURI path, SetAclAction action, List<AclEntry> entries, SetAclPOptions options) throws AlluxioStatusException { retryRPC(() -> mClient.setAcl( SetAclPRequest.newBuilder().setPath(path.getPath()).setAction(action) .addAllEntries(entries.stream().map(GrpcUtils::toProto).collect(Collectors.toList())) .setOptions(options).build()), "SetAcl"); }
@Override public List<AlluxioURI> checkConsistency(final AlluxioURI path, final CheckConsistencyPOptions options) throws AlluxioStatusException { return retryRPC(() -> { List<String> inconsistentPaths = mClient.checkConsistency(CheckConsistencyPRequest .newBuilder().setPath(path.getPath()).setOptions(options).build()) .getInconsistentPathsList(); List<AlluxioURI> inconsistentUris = new ArrayList<>(inconsistentPaths.size()); for (String inconsistentPath : inconsistentPaths) { inconsistentUris.add(new AlluxioURI(inconsistentPath)); } return inconsistentUris; }, "CheckConsistency"); }
@Override public synchronized void stopSync(final AlluxioURI path) throws AlluxioStatusException { retryRPC(() -> mClient.stopSync(StopSyncPRequest.newBuilder().setPath(path.getPath()).build()), "StopSync"); }
@Override public void scheduleAsyncPersist(final AlluxioURI path) throws AlluxioStatusException { retryRPC( () -> mClient.scheduleAsyncPersistence( ScheduleAsyncPersistencePRequest.newBuilder().setPath(path.getPath()).build()), "ScheduleAsyncPersist"); }
@Override public synchronized void startSync(final AlluxioURI path) throws AlluxioStatusException { retryRPC( () -> mClient.startSync(StartSyncPRequest.newBuilder().setPath(path.getPath()).build()), "StartSync"); }
@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"); }
@Override public void setAttribute(final AlluxioURI path, final SetAttributePOptions options) throws AlluxioStatusException { retryRPC(() -> mClient.setAttribute(SetAttributePRequest.newBuilder() .setPath(path.getPath()).setOptions(options).build()), "SetAttribute"); }
@Override public void createFile(final AlluxioURI path, final CreateFilePOptions options) throws AlluxioStatusException { retryRPC(() -> mClient.createFile(CreateFilePRequest.newBuilder().setPath(path.getPath()) .setOptions(options).build()), "CreateFile"); }
@Override public void free(final AlluxioURI path, final FreePOptions options) throws AlluxioStatusException { retryRPC(() -> mClient.free(FreePRequest.newBuilder().setPath(path.getPath()) .setOptions(options).build()), "Free"); }
@Override public void createDirectory(final AlluxioURI path, final CreateDirectoryPOptions options) throws AlluxioStatusException { retryRPC( () -> mClient.createDirectory(CreateDirectoryPRequest.newBuilder() .setPath(path.getPath()).setOptions(options).build()), "CreateDirectory"); }
@Override public void completeFile(final AlluxioURI path, final CompleteFilePOptions options) throws AlluxioStatusException { retryRPC(() -> mClient.completeFile(CompleteFilePRequest.newBuilder() .setPath(path.getPath()).setOptions(options).build()), "CompleteFile"); }
@Override public void delete(final AlluxioURI path, final DeletePOptions options) throws AlluxioStatusException { retryRPC(() -> mClient.remove(DeletePRequest.newBuilder().setPath(path.getPath()) .setOptions(options).build()), "Delete"); }
@Override public void updateUfsMode(final AlluxioURI ufsUri, final UpdateUfsModePOptions options) throws AlluxioStatusException { retryRPC( () -> mClient.updateUfsMode(UpdateUfsModePRequest.newBuilder() .setUfsPath(ufsUri.getRootPath()).setOptions(options).build()), "UpdateUfsMode"); } }
@Override public void mount(final AlluxioURI alluxioPath, final AlluxioURI ufsPath, final MountPOptions options) throws AlluxioStatusException { retryRPC( () -> mClient.mount(MountPRequest.newBuilder().setAlluxioPath(alluxioPath.toString()) .setUfsPath(ufsPath.toString()).setOptions(options).build()), "Mount"); }