use of alluxio.master.metrics.MetricsMasterFactory 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.metrics.MetricsMasterFactory 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.metrics.MetricsMasterFactory 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);
}
use of alluxio.master.metrics.MetricsMasterFactory in project alluxio by Alluxio.
the class BackupManagerTest method rocksInodeStoreIteratorNotUsed.
@Test
public void rocksInodeStoreIteratorNotUsed() throws Exception {
// Prepare some data for the iterator
List<InodeView> inodes = new ArrayList<>();
inodes.add(createRootDir(99L));
inodes.add(createNewFile(100L));
inodes.add(createNewFile(101L));
inodes.add(createNewFile(102L));
// When RocksInodeStore.iterator(), return mock iterator
RocksInodeStore mockInodeStore = mock(RocksInodeStore.class);
// Make sure the iterator is not used in the backup operation
when(mockInodeStore.getCloseableIterator()).thenThrow(new UnsupportedOperationException());
// When the root inode is asked for, return the directory
InodeView dir = inodes.get(0);
when(mockInodeStore.get(eq(0L))).thenReturn(Optional.of(new InodeDirectory((InodeDirectoryView) dir)));
CoreMasterContext masterContext = MasterTestUtils.testMasterContext(new NoopJournalSystem(), null, () -> new HeapBlockStore(), x -> mockInodeStore);
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
mBlockMaster = new DefaultBlockMaster(mMetricsMaster, masterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
mRegistry.add(BlockMaster.class, mBlockMaster);
// Prepare the FileSystemMaster for the backup operation
FileSystemMaster fsMaster = new DefaultFileSystemMaster(mBlockMaster, masterContext, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
mRegistry.add(FileSystemMaster.class, fsMaster);
mRegistry.start(true);
// Finish backup operation
BackupManager manager = new BackupManager(mRegistry);
File backupDir = AlluxioTestDirectory.createTemporaryDirectory("backup-dir");
File backupFile = new File(backupDir, "1.backup");
AtomicLong counter = new AtomicLong(0L);
// No exception means the RocksInodeStore iterator is not used
manager.backup(new FileOutputStream(backupFile), counter);
}
use of alluxio.master.metrics.MetricsMasterFactory in project alluxio by Alluxio.
the class BackupManagerTest method rocksBlockStoreIteratorClosed.
@Test
public void rocksBlockStoreIteratorClosed() throws Exception {
// Prepare some data for the iterator
List<BlockStore.Block> blocks = new ArrayList<>();
blocks.add(createNewBlock(1L));
blocks.add(createNewBlock(2L));
blocks.add(createNewBlock(3L));
// When RocksBlockStore.iterator(), return mock iterator
AtomicBoolean blockIteratorClosed = new AtomicBoolean(false);
CloseableIterator<BlockStore.Block> testBlockIter = CloseableIterator.create(blocks.iterator(), (whatever) -> blockIteratorClosed.set(true));
RocksBlockStore mockBlockStore = mock(RocksBlockStore.class);
when(mockBlockStore.iterator()).thenReturn(testBlockIter);
// Prepare the BlockMaster for the backup operation
CoreMasterContext masterContext = MasterTestUtils.testMasterContext(new NoopJournalSystem(), null, () -> mockBlockStore, x -> new HeapInodeStore());
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
mBlockMaster = new DefaultBlockMaster(mMetricsMaster, masterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
mRegistry.add(BlockMaster.class, mBlockMaster);
mRegistry.start(true);
// Perform the backup operation
BackupManager manager = new BackupManager(mRegistry);
File backupDir = AlluxioTestDirectory.createTemporaryDirectory("backup-dir");
File backupFile = new File(backupDir, "1.backup");
AtomicLong counter = new AtomicLong(0L);
manager.backup(new FileOutputStream(backupFile), counter);
// verify iterators all closed properly
assertTrue(blockIteratorClosed.get());
}
Aggregations