/** * @param user user to get known items for * @return set of known items for the user (immutable, but thread-safe) */ public Set<String> getKnownItems(String user) { MutableSet<String> knownItemsForUser = doGetKnownItems(user); if (knownItemsForUser == null) { return Collections.emptySet(); } synchronized (knownItemsForUser) { if (knownItemsForUser.isEmpty()) { return Collections.emptySet(); } // Must copy since the original object is synchronized return knownItemsForUser.clone().asUnmodifiable(); } }
ArtifactRestrictions(MutableSet<String> includes, MutableSet<String> excludes) { this.includes = includes == null ? UnifiedSet.<String>newSet() : includes; this.excludes = excludes == null ? UnifiedSet.<String>newSet() : excludes; if (!this.includes.isEmpty() && !this.excludes.isEmpty()) { throw new IllegalArgumentException("Cannot specify both include and exclude"); } }
ArtifactRestrictions(MutableSet<String> includes, MutableSet<String> excludes) { this.includes = includes == null ? UnifiedSet.<String>newSet() : includes; this.excludes = excludes == null ? UnifiedSet.<String>newSet() : excludes; if (!this.includes.isEmpty() && !this.excludes.isEmpty()) { throw new IllegalArgumentException("Cannot specify both include and exclude"); } }
@VisibleForTesting MutableSet<SchemaObjectRow> getInvalidObjects(Connection conn, RichIterable<PhysicalSchema> physicalSchemas) { LOG.info("Checking for invalid objects"); String schemaInClause = physicalSchemas.collect(new Function<PhysicalSchema, String>() { @Override public String valueOf(PhysicalSchema physicalSchema) { return physicalSchema.getPhysicalName(); } }).makeString("('", "','", "')"); MutableSet<SchemaObjectRow> oldInvalidObjects = queryOldInvalidObjects(conn, schemaInClause); try { MutableSet<SchemaObjectRow> newInvalidObjects = queryNewInvalidObjects(conn, schemaInClause); if (oldInvalidObjects.isEmpty() && newInvalidObjects.notEmpty()) { deployMetricsCollector.addMetric("invalidObjectQuery.resultsOnlyInNew", true); } else if (oldInvalidObjects.notEmpty() && newInvalidObjects.isEmpty()) { deployMetricsCollector.addMetric("invalidObjectQuery.resultsOnlyInOld", true); } return oldInvalidObjects.withAll(newInvalidObjects); } catch (DataAccessException e) { deployMetricsCollector.addMetric("oldInvalidObjectQueryRequired", true); LOG.debug("Failed to execute new invalid objects SQL; falling back to old query"); return oldInvalidObjects; } }
@VisibleForTesting MutableSet<SchemaObjectRow> getInvalidObjects(Connection conn, RichIterable<PhysicalSchema> physicalSchemas) { LOG.info("Checking for invalid objects"); String schemaInClause = physicalSchemas.collect(new Function<PhysicalSchema, String>() { @Override public String valueOf(PhysicalSchema physicalSchema) { return physicalSchema.getPhysicalName(); } }).makeString("('", "','", "')"); MutableSet<SchemaObjectRow> oldInvalidObjects = queryOldInvalidObjects(conn, schemaInClause); try { MutableSet<SchemaObjectRow> newInvalidObjects = queryNewInvalidObjects(conn, schemaInClause); if (oldInvalidObjects.isEmpty() && newInvalidObjects.notEmpty()) { deployMetricsCollector.addMetric("invalidObjectQuery.resultsOnlyInNew", true); } else if (oldInvalidObjects.notEmpty() && newInvalidObjects.isEmpty()) { deployMetricsCollector.addMetric("invalidObjectQuery.resultsOnlyInOld", true); } return oldInvalidObjects.withAll(newInvalidObjects); } catch (DataAccessException e) { deployMetricsCollector.addMetric("oldInvalidObjectQueryRequired", true); LOG.debug("Failed to execute new invalid objects SQL; falling back to old query"); return oldInvalidObjects; } }
if (cardsWithNextPlayer.isEmpty())
final MutableSet<String> schemasToExclude = iterString(envCfg, "excludeSchemas").toSet(); if (!schemasToInclude.isEmpty() && !schemasToExclude.isEmpty()) { throw new IllegalArgumentException("Environment " + dbEnv.getName() + " has includeSchemas [" + schemasToInclude + "] and excludeSchemas [" + schemasToExclude + "] defined; please only specify one of them"); } else if (!schemasToInclude.isEmpty()) { schemaObjs = schemaObjs.select(new Predicate<Schema>() { @Override } else if (!schemasToExclude.isEmpty()) { schemaObjs = schemaObjs.reject(new Predicate<Schema>() { @Override
final MutableSet<String> schemasToExclude = iterString(envCfg, "excludeSchemas").toSet(); if (!schemasToInclude.isEmpty() && !schemasToExclude.isEmpty()) { throw new IllegalArgumentException("Environment " + dbEnv.getName() + " has includeSchemas [" + schemasToInclude + "] and excludeSchemas [" + schemasToExclude + "] defined; please only specify one of them"); } else if (!schemasToInclude.isEmpty()) { schemaObjs = schemaObjs.select(new Predicate<Schema>() { @Override } else if (!schemasToExclude.isEmpty()) { schemaObjs = schemaObjs.reject(new Predicate<Schema>() { @Override
String replaceSnippet(String sqlSnippet) { for (RevengPatternOutput objectOutput : objectNames) { MutableSet<String> replacerSchemas = objectToSchemasMap.get(objectOutput.getPrimaryName()); if (replacerSchemas == null || replacerSchemas.isEmpty()) { replacerSchemas = objectToSchemasMap.valuesView().toSet(); if (replacerSubSchemas == null || replacerSubSchemas.isEmpty()) { replacerSubSchemas = objectToSubSchemasMap.valuesView().toSet();
String replaceSnippet(String sqlSnippet) { for (RevengPatternOutput objectOutput : objectNames) { MutableSet<String> replacerSchemas = objectToSchemasMap.get(objectOutput.getPrimaryName()); if (replacerSchemas == null || replacerSchemas.isEmpty()) { replacerSchemas = objectToSchemasMap.valuesView().toSet(); if (replacerSubSchemas == null || replacerSubSchemas.isEmpty()) { replacerSubSchemas = objectToSubSchemasMap.valuesView().toSet();
@Test public void testIncludeEnvs() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("includeEnvs", "dev1,dev3")) ); assertEquals(1, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class)); assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getIncludes()); assertTrue(restrictions.getFirst().getExcludes().isEmpty()); }
@Test public void testExcludeEnvs() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("excludeEnvs", "dev1,dev3")) ); assertEquals(1, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class)); assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getExcludes()); assertTrue(restrictions.getFirst().getIncludes().isEmpty()); }
@Test public void testIncludeEnvsExcludePlatforms() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with( "includeEnvs", "dev1,dev3", "excludePlatforms", "HSQL,HIVE")) ); assertEquals(2, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactEnvironmentRestrictions.class)); assertEquals(UnifiedSet.newSetWith("dev1", "dev3"), restrictions.getFirst().getIncludes()); assertTrue(restrictions.getFirst().getExcludes().isEmpty()); assertThat(restrictions.getLast(), instanceOf(ArtifactPlatformRestrictions.class)); assertTrue(restrictions.getLast().getIncludes().isEmpty()); assertEquals(UnifiedSet.newSetWith("HSQL", "HIVE"), restrictions.getLast().getExcludes()); } }
@Test public void testIncludePlatforms() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("includePlatforms", "DB2,SYBASE_ASE")) ); assertEquals(1, restrictions.size()); assertThat(restrictions.getFirst(), instanceOf(ArtifactPlatformRestrictions.class)); assertEquals(UnifiedSet.newSetWith("DB2", "SYBASE_ASE"), restrictions.getFirst().getIncludes()); assertTrue(restrictions.getFirst().getExcludes().isEmpty()); }
@Test public void testExcludePlatforms() { ImmutableList<ArtifactRestrictions> restrictions = this.restrictionsReader.valueOf( this.doc(TextMarkupDocumentReader.TAG_METADATA, null, Maps.immutable.with("excludePlatforms", "HSQL,HIVE")) ); assertEquals(1, restrictions.size()); assertEquals(UnifiedSet.newSetWith("HSQL", "HIVE"), restrictions.getFirst().getExcludes()); assertTrue(restrictions.getFirst().getIncludes().isEmpty()); }