/** * Creates a file system context with a subject. * * @param subject the parent subject, set to null if not present */ private FileSystemContext(Subject subject, AlluxioConfiguration alluxioConf) { this(ClientContext.create(subject, alluxioConf)); }
/** * Prints Alluxio configuration. * * @param args the arguments to specify the unit (optional) and configuration key (optional) */ public static void main(String[] args) { System.exit(getConf( ClientContext.create(new InstancedConfiguration(ConfigurationUtils.defaults())), args)); }
/** * Constructs an instance of {@link WorkerUfsManager}. */ public WorkerUfsManager() { mMasterClient = mCloser.register(new FileSystemMasterClient(MasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())).build())); }
/** * Constructs an instance of {@link JobUfsManager}. */ public JobUfsManager() { mMasterClient = mCloser.register(new FileSystemMasterClient(MasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())).build())); }
/** * Creates a new block master client pool. */ public BlockMasterClientPool() { super(ServerConfiguration.getInt(PropertyKey.WORKER_BLOCK_MASTER_CLIENT_POOL_SIZE)); mClientList = new ConcurrentLinkedQueue<>(); mMasterContext = MasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())).build(); }
/** * Initializes the context. Only called in the factory methods and reset. */ private synchronized void init(AlluxioConfiguration alluxioConf) { mJobMasterInquireClient = MasterInquireClient.Factory.createForJobMaster(alluxioConf); mJobMasterClientPool = new JobMasterClientPool(JobMasterClientContext .newBuilder(ClientContext.create(alluxioConf)).build()); }
/** * @return a meta master client */ public synchronized MetaMasterClient getMetaMasterClient() { Preconditions.checkState(mState == State.STARTED, "must be in the started state to create a meta master client, but state was %s", mState); return new RetryHandlingMetaMasterClient(MasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())) .setMasterInquireClient(getMasterInquireClient()) .build()); }
/** * Creates a new instance of {@link JobWorker}. * * @param ufsManager the ufs manager */ JobWorker(UfsManager ufsManager) { super( Executors.newFixedThreadPool(1, ThreadFactoryUtils.build("job-worker-heartbeat-%d", true))); mUfsManager = ufsManager; mJobMasterClient = JobMasterClient.Factory.create(JobMasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())).build()); mTaskExecutorManager = new TaskExecutorManager(); }
@Before public void before() { mMockJobMasterContext = mock(JobMasterContext.class); mMockFileSystemContext = PowerMockito.mock(FileSystemContext.class); when(mMockFileSystemContext.getClientContext()) .thenReturn(ClientContext.create(ServerConfiguration.global())); mMockBlockStore = PowerMockito.mock(AlluxioBlockStore.class); mMockFileSystem = mock(FileSystem.class); mMockUfsManager = mock(UfsManager.class); }
@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}); } }
/** * Sets up the file system and the context before a test runs. */ @Before public void before() { mClientContext = ClientContext.create(mConf); mFileContext = PowerMockito.mock(FileSystemContext.class); mFileSystem = new DummyAlluxioFileSystem(mFileContext); mFileSystemMasterClient = PowerMockito.mock(FileSystemMasterClient.class); when(mFileContext.acquireMasterClient()).thenReturn(mFileSystemMasterClient); when(mFileContext.getClientContext()).thenReturn(mClientContext); when(mFileContext.getConf()).thenReturn(mConf); }
@Before public void before() throws Exception { AlluxioConfiguration conf = ConfigurationTestUtils.defaults(); mMockFileSystem = Mockito.mock(FileSystem.class); mMockFileSystemContext = PowerMockito.mock(FileSystemContext.class); when(mMockFileSystemContext.getClientContext()) .thenReturn(ClientContext.create(conf)); when(mMockFileSystemContext.getConf()) .thenReturn(conf); mMockInStream = new MockFileInStream(mMockFileSystemContext, TEST_SOURCE_CONTENTS, conf); when(mMockFileSystem.openFile(new AlluxioURI(TEST_SOURCE))).thenReturn(mMockInStream); mMockOutStream = new MockFileOutStream(mMockFileSystemContext); when(mMockFileSystem.createFile(eq(new AlluxioURI(TEST_DESTINATION)), any(CreateFilePOptions.class))).thenReturn(mMockOutStream); mMockUfsManager = Mockito.mock(UfsManager.class); }
protected BaseTestClient() { super(ClientContext.create(new InstancedConfiguration(ConfigurationUtils.defaults())), null, () -> new CountingRetry(1)); }
/** * Constructs a default block worker. * * @param ufsManager ufs manager */ DefaultBlockWorker(UfsManager ufsManager) { this(new BlockMasterClientPool(), new FileSystemMasterClient(MasterClientContext .newBuilder(ClientContext.create(ServerConfiguration.global())).build()), new Sessions(), new TieredBlockStore(), ufsManager); }
@Before public void before() throws Exception { mClientContext = ClientContext.create(mConf); mContext = PowerMockito.mock(FileSystemContext.class); mAddress = Mockito.mock(WorkerNetAddress.class); mClient = mock(BlockWorkerClient.class); mRequestObserver = mock(ClientCallStreamObserver.class); PowerMockito.when(mContext.getClientContext()).thenReturn(mClientContext); PowerMockito.when(mContext.getConf()).thenReturn(mConf); PowerMockito.when(mContext.acquireBlockWorkerClient(mAddress)).thenReturn(mClient); PowerMockito.doNothing().when(mContext).releaseBlockWorkerClient(mAddress, mClient); PowerMockito.when(mClient.writeBlock(any(StreamObserver.class))).thenReturn(mRequestObserver); PowerMockito.when(mRequestObserver.isReady()).thenReturn(true); }
@Before public void before() throws Exception { mContext = PowerMockito.mock(FileSystemContext.class); mAddress = mock(WorkerNetAddress.class); mClient = mock(BlockWorkerClient.class); mRequestObserver = mock(ClientCallStreamObserver.class); PowerMockito.when(mContext.acquireBlockWorkerClient(mAddress)).thenReturn(mClient); PowerMockito.when(mContext.getClientContext()) .thenReturn(ClientContext.create(mConf)); PowerMockito.when(mContext.getConf()).thenReturn(mConf); PowerMockito.doNothing().when(mContext).releaseBlockWorkerClient(mAddress, mClient); PowerMockito.when(mClient.writeBlock(any(StreamObserver.class))).thenReturn(mRequestObserver); PowerMockito.when(mRequestObserver.isReady()).thenReturn(true); }
@Before public void before() throws Exception { mMockJobMasterContext = Mockito.mock(JobMasterContext.class); mMockFileSystem = PowerMockito.mock(FileSystem.class); mMockBlockStore = PowerMockito.mock(AlluxioBlockStore.class); mMockFsContext = PowerMockito.mock(FileSystemContext.class); PowerMockito.mockStatic(AlluxioBlockStore.class); PowerMockito.when(AlluxioBlockStore.create(Mockito.any(FileSystemContext.class))) .thenReturn(mMockBlockStore); Mockito.when(mMockBlockStore.getAllWorkers()).thenReturn(BLOCK_WORKERS); PowerMockito.when(mMockFsContext.getClientContext()) .thenReturn(ClientContext.create(ServerConfiguration.global())); PowerMockito.when(mMockFsContext.getConf()) .thenReturn(ServerConfiguration.global()); }
/** * @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)); }
@Test public void createShortCircuitDisabled() throws Exception { try (Closeable c = new ConfigurationRule(PropertyKey.USER_SHORT_CIRCUIT_ENABLED, "false", mConf) .toResource()) { WorkerNetAddress dataSource = new WorkerNetAddress(); when(mMockContext.getClientContext()).thenReturn(ClientContext.create(mConf)); BlockInStream.BlockInStreamSource dataSourceType = BlockInStream.BlockInStreamSource.LOCAL; BlockInStream stream = BlockInStream.create(mMockContext, mInfo, dataSource, dataSourceType, mOptions); Assert.assertFalse(stream.isShortCircuit()); } }
@Before public void before() throws Exception { mContext = PowerMockito.mock(FileSystemContext.class); when(mContext.getClientContext()) .thenReturn(ClientContext.create(ConfigurationTestUtils.defaults())); when(mContext.getConf()).thenReturn(ConfigurationTestUtils.defaults()); mAddress = mock(WorkerNetAddress.class); ReadRequest readRequest = ReadRequest.newBuilder().setBlockId(BLOCK_ID).setChunkSize(CHUNK_SIZE).build(); mFactory = new GrpcDataReader.Factory(mContext, mAddress, readRequest); mClient = mock(BlockWorkerClient.class); mRequestObserver = mock(ClientCallStreamObserver.class); when(mContext.acquireBlockWorkerClient(mAddress)).thenReturn(mClient); PowerMockito.doNothing().when(mContext).releaseBlockWorkerClient(mAddress, mClient); when(mClient.readBlock(any(StreamObserver.class))).thenReturn(mRequestObserver); when(mRequestObserver.isReady()).thenReturn(true); }