diff options
author | Harald Musum <musum@verizonmedia.com> | 2019-07-15 10:47:06 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2019-07-15 10:47:06 +0200 |
commit | 461f3270076319a6a16f51068423cae6a9b62a17 (patch) | |
tree | 1494a376662c69d09ccfaff1a84575575e951f5d /configserver | |
parent | ec17f2b9d074a8d96a3372c55064aa2591586ba0 (diff) |
Remove unused code
getSession() was always called with 0 timeout.
removeSession() was not in use.
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java | 2 | ||||
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java | 100 |
2 files changed, 3 insertions, 99 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 192488c11ab..091620a72f9 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -460,7 +460,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye Tenant tenant = tenantRepository.getTenant(applicationId.tenant()); if (tenant == null) throw new NotFoundException("Tenant '" + applicationId.tenant() + "' not found"); long sessionId = getSessionIdForApplication(tenant, applicationId); - RemoteSession session = tenant.getRemoteSessionRepo().getSession(sessionId, 0); + RemoteSession session = tenant.getRemoteSessionRepo().getSession(sessionId); return session.ensureApplicationLoaded().getForVersionOrLatest(version, clock.instant()); } catch (NotFoundException e) { log.log(LogLevel.WARNING, "Failed getting application for '" + applicationId + "': " + e.getMessage()); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java index 415ff268309..3400504fb58 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepo.java @@ -1,14 +1,6 @@ // 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.transaction.AbstractTransaction; -import com.yahoo.transaction.NestedTransaction; -import com.yahoo.transaction.Transaction; -import com.yahoo.vespa.config.server.TimeoutBudget; -import com.yahoo.vespa.config.server.NotFoundException; - -import java.time.Clock; -import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -29,16 +21,10 @@ public class SessionRepo<SESSIONTYPE extends Session> { sessions.put(session.getSessionId(), session); } - public synchronized SESSIONTYPE removeSession(long id) { + synchronized void removeSession(long id) { if ( ! sessions.containsKey(id)) throw new IllegalArgumentException("No session with id '" + id + "' exists"); - return sessions.remove(id); - } - - public void removeSession(long id, NestedTransaction nestedTransaction) { - SessionRepoTransaction transaction = new SessionRepoTransaction(); - transaction.addRemoveOperation(id); - nestedTransaction.add(transaction); + sessions.remove(id); } /** @@ -51,90 +37,8 @@ public class SessionRepo<SESSIONTYPE extends Session> { return sessions.get(id); } - /** - * Gets a Session with a timeout - * - * @param id session id - * @param timeoutInMillis timeout for getting session (loops and wait for session to show up if not found) - * @return a session belonging to the id supplied, or null if no session with the id was found - */ - public synchronized SESSIONTYPE getSession(long id, long timeoutInMillis) { - try { - return internalGetSession(id, timeoutInMillis); - } catch (InterruptedException e) { - throw new RuntimeException("Interrupted while retrieving session with id " + id); - } - } - - private synchronized SESSIONTYPE internalGetSession(long id, long timeoutInMillis) throws InterruptedException { - TimeoutBudget timeoutBudget = new TimeoutBudget(Clock.systemUTC(), Duration.ofMillis(timeoutInMillis)); - do { - SESSIONTYPE session = getSession(id); - if (session != null) { - return session; - } - wait(100); - } while (timeoutBudget.hasTimeLeft()); - throw new NotFoundException("Unable to retrieve session with id " + id + " before timeout was reached"); - } - public synchronized Collection<SESSIONTYPE> listSessions() { return new ArrayList<>(sessions.values()); } - public class SessionRepoTransaction extends AbstractTransaction { - - void addRemoveOperation(long sessionIdToRemove) { - add(new RemoveOperation(sessionIdToRemove)); - } - - @Override - public void prepare() { } - - @Override - @SuppressWarnings("unchecked") - public void commit() { - for (Operation operation : operations()) - ((SessionOperation)operation).commit(); - } - - @Override - @SuppressWarnings("unchecked") - public void rollbackOrLog() { - for (Operation operation : operations()) - ((SessionOperation)operation).rollback(); - } - - abstract class SessionOperation implements Transaction.Operation { - - abstract void commit(); - - abstract void rollback(); - - } - - public class RemoveOperation extends SessionOperation { - - private final long sessionIdToRemove; - private SESSIONTYPE removed = null; - - RemoveOperation(long sessionIdToRemove) { - this.sessionIdToRemove = sessionIdToRemove; - } - - @Override - public void commit() { - removed = removeSession(sessionIdToRemove); - } - - @Override - public void rollback() { - if (removed != null) - addSession(removed); - } - - } - - } - } |