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