/** * Deletes the server. */ public void delete() { try { Files.walkFileTree(partition.dataDirectory().toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } }); } catch (IOException e) { log.error("Failed to delete partition: {}", e); } }
private RaftServer buildServer() { return RaftServer.builder(localMemberId) .withName(partition.name()) .withMembershipService(membershipService) .withProtocol(new RaftServerCommunicator( partition.name(), Serializer.using(RaftNamespaces.RAFT_PROTOCOL), clusterCommunicator)) .withPrimitiveTypes(primitiveTypes) .withElectionTimeout(Duration.ofMillis(ELECTION_TIMEOUT_MILLIS)) .withHeartbeatInterval(Duration.ofMillis(HEARTBEAT_INTERVAL_MILLIS)) .withStorage(RaftStorage.builder() .withPrefix(partition.name()) .withDirectory(partition.dataDirectory()) .withStorageLevel(config.getStorageConfig().getLevel()) .withMaxSegmentSize((int) config.getStorageConfig().getSegmentSize().bytes()) .withMaxEntrySize((int) config.getStorageConfig().getMaxEntrySize().bytes()) .withFlushOnCommit(config.getStorageConfig().isFlushOnCommit()) .withDynamicCompaction(config.getCompactionConfig().isDynamic()) .withFreeDiskBuffer(config.getCompactionConfig().getFreeDiskBuffer()) .withFreeMemoryBuffer(config.getCompactionConfig().getFreeMemoryBuffer()) .withNamespace(RaftNamespaces.RAFT_STORAGE) .build()) .withThreadContextFactory(threadContextFactory) .build(); }