@Override public boolean evaluate() throws Exception { return !mfs.getWALFileSystem().exists(remoteWAL); }
@VisibleForTesting protected void createDirForRemoteWAL(MasterProcedureEnv env) throws IOException { MasterFileSystem mfs = env.getMasterFileSystem(); Path remoteWALDir = new Path(mfs.getWALRootDir(), ReplicationUtils.REMOTE_WAL_DIR_NAME); Path remoteWALDirForPeer = ReplicationUtils.getPeerRemoteWALDir(remoteWALDir, peerId); FileSystem walFs = mfs.getWALFileSystem(); if (walFs.exists(remoteWALDirForPeer)) { LOG.warn("Wal dir {} already exists, usually this should not happen, continue anyway", remoteWALDirForPeer); } else if (!walFs.mkdirs(remoteWALDirForPeer)) { throw new IOException("Failed to create remote wal dir " + remoteWALDirForPeer); } }
public MasterWalManager(MasterServices services) throws IOException { this(services.getConfiguration(), services.getMasterFileSystem().getWALFileSystem(), services.getMasterFileSystem().getWALRootDir(), services); }
public SyncReplicationReplayWALManager(MasterServices services) throws IOException, ReplicationException { this.serverManager = services.getServerManager(); this.fs = services.getMasterFileSystem().getWALFileSystem(); this.walRootDir = services.getMasterFileSystem().getWALRootDir(); this.remoteWALDir = new Path(this.walRootDir, ReplicationUtils.REMOTE_WAL_DIR_NAME); serverManager.registerListener(new ServerListener() { @Override public void serverAdded(ServerName serverName) { MasterProcedureScheduler scheduler = services.getMasterProcedureExecutor().getEnvironment().getProcedureScheduler(); for (UsedReplayWorkersForPeer usedWorkers : usedWorkersByPeer.values()) { synchronized (usedWorkers) { usedWorkers.wake(scheduler); } } } }); }
MasterFileSystem mfs = UTIL2.getHBaseCluster().getMaster().getMasterFileSystem(); Path remoteWALDir = getRemoteWALDir(mfs, PEER_ID); assertFalse(mfs.getWALFileSystem().exists(remoteWALDir)); UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.STANDBY); assertTrue(mfs.getWALFileSystem().exists(remoteWALDir)); try (Table table = UTIL2.getConnection().getTable(TABLE_NAME)) { assertDisallow(table, t -> t.get(new Get(Bytes.toBytes("row"))));
MasterFileSystem mfs = UTIL2.getHBaseCluster().getMaster().getMasterFileSystem(); Path remoteWALDir = getRemoteWALDir(mfs, PEER_ID); assertFalse(mfs.getWALFileSystem().exists(remoteWALDir)); UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.STANDBY); assertTrue(mfs.getWALFileSystem().exists(remoteWALDir)); UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.ACTIVE);
Path remoteWALDir = ReplicationUtils.getPeerRemoteWALDir( new Path(mfs.getWALRootDir(), ReplicationUtils.REMOTE_WAL_DIR_NAME), PEER_ID); FileStatus[] remoteWALStatus = mfs.getWALFileSystem().listStatus(remoteWALDir); assertEquals(1, remoteWALStatus.length); Path remoteWAL = remoteWALStatus[0].getPath(); remoteWALStatus = mfs.getWALFileSystem().listStatus(remoteWALDir); assertEquals(1, remoteWALStatus.length); remoteWAL = remoteWALStatus[0].getPath(); assertTrue(mfs.getWALFileSystem().exists(remoteWAL));
@BeforeClass public static void setupCluster() throws Exception { UTIL.startMiniCluster(RS_NUMBER); UTIL.getHBaseCluster().waitForActiveAndReadyMaster(); conf = UTIL.getConfiguration(); HMaster master = UTIL.getHBaseCluster().getMaster(); fs = master.getMasterFileSystem().getWALFileSystem(); syncReplicationReplayWALManager = master.getSyncReplicationReplayWALManager(); procExec = master.getMasterProcedureExecutor(); }
MasterFileSystem mfs = UTIL2.getHBaseCluster().getMaster().getMasterFileSystem(); Path remoteWALDir = getRemoteWALDir(mfs, PEER_ID); assertFalse(mfs.getWALFileSystem().exists(remoteWALDir)); UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.STANDBY); assertTrue(mfs.getWALFileSystem().exists(remoteWALDir)); UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.ACTIVE);
Path remoteWALDir = ReplicationUtils.getPeerRemoteWALDir( new Path(mfs.getWALRootDir(), ReplicationUtils.REMOTE_WAL_DIR_NAME), PEER_ID); FileStatus[] remoteWALStatus = mfs.getWALFileSystem().listStatus(remoteWALDir); assertEquals(1, remoteWALStatus.length); Path remoteWAL = remoteWALStatus[0].getPath();
@Before public void before() throws IOException { MasterFileSystem mfs = Mockito.mock(MasterFileSystem.class); Mockito.when(mfs.getWALFileSystem()).thenReturn(HTU.getTestFileSystem()); Path walRootDir = HTU.createWALRootDir(); Mockito.when(mfs.getWALRootDir()).thenReturn(walRootDir); this.masterServices = Mockito.mock(MasterServices.class); Mockito.when(this.masterServices.getConfiguration()).thenReturn(HTU.getConfiguration()); Mockito.when(this.masterServices.getMasterFileSystem()).thenReturn(mfs); Mockito.when(this.masterServices.getServerName()). thenReturn(ServerName.parseServerName("master.example.org,0123,456")); this.mwm = new MasterWalManager(this.masterServices); }
@Test public void testIsWALDirectoryNameWithWALs() throws IOException { ServerName sn = ServerName.parseServerName("x.example.org,1234,5678"); assertFalse(this.mwm.isWALDirectoryNameWithWALs(sn)); FileSystem walFS = this.masterServices.getMasterFileSystem().getWALFileSystem(); Path dir = new Path(this.mwm.getWALDirPath(), sn.toString()); assertTrue(walFS.mkdirs(dir)); assertTrue(this.mwm.isWALDirectoryNameWithWALs(sn)); // Make sure works when dir is SPLITTING Set<ServerName> sns = new HashSet<ServerName>(); sns.add(sn); List<Path> paths = this.mwm.createAndGetLogDirs(sns); assertTrue(this.mwm.isWALDirectoryNameWithWALs(sn)); } }