Skip to content

Commit

Permalink
[hotfix] Replace nio.Path with File in RestHandlerConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
tillrohrmann committed Apr 13, 2018
1 parent 6356128 commit 7a78d00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
Expand Down Expand Up @@ -539,9 +537,9 @@ private Configuration generateClusterConfiguration(Configuration configuration)
final Configuration resultConfiguration = new Configuration(Preconditions.checkNotNull(configuration));

final String webTmpDir = configuration.getString(WebOptions.TMP_DIR);
final Path uniqueWebTmpDir = Paths.get(webTmpDir, "flink-web-" + UUID.randomUUID());
final File uniqueWebTmpDir = new File(webTmpDir, "flink-web-" + UUID.randomUUID());

resultConfiguration.setString(WebOptions.TMP_DIR, uniqueWebTmpDir.toAbsolutePath().toString());
resultConfiguration.setString(WebOptions.TMP_DIR, uniqueWebTmpDir.getAbsolutePath());

return resultConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
import org.apache.flink.configuration.WebOptions;
import org.apache.flink.util.Preconditions;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.File;

/**
* Configuration object containing values for the rest handler configuration.
Expand All @@ -37,13 +36,13 @@ public class RestHandlerConfiguration {

private final Time timeout;

private final Path webUiDir;
private final File webUiDir;

public RestHandlerConfiguration(
long refreshInterval,
int maxCheckpointStatisticCacheEntries,
Time timeout,
Path webUiDir) {
File webUiDir) {
Preconditions.checkArgument(refreshInterval > 0L, "The refresh interval (ms) should be larger than 0.");
this.refreshInterval = refreshInterval;

Expand All @@ -65,7 +64,7 @@ public Time getTimeout() {
return timeout;
}

public Path getWebUiDir() {
public File getWebUiDir() {
return webUiDir;
}

Expand All @@ -77,7 +76,7 @@ public static RestHandlerConfiguration fromConfiguration(Configuration configura
final Time timeout = Time.milliseconds(configuration.getLong(WebOptions.TIMEOUT));

final String rootDir = "flink-web-ui";
final Path webUiDir = Paths.get(configuration.getString(WebOptions.TMP_DIR), rootDir);
final File webUiDir = new File(configuration.getString(WebOptions.TMP_DIR), rootDir);

return new RestHandlerConfiguration(
refreshInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -516,7 +515,7 @@ protected List<Tuple2<RestHandlerSpecification, ChannelInboundHandler>> initiali
timeout,
responseHeaders);

final Path webUiDir = restConfiguration.getWebUiDir();
final File webUiDir = restConfiguration.getWebUiDir();

Optional<StaticFileServerHandler<T>> optWebContent;

Expand All @@ -525,7 +524,7 @@ protected List<Tuple2<RestHandlerSpecification, ChannelInboundHandler>> initiali
leaderRetriever,
restAddressFuture,
timeout,
webUiDir.toFile());
webUiDir);
} catch (IOException e) {
log.warn("Could not load web content handler.", e);
optWebContent = Optional.empty();
Expand Down Expand Up @@ -655,15 +654,15 @@ protected CompletableFuture<Void> shutDownInternal() {

final CompletableFuture<Void> shutdownFuture = super.shutDownInternal();

final Path webUiDir = restConfiguration.getWebUiDir();
final File webUiDir = restConfiguration.getWebUiDir();

return FutureUtils.runAfterwardsAsync(
shutdownFuture,
() -> {
Exception exception = null;
try {
log.info("Removing cache directory {}", webUiDir);
FileUtils.deleteDirectory(webUiDir.toFile());
FileUtils.deleteDirectory(webUiDir);
} catch (Exception e) {
exception = e;
}
Expand Down

0 comments on commit 7a78d00

Please sign in to comment.