Search in sources :

Example 21 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class GrpcDataWriterTest method closedBlockWorkerClientTest.

@Test
public void closedBlockWorkerClientTest() throws IOException {
    CloseableResource<BlockWorkerClient> resource = Mockito.mock(CloseableResource.class);
    when(resource.get()).thenReturn(mClient);
    FileSystemContext context = PowerMockito.mock(FileSystemContext.class);
    when(context.acquireBlockWorkerClient(any(WorkerNetAddress.class))).thenReturn(resource);
    when(context.getClusterConf()).thenReturn(mConf);
    mConf.set(PropertyKey.USER_STREAMING_WRITER_CLOSE_TIMEOUT, "1");
    GrpcDataWriter writer = GrpcDataWriter.create(context, mAddress, BLOCK_ID, 0, RequestType.ALLUXIO_BLOCK, OutStreamOptions.defaults(mClientContext).setWriteTier(0));
    verify(resource, times(0)).close();
    verifyWriteRequests(mClient, 0, 0);
    writer.close();
    verify(resource, times(1)).close();
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) FileSystemContext(alluxio.client.file.FileSystemContext) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 22 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class ListCommandIntegrationTest method setPathConfigurations.

/**
 * Sets path level configurations through meta master client, and update client configurations
 * from meta master afterwards.
 *
 * @return the configuration after updating from meta master
 */
private InstancedConfiguration setPathConfigurations() throws Exception {
    FileSystemContext metaCtx = FileSystemContext.create(ServerConfiguration.global());
    MetaMasterConfigClient client = new RetryHandlingMetaMasterConfigClient(MasterClientContext.newBuilder(metaCtx.getClientContext()).build());
    client.setPathConfiguration(new AlluxioURI(DIR1), PROPERTY_KEY1, PROPERTY_VALUE1);
    client.setPathConfiguration(new AlluxioURI(DIR2), PROPERTY_KEY2, PROPERTY_VALUE2);
    InetSocketAddress address = sLocalAlluxioClusterResource.get().getLocalAlluxioMaster().getAddress();
    FileSystemContext fsCtx = FileSystemContext.create(ServerConfiguration.global());
    fsCtx.getClientContext().loadConf(address, true, true);
    return (InstancedConfiguration) fsCtx.getClusterConf();
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) RetryHandlingMetaMasterConfigClient(alluxio.client.meta.RetryHandlingMetaMasterConfigClient) MetaMasterConfigClient(alluxio.client.meta.MetaMasterConfigClient) InetSocketAddress(java.net.InetSocketAddress) FileSystemContext(alluxio.client.file.FileSystemContext) RetryHandlingMetaMasterConfigClient(alluxio.client.meta.RetryHandlingMetaMasterConfigClient) AlluxioURI(alluxio.AlluxioURI)

Example 23 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class ShowCommandIntegrationTest method setPathConfigurations.

/**
 * Sets path level configurations through meta master client, and update client configurations
 * from meta master afterwards.
 *
 * @return the configuration after updating from meta master
 */
private InstancedConfiguration setPathConfigurations() throws Exception {
    FileSystemContext metaCtx = FileSystemContext.create(ServerConfiguration.global());
    MetaMasterConfigClient client = new RetryHandlingMetaMasterConfigClient(MasterClientContext.newBuilder(metaCtx.getClientContext()).build());
    client.setPathConfiguration(new AlluxioURI(DIR1), PROPERTY_KEY11, PROPERTY_VALUE11);
    client.setPathConfiguration(new AlluxioURI(DIR1), PROPERTY_KEY12, PROPERTY_VALUE12);
    client.setPathConfiguration(new AlluxioURI(DIR2), PROPERTY_KEY2, PROPERTY_VALUE2);
    InetSocketAddress address = sLocalAlluxioClusterResource.get().getLocalAlluxioMaster().getAddress();
    FileSystemContext fsCtx = FileSystemContext.create(ServerConfiguration.global());
    fsCtx.getClientContext().loadConf(address, true, true);
    return (InstancedConfiguration) fsCtx.getClusterConf();
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) RetryHandlingMetaMasterConfigClient(alluxio.client.meta.RetryHandlingMetaMasterConfigClient) MetaMasterConfigClient(alluxio.client.meta.MetaMasterConfigClient) InetSocketAddress(java.net.InetSocketAddress) FileSystemContext(alluxio.client.file.FileSystemContext) RetryHandlingMetaMasterConfigClient(alluxio.client.meta.RetryHandlingMetaMasterConfigClient) AlluxioURI(alluxio.AlluxioURI)

Example 24 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class CacheRequestManagerTest method before.

/**
 * Sets up all dependencies before a test runs.
 */
@Before
public void before() throws IOException {
    BlockMasterClient blockMasterClient = mock(BlockMasterClient.class);
    BlockMasterClientPool blockMasterClientPool = spy(new BlockMasterClientPool());
    when(blockMasterClientPool.createNewResource()).thenReturn(blockMasterClient);
    TieredBlockStore blockStore = new TieredBlockStore();
    FileSystemMasterClient fileSystemMasterClient = mock(FileSystemMasterClient.class);
    Sessions sessions = mock(Sessions.class);
    // Connect to the real UFS for testing
    UfsManager ufsManager = mock(UfsManager.class);
    mRootUfs = ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS);
    UfsManager.UfsClient ufsClient = new UfsManager.UfsClient(() -> UnderFileSystem.Factory.create(mRootUfs, UnderFileSystemConfiguration.defaults(ServerConfiguration.global())), new AlluxioURI(mRootUfs));
    when(ufsManager.get(anyLong())).thenReturn(ufsClient);
    mBlockWorker = spy(new DefaultBlockWorker(blockMasterClientPool, fileSystemMasterClient, sessions, blockStore, ufsManager));
    FileSystemContext context = mock(FileSystemContext.class);
    mCacheRequestManager = spy(new CacheRequestManager(GrpcExecutors.CACHE_MANAGER_EXECUTOR, mBlockWorker, context));
    // Write an actual file to UFS
    String testFilePath = File.createTempFile("temp", null, new File(mRootUfs)).getAbsolutePath();
    byte[] buffer = BufferUtils.getIncreasingByteArray(CHUNK_SIZE);
    BufferUtils.writeBufferToFile(testFilePath, buffer);
    // create options
    BlockInfo info = new BlockInfo().setBlockId(BLOCK_ID).setLength(CHUNK_SIZE);
    URIStatus dummyStatus = new URIStatus(new FileInfo().setPersisted(true).setUfsPath(testFilePath).setBlockIds(Collections.singletonList(BLOCK_ID)).setLength(CHUNK_SIZE).setBlockSizeBytes(CHUNK_SIZE).setFileBlockInfos(Collections.singletonList(new FileBlockInfo().setBlockInfo(info))));
    OpenFilePOptions readOptions = FileSystemOptions.openFileDefaults(mConf);
    InStreamOptions options = new InStreamOptions(dummyStatus, readOptions, mConf);
    mOpenUfsBlockOptions = options.getOpenUfsBlockOptions(BLOCK_ID);
}
Also used : UfsManager(alluxio.underfs.UfsManager) Sessions(alluxio.Sessions) URIStatus(alluxio.client.file.URIStatus) FileBlockInfo(alluxio.wire.FileBlockInfo) InStreamOptions(alluxio.client.file.options.InStreamOptions) FileSystemMasterClient(alluxio.worker.file.FileSystemMasterClient) FileInfo(alluxio.wire.FileInfo) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) FileSystemContext(alluxio.client.file.FileSystemContext) OpenFilePOptions(alluxio.grpc.OpenFilePOptions) File(java.io.File) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 25 with FileSystemContext

use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.

the class AlluxioFuse method main.

/**
 * Running this class will mount the file system according to the options passed to this function
 * {@link #parseOptions(String[], AlluxioConfiguration)}. The user-space fuse application will
 * stay on the foreground and keep the file system mounted. The user can unmount the file system
 * by gracefully killing (SIGINT) the process.
 *
 * @param args arguments to run the command line
 */
public static void main(String[] args) {
    LOG.info("Alluxio version: {}-{}", RuntimeConstants.VERSION, ProjectConstants.REVISION);
    AlluxioConfiguration conf = InstancedConfiguration.defaults();
    FileSystemContext fsContext = FileSystemContext.create(conf);
    try {
        InetSocketAddress confMasterAddress = fsContext.getMasterClientContext().getConfMasterInquireClient().getPrimaryRpcAddress();
        RetryUtils.retry("load cluster default configuration with master " + confMasterAddress, () -> fsContext.getClientContext().loadConfIfNotLoaded(confMasterAddress), RetryUtils.defaultClientRetry(conf.getDuration(PropertyKey.USER_RPC_RETRY_MAX_DURATION), conf.getDuration(PropertyKey.USER_RPC_RETRY_BASE_SLEEP_MS), conf.getDuration(PropertyKey.USER_RPC_RETRY_MAX_SLEEP_MS)));
    } catch (IOException e) {
        LOG.warn("Failed to load cluster default configuration for Fuse process. " + "Proceed with local configuration for FUSE: {}", e.toString());
    }
    conf = fsContext.getClusterConf();
    final FuseMountOptions opts = parseOptions(args, conf);
    if (opts == null) {
        System.exit(1);
    }
    CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.CLIENT);
    MetricsSystem.startSinks(conf.getString(PropertyKey.METRICS_CONF_FILE));
    if (conf.getBoolean(PropertyKey.FUSE_WEB_ENABLED)) {
        FuseWebServer webServer = new FuseWebServer(NetworkAddressUtils.ServiceType.FUSE_WEB.getServiceName(), NetworkAddressUtils.getBindAddress(NetworkAddressUtils.ServiceType.FUSE_WEB, ServerConfiguration.global()));
        webServer.start();
    }
    startJvmMonitorProcess();
    try (FileSystem fs = FileSystem.Factory.create(fsContext)) {
        FuseUmountable fuseUmountable = launchFuse(fs, conf, opts, true);
    } catch (IOException e) {
        LOG.error("Failed to launch FUSE", e);
        System.exit(-1);
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) FileSystem(alluxio.client.file.FileSystem) FileSystemContext(alluxio.client.file.FileSystemContext) IOException(java.io.IOException) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Aggregations

FileSystemContext (alluxio.client.file.FileSystemContext)28 AlluxioURI (alluxio.AlluxioURI)11 Test (org.junit.Test)9 URIStatus (alluxio.client.file.URIStatus)8 InstancedConfiguration (alluxio.conf.InstancedConfiguration)8 FileSystem (alluxio.client.file.FileSystem)7 WorkerNetAddress (alluxio.wire.WorkerNetAddress)7 IOException (java.io.IOException)7 Before (org.junit.Before)7 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)5 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)5 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)5 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)5 BlockInfo (alluxio.wire.BlockInfo)5 FileBlockInfo (alluxio.wire.FileBlockInfo)5 ClientContext (alluxio.ClientContext)4 InStreamOptions (alluxio.client.file.options.InStreamOptions)4 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)4 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4