blob: 298acaca9017a997aeccc37d0f2f151b6dce3753 (
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
44
45
46
47
48
49
50
51
52
53
|
// 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.session;
import com.yahoo.config.provision.TenantName;
import com.yahoo.path.Path;
import com.yahoo.config.model.api.ConfigDefinitionRepo;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.vespa.config.server.GlobalComponentRegistry;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
import com.yahoo.vespa.curator.Curator;
import java.time.Clock;
/**
* @author Ulf Lilleengen
*/
public class RemoteSessionFactory {
private final GlobalComponentRegistry componentRegistry;
private final Curator curator;
private final ConfigCurator configCurator;
private final Path sessionDirPath;
private final ConfigDefinitionRepo defRepo;
private final TenantName tenant;
private final ConfigserverConfig configserverConfig;
private final Clock clock;
public RemoteSessionFactory(GlobalComponentRegistry componentRegistry,
Path sessionsPath,
TenantName tenant,
Clock clock) {
this.componentRegistry = componentRegistry;
this.curator = componentRegistry.getCurator();
this.configCurator = componentRegistry.getConfigCurator();
this.sessionDirPath = sessionsPath;
this.tenant = tenant;
this.defRepo = componentRegistry.getConfigDefinitionRepo();
this.configserverConfig = componentRegistry.getConfigserverConfig();
this.clock = clock;
}
public RemoteSession createSession(long sessionId) {
Path sessionPath = sessionDirPath.append(String.valueOf(sessionId));
SessionZooKeeperClient sessionZKClient = new SessionZooKeeperClient(curator,
configCurator,
sessionPath,
defRepo,
configserverConfig.serverId(),
componentRegistry.getZone().nodeFlavors());
return new RemoteSession(tenant, sessionId, componentRegistry, sessionZKClient, clock);
}
}
|