Skip to content

Commit

Permalink
Revert "Fixed issue where ConfigNode might recover incorrectly under …
Browse files Browse the repository at this point in the history
…SimpleConsensus" (apache#11987)
  • Loading branch information
SpriCoder authored Jan 27, 2024
1 parent a544517 commit 769a151
Showing 1 changed file with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

/** StateMachine for ConfigRegion. */
public class ConfigRegionStateMachine implements IStateMachine, IStateMachine.EventApi {
Expand Down Expand Up @@ -87,8 +84,6 @@ public class ConfigRegionStateMachine implements IStateMachine, IStateMachine.Ev
private static final long LOG_FILE_MAX_SIZE =
CONF.getConfigNodeSimpleConsensusLogSegmentSizeMax();
private final TEndPoint currentNodeTEndPoint;
private static Pattern LOG_INPROGRESS_PATTERN = Pattern.compile("\\d+");
private static Pattern LOG_PATTERN = Pattern.compile("(?<=_)(\\d+)$");

public ConfigRegionStateMachine(ConfigManager configManager, ConfigPlanExecutor executor) {
this.executor = executor;
Expand Down Expand Up @@ -328,7 +323,6 @@ private void initStandAloneConfigNode() {
dir.mkdirs();
String[] list = new File(CURRENT_FILE_DIR).list();
if (list != null && list.length != 0) {
Arrays.sort(list, new FileComparator());
for (String logFileName : list) {
File logFile =
SystemFileFactory.INSTANCE.getFile(CURRENT_FILE_DIR + File.separator + logFileName);
Expand Down Expand Up @@ -401,21 +395,4 @@ private void createLogFile(int endIndex) {
e);
}
}

static class FileComparator implements Comparator<String> {
@Override
public int compare(String filename1, String filename2) {
long id1 = parseEndIndex(filename1);
long id2 = parseEndIndex(filename2);
return Long.compare(id1, id2);
}
}

static long parseEndIndex(String filename) {
if (filename.startsWith("log_inprogress_")) {
return Long.parseLong(LOG_INPROGRESS_PATTERN.matcher(filename).group());
} else {
return Long.parseLong(LOG_PATTERN.matcher(filename).group());
}
}
}

0 comments on commit 769a151

Please sign in to comment.