This is an automated email from the ASF dual-hosted git repository. ycai pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra-sidecar.git
The following commit(s) were added to refs/heads/trunk by this push: new 7b8b607c CASSANDRASC-154: Remove duplicated AbstractSchema (#142) 7b8b607c is described below commit 7b8b607c848f107d16c1523d06246a471a55d410 Author: Yifan Cai <y...@apache.org> AuthorDate: Mon Oct 28 18:51:30 2024 -0700 CASSANDRASC-154: Remove duplicated AbstractSchema (#142) Patch by Yifan Cai; Reviewed by Francisco Guerrero for CASSANDRASC-154 --- CHANGES.txt | 1 + .../sidecar/db/schema/AbstractSchema.java | 3 +- .../sidecar/db/schema/AbstractSchema.java | 82 ---------------------- 3 files changed, 3 insertions(+), 83 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index df6bf8ba..c256a0d0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 1.0.0 ----- + * Remove duplicated AbstractSchema class (CASSANDRASC-154) * Fix RestoreRangeTask not terminating (CASSANDRASC-153) * Fix restore job of coordinated write not proceeding (CASSANDRASC-152) * Add vert.x auth subproject for mTLS authentication support in Sidecar (CASSANDRASC-146) diff --git a/server-common/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java b/server-common/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java index 7301e7b4..9d9bb378 100644 --- a/server-common/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java +++ b/server-common/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java @@ -21,6 +21,7 @@ package org.apache.cassandra.sidecar.db.schema; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.datastax.driver.core.ConsistencyLevel; import com.datastax.driver.core.Metadata; import com.datastax.driver.core.PreparedStatement; import com.datastax.driver.core.ResultSet; @@ -44,7 +45,7 @@ public abstract class AbstractSchema protected PreparedStatement prepare(PreparedStatement cached, Session session, String cqlLiteral) { - return cached == null ? session.prepare(cqlLiteral) : cached; + return cached == null ? session.prepare(cqlLiteral).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM) : cached; } protected boolean initializeInternal(@NotNull Session session) diff --git a/server/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java b/server/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java deleted file mode 100644 index e119bf6b..00000000 --- a/server/src/main/java/org/apache/cassandra/sidecar/db/schema/AbstractSchema.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.sidecar.db.schema; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.datastax.driver.core.ConsistencyLevel; -import com.datastax.driver.core.Metadata; -import com.datastax.driver.core.PreparedStatement; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Session; -import org.apache.cassandra.sidecar.exceptions.SidecarSchemaModificationException; -import org.jetbrains.annotations.NotNull; - -/** - * Abstract schema - */ -abstract class AbstractSchema -{ - protected Logger logger = LoggerFactory.getLogger(this.getClass()); - private boolean initialized = false; - - public synchronized boolean initialize(@NotNull Session session) - { - initialized = initialized || initializeInternal(session); - return initialized; - } - - protected PreparedStatement prepare(PreparedStatement cached, Session session, String cqlLiteral) - { - return cached == null ? session.prepare(cqlLiteral).setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM) : cached; - } - - protected boolean initializeInternal(@NotNull Session session) - { - if (!exists(session.getCluster().getMetadata())) - { - try - { - ResultSet res = session.execute(createSchemaStatement()); - if (!res.getExecutionInfo().isSchemaInAgreement()) - { - logger.warn("Schema is not yet in agreement."); - return false; - } - } - catch (Exception exception) - { - String schemaName = this.getClass().getSimpleName(); - throw new SidecarSchemaModificationException("Failed to modify schema for " + schemaName, exception); - } - } - - prepareStatements(session); - return true; - } - - protected abstract String keyspaceName(); - - protected abstract void prepareStatements(@NotNull Session session); - - protected abstract boolean exists(@NotNull Metadata metadata); - - protected abstract String createSchemaStatement(); -} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org