Search in sources :

Example 11 with MasterRegistry

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

the class AlluxioMasterRestServiceHandlerTest method before.

@Before
public void before() throws Exception {
    mMasterProcess = mock(AlluxioMasterProcess.class);
    ServletContext context = mock(ServletContext.class);
    mRegistry = new MasterRegistry();
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext();
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    registerMockUfs();
    mBlockMaster = new BlockMasterFactory().create(mRegistry, masterContext);
    mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, masterContext);
    mRegistry.start(true);
    when(mMasterProcess.getMaster(BlockMaster.class)).thenReturn(mBlockMaster);
    when(mMasterProcess.getMaster(FileSystemMaster.class)).thenReturn(mFileSystemMaster);
    when(context.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn(mMasterProcess);
    mHandler = new AlluxioMasterRestServiceHandler(context);
    // Register two workers
    long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1);
    long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2);
    List<String> tiers = Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD);
    mBlockMaster.workerRegister(worker1, tiers, WORKER1_TOTAL_BYTES_ON_TIERS, WORKER1_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_LOCATIONS, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
    mBlockMaster.workerRegister(worker2, tiers, WORKER2_TOTAL_BYTES_ON_TIERS, WORKER2_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_LOCATIONS, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
    String filesPinnedProperty = MetricKey.MASTER_FILES_PINNED.getName();
    MetricsSystem.METRIC_REGISTRY.remove(filesPinnedProperty);
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) CoreMasterContext(alluxio.master.CoreMasterContext) FileSystemMasterFactory(alluxio.master.file.FileSystemMasterFactory) ServletContext(javax.servlet.ServletContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Example 12 with MasterRegistry

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

the class TableMasterFactoryTest method disabled.

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

Example 13 with MasterRegistry

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

the class FileSystemMasterTest method startServices.

private void startServices() throws Exception {
    mRegistry = new MasterRegistry();
    mJournalSystem = JournalTestUtils.createJournalSystem(mJournalFolder);
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext(mJournalSystem, new TestUserState(TEST_USER, ServerConfiguration.global()));
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    mMetrics = Lists.newArrayList();
    mBlockMaster = new BlockMasterFactory().create(mRegistry, masterContext);
    mExecutorService = Executors.newFixedThreadPool(4, ThreadFactoryUtils.build("DefaultFileSystemMasterTest-%d", true));
    mFileSystemMaster = new DefaultFileSystemMaster(mBlockMaster, masterContext, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mInodeStore = mFileSystemMaster.getInodeStore();
    mInodeTree = mFileSystemMaster.getInodeTree();
    mRegistry.add(FileSystemMaster.class, mFileSystemMaster);
    mJournalSystem.start();
    mJournalSystem.gainPrimacy();
    mRegistry.start(true);
    // set up workers
    mWorkerId1 = mBlockMaster.getWorkerId(new WorkerNetAddress().setHost("localhost").setRpcPort(80).setDataPort(81).setWebPort(82));
    mBlockMaster.workerRegister(mWorkerId1, Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.MB, Constants.MEDIUM_SSD, (long) Constants.MB), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.KB, Constants.MEDIUM_SSD, (long) Constants.KB), ImmutableMap.of(), new HashMap<String, StorageList>(), RegisterWorkerPOptions.getDefaultInstance());
    mWorkerId2 = mBlockMaster.getWorkerId(new WorkerNetAddress().setHost("remote").setRpcPort(80).setDataPort(81).setWebPort(82));
    mBlockMaster.workerRegister(mWorkerId2, Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.MB, Constants.MEDIUM_SSD, (long) Constants.MB), ImmutableMap.of(Constants.MEDIUM_MEM, (long) Constants.KB, Constants.MEDIUM_SSD, (long) Constants.KB), ImmutableMap.of(), new HashMap<String, StorageList>(), RegisterWorkerPOptions.getDefaultInstance());
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) WorkerNetAddress(alluxio.wire.WorkerNetAddress) TestUserState(alluxio.security.user.TestUserState) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) StorageList(alluxio.grpc.StorageList) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Example 14 with MasterRegistry

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

the class MetricsMasterTest method before.

@Before
public void before() throws Exception {
    MetricsSystem.clearAllMetrics();
    mRegistry = new MasterRegistry();
    mClock = new ManualClock();
    mExecutorService = Executors.newFixedThreadPool(2, ThreadFactoryUtils.build("TestMetricsMaster-%d", true));
    mMetricsMaster = new DefaultMetricsMaster(MasterTestUtils.testMasterContext(), mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    mRegistry.start(true);
}
Also used : ManualClock(alluxio.clock.ManualClock) MasterRegistry(alluxio.master.MasterRegistry) Before(org.junit.Before)

Example 15 with MasterRegistry

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

the class JournalSinkTest method before.

@Before
public void before() throws Exception {
    mJournalFolder = mTestFolder.newFolder().getAbsolutePath();
    mJournalSystem = JournalTestUtils.createJournalSystem(mJournalFolder);
    mRegistry = new MasterRegistry();
    mEntries = new LinkedBlockingQueue<>();
    mJournalSink = new TestJournalSink(mEntries);
    startMasters(mRegistry, mJournalSystem, mJournalSink, true);
    mFileSystemMaster = mRegistry.get(FileSystemMaster.class);
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) MasterRegistry(alluxio.master.MasterRegistry) Before(org.junit.Before)

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