Gitlab Community Edition Instance

Commit be5a1158 authored by mhellka's avatar mhellka
Browse files

Log failing SessionListener hooks.

parent 5e06abe7
Pipeline #120054 passed with stages
in 10 minutes and 1 second
......@@ -14,12 +14,22 @@ public interface SessionListener {
default void onVaultOpenend(CDStarVault vault) {
}
/**
* Called during prepare phase, before the archives are committed but after the
* transaction was marked as prparing.
*/
default void onPrepare(CDStarSession session) {
}
/**
* Called after a successful commit. Errors thrown here are logged but ignored.
*/
default void onCommit(CDStarSession session) {
}
/**
* Called after a session rollback. Errors are logged but ignored.
*/
default void onRollback(CDStarSession session) {
}
......
......@@ -8,6 +8,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.gwdg.cdstar.GromitIterable;
import de.gwdg.cdstar.runtime.VaultConfig;
import de.gwdg.cdstar.runtime.client.exc.VaultNotFound;
......@@ -21,6 +24,7 @@ import de.gwdg.cdstar.ta.UserTransaction;
import de.gwdg.cdstar.ta.exc.TARollbackException;
class SessionImpl implements CDStarSession {
private static final Logger listenerLog = LoggerFactory.getLogger(SessionListener.class);
private final class TransactionListenerBridge implements TAListener {
......@@ -31,12 +35,14 @@ class SessionImpl implements CDStarSession {
@Override
public void afterCommit(TransactionInfo t) {
listeners.forEach(l -> l.onCommit(SessionImpl.this));
listeners.forEach(l -> l.onCommit(SessionImpl.this),
e -> listenerLog.warn("After-commit hook for session {} failed", tx.getId(), e));
}
@Override
public void afterRollback(TransactionInfo t) {
listeners.forEach(l -> l.onRollback(SessionImpl.this));
listeners.forEach(l -> l.onRollback(SessionImpl.this),
e -> listenerLog.warn("After-rollback hook for session {} failed", tx.getId(), e));
}
}
......@@ -47,7 +53,7 @@ class SessionImpl implements CDStarSession {
private final ArrayList<VaultImpl> vaults = new ArrayList<>(1);
long timeout = -1;
private Map<String, Object> context;
private VaultRegistry vaultRegistry;
private final VaultRegistry vaultRegistry;
/**
* Create a new session
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment