private long getNextBlockId() throws IOException { try (CloseableResource<FileSystemMasterClient> masterClient = mContext .acquireMasterClientResource()) { return masterClient.get().getNewBlockIdForFile(mUri); } }
/** * Schedules the async persistence of the current file. */ protected void scheduleAsyncPersist() throws IOException { try (CloseableResource<FileSystemMasterClient> masterClient = mContext .acquireMasterClientResource()) { masterClient.get().scheduleAsyncPersist(mUri); } }
@Override public int run(CommandLine cl) { try (CloseableResource<FileSystemMasterClient> client = mFsContext.acquireMasterClientResource()) { try { InetSocketAddress address = client.get().getAddress(); System.out.println(address.getHostName()); List<InetSocketAddress> addresses = Arrays.asList(address); MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () -> new ExponentialBackoffRetry(50, 100, 2), mFsContext.getConf() ); try { inquireClient.getPrimaryRpcAddress(); } catch (UnavailableException e) { System.err.println("The leader is not currently serving requests."); } } catch (UnavailableException e) { System.err.println("Failed to get the leader master."); } } return 0; }
/** * Checks if the master client service is available. * Throws an exception if fails to determine that the master client service is running. * * @param alluxioConf Alluxio configuration */ public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException { try (CloseableResource<FileSystemMasterClient> client = FileSystemContext.create(ClientContext.create(alluxioConf)) .acquireMasterClientResource()) { InetSocketAddress address = client.get().getAddress(); List<InetSocketAddress> addresses = Arrays.asList(address); MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () -> new ExponentialBackoffRetry(50, 100, 2), alluxioConf); inquireClient.getPrimaryRpcAddress(); } catch (UnavailableException e) { throw new IOException("Cannot connect to Alluxio leader master."); } }
.acquireMasterClientResource()) { masterClient.get().completeFile(mUri, optionsBuilder.build());
PowerMockito.when(AlluxioBlockStore.create(mFileSystemContext)).thenReturn(mBlockStore); when(mFileSystemContext.acquireMasterClientResource()) .thenReturn(new DummyCloseableResource<>(mFileSystemMasterClient)); when(mFileSystemMasterClient.getStatus(any(AlluxioURI.class), any(GetStatusPOptions.class)))