blob: 93cd68f6dd617bfa2cc319906a5cb4b4c7e6a73c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.deploy;
import com.google.common.io.Files;
import com.yahoo.config.provision.TenantName;
import com.yahoo.io.IOUtils;
import com.yahoo.path.Path;
import com.yahoo.vespa.config.server.ConfigServerDB;
import java.io.File;
/*
* Holds file system directories for a tenant
*
* @author tonytv
*/
public class TenantFileSystemDirs {
private final File serverDB;
private final TenantName tenant;
public TenantFileSystemDirs(File dir, TenantName tenant) {
this.serverDB = dir;
this.tenant = tenant;
ConfigServerDB.createDirectory(sessionsPath());
}
public static TenantFileSystemDirs createTestDirs(TenantName tenantName) {
return new TenantFileSystemDirs(Files.createTempDir(), tenantName);
}
public File sessionsPath() {
return new File(serverDB, Path.fromString("tenants").append(tenant.value()).append("sessions").getRelative());
}
public File getUserApplicationDir(long generation) {
return new File(sessionsPath(), String.valueOf(generation));
}
public void delete() {
IOUtils.recursiveDeleteDir(new File(serverDB, Path.fromString("tenants").append(tenant.value()).getRelative()));
}
}
|