Search in sources :

Example 1 with UfsClient

use of alluxio.underfs.UfsManager.UfsClient in project alluxio by Alluxio.

the class UfsFileWriteHandlerTest method before.

@Before
public void before() throws Exception {
    mFile = mTestFolder.newFile();
    mOutputStream = new FileOutputStream(mFile);
    UnderFileSystem mockUfs = Mockito.mock(UnderFileSystem.class);
    UfsManager ufsManager = Mockito.mock(UfsManager.class);
    UfsClient ufsClient = new UfsClient(() -> mockUfs, AlluxioURI.EMPTY_URI);
    Mockito.when(ufsManager.get(TEST_MOUNT_ID)).thenReturn(ufsClient);
    Mockito.when(mockUfs.createNonexistingFile(Mockito.anyString(), Mockito.any(CreateOptions.class))).thenReturn(mOutputStream).thenReturn(new FileOutputStream(mFile, true));
    mResponseObserver = Mockito.mock(StreamObserver.class);
    mWriteHandler = new UfsFileWriteHandler(ufsManager, mResponseObserver, mUserInfo);
    setupResponseTrigger();
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) UfsManager(alluxio.underfs.UfsManager) FileOutputStream(java.io.FileOutputStream) UfsClient(alluxio.underfs.UfsManager.UfsClient) UnderFileSystem(alluxio.underfs.UnderFileSystem) Before(org.junit.Before)

Example 2 with UfsClient

use of alluxio.underfs.UfsManager.UfsClient in project alluxio by Alluxio.

the class MountTableTest method before.

@Before
public void before() throws Exception {
    UfsManager ufsManager = mock(UfsManager.class);
    UfsClient ufsClient = new UfsManager.UfsClient(() -> mTestUfs, AlluxioURI.EMPTY_URI);
    when(ufsManager.get(anyLong())).thenReturn(ufsClient);
    mMountTable = new MountTable(ufsManager, new MountInfo(new AlluxioURI(MountTable.ROOT), new AlluxioURI(ROOT_UFS), IdUtils.ROOT_MOUNT_ID, MountContext.defaults().getOptions().build()));
}
Also used : UfsManager(alluxio.underfs.UfsManager) UfsClient(alluxio.underfs.UfsManager.UfsClient) MountInfo(alluxio.master.file.meta.options.MountInfo) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 3 with UfsClient

use of alluxio.underfs.UfsManager.UfsClient in project alluxio by Alluxio.

the class UnderFileSystemBlockReaderTest method before.

@Before
public void before() throws Exception {
    String ufsFolder = ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
    String testFilePath = File.createTempFile("temp", null, new File(ufsFolder)).getAbsolutePath();
    byte[] buffer = BufferUtils.getIncreasingByteArray((int) TEST_BLOCK_SIZE * 2);
    BufferUtils.writeBufferToFile(testFilePath, buffer);
    mAlluxioBlockStore = new TieredBlockStore();
    mUfsManager = mock(UfsManager.class);
    mUfsInstreamCache = new UfsInputStreamCache();
    UfsClient ufsClient = new UfsClient(() -> UnderFileSystem.Factory.create(testFilePath, UnderFileSystemConfiguration.defaults(ServerConfiguration.global())), new AlluxioURI(testFilePath));
    when(mUfsManager.get(anyLong())).thenReturn(ufsClient);
    mOpenUfsBlockOptions = Protocol.OpenUfsBlockOptions.newBuilder().setMaxUfsReadConcurrency(10).setBlockSize(TEST_BLOCK_SIZE).setOffsetInFile(TEST_BLOCK_SIZE).setUfsPath(testFilePath).build();
    mUnderFileSystemBlockMeta = new UnderFileSystemBlockMeta(SESSION_ID, BLOCK_ID, mOpenUfsBlockOptions);
}
Also used : UnderFileSystemBlockMeta(alluxio.worker.block.meta.UnderFileSystemBlockMeta) UfsManager(alluxio.underfs.UfsManager) UfsClient(alluxio.underfs.UfsManager.UfsClient) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Aggregations

UfsManager (alluxio.underfs.UfsManager)3 UfsClient (alluxio.underfs.UfsManager.UfsClient)3 Before (org.junit.Before)3 AlluxioURI (alluxio.AlluxioURI)2 MountInfo (alluxio.master.file.meta.options.MountInfo)1 UnderFileSystem (alluxio.underfs.UnderFileSystem)1 UnderFileSystemBlockMeta (alluxio.worker.block.meta.UnderFileSystemBlockMeta)1 StreamObserver (io.grpc.stub.StreamObserver)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1