From: Robert Varga Date: Fri, 3 May 2019 10:48:34 +0000 (+0200) Subject: Change segmented journal naming X-Git-Tag: release/sodium~103 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=849e994c06fe5fd78bf72bddbf07e7d32576b84b Change segmented journal naming Using Base64 encoding is not quite nice for debugging purposes, use URLEncoder, so that we are consistent with snapshot store JIRA: CONTROLLER-1884 Change-Id: I55f7bef79b7d5c14ab10180444770fedcc23eab9 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java b/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java index 1dfcf4aef6..ac59c8fb41 100644 --- a/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java +++ b/opendaylight/md-sal/sal-akka-segmented-journal/src/main/java/org/opendaylight/controller/akka/segjournal/SegmentedFileJournal.java @@ -21,9 +21,10 @@ import com.typesafe.config.ConfigMemorySize; import io.atomix.storage.StorageLevel; import io.atomix.storage.journal.SegmentedJournal; import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Base64; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -116,8 +117,7 @@ public class SegmentedFileJournal extends AsyncWriteJournal { } private ActorRef createHandler(final String persistenceId) { - final String directoryName = Base64.getUrlEncoder().encodeToString(persistenceId.getBytes( - StandardCharsets.UTF_8)); + final String directoryName = encode(persistenceId); final File directory = new File(rootDir, directoryName); LOG.debug("Creating handler for {} in directory {}", persistenceId, directory); @@ -142,6 +142,16 @@ public class SegmentedFileJournal extends AsyncWriteJournal { return message.promise.future(); } + private static String encode(final String str) { + try { + return URLEncoder.encode(str, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + // Shouldn't happen + LOG.warn("Error encoding {}", str, e); + return str; + } + } + private static int getBytes(final Config config, final String path, final int defaultValue) { if (!config.hasPath(path)) { return defaultValue;