Search in sources :

Example 91 with FileSystem

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

the class LsCommandSecurityIntegrationTest method lsWithExtendedAcl.

@Test
public void lsWithExtendedAcl() throws IOException, AlluxioException {
    int size = 50;
    FileSystem fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState("test_user_ls", ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WritePType.MUST_CACHE, 20);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFile", WritePType.MUST_CACHE, size, size);
    sFsShell.run("ls", "--sort", "path", "/testRoot");
    // CHECKSTYLE.OFF: LineLengthExceed - Improve readability
    checkOutput("drwxr-xr-x  test_user_ls   test_user_ls                 1   NOT_PERSISTED .+ .+ DIR /testRoot/testDir", "-rw-r--r--  test_user_ls   test_user_ls                50   NOT_PERSISTED .+ .+ 100% /testRoot/testFile");
    // CHECKSTYLE.ON: LineLengthExceed
    mOutput.reset();
    fs.setAcl(new AlluxioURI("/testRoot/testDir"), SetAclAction.MODIFY, Arrays.asList(AclEntry.fromCliString("default:user:nameduser:rwx")));
    fs.setAcl(new AlluxioURI("/testRoot/testFile"), SetAclAction.MODIFY, Arrays.asList(AclEntry.fromCliString("user:nameduser:rwx")));
    sFsShell.run("ls", "--sort", "path", "/testRoot");
    // CHECKSTYLE.OFF: LineLengthExceed - Improve readability
    checkOutput("drwxr-xr-x\\+ test_user_ls   test_user_ls                 1   NOT_PERSISTED .+ .+  DIR /testRoot/testDir", "-rw-r--r--\\+ test_user_ls   test_user_ls                50   NOT_PERSISTED .+ .+ 100% /testRoot/testFile");
// CHECKSTYLE.ON: LineLengthExceed
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState) AlluxioURI(alluxio.AlluxioURI) AbstractFileSystemShellTest(alluxio.client.cli.fs.AbstractFileSystemShellTest) Test(org.junit.Test) FileSystemShellUtilsTest(alluxio.client.cli.fs.FileSystemShellUtilsTest)

Example 92 with FileSystem

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

the class LsCommandSecurityIntegrationTest method createFiles.

// Helper function to create a set of files in the file system
private void createFiles() throws Exception {
    FileSystem fs = sLocalAlluxioCluster.getClient(FileSystemContext.create(new TestUserState("test_user_ls", ServerConfiguration.global()).getSubject(), ServerConfiguration.global()));
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WritePType.MUST_CACHE, 10);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", WritePType.MUST_CACHE, 20);
    FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WritePType.THROUGH, 30);
}
Also used : FileSystem(alluxio.client.file.FileSystem) TestUserState(alluxio.security.user.TestUserState)

Example 93 with FileSystem

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

the class ManagerProcessContext method getMountPointList.

/**
 * Get a list of mount points and their information.
 *
 * @return a MountPointList object
 */
public ListMountPointResponse.Payload getMountPointList() {
    List<alluxio.hub.proto.MountPointInfo> mountPoints = new ArrayList<>();
    FileSystem fs = getFileSystem();
    if (fs == null) {
        LOG.debug("Unable to get file system client");
        return ListMountPointResponse.Payload.getDefaultInstance();
    }
    try {
        Map<String, MountPointInfo> mountTable = fs.getMountTable();
        Set<String> syncSet = fs.getSyncPathList().stream().map(syncPoint -> syncPoint.getSyncPointUri().toString()).collect(Collectors.toSet());
        for (Map.Entry<String, MountPointInfo> entry : mountTable.entrySet()) {
            alluxio.hub.proto.MountPointInfo.Builder builder = alluxio.hub.proto.MountPointInfo.newBuilder();
            MountPointInfo mountInfo = entry.getValue();
            // Generic mount point info
            builder.setAlluxioPath(entry.getKey()).setUfsUri(mountInfo.getUfsUri()).setUfsType(mountInfo.getUfsType()).setReadOnly(mountInfo.getReadOnly()).setShared(mountInfo.getShared());
            Map<String, String> prop = new HashMap<>(mountInfo.getProperties());
            // remove properties that are explicitly shown as options
            prop.remove(PropertyKey.UNDERFS_HDFS_CONFIGURATION.getName());
            // HDFS specific mount point info
            if (mountInfo.getUfsType().toLowerCase().equals("hdfs")) {
                prop.remove(PropertyKey.UNDERFS_VERSION.getName());
                HDFSMountPointInfo.Builder hdfsBuilder = HDFSMountPointInfo.newBuilder();
                String[] confFileNames = mountInfo.getProperties().getOrDefault(PropertyKey.UNDERFS_HDFS_CONFIGURATION.getName(), "").split(":");
                String coreSiteFileName = "";
                String hdfsSiteFileName = "";
                for (String confFile : confFileNames) {
                    if (confFile.contains("hdfs-site.xml")) {
                        hdfsSiteFileName = confFile;
                    } else if (confFile.contains("core-site.xml")) {
                        coreSiteFileName = confFile;
                    }
                }
                String hdfsVersion = mountInfo.getProperties().getOrDefault(PropertyKey.UNDERFS_VERSION.getName(), "");
                // Use file name in place of file content for now
                // Need to verify syncing through active sync api
                hdfsBuilder.setEnableSync(syncSet.contains(entry.getKey())).setCoreSiteFilePath(coreSiteFileName).setHdfsSiteFilePath(hdfsSiteFileName).setHdfsVersion(hdfsVersion);
                builder.setHdfsInfo(hdfsBuilder);
            }
            builder.putAllProperties(prop);
            mountPoints.add(builder.build());
        }
    } catch (AlluxioException e) {
        LOG.debug("getMountTable failed due to " + e.getMessage());
        return ListMountPointResponse.Payload.getDefaultInstance();
    } catch (IOException e) {
        LOG.debug("RPC to get mount table failed due to " + e.getMessage());
        return ListMountPointResponse.Payload.getDefaultInstance();
    }
    return ListMountPointResponse.Payload.newBuilder().addAllMountPoint(mountPoints).build();
}
Also used : RemoveFile(alluxio.hub.proto.RemoveFile) PropertyKey(alluxio.conf.PropertyKey) UploadFile(alluxio.hub.proto.UploadFile) IOTaskSummary(alluxio.stress.worker.IOTaskSummary) FileSystem(alluxio.client.file.FileSystem) SpeedTestRequest(alluxio.hub.proto.SpeedTestRequest) AgentFileUploadResponse(alluxio.hub.proto.AgentFileUploadResponse) Duration(java.time.Duration) Map(java.util.Map) Status(io.grpc.Status) CLUSTER_DEFAULT(alluxio.conf.Source.CLUSTER_DEFAULT) AgentWriteConfigurationSetRequest(alluxio.hub.proto.AgentWriteConfigurationSetRequest) ValidationUtils(alluxio.cli.ValidationUtils) AgentProcessStatusChangeResponse(alluxio.hub.proto.AgentProcessStatusChangeResponse) RpcClient(alluxio.hub.common.RpcClient) Set(java.util.Set) AlluxioException(alluxio.exception.AlluxioException) AgentHeartbeatRequest(alluxio.hub.proto.AgentHeartbeatRequest) ThreadSafe(javax.annotation.concurrent.ThreadSafe) GetPrestoConfDirResponse(alluxio.hub.proto.GetPrestoConfDirResponse) AlluxioProperties(alluxio.conf.AlluxioProperties) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) AgentGetConfigurationSetRequest(alluxio.hub.proto.AgentGetConfigurationSetRequest) Config(io.fabric8.kubernetes.client.Config) Source(alluxio.conf.Source) InstancedConfiguration(alluxio.conf.InstancedConfiguration) AgentFileUploadRequest(alluxio.hub.proto.AgentFileUploadRequest) RuntimeConstants(alluxio.RuntimeConstants) AgentShutdownRequest(alluxio.hub.proto.AgentShutdownRequest) DetectPrestoResponse(alluxio.hub.proto.DetectPrestoResponse) RemoveFileRequest(alluxio.hub.proto.RemoveFileRequest) ProcessStatusChangeResponse(alluxio.hub.proto.ProcessStatusChangeResponse) ArrayList(java.util.ArrayList) UfsIOBench(alluxio.stress.cli.UfsIOBench) AlluxioClusterHeartbeatResponse(alluxio.hub.proto.AlluxioClusterHeartbeatResponse) AlluxioURI(alluxio.AlluxioURI) HubNodeAddress(alluxio.hub.proto.HubNodeAddress) ListMountPointResponse(alluxio.hub.proto.ListMountPointResponse) RequestStreamObserver(alluxio.hub.manager.rpc.observer.RequestStreamObserver) UfsIOParameters(alluxio.stress.worker.UfsIOParameters) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) MountPOptions(alluxio.grpc.MountPOptions) HubAuthenticationInterceptor(alluxio.hub.manager.rpc.interceptor.HubAuthenticationInterceptor) RetryPolicy(alluxio.retry.RetryPolicy) Nullable(javax.annotation.Nullable) ListFile(alluxio.hub.proto.ListFile) Properties(java.util.Properties) AgentDetectPrestoResponse(alluxio.hub.proto.AgentDetectPrestoResponse) PingManagerRequest(alluxio.hub.proto.PingManagerRequest) IOException(java.io.IOException) AgentWriteConfigurationSetResponse(alluxio.hub.proto.AgentWriteConfigurationSetResponse) DeleteMountPointResponse(alluxio.hub.proto.DeleteMountPointResponse) AlluxioClusterHeartbeatRequest(alluxio.hub.proto.AlluxioClusterHeartbeatRequest) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) ApplyMountPointResponse(alluxio.hub.proto.ApplyMountPointResponse) Lock(java.util.concurrent.locks.Lock) HubAuthentication(alluxio.hub.proto.HubAuthentication) AgentSetPrestoConfRequest(alluxio.hub.proto.AgentSetPrestoConfRequest) PingManagerResponse(alluxio.hub.proto.PingManagerResponse) Preconditions(com.google.common.base.Preconditions) UploadFileResponse(alluxio.hub.proto.UploadFileResponse) AgentListFileRequest(alluxio.hub.proto.AgentListFileRequest) HubUtil(alluxio.hub.common.HubUtil) DetectPrestoRequest(alluxio.hub.proto.DetectPrestoRequest) AgentSetPrestoConfResponse(alluxio.hub.proto.AgentSetPrestoConfResponse) AlluxioCluster(alluxio.hub.manager.util.AlluxioCluster) AgentShutdownResponse(alluxio.hub.proto.AgentShutdownResponse) ListCatalogRequest(alluxio.hub.proto.ListCatalogRequest) JsonSerializable(alluxio.util.JsonSerializable) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet) LoggerFactory(org.slf4j.LoggerFactory) SpeedTestResponse(alluxio.hub.proto.SpeedTestResponse) Channel(io.grpc.Channel) GetConfigurationSetResponse(alluxio.hub.proto.GetConfigurationSetResponse) RegisterManagerResponse(alluxio.hub.proto.RegisterManagerResponse) LogUtils(alluxio.util.LogUtils) AgentRemoveFileResponse(alluxio.hub.proto.AgentRemoveFileResponse) HostedManagerServiceGrpc(alluxio.hub.proto.HostedManagerServiceGrpc) InvalidPathException(alluxio.exception.InvalidPathException) StreamObserver(io.grpc.stub.StreamObserver) DeleteMountPointRequest(alluxio.hub.proto.DeleteMountPointRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) GrpcChannel(alluxio.grpc.GrpcChannel) AgentDetectPrestoRequest(alluxio.hub.proto.AgentDetectPrestoRequest) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) RegisterManagerRequest(alluxio.hub.proto.RegisterManagerRequest) HubCluster(alluxio.hub.manager.util.HubCluster) ServerConfiguration(alluxio.conf.ServerConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) ExponentialTimeBoundedRetry(alluxio.retry.ExponentialTimeBoundedRetry) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) GetConfigurationSetRequest(alluxio.hub.proto.GetConfigurationSetRequest) SetPrestoConfDirRequest(alluxio.hub.proto.SetPrestoConfDirRequest) ByteString(com.google.protobuf.ByteString) Base64(java.util.Base64) List(java.util.List) SetPrestoConfDirResponse(alluxio.hub.proto.SetPrestoConfDirResponse) HubMetadata(alluxio.hub.proto.HubMetadata) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) ListCatalogResponse(alluxio.hub.proto.ListCatalogResponse) RemoveFileResponse(alluxio.hub.proto.RemoveFileResponse) Pattern(java.util.regex.Pattern) AgentListCatalogRequest(alluxio.hub.proto.AgentListCatalogRequest) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) MountPointInfo(alluxio.wire.MountPointInfo) HashMap(java.util.HashMap) NetworkAddressUtils(alluxio.util.network.NetworkAddressUtils) AgentManagerServiceGrpc(alluxio.hub.proto.AgentManagerServiceGrpc) ListFileResponse(alluxio.hub.proto.ListFileResponse) Function(java.util.function.Function) SpeedStat(alluxio.hub.proto.SpeedStat) WriteConfigurationSetResponse(alluxio.hub.proto.WriteConfigurationSetResponse) ExecutionType(alluxio.hub.proto.ExecutionType) AlluxioNodeType(alluxio.hub.proto.AlluxioNodeType) PrestoCatalogListingResult(alluxio.hub.proto.PrestoCatalogListingResult) PathUtils(alluxio.util.io.PathUtils) ImmutableList(com.google.common.collect.ImmutableList) HDFSMountPointInfo(alluxio.hub.proto.HDFSMountPointInfo) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) AlluxioEdition(alluxio.hub.proto.AlluxioEdition) ExecutorService(java.util.concurrent.ExecutorService) RegisterAgentRequest(alluxio.hub.proto.RegisterAgentRequest) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) AgentRemoveFileRequest(alluxio.hub.proto.AgentRemoveFileRequest) ApplyMountPointRequest(alluxio.hub.proto.ApplyMountPointRequest) GetPrestoConfDirRequest(alluxio.hub.proto.GetPrestoConfDirRequest) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) Pair(alluxio.collections.Pair) UploadFileRequest(alluxio.hub.proto.UploadFileRequest) HubStatus(alluxio.hub.proto.HubStatus) ConfigurationUtils(alluxio.util.ConfigurationUtils) HubSslContextProvider(alluxio.hub.common.HubSslContextProvider) ProcessStatusChangeRequest(alluxio.hub.proto.ProcessStatusChangeRequest) WriteConfigurationSetRequest(alluxio.hub.proto.WriteConfigurationSetRequest) FileSystemContext(alluxio.client.file.FileSystemContext) ListFileRequest(alluxio.hub.proto.ListFileRequest) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) ListMountPointRequest(alluxio.hub.proto.ListMountPointRequest) Collections(java.util.Collections) SpeedTestParameter(alluxio.hub.proto.SpeedTestParameter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) HDFSMountPointInfo(alluxio.hub.proto.HDFSMountPointInfo) MountPointInfo(alluxio.wire.MountPointInfo) HDFSMountPointInfo(alluxio.hub.proto.HDFSMountPointInfo) FileSystem(alluxio.client.file.FileSystem) Map(java.util.Map) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) AlluxioException(alluxio.exception.AlluxioException)

Example 94 with FileSystem

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

the class ManagerProcessContextTest method testSpeedTest.

@Test
public void testSpeedTest() throws Exception {
    UfsIOBench bench = Mockito.mock(UfsIOBench.class);
    FileSystem mockFs = Mockito.mock(FileSystem.class);
    doReturn(mockFs).when(mContext).getFileSystem();
    doReturn(bench).when(mContext).getIOBench();
    Map<String, MountPointInfo> mt = new HashMap<>();
    MountPointInfo info = new MountPointInfo().setMountId(1).setReadOnly(true).setUfsType("hdfs").setUfsUri("hdfs://localhost:9000");
    mt.put("/", info);
    doReturn(mt).when(mockFs).getMountTable();
    IOTaskSummary summ = new IOTaskSummary();
    IOTaskSummary.SpeedStat read = generateSpeedStat();
    IOTaskSummary.SpeedStat write = generateSpeedStat();
    summ.setReadSpeedStat(read);
    summ.setWriteSpeedStat(write);
    doReturn(summ.toJson()).when(bench).run(any());
    SpeedTestResponse.Payload resp = mContext.speedTest(SpeedTestRequest.newBuilder().setPayload(SpeedTestRequest.Payload.newBuilder().setMountPoint("/").setPath("bbb").setClusterParallelism(0).setNodeParallelism(0).setDataSize("1m")).build());
    SpeedStat readResp = resp.getReadSpeedStat();
    SpeedStat writeResp = resp.getWriteSpeedStat();
    List<String> errResp = resp.getErrorList();
    SpeedTestParameter params = resp.getParameters();
    assertEquals(read.mAvgSpeedMbps, readResp.getAvgSpeedMbps(), 1E-10);
    assertEquals(read.mMinSpeedMbps, readResp.getMinSpeedMbps(), 1E-10);
    assertEquals(read.mMaxSpeedMbps, readResp.getMaxSpeedMbps(), 1E-10);
    assertEquals(read.mStdDev, readResp.getStdDev(), 1E-10);
    assertEquals(read.mTotalDurationSeconds, readResp.getTotalDurationSeconds(), 1E-10);
    assertEquals(read.mTotalSizeBytes, readResp.getTotalSizeBytes(), 1E-10);
    assertEquals(write.mAvgSpeedMbps, writeResp.getAvgSpeedMbps(), 1E-10);
    assertEquals(write.mMinSpeedMbps, writeResp.getMinSpeedMbps(), 1E-10);
    assertEquals(write.mMaxSpeedMbps, writeResp.getMaxSpeedMbps(), 1E-10);
    assertEquals(write.mStdDev, writeResp.getStdDev(), 1E-10);
    assertEquals(write.mTotalDurationSeconds, writeResp.getTotalDurationSeconds(), 1E-10);
    assertEquals(write.mTotalSizeBytes, writeResp.getTotalSizeBytes(), 1E-10);
    assertEquals(0, errResp.size());
    summ.setErrors(Collections.singletonList("testErr"));
    doReturn(summ.toJson()).when(bench).run(any());
    resp = mContext.speedTest(SpeedTestRequest.newBuilder().setPayload(SpeedTestRequest.Payload.newBuilder().setMountPoint("/").setPath("bbb").setClusterParallelism(0).setNodeParallelism(0).setDataSize("1m")).build());
    errResp = resp.getErrorList();
    assertEquals(1, errResp.size());
    assertEquals("testErr", errResp.get(0));
}
Also used : SpeedTestResponse(alluxio.hub.proto.SpeedTestResponse) HashMap(java.util.HashMap) SpeedStat(alluxio.hub.proto.SpeedStat) IOTaskSummary(alluxio.stress.worker.IOTaskSummary) MountPointInfo(alluxio.wire.MountPointInfo) SpeedTestParameter(alluxio.hub.proto.SpeedTestParameter) FileSystem(alluxio.client.file.FileSystem) UfsIOBench(alluxio.stress.cli.UfsIOBench) BaseHubTest(alluxio.hub.test.BaseHubTest) Test(org.junit.Test)

Example 95 with FileSystem

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

the class TestDatabase method genTable.

public static void genTable(int numOfTable, int numOfPartitions, boolean generateFiles) {
    DATABASE.mUdbTables.clear();
    FileSystem fs = null;
    if (generateFiles) {
        fs = FileSystem.Factory.create(ServerConfiguration.global());
    }
    for (int i = 0; i < numOfTable; i++) {
        DATABASE.mUdbTables.put(getTableName(i), new TestUdbTable(TEST_UDB_NAME, getTableName(i), numOfPartitions, fs));
    }
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Aggregations

FileSystem (alluxio.client.file.FileSystem)122 AlluxioURI (alluxio.AlluxioURI)90 Test (org.junit.Test)75 URIStatus (alluxio.client.file.URIStatus)42 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)22 FileInStream (alluxio.client.file.FileInStream)13 IOException (java.io.IOException)12 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)11 ArrayList (java.util.ArrayList)11 FileOutStream (alluxio.client.file.FileOutStream)10 AlluxioException (alluxio.exception.AlluxioException)9 File (java.io.File)9 Path (javax.ws.rs.Path)9 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)8 HashMap (java.util.HashMap)8 FileSystemContext (alluxio.client.file.FileSystemContext)7 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)6 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)6 TestUserState (alluxio.security.user.TestUserState)6 InstancedConfiguration (alluxio.conf.InstancedConfiguration)5