|
53 | 53 | import java.nio.ByteBuffer; |
54 | 54 | import java.nio.file.Files; |
55 | 55 | import java.nio.file.StandardCopyOption; |
56 | | -import java.util.Arrays; |
57 | | -import java.util.Comparator; |
58 | 56 | import java.util.Optional; |
59 | 57 | import java.util.concurrent.ExecutorService; |
60 | 58 | import java.util.concurrent.ScheduledExecutorService; |
61 | 59 | import java.util.concurrent.TimeUnit; |
62 | | -import java.util.regex.Pattern; |
63 | 60 |
|
64 | 61 | /** StateMachine for ConfigRegion. */ |
65 | 62 | public class ConfigRegionStateMachine implements IStateMachine, IStateMachine.EventApi { |
@@ -87,8 +84,6 @@ public class ConfigRegionStateMachine implements IStateMachine, IStateMachine.Ev |
87 | 84 | private static final long LOG_FILE_MAX_SIZE = |
88 | 85 | CONF.getConfigNodeSimpleConsensusLogSegmentSizeMax(); |
89 | 86 | private final TEndPoint currentNodeTEndPoint; |
90 | | - private static Pattern LOG_INPROGRESS_PATTERN = Pattern.compile("\\d+"); |
91 | | - private static Pattern LOG_PATTERN = Pattern.compile("(?<=_)(\\d+)$"); |
92 | 87 |
|
93 | 88 | public ConfigRegionStateMachine(ConfigManager configManager, ConfigPlanExecutor executor) { |
94 | 89 | this.executor = executor; |
@@ -328,7 +323,6 @@ private void initStandAloneConfigNode() { |
328 | 323 | dir.mkdirs(); |
329 | 324 | String[] list = new File(CURRENT_FILE_DIR).list(); |
330 | 325 | if (list != null && list.length != 0) { |
331 | | - Arrays.sort(list, new FileComparator()); |
332 | 326 | for (String logFileName : list) { |
333 | 327 | File logFile = |
334 | 328 | SystemFileFactory.INSTANCE.getFile(CURRENT_FILE_DIR + File.separator + logFileName); |
@@ -401,21 +395,4 @@ private void createLogFile(int endIndex) { |
401 | 395 | e); |
402 | 396 | } |
403 | 397 | } |
404 | | - |
405 | | - static class FileComparator implements Comparator<String> { |
406 | | - @Override |
407 | | - public int compare(String filename1, String filename2) { |
408 | | - long id1 = parseEndIndex(filename1); |
409 | | - long id2 = parseEndIndex(filename2); |
410 | | - return Long.compare(id1, id2); |
411 | | - } |
412 | | - } |
413 | | - |
414 | | - static long parseEndIndex(String filename) { |
415 | | - if (filename.startsWith("log_inprogress_")) { |
416 | | - return Long.parseLong(LOG_INPROGRESS_PATTERN.matcher(filename).group()); |
417 | | - } else { |
418 | | - return Long.parseLong(LOG_PATTERN.matcher(filename).group()); |
419 | | - } |
420 | | - } |
421 | 398 | } |
0 commit comments