Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sample-operators/leader-election/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.takes</groupId>
Expand Down
5 changes: 5 additions & 0 deletions sample-operators/mysql-schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import static io.javaoperatorsdk.operator.sample.dependent.SecretDependentResource.MYSQL_SECRET_USERNAME;
import static java.lang.String.format;

@SchemaConfig(pollPeriod = 700, host = "127.0.0.1",
@SchemaConfig(pollPeriod = 400, host = "127.0.0.1",
port = SchemaDependentResource.LOCAL_PORT,
user = "root", password = "password") // NOSONAR: password is only used locally, example only
@Configured(by = SchemaConfig.class, with = ResourcePollerConfig.class,
Expand Down Expand Up @@ -63,7 +63,9 @@ public void configureWith(ResourcePollerConfig config) {

@Override
public Schema desired(MySQLSchema primary, Context<MySQLSchema> context) {
return new Schema(primary.getMetadata().getName(), primary.getSpec().getEncoding());
var desired = new Schema(primary.getMetadata().getName(), primary.getSpec().getEncoding());
log.debug("Desired schema: {}", desired);
return desired;
}

@Override
Expand All @@ -72,6 +74,7 @@ public Schema create(Schema target, MySQLSchema mySQLSchema, Context<MySQLSchema
Secret secret = context.getSecondaryResource(Secret.class).orElseThrow();
var username = decode(secret.getData().get(MYSQL_SECRET_USERNAME));
var password = decode(secret.getData().get(MYSQL_SECRET_PASSWORD));
log.debug("Creating schema: {}", target);
return SchemaService.createSchemaAndRelatedUser(
connection,
target.getName(),
Expand Down Expand Up @@ -107,8 +110,10 @@ public static String decode(String value) {
@Override
public Set<Schema> fetchResources(MySQLSchema primaryResource) {
try (Connection connection = getConnection()) {
return SchemaService.getSchema(connection, primaryResource.getMetadata().getName())
var schema = SchemaService.getSchema(connection, primaryResource.getMetadata().getName())
.map(Set::of).orElseGet(Collections::emptySet);
log.debug("Fetched schema: {}", schema);
return schema;
} catch (SQLException e) {
throw new RuntimeException("Error while trying read Schema", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass())
return false;
Schema schema = (Schema) o;
return Objects.equals(name, schema.name) && Objects.equals(characterSet, schema.characterSet);
return Objects.equals(name, schema.name);
}

@Override
public int hashCode() {
return Objects.hash(name, characterSet);
}

@Override
public String toString() {
return "Schema{" +
"name='" + name + '\'' +
", characterSet='" + characterSet + '\'' +
'}';
}
}
5 changes: 5 additions & 0 deletions sample-operators/tomcat-operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.takes</groupId>
<artifactId>takes</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions sample-operators/webpage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.takes</groupId>
<artifactId>takes</artifactId>
Expand Down