Search in sources :

Example 16 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class BlockMasterRegisterStreamIntegrationTest method before.

/**
 * Sets up the dependencies before a test runs.
 */
@Before
public void before() throws Exception {
    // Set the config properties
    ServerConfiguration.set(PropertyKey.WORKER_REGISTER_STREAM_ENABLED, true);
    ServerConfiguration.set(PropertyKey.WORKER_REGISTER_STREAM_BATCH_SIZE, BATCH_SIZE);
    ServerConfiguration.set(PropertyKey.MASTER_WORKER_TIMEOUT_MS, MASTER_WORKER_TIMEOUT);
    ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_STREAM_RESPONSE_TIMEOUT, "1s");
    ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED, false);
    mRegistry = new MasterRegistry();
    mMasterContext = MasterTestUtils.testMasterContext();
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, mMasterContext);
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    mClock = new ManualClock();
    mExecutorService = Executors.newFixedThreadPool(10, ThreadFactoryUtils.build("TestBlockMaster-%d", true));
    mBlockMaster = new DefaultBlockMaster(mMetricsMaster, mMasterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mRegistry.add(BlockMaster.class, mBlockMaster);
    mRegistry.start(true);
    mHandler = new BlockMasterWorkerServiceHandler(mBlockMaster);
}
Also used : ManualClock(alluxio.clock.ManualClock) DefaultBlockMaster(alluxio.master.block.DefaultBlockMaster) BlockMasterWorkerServiceHandler(alluxio.master.block.BlockMasterWorkerServiceHandler) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Example 17 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class TableMasterFactoryTest method enabled.

@Test
public void enabled() throws Exception {
    ServerConfiguration.global().set(PropertyKey.TABLE_ENABLED, true);
    MasterRegistry registry = new MasterRegistry();
    MasterUtils.createMasters(registry, mContext);
    Set<String> names = registry.getServers().stream().map(Server::getName).collect(Collectors.toSet());
    assertTrue(names.contains(Constants.TABLE_MASTER_NAME));
}
Also used : MasterRegistry(alluxio.master.MasterRegistry) Test(org.junit.Test)

Example 18 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class FileSystemMasterSyncMetadataTest method startServices.

private void startServices() throws Exception {
    mExecutorService = Executors.newFixedThreadPool(4, ThreadFactoryUtils.build("DefaultFileSystemMasterTest-%d", true));
    mRegistry = new MasterRegistry();
    JournalSystem journalSystem = JournalTestUtils.createJournalSystem(mJournalFolder.getAbsolutePath());
    CoreMasterContext context = MasterTestUtils.testMasterContext(journalSystem);
    new MetricsMasterFactory().create(mRegistry, context);
    new BlockMasterFactory().create(mRegistry, context);
    mFileSystemMaster = new SyncAwareFileSystemMasterFactory().create(mRegistry, context);
    journalSystem.start();
    journalSystem.gainPrimacy();
    mRegistry.start(true);
    mUfs = Mockito.mock(UnderFileSystem.class);
    PowerMockito.mockStatic(UnderFileSystem.Factory.class);
    Mockito.when(UnderFileSystem.Factory.create(anyString(), any())).thenReturn(mUfs);
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) JournalSystem(alluxio.master.journal.JournalSystem) MasterRegistry(alluxio.master.MasterRegistry) UnderFileSystem(alluxio.underfs.UnderFileSystem) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Example 19 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class BlockMasterWorkerServiceHandlerTest method initServiceHandler.

public void initServiceHandler(boolean leaseEnabled) throws Exception {
    if (leaseEnabled) {
        ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED, true);
        ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_TTL, "3s");
        // Tests on the JVM check logic will be done separately
        ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_RESPECT_JVM_SPACE, false);
        ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_COUNT, 1);
    } else {
        ServerConfiguration.set(PropertyKey.MASTER_WORKER_REGISTER_LEASE_ENABLED, false);
    }
    mRegistry = new MasterRegistry();
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext();
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    mClock = new ManualClock();
    mExecutorService = Executors.newFixedThreadPool(2, ThreadFactoryUtils.build("TestBlockMaster-%d", true));
    mBlockMaster = new DefaultBlockMaster(mMetricsMaster, masterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mRegistry.add(BlockMaster.class, mBlockMaster);
    mRegistry.start(true);
    mHandler = new BlockMasterWorkerServiceHandler(mBlockMaster);
}
Also used : ManualClock(alluxio.clock.ManualClock) CoreMasterContext(alluxio.master.CoreMasterContext) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Example 20 with MasterRegistry

use of alluxio.master.MasterRegistry 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

MasterRegistry (alluxio.master.MasterRegistry)20 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)15 BlockMasterFactory (alluxio.master.block.BlockMasterFactory)11 Before (org.junit.Before)11 CoreMasterContext (alluxio.master.CoreMasterContext)10 JournalSystem (alluxio.master.journal.JournalSystem)6 ManualClock (alluxio.clock.ManualClock)5 MountInfo (alluxio.master.file.meta.options.MountInfo)4 UfsManager (alluxio.underfs.UfsManager)4 InodeDirectoryIdGenerator (alluxio.master.file.meta.InodeDirectoryIdGenerator)3 InodeLockManager (alluxio.master.file.meta.InodeLockManager)3 InodeTree (alluxio.master.file.meta.InodeTree)3 MountTable (alluxio.master.file.meta.MountTable)3 Test (org.junit.Test)3 BlockMaster (alluxio.master.block.BlockMaster)2 FileSystemMaster (alluxio.master.file.FileSystemMaster)2 FileSystemMasterFactory (alluxio.master.file.FileSystemMasterFactory)2 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)2 TestUserState (alluxio.security.user.TestUserState)2 AlluxioURI (alluxio.AlluxioURI)1