use of com.yahoo.path.Path in project vespa by vespa-engine.
the class ApplicationFileTest method testApplicationFile.
@Test
public void testApplicationFile() throws Exception {
Path p1 = Path.fromString("foo/bar/baz");
ApplicationFile f1 = getApplicationFile(p1);
ApplicationFile f2 = getApplicationFile(p1);
assertThat(f1.getPath(), is(p1));
assertThat(f2.getPath(), is(p1));
}
use of com.yahoo.path.Path in project vespa by vespa-engine.
the class TensorFlowFeatureConverter method transformLargeConstant.
private void transformLargeConstant(ModelStore store, RankProfile profile, QueryProfileRegistry queryProfiles, Set<String> constantsReplacedByMacros, String constantName, Tensor constantValue) {
RankProfile.Macro macroOverridingConstant = profile.getMacros().get(constantName);
if (macroOverridingConstant != null) {
TensorType macroType = macroOverridingConstant.getRankingExpression().type(profile.typeContext(queryProfiles));
if (!macroType.equals(constantValue.type()))
throw new IllegalArgumentException("Macro '" + constantName + "' replaces the constant with this name. " + "The required type of this is " + constantValue.type() + ", but the macro returns " + macroType);
// will replace constant(constantName) by constantName later
constantsReplacedByMacros.add(constantName);
} else {
Path constantPath = store.writeLargeConstant(constantName, constantValue);
if (!profile.getSearch().getRankingConstants().containsKey(constantName)) {
profile.getSearch().addRankingConstant(new RankingConstant(constantName, constantValue.type(), constantPath.toString()));
}
}
}
use of com.yahoo.path.Path in project vespa by vespa-engine.
the class RemoteSessionFactory method createSession.
public RemoteSession createSession(long sessionId) {
Path sessionPath = this.sessionsPath.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);
}
use of com.yahoo.path.Path in project vespa by vespa-engine.
the class SessionFactoryImpl method create.
private LocalSession create(File applicationFile, String applicationName, long currentlyActiveSession, TimeoutBudget timeoutBudget) {
long sessionId = sessionCounter.nextSessionId();
Path sessionIdPath = sessionsPath.append(String.valueOf(sessionId));
log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute());
try {
ensureZKPathDoesNotExist(sessionIdPath);
SessionZooKeeperClient sessionZooKeeperClient = new SessionZooKeeperClient(curator, configCurator, sessionIdPath, defRepo, serverId, nodeFlavors);
File userApplicationDir = tenantFileSystemDirs.getUserApplicationDir(sessionId);
IOUtils.copyDirectory(applicationFile, userApplicationDir);
ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, applicationName, sessionId, currentlyActiveSession);
applicationPackage.writeMetaData();
return createSessionFromApplication(applicationPackage, sessionId, sessionZooKeeperClient, timeoutBudget, clock);
} catch (Exception e) {
throw new RuntimeException("Error creating session " + sessionIdPath, e);
}
}
use of com.yahoo.path.Path in project vespa by vespa-engine.
the class RemoteSessionRepo method sessionAdded.
/**
* A session for which we don't have a watcher, i.e. hitherto unknown to us.
*
* @param sessionId session id for the new session
*/
private void sessionAdded(long sessionId) {
try {
log.log(LogLevel.DEBUG, "Adding session to RemoteSessionRepo: " + sessionId);
RemoteSession session = remoteSessionFactory.createSession(sessionId);
Path sessionPath = sessionsPath.append(String.valueOf(sessionId));
Curator.FileCache fileCache = curator.createFileCache(sessionPath.append(ConfigCurator.SESSIONSTATE_ZK_SUBPATH).getAbsolute(), false);
fileCache.addListener(this);
loadSessionIfActive(session);
sessionStateWatchers.put(sessionId, new SessionStateWatcher(fileCache, reloadHandler, session, metrics));
internalAddSession(session);
metrics.incAddedSessions();
} catch (Exception e) {
log.log(Level.WARNING, "Failed loading session " + sessionId + ": No config for this session can be served", e);
}
}
Aggregations