use of io.hops.hopsworks.persistence.entity.airflow.MaterializedJWT in project hopsworks by logicalclocks.
the class JupyterJWTManager method cleanJWT.
@Lock(LockType.WRITE)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void cleanJWT(String cid, Integer port) {
Optional<JupyterJWT> optional = Optional.ofNullable(pidAndPortToJWT.get(new CidAndPort(cid, port)));
if (!optional.isPresent()) {
LOG.log(WARNING, "JupyterJWT not found for cid " + cid + " and port " + port);
return;
}
JupyterJWT element = optional.get();
try {
MaterializedJWTID materializedJWTID = new MaterializedJWTID(element.project.getId(), element.user.getUid(), MaterializedJWTID.USAGE.JUPYTER);
MaterializedJWT material = materializedJWTFacade.findById(materializedJWTID);
jwtTokenWriter.deleteToken(element);
if (material != null) {
materializedJWTFacade.delete(materializedJWTID);
}
removeToken(element.pidAndPort);
jwtController.invalidate(element.token);
} catch (Exception ex) {
// Catch everything and do not fail. If we failed to determine the status of Jupyter, we renew the token
// to be safe
LOG.log(Level.FINE, "Could not determine if Jupyter JWT for " + element + " is still valid. Renewing it...");
}
}
Aggregations