Search in sources :

Example 1 with Path

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));
}
Also used : Path(com.yahoo.path.Path) ApplicationFile(com.yahoo.config.application.api.ApplicationFile) Test(org.junit.Test)

Example 2 with Path

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()));
        }
    }
}
Also used : Path(com.yahoo.path.Path) RankProfile(com.yahoo.searchdefinition.RankProfile) TensorType(com.yahoo.tensor.TensorType) RankingConstant(com.yahoo.searchdefinition.RankingConstant)

Example 3 with Path

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);
}
Also used : Path(com.yahoo.path.Path)

Example 4 with Path

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);
    }
}
Also used : Path(com.yahoo.path.Path) File(java.io.File) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Example 5 with Path

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);
    }
}
Also used : Path(com.yahoo.path.Path) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) Curator(com.yahoo.vespa.curator.Curator)

Aggregations

Path (com.yahoo.path.Path)32 Test (org.junit.Test)10 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)4 ConfigCurator (com.yahoo.vespa.config.server.zookeeper.ConfigCurator)4 File (java.io.File)4 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)3 Node (com.yahoo.vespa.curator.mock.MemoryFileSystem.Node)3 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)3 KeeperException (org.apache.zookeeper.KeeperException)3 RankingConstant (com.yahoo.searchdefinition.RankingConstant)2 Curator (com.yahoo.vespa.curator.Curator)2 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)1 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 TenantName (com.yahoo.config.provision.TenantName)1 NamedReader (com.yahoo.io.reader.NamedReader)1 RankProfile (com.yahoo.searchdefinition.RankProfile)1 Tensor (com.yahoo.tensor.Tensor)1 TensorType (com.yahoo.tensor.TensorType)1 NestedTransaction (com.yahoo.transaction.NestedTransaction)1