Search in sources :

Example 11 with MetricsMasterFactory

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);
}
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 MetricsMasterFactory

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());
}
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 13 with MetricsMasterFactory

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);
}
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 14 with MetricsMasterFactory

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);
}
Also used : RocksInodeStore(alluxio.master.metastore.rocks.RocksInodeStore) InodeView(alluxio.master.file.meta.InodeView) DefaultBlockMaster(alluxio.master.block.DefaultBlockMaster) ArrayList(java.util.ArrayList) HeapBlockStore(alluxio.master.metastore.heap.HeapBlockStore) DefaultFileSystemMaster(alluxio.master.file.DefaultFileSystemMaster) FileSystemMaster(alluxio.master.file.FileSystemMaster) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) InodeDirectory(alluxio.master.file.meta.InodeDirectory) AtomicLong(java.util.concurrent.atomic.AtomicLong) DefaultFileSystemMaster(alluxio.master.file.DefaultFileSystemMaster) FileOutputStream(java.io.FileOutputStream) File(java.io.File) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Test(org.junit.Test)

Example 15 with MetricsMasterFactory

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());
}
Also used : DefaultBlockMaster(alluxio.master.block.DefaultBlockMaster) ArrayList(java.util.ArrayList) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) RocksBlockStore(alluxio.master.metastore.rocks.RocksBlockStore) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicLong(java.util.concurrent.atomic.AtomicLong) FileOutputStream(java.io.FileOutputStream) Block(alluxio.proto.meta.Block) File(java.io.File) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Test(org.junit.Test)

Aggregations

MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)18 MasterRegistry (alluxio.master.MasterRegistry)15 BlockMasterFactory (alluxio.master.block.BlockMasterFactory)12 CoreMasterContext (alluxio.master.CoreMasterContext)11 Before (org.junit.Before)9 JournalSystem (alluxio.master.journal.JournalSystem)6 ManualClock (alluxio.clock.ManualClock)4 MountInfo (alluxio.master.file.meta.options.MountInfo)4 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)4 UfsManager (alluxio.underfs.UfsManager)4 DefaultBlockMaster (alluxio.master.block.DefaultBlockMaster)3 FileSystemMasterFactory (alluxio.master.file.FileSystemMasterFactory)3 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 BlockMaster (alluxio.master.block.BlockMaster)2 FileSystemMaster (alluxio.master.file.FileSystemMaster)2 MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)2 TestUserState (alluxio.security.user.TestUserState)2