Search in sources :

Example 1 with MasterUfsManager

use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.

the class DefaultFileSystemMaster method getRootMountInfo.

private static MountInfo getRootMountInfo(MasterUfsManager ufsManager) {
    try (CloseableResource<UnderFileSystem> resource = ufsManager.getRoot().acquireUfsResource()) {
        boolean shared = resource.get().isObjectStorage() && ServerConfiguration.getBoolean(PropertyKey.UNDERFS_OBJECT_STORE_MOUNT_SHARED_PUBLICLY);
        boolean readonly = ServerConfiguration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_READONLY);
        String rootUfsUri = PathUtils.normalizePath(ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS), AlluxioURI.SEPARATOR);
        Map<String, String> rootUfsConf = ServerConfiguration.getNestedProperties(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION).entrySet().stream().filter(entry -> entry.getValue() != null).collect(Collectors.toMap(Map.Entry::getKey, entry -> String.valueOf(entry.getValue())));
        MountPOptions mountOptions = MountContext.mergeFrom(MountPOptions.newBuilder().setShared(shared).setReadOnly(readonly).putAllProperties(rootUfsConf)).getOptions().build();
        return new MountInfo(new AlluxioURI(MountTable.ROOT), new AlluxioURI(rootUfsUri), IdUtils.ROOT_MOUNT_ID, mountOptions);
    }
}
Also used : SystemClock(alluxio.clock.SystemClock) OK(alluxio.master.file.InodeSyncStream.SyncStatus.OK) Server(alluxio.Server) PropertyKey(alluxio.conf.PropertyKey) StringUtils(org.apache.commons.lang3.StringUtils) CloseableResource(alluxio.resource.CloseableResource) Map(java.util.Map) LockedInodePathList(alluxio.master.file.meta.LockedInodePathList) WorkerHeartbeatContext(alluxio.master.file.contexts.WorkerHeartbeatContext) InodeDirectory(alluxio.master.file.meta.InodeDirectory) ClientContext(alluxio.ClientContext) ReadOnlyInodeStore(alluxio.master.metastore.ReadOnlyInodeStore) UfsSyncPathCache(alluxio.master.file.meta.UfsSyncPathCache) ConnectionFailedException(alluxio.exception.ConnectionFailedException) ProtobufUtils(alluxio.master.ProtobufUtils) UpdateInodeFileEntry(alluxio.proto.journal.File.UpdateInodeFileEntry) Stream(java.util.stream.Stream) InodeTree(alluxio.master.file.meta.InodeTree) OperationContext(alluxio.master.file.contexts.OperationContext) SetAclAction(alluxio.grpc.SetAclAction) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) InternalOperationContext(alluxio.master.file.contexts.InternalOperationContext) InodeFile(alluxio.master.file.meta.InodeFile) PersistConfig(alluxio.job.plan.persist.PersistConfig) AuthType(alluxio.security.authentication.AuthType) Supplier(java.util.function.Supplier) UnderFileSystemUtils(alluxio.util.UnderFileSystemUtils) LockedInodePath(alluxio.master.file.meta.LockedInodePath) GrpcUtils(alluxio.grpc.GrpcUtils) MountInfo(alluxio.master.file.meta.options.MountInfo) AlluxioURI(alluxio.AlluxioURI) MountPOptions(alluxio.grpc.MountPOptions) MetricsSystem(alluxio.metrics.MetricsSystem) UpdateInodeEntry(alluxio.proto.journal.File.UpdateInodeEntry) RetryPolicy(alluxio.retry.RetryPolicy) PersistFile(alluxio.wire.PersistFile) IdUtils(alluxio.util.IdUtils) PersistenceState(alluxio.master.file.meta.PersistenceState) IOException(java.io.IOException) UfsAbsentPathCache(alluxio.master.file.meta.UfsAbsentPathCache) TreeMap(java.util.TreeMap) UfsStatus(alluxio.underfs.UfsStatus) UfsFileStatus(alluxio.underfs.UfsFileStatus) Preconditions(com.google.common.base.Preconditions) FreeContext(alluxio.master.file.contexts.FreeContext) AclEntry(alluxio.security.authorization.AclEntry) Reconfigurable(alluxio.conf.Reconfigurable) MountTable(alluxio.master.file.meta.MountTable) CommonUtils(alluxio.util.CommonUtils) InodeLockManager(alluxio.master.file.meta.InodeLockManager) InodePathPair(alluxio.master.file.meta.InodePathPair) FailedPreconditionException(alluxio.exception.status.FailedPreconditionException) Fingerprint(alluxio.underfs.Fingerprint) AclEntryType(alluxio.security.authorization.AclEntryType) DeleteContext(alluxio.master.file.contexts.DeleteContext) LoadMetadataContext(alluxio.master.file.contexts.LoadMetadataContext) RenameEntry(alluxio.proto.journal.File.RenameEntry) HeartbeatThread(alluxio.heartbeat.HeartbeatThread) InvalidPathException(alluxio.exception.InvalidPathException) ListStatusContext(alluxio.master.file.contexts.ListStatusContext) MetricKey(alluxio.metrics.MetricKey) SyncPointInfo(alluxio.wire.SyncPointInfo) FileSystemMasterCommonPOptions(alluxio.grpc.FileSystemMasterCommonPOptions) Journaled(alluxio.master.journal.Journaled) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CheckpointName(alluxio.master.journal.checkpoint.CheckpointName) Collectors(java.util.stream.Collectors) MkdirsOptions(alluxio.underfs.options.MkdirsOptions) InodeStore(alluxio.master.metastore.InodeStore) SecurityUtils(alluxio.util.SecurityUtils) CoreMasterContext(alluxio.master.CoreMasterContext) CommandType(alluxio.wire.CommandType) SetAttributeContext(alluxio.master.file.contexts.SetAttributeContext) FileAlreadyCompletedException(alluxio.exception.FileAlreadyCompletedException) Function(java.util.function.Function) Stack(java.util.Stack) MetricInfo(alluxio.metrics.MetricInfo) ExistsContext(alluxio.master.file.contexts.ExistsContext) HashSet(java.util.HashSet) Constants(alluxio.Constants) FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) NOT_NEEDED(alluxio.master.file.InodeSyncStream.SyncStatus.NOT_NEEDED) ExecutorService(java.util.concurrent.ExecutorService) AuthenticatedClientUser(alluxio.security.authentication.AuthenticatedClientUser) SetAclEntry(alluxio.proto.journal.File.SetAclEntry) Logger(org.slf4j.Logger) Pair(alluxio.collections.Pair) AsyncUserAccessAuditLogWriter(alluxio.master.audit.AsyncUserAccessAuditLogWriter) NotFoundException(alluxio.exception.status.NotFoundException) LockResource(alluxio.resource.LockResource) UnexpectedAlluxioException(alluxio.exception.UnexpectedAlluxioException) CallTracker(alluxio.master.file.contexts.CallTracker) UfsBlockLocationCache(alluxio.master.file.meta.UfsBlockLocationCache) CreateDirectoryContext(alluxio.master.file.contexts.CreateDirectoryContext) CreateFileContext(alluxio.master.file.contexts.CreateFileContext) Arrays(java.util.Arrays) BlockInfo(alluxio.wire.BlockInfo) PersistCommandOptions(alluxio.wire.PersistCommandOptions) GrpcService(alluxio.grpc.GrpcService) TimeSeries(alluxio.metrics.TimeSeries) WorkerInfo(alluxio.wire.WorkerInfo) DelegatingJournaled(alluxio.master.journal.DelegatingJournaled) PreconditionMessage(alluxio.exception.PreconditionMessage) AuditContext(alluxio.master.audit.AuditContext) DescendantType(alluxio.file.options.DescendantType) ActiveSyncManager(alluxio.master.file.activesync.ActiveSyncManager) Set(java.util.Set) AlluxioException(alluxio.exception.AlluxioException) GetStatusContext(alluxio.master.file.contexts.GetStatusContext) UnderFileSystem(alluxio.underfs.UnderFileSystem) JobInfo(alluxio.job.wire.JobInfo) ServiceType(alluxio.grpc.ServiceType) Iterables(com.google.common.collect.Iterables) CountingRetry(alluxio.retry.CountingRetry) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Callable(java.util.concurrent.Callable) InodeDirectoryView(alluxio.master.file.meta.InodeDirectoryView) Mode(alluxio.security.authorization.Mode) Metric(alluxio.metrics.Metric) ArrayList(java.util.ArrayList) ReconfigurableRegistry(alluxio.conf.ReconfigurableRegistry) BlockInfoException(alluxio.exception.BlockInfoException) InodeDirectoryIdGenerator(alluxio.master.file.meta.InodeDirectoryIdGenerator) Builder(alluxio.proto.journal.File.UpdateInodeFileEntry.Builder) Nullable(javax.annotation.Nullable) LoadDescendantPType(alluxio.grpc.LoadDescendantPType) MountContext(alluxio.master.file.contexts.MountContext) MetricRegistry(com.codahale.metrics.MetricRegistry) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) RenameContext(alluxio.master.file.contexts.RenameContext) FileSystemCommandOptions(alluxio.wire.FileSystemCommandOptions) JobMasterClientPool(alluxio.client.job.JobMasterClientPool) FileSystemCommand(alluxio.wire.FileSystemCommand) ExecutorServiceFactory(alluxio.util.executor.ExecutorServiceFactory) UfsInfo(alluxio.wire.UfsInfo) JournaledGroup(alluxio.master.journal.JournaledGroup) ExecutorServiceFactories(alluxio.util.executor.ExecutorServiceFactories) NotThreadSafe(javax.annotation.concurrent.NotThreadSafe) ServerInterceptors(io.grpc.ServerInterceptors) MasterUfsManager(alluxio.underfs.MasterUfsManager) ScheduleAsyncPersistenceContext(alluxio.master.file.contexts.ScheduleAsyncPersistenceContext) LoggerFactory(org.slf4j.LoggerFactory) FileBlockInfo(alluxio.wire.FileBlockInfo) NewBlockEntry(alluxio.proto.journal.File.NewBlockEntry) LogUtils(alluxio.util.LogUtils) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) Counter(com.codahale.metrics.Counter) JobMasterClient(alluxio.client.job.JobMasterClient) CheckConsistencyContext(alluxio.master.file.contexts.CheckConsistencyContext) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) LockPattern(alluxio.master.file.meta.InodeTree.LockPattern) TtlAction(alluxio.grpc.TtlAction) ServerConfiguration(alluxio.conf.ServerConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) CompleteFileContext(alluxio.master.file.contexts.CompleteFileContext) TimeSeriesStore(alluxio.master.metrics.TimeSeriesStore) PermissionDeniedException(alluxio.exception.status.PermissionDeniedException) LoadMetadataPOptions(alluxio.grpc.LoadMetadataPOptions) Streams(com.google.common.collect.Streams) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Sets(com.google.common.collect.Sets) FileNotFoundException(java.io.FileNotFoundException) DelegatingReadOnlyInodeStore(alluxio.master.metastore.DelegatingReadOnlyInodeStore) AccessControlException(alluxio.exception.AccessControlException) File(alluxio.proto.journal.File) List(java.util.List) InvalidFileSizeException(alluxio.exception.InvalidFileSizeException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) LoadMetadataPType(alluxio.grpc.LoadMetadataPType) ModeUtils(alluxio.util.ModeUtils) Gauge(com.codahale.metrics.Gauge) UFS_OP_SAVED_PREFIX(alluxio.metrics.MetricInfo.UFS_OP_SAVED_PREFIX) UfsManager(alluxio.underfs.UfsManager) JournalContext(alluxio.master.journal.JournalContext) SortedMap(java.util.SortedMap) UnavailableException(alluxio.exception.status.UnavailableException) MountPointInfo(alluxio.wire.MountPointInfo) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) HashMap(java.util.HashMap) SetAttributePOptions(alluxio.grpc.SetAttributePOptions) BlockId(alluxio.master.block.BlockId) BlockMaster(alluxio.master.block.BlockMaster) CheckAccessContext(alluxio.master.file.contexts.CheckAccessContext) JournalEntry(alluxio.proto.journal.Journal.JournalEntry) DeletePOptions(alluxio.grpc.DeletePOptions) PathUtils(alluxio.util.io.PathUtils) DirectoryNotEmptyException(alluxio.exception.DirectoryNotEmptyException) ClientIpAddressInjector(alluxio.security.authentication.ClientIpAddressInjector) PrefixList(alluxio.collections.PrefixList) SetAclContext(alluxio.master.file.contexts.SetAclContext) CoreMaster(alluxio.master.CoreMaster) HeartbeatContext(alluxio.heartbeat.HeartbeatContext) Iterator(java.util.Iterator) ExceptionMessage(alluxio.exception.ExceptionMessage) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) ProtoUtils(alluxio.util.proto.ProtoUtils) TimeUnit(java.util.concurrent.TimeUnit) BlockLocation(alluxio.wire.BlockLocation) FAILED(alluxio.master.file.InodeSyncStream.SyncStatus.FAILED) LockingScheme(alluxio.master.file.meta.LockingScheme) FileInfo(alluxio.wire.FileInfo) VisibleForTesting(com.google.common.annotations.VisibleForTesting) UfsMode(alluxio.underfs.UfsMode) Collections(java.util.Collections) Inode(alluxio.master.file.meta.Inode) MountPOptions(alluxio.grpc.MountPOptions) UnderFileSystem(alluxio.underfs.UnderFileSystem) MountInfo(alluxio.master.file.meta.options.MountInfo) Map(java.util.Map) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ImmutableMap(com.google.common.collect.ImmutableMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) AlluxioURI(alluxio.AlluxioURI)

Example 2 with MasterUfsManager

use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.

the class LazyUfsBlockLocationCacheTest method before.

/**
 * Sets up a new {@link AsyncUfsAbsentPathCache} before a test runs.
 */
@Before
public void before() throws Exception {
    mLocalUfsPath = Files.createTempDir().getAbsolutePath();
    mLocalUfs = UnderFileSystem.Factory.create(mLocalUfsPath, UnderFileSystemConfiguration.defaults(ServerConfiguration.global()));
    mMountId = IdUtils.getRandomNonNegativeLong();
    mUfsManager = new MasterUfsManager();
    MountPOptions options = MountContext.defaults().getOptions().build();
    mUfsManager.addMount(mMountId, new AlluxioURI(mLocalUfsPath), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()).setReadOnly(options.getReadOnly()).setShared(options.getShared()).createMountSpecificConf(Collections.<String, String>emptyMap()));
    mMountTable = new MountTable(mUfsManager, new MountInfo(new AlluxioURI("/"), new AlluxioURI("/ufs"), 1, MountContext.defaults().getOptions().build()));
    mMountTable.add(NoopJournalContext.INSTANCE, new AlluxioURI("/mnt"), new AlluxioURI(mLocalUfsPath), mMountId, options);
    mUfsBlockLocationCache = new LazyUfsBlockLocationCache(mMountTable);
}
Also used : MountPOptions(alluxio.grpc.MountPOptions) MountInfo(alluxio.master.file.meta.options.MountInfo) MasterUfsManager(alluxio.underfs.MasterUfsManager) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 3 with MasterUfsManager

use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.

the class AsyncUfsAbsentPathCacheTest method before.

/**
 * Sets up a new {@link AsyncUfsAbsentPathCache} before a test runs.
 */
@Before
public void before() throws Exception {
    mLocalUfsPath = mTemp.getRoot().getAbsolutePath();
    mUfsManager = new MasterUfsManager();
    mMountTable = new MountTable(mUfsManager, new MountInfo(new AlluxioURI("/"), new AlluxioURI("/ufs"), 1, MountContext.defaults().getOptions().build()));
    mUfsAbsentPathCache = new AsyncUfsAbsentPathCache(mMountTable, THREADS);
    mMountId = IdUtils.getRandomNonNegativeLong();
    MountPOptions options = MountContext.defaults().getOptions().build();
    mUfsManager.addMount(mMountId, new AlluxioURI(mLocalUfsPath), UnderFileSystemConfiguration.defaults(ConfigurationTestUtils.defaults()).setReadOnly(options.getReadOnly()).setShared(options.getShared()).createMountSpecificConf(Collections.<String, String>emptyMap()));
    mMountTable.add(NoopJournalContext.INSTANCE, new AlluxioURI("/mnt"), new AlluxioURI(mLocalUfsPath), mMountId, options);
}
Also used : MountPOptions(alluxio.grpc.MountPOptions) MountInfo(alluxio.master.file.meta.options.MountInfo) MasterUfsManager(alluxio.underfs.MasterUfsManager) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 4 with MasterUfsManager

use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.

the class TableMasterFactoryTest method before.

@Before
public void before() {
    mContext = CoreMasterContext.newBuilder().setJournalSystem(new NoopJournalSystem()).setSafeModeManager(new TestSafeModeManager()).setBackupManager(mock(BackupManager.class)).setBlockStoreFactory(HeapBlockStore::new).setInodeStoreFactory(x -> new HeapInodeStore()).setUfsManager(new MasterUfsManager()).build();
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_FOLDER, sTemp.getRoot().getAbsolutePath());
}
Also used : ServerConfiguration(alluxio.conf.ServerConfiguration) MasterUfsManager(alluxio.underfs.MasterUfsManager) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) Assert.assertTrue(org.junit.Assert.assertTrue) Server(alluxio.Server) Set(java.util.Set) Test(org.junit.Test) BackupManager(alluxio.master.BackupManager) HeapBlockStore(alluxio.master.metastore.heap.HeapBlockStore) PropertyKey(alluxio.conf.PropertyKey) Collectors(java.util.stream.Collectors) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore) Constants(alluxio.Constants) Assert.assertFalse(org.junit.Assert.assertFalse) TestSafeModeManager(alluxio.master.TestSafeModeManager) After(org.junit.After) CoreMasterContext(alluxio.master.CoreMasterContext) MasterRegistry(alluxio.master.MasterRegistry) ClassRule(org.junit.ClassRule) MasterUtils(alluxio.master.MasterUtils) TemporaryFolder(org.junit.rules.TemporaryFolder) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) TestSafeModeManager(alluxio.master.TestSafeModeManager) HeapBlockStore(alluxio.master.metastore.heap.HeapBlockStore) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) MasterUfsManager(alluxio.underfs.MasterUfsManager) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore) Before(org.junit.Before)

Example 5 with MasterUfsManager

use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.

the class MasterTestUtils method createFileSystemMasterFromJournal.

/**
 * Creates a new {@link FileSystemMaster} from journal along with its dependencies, and returns
 * the master registry and the journal system.
 *
 * @param isLeader whether to start as a leader
 * @param userState the user state for the server. if null, will use ServerUserState.global()
 * @param journalFolder the folder of the master journal
 * @return a resource that contains the master registry and the journal system
 */
private static FsMasterResource createFileSystemMasterFromJournal(boolean isLeader, UserState userState, String journalFolder) throws Exception {
    String masterJournal = journalFolder;
    MasterRegistry registry = new MasterRegistry();
    SafeModeManager safeModeManager = new TestSafeModeManager();
    long startTimeMs = System.currentTimeMillis();
    int port = ServerConfiguration.getInt(PropertyKey.MASTER_RPC_PORT);
    String baseDir = ServerConfiguration.getString(PropertyKey.MASTER_METASTORE_DIR);
    JournalSystem journalSystem = JournalTestUtils.createJournalSystem(masterJournal);
    if (userState == null) {
        userState = ServerUserState.global();
    }
    CoreMasterContext masterContext = CoreMasterContext.newBuilder().setJournalSystem(journalSystem).setSafeModeManager(safeModeManager).setBackupManager(mock(BackupManager.class)).setBlockStoreFactory(MasterUtils.getBlockStoreFactory(baseDir)).setInodeStoreFactory(MasterUtils.getInodeStoreFactory(baseDir)).setStartTimeMs(startTimeMs).setUserState(userState).setPort(port).setUfsManager(new MasterUfsManager()).build();
    new MetricsMasterFactory().create(registry, masterContext);
    new BlockMasterFactory().create(registry, masterContext);
    new FileSystemMasterFactory().create(registry, masterContext);
    journalSystem.start();
    if (isLeader) {
        journalSystem.gainPrimacy();
    }
    registry.start(isLeader);
    return new FsMasterResource(registry, journalSystem);
}
Also used : TestSafeModeManager(alluxio.master.TestSafeModeManager) BlockMasterFactory(alluxio.master.block.BlockMasterFactory) MasterRegistry(alluxio.master.MasterRegistry) MasterUfsManager(alluxio.underfs.MasterUfsManager) SafeModeManager(alluxio.master.SafeModeManager) TestSafeModeManager(alluxio.master.TestSafeModeManager) CoreMasterContext(alluxio.master.CoreMasterContext) FileSystemMasterFactory(alluxio.master.file.FileSystemMasterFactory) JournalSystem(alluxio.master.journal.JournalSystem) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Aggregations

MasterUfsManager (alluxio.underfs.MasterUfsManager)5 AlluxioURI (alluxio.AlluxioURI)3 MountPOptions (alluxio.grpc.MountPOptions)3 MountInfo (alluxio.master.file.meta.options.MountInfo)3 Constants (alluxio.Constants)2 Server (alluxio.Server)2 PropertyKey (alluxio.conf.PropertyKey)2 ServerConfiguration (alluxio.conf.ServerConfiguration)2 CoreMasterContext (alluxio.master.CoreMasterContext)2 MasterRegistry (alluxio.master.MasterRegistry)2 TestSafeModeManager (alluxio.master.TestSafeModeManager)2 Before (org.junit.Before)2 ClientContext (alluxio.ClientContext)1 JobMasterClient (alluxio.client.job.JobMasterClient)1 JobMasterClientPool (alluxio.client.job.JobMasterClientPool)1 SystemClock (alluxio.clock.SystemClock)1 Pair (alluxio.collections.Pair)1 PrefixList (alluxio.collections.PrefixList)1 Reconfigurable (alluxio.conf.Reconfigurable)1 ReconfigurableRegistry (alluxio.conf.ReconfigurableRegistry)1