public void report(final ProblemReport pr) { if (problemReports.containsKey(pr)) { return;
/** * Is the given username a member of the sysAdmin role * * @param username * User to verify membership in sysadmin role * @param repositoryConnection * RepositoryConnection to run queries against * @return * @throws BocaException */ public boolean isSystemUser(URI username, RepositoryConnection repositoryConnection) throws BocaException { try { resetLock.readLock().lock(); if (adminUsersCache.containsKey(username)) { Boolean isSystemUser = (Boolean) adminUsersCache.get(username); return isSystemUser.booleanValue(); } else { Long userId = repositoryConnection.getNodeLayout().fetchId(username); boolean isSystemUser = repositoryConnection.isUserInRole(userId, Constants.defaultSystemRoleURI); adminUsersCache.put(username, new Boolean(isSystemUser)); return isSystemUser; } } finally { resetLock.readLock().unlock(); } }
@Override public Transformer resolve(DataType source, DataType result) throws ResolverException { String cacheKey = getDataTypeSourceResultPairHash(source, result); readWriteLock.readLock().lock(); try { if (cache.containsKey(cacheKey)) { return (Converter) cache.get(cacheKey); } } finally { readWriteLock.readLock().unlock(); } List<Converter> converters = converterFilter.filter(lookupStrategyTransformation.lookupConverters(source, result), source, result); if (converters.size() > 1) { throw new ResolverException(CoreMessages.transformHasMultipleMatches(source.getType(), result.getType(), converters)); } Transformer converter = (converters.size() == 0) ? null : converters.get(0); readWriteLock.writeLock().lock(); try { cache.put(cacheKey, converter); } finally { readWriteLock.writeLock().unlock(); } return converter; }
try if (cache.containsKey(cacheKey))
public JoinEdge getCachedOrNewJoinEdge(JoinSpec joinSpec, JoinVertex left, JoinVertex right) { Pair<JoinVertex,JoinVertex> cacheKey = new Pair<JoinVertex, JoinVertex>(left, right); if (edgeCache.containsKey(cacheKey)) { return (JoinEdge) edgeCache.get(cacheKey); } else { return cacheEdge(new JoinEdge(joinSpec, left, right)); } }
public JoinEdge getCachedOrNewJoinEdge(JoinSpec joinSpec, JoinVertex left, JoinVertex right) { Pair<JoinVertex,JoinVertex> cacheKey = new Pair<>(left, right); if (edgeCache.containsKey(cacheKey)) { return (JoinEdge) edgeCache.get(cacheKey); } else { return cacheEdge(new JoinEdge(joinSpec, left, right)); } }
public void report(final ProblemReport pr) { synchronized (problemReports) { if (problemReports.containsKey(pr)) { return; } problemReports.put(pr, System.currentTimeMillis()); } Runnable r = new Runnable() { @Override public void run() { log.debug("Filing problem report " + pr.getTableName() + " " + pr.getProblemType() + " " + pr.getResource()); try { if (pr.getTableName().equals(Constants.METADATA_TABLE_ID)) { // file report in zookeeper pr.saveToZooKeeper(); } else { // file report in metadata table pr.saveToMetadataTable(); } } catch (Exception e) { log.error("Failed to file problem report " + pr.getTableName() + " " + pr.getProblemType() + " " + pr.getResource(), e); } } }; try { reportExecutor.execute(new LoggingRunnable(log, r)); } catch (RejectedExecutionException ree) { log.error("Failed to report problem " + pr.getTableName() + " " + pr.getProblemType() + " " + pr.getResource() + " " + ree.getMessage()); } }
/** * Is the given userId a member of the sysAdmin role * * @param authenticatedUserId * Userid to verify membership in sysadmin role * @param repositoryConnection * RepositoryConnection to run queries against * @return * @throws BocaException */ public boolean isSystemUser(Long authenticatedUserId, RepositoryConnection repositoryConnection) throws BocaException { URI user = repositoryConnection.getNodeLayout().getNodeURILayout().fetchValue(authenticatedUserId); if (adminUsersCache.containsKey(user)) { Boolean isSystemUser = (Boolean) adminUsersCache.get(user); return isSystemUser.booleanValue(); } else { boolean isSystemUser = repositoryConnection.isUserInRole(authenticatedUserId, Constants.defaultSystemRoleURI); adminUsersCache.put(user, new Boolean(isSystemUser)); return isSystemUser; } }
public void report(final ProblemReport pr) { if (problemReports.containsKey(pr)) { return;
/** * {@inheritDoc} * * {@link #providePrincipal(String)} is called, if no matching entry * is present in the cache.<br> * NOTE: If the cache is enabled to contain negative entries (see * {@link #NEGATIVE_ENTRY_KEY} configuration option), the cache will also * store negative matches (as <code>null</code> values) in the principal cache. */ public synchronized Principal getPrincipal(String principalName) { checkInitialized(); if (cache.containsKey(principalName)) { return (Principal) cache.get(principalName); } else { Principal principal = providePrincipal(principalName); if (principal != null || includeNegative) { cache.put(principalName, principal); } return principal; } }
/** * {@inheritDoc} * * {@link #providePrincipal(String)} is called, if no matching entry * is present in the cache.<br> * NOTE: If the cache is enabled to contain negative entries (see * {@link #NEGATIVE_ENTRY_KEY} configuration option), the cache will also * store negative matches (as <code>null</code> values) in the principal cache. */ public synchronized Principal getPrincipal(String principalName) { checkInitialized(); if (cache.containsKey(principalName)) { return (Principal) cache.get(principalName); } else { Principal principal = providePrincipal(principalName); if (principal != null || includeNegative) { cache.put(principalName, principal); } return principal; } }
if (secondLevelCache != null && !uncacheableKeys.containsKey(key)) { final Element secondLevelElement = secondLevelCache.get(key, Element.class); if (secondLevelElement == null) {
@VisibleForTesting IPentahoUser convertToPentahoUser( User jackrabbitUser ) throws RepositoryException { if ( getUserCache().containsKey( jackrabbitUser.getID() ) ) { return (IPentahoUser) getUserCache().get( jackrabbitUser.getID() ); } IPentahoUser pentahoUser = null; Value[] propertyValues = null; String description = null; try { propertyValues = jackrabbitUser.getProperty( "description" ); //$NON-NLS-1$ description = propertyValues.length > 0 ? propertyValues[ 0 ].getString() : null; } catch ( Exception ex ) { // CHECKSTYLES IGNORE } Credentials credentials = jackrabbitUser.getCredentials(); String password = null; if ( credentials instanceof CryptedSimpleCredentials ) { password = new String( ( (CryptedSimpleCredentials) credentials ).getPassword() ); } pentahoUser = new PentahoUser( getTenantedUserNameUtils().getTenant( jackrabbitUser.getID() ), getTenantedUserNameUtils() .getPrincipleName( jackrabbitUser.getID() ), password, description, !jackrabbitUser.isDisabled() ); if ( isUseJackrabbitUserCache() ) { getUserCache().put( jackrabbitUser.getID(), pentahoUser ); } return pentahoUser; }