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();
}
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();
}
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();
}
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);
}
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);
}
}
Aggregations