• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #9905

23 Aug 2023 06:20AM UTC coverage: 47.785% (-0.1%) from 47.922%
#9905

push

travis_ci

web-flow
[To rel/1.2][Metric] Fix flush point statistics (#10934)

23 of 23 new or added lines in 1 file covered. (100.0%)

79851 of 167106 relevant lines covered (47.78%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.59
/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/common/Utils.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19
package org.apache.iotdb.consensus.common;
20

21
import org.slf4j.Logger;
22
import org.slf4j.LoggerFactory;
23

24
import java.io.File;
25
import java.io.IOException;
26
import java.nio.file.FileVisitResult;
27
import java.nio.file.FileVisitor;
28
import java.nio.file.Files;
29
import java.nio.file.Path;
30
import java.nio.file.attribute.BasicFileAttributes;
31
import java.util.ArrayList;
32
import java.util.Collections;
33
import java.util.List;
34

35
public class Utils {
36
  private static final Logger logger = LoggerFactory.getLogger(Utils.class);
1✔
37

38
  private Utils() {}
39

40
  public static List<Path> listAllRegularFilesRecursively(File rootDir) {
41
    List<Path> allFiles = new ArrayList<>();
1✔
42
    try {
43
      Files.walkFileTree(
1✔
44
          rootDir.toPath(),
1✔
45
          new FileVisitor<Path>() {
1✔
46
            @Override
47
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
48
              return FileVisitResult.CONTINUE;
1✔
49
            }
50

51
            @Override
52
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
53
              if (attrs.isRegularFile()) {
1✔
54
                allFiles.add(file);
1✔
55
              }
56
              return FileVisitResult.CONTINUE;
1✔
57
            }
58

59
            @Override
60
            public FileVisitResult visitFileFailed(Path file, IOException exc) {
61
              logger.info("visit file {} failed due to {}", file.toAbsolutePath(), exc);
×
62
              return FileVisitResult.TERMINATE;
×
63
            }
64

65
            @Override
66
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
67
              return FileVisitResult.CONTINUE;
1✔
68
            }
69
          });
70
    } catch (IOException ioException) {
×
71
      logger.error("IOException occurred during listing snapshot directory: ", ioException);
×
72
      return Collections.emptyList();
×
73
    }
1✔
74
    return allFiles;
1✔
75
  }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc