/** * retrieve the next path to use for writing. Increments the internal filenum. */ private Path getNewPath() throws IOException { this.filenum.set(System.currentTimeMillis()); Path newPath = getCurrentFileName(); while (fs.exists(newPath)) { this.filenum.incrementAndGet(); newPath = getCurrentFileName(); } return newPath; }
/** * return the current filename from the current wal. */ @VisibleForTesting public static Path getCurrentFileName(final WAL wal) { return ((AbstractFSWAL<?>) wal).getCurrentFileName(); }
/** * It returns the file create timestamp from the file name. For name format see * {@link #validateWALFilename(String)} public until remaining tests move to o.a.h.h.wal * @param wal must not be null * @return the file number that is part of the WAL file name */ @VisibleForTesting public static long extractFileNumFromWAL(final WAL wal) { final Path walName = ((AbstractFSWAL<?>) wal).getCurrentFileName(); if (walName == null) { throw new IllegalArgumentException("The WAL path couldn't be null"); } Matcher matcher = WAL_FILE_NAME_PATTERN.matcher(walName.getName()); if (matcher.matches()) { return Long.parseLong(matcher.group(2)); } else { throw new IllegalArgumentException(walName.getName() + " is not a valid wal file name"); } }
private void waitUntilReplicatedToTheCurrentWALFile(HRegionServer rs) throws Exception { Path path = ((AbstractFSWAL<?>) rs.getWAL(null)).getCurrentFileName(); String logPrefix = AbstractFSWALProvider.getWALPrefixFromWALName(path.getName()); UTIL.waitFor(30000, new ExplainingPredicate<Exception>() { @Override public boolean evaluate() throws Exception { ReplicationSourceManager manager = ((Replication) rs.getReplicationSourceService()).getReplicationManager(); return manager.getWALs().get(PEER_ID).get(logPrefix).size() == 1; } @Override public String explainFailure() throws Exception { return "Still not replicated to the current WAL file yet"; } }); }
incThread.join(); Path logPath = ((AbstractFSWAL<?>) region.getWAL()).getCurrentFileName(); region.getWAL().rollWriter(); Thread.sleep(10);
HRegionServer server = TEST_UTIL.getHBaseCluster().getRegionServer(0); AbstractFSWAL<?> wal = (AbstractFSWAL<?>) server.getWAL(null); Path currentFile = wal.getCurrentFileName();
private long getMaxSeqId(HRegionServer rs, RegionInfo region) throws IOException { Path walFile = ((AbstractFSWAL<?>) rs.getWAL(null)).getCurrentFileName(); long maxSeqId = -1L; try (WAL.Reader reader = WALFactory.createReader(UTIL.getTestFileSystem(), walFile, UTIL.getConfiguration())) { for (;;) { WAL.Entry entry = reader.next(); if (entry == null) { break; } if (Bytes.equals(region.getEncodedNameAsBytes(), entry.getKey().getEncodedRegionName())) { maxSeqId = Math.max(maxSeqId, entry.getKey().getSequenceId()); } } } return maxSeqId; }
String walGroupId = AbstractFSWALProvider.getWALPrefixFromWALName( ((AbstractFSWAL<?>) rs.getWAL(RegionInfoBuilder.newBuilder(TABLE_NAME).build())) .getCurrentFileName().getName()); UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
private void waitUntilReplicatedToTheCurrentWALFile(HRegionServer rs) throws Exception { Path path = ((AbstractFSWAL<?>) rs.getWAL(null)).getCurrentFileName(); String logPrefix = AbstractFSWALProvider.getWALPrefixFromWALName(path.getName()); UTIL.waitFor(30000, new ExplainingPredicate<Exception>() { @Override public boolean evaluate() throws Exception { ReplicationSourceManager manager = ((Replication) rs.getReplicationSourceService()).getReplicationManager(); return manager.getWALs().get(PEER_ID).get(logPrefix).size() == 1; } @Override public String explainFailure() throws Exception { return "Still not replicated to the current WAL file yet"; } }); }
incThread.join(); Path logPath = ((AbstractFSWAL<?>) region.getWAL()).getCurrentFileName(); region.getWAL().rollWriter(); Thread.sleep(10);
HRegionServer server = TEST_UTIL.getHBaseCluster().getRegionServer(0); AbstractFSWAL<?> wal = (AbstractFSWAL<?>) server.getWAL(null); Path currentFile = wal.getCurrentFileName();
private long getMaxSeqId(HRegionServer rs, RegionInfo region) throws IOException { Path walFile = ((AbstractFSWAL<?>) rs.getWAL(null)).getCurrentFileName(); long maxSeqId = -1L; try (WAL.Reader reader = WALFactory.createReader(UTIL.getTestFileSystem(), walFile, UTIL.getConfiguration())) { for (;;) { WAL.Entry entry = reader.next(); if (entry == null) { break; } if (Bytes.equals(region.getEncodedNameAsBytes(), entry.getKey().getEncodedRegionName())) { maxSeqId = Math.max(maxSeqId, entry.getKey().getSequenceId()); } } } return maxSeqId; }