This is an automated email from the ASF dual-hosted git repository. mck pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit b92620c387d3e8d38f5cf7dfb0d5b89634099ead Merge: ab8705e a6ea521 Author: Mick Semb Wever <[email protected]> AuthorDate: Mon Aug 30 21:37:15 2021 +0200 Merge branch 'cassandra-4.0' into trunk CHANGES.txt | 1 + build.xml | 2 ++ .../org/apache/cassandra/service/snapshot/SnapshotManifestTest.java | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --cc CHANGES.txt index 6da7d5c,8b4018a..7b792e4 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,26 -1,7 +1,27 @@@ -4.0.1 +4.1 + * Exclude Jackson 1.x transitive dependency of hadoop* provided dependencies (CASSANDRA-16854) + * Add client warnings and abort to tombstone and coordinator reads which go past a low/high watermark (CASSANDRA-16850) + * Add TTL support to nodetool snapshots (CASSANDRA-16789) + * Allow CommitLogSegmentReader to optionally skip sync marker CRC checks (CASSANDRA-16842) + * allow blocking IPs from updating metrics about traffic (CASSANDRA-16859) + * Request-Based Native Transport Rate-Limiting (CASSANDRA-16663) + * Implement nodetool getauditlog command (CASSANDRA-16725) + * Clean up repair code (CASSANDRA-13720) + * Background schedule to clean up orphaned hints files (CASSANDRA-16815) + * Modify SecondaryIndexManager#indexPartition() to retrieve only columns for which indexes are actually being built (CASSANDRA-16776) + * Batch the token metadata update to improve the speed (CASSANDRA-15291) + * Reduce the log level on "expected" repair exceptions (CASSANDRA-16775) + * Make JMXTimer expose attributes using consistent time unit (CASSANDRA-16760) + * Remove check on gossip status from DynamicEndpointSnitch::updateScores (CASSANDRA-11671) + * Fix AbstractReadQuery::toCQLString not returning valid CQL (CASSANDRA-16510) + * Log when compacting many tombstones (CASSANDRA-16780) + * Display bytes per level in tablestats for LCS tables (CASSANDRA-16799) + * Add isolated flush timer to CommitLogMetrics and ensure writes correspond to single WaitingOnCommit data points (CASSANDRA-16701) + * Add a system property to set hostId if not yet initialized (CASSANDRA-14582) + * GossiperTest.testHasVersion3Nodes didn't take into account trunk version changes, fixed to rely on latest version (CASSANDRA-16651) +Merged from 4.0: * Tolerate missing DNS entry when completing a host replacement (CASSANDRA-16873) - * Harden PrunableArrayQueue against Pruner implementations that might throw exceptions (CASSANDRA-16866) + * Harden PrunableArrayQueue against Pruner implementations that might throw exceptions (CASSANDRA-16866) * Move RepairedDataInfo to the execution controller rather than the ReadCommand to avoid unintended sharing (CASSANDRA-16721) * Bump zstd-jni version to 1.5.0-4 (CASSANDRA-16884) * Remove assumption that all urgent messages are small (CASSANDRA-16877) diff --cc build.xml index 16dd96f,a8cfe11..3d827ce --- a/build.xml +++ b/build.xml @@@ -544,7 -544,8 +545,8 @@@ </dependency> <dependency groupId="org.apache.hadoop" artifactId="hadoop-minicluster" version="1.0.3" scope="provided"> <exclusion groupId="asm" artifactId="asm"/> <!-- this is the outdated version 3.1 --> - <exclusion groupId="org.slf4j" artifactId="slf4j-api"/> + <exclusion groupId="org.codehaus.jackson" artifactId="jackson-mapper-asl"/> + <exclusion groupId="org.slf4j" artifactId="slf4j-api"/> </dependency> <dependency groupId="net.java.dev.jna" artifactId="jna" version="5.6.0"/> diff --cc test/unit/org/apache/cassandra/service/snapshot/SnapshotManifestTest.java index f72d1ec,0000000..8760270 mode 100644,000000..100644 --- a/test/unit/org/apache/cassandra/service/snapshot/SnapshotManifestTest.java +++ b/test/unit/org/apache/cassandra/service/snapshot/SnapshotManifestTest.java @@@ -1,117 -1,0 +1,117 @@@ +/* + * 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.service.snapshot; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; +import java.util.Arrays; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import static org.assertj.core.api.Assertions.assertThatIOException; +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.cassandra.config.Duration; - import org.codehaus.jackson.map.ObjectMapper; ++import com.fasterxml.jackson.databind.ObjectMapper; + +public class SnapshotManifestTest +{ + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @Test + public void testDeserializeFromInvalidFile() throws IOException { + File manifestFile = tempFolder.newFile("invalid"); + assertThatIOException().isThrownBy( + () -> { + SnapshotManifest.deserializeFromJsonFile(manifestFile); + }); + + FileOutputStream out = new FileOutputStream(manifestFile); + out.write(1); + out.write(2); + out.write(3); + out.close(); + assertThatIOException().isThrownBy( + () -> SnapshotManifest.deserializeFromJsonFile(manifestFile)); + } + + @Test + public void testDeserializeManifest() throws IOException + { + Map<String, Object> map = new HashMap<>(); + String createdAt = "2021-07-03T10:37:30Z"; + String expiresAt = "2021-08-03T10:37:30Z"; + map.put("created_at", createdAt); + map.put("expires_at", expiresAt); + map.put("files", Arrays.asList("db1", "db2", "db3")); + + ObjectMapper mapper = new ObjectMapper(); + File manifestFile = tempFolder.newFile("manifest.json"); + mapper.writeValue(manifestFile, map); + SnapshotManifest manifest = SnapshotManifest.deserializeFromJsonFile(manifestFile); + + assertThat(manifest.getExpiresAt()).isEqualTo(Instant.parse(expiresAt)); + assertThat(manifest.getCreatedAt()).isEqualTo(Instant.parse(createdAt)); + assertThat(manifest.getFiles()).contains("db1").contains("db2").contains("db3").hasSize(3); + } + + @Test + public void testOptionalFields() throws IOException { + Map<String, Object> map = new HashMap<>(); + map.put("files", Arrays.asList("db1", "db2", "db3")); + ObjectMapper mapper = new ObjectMapper(); + File manifestFile = tempFolder.newFile("manifest.json"); + mapper.writeValue(manifestFile, map); + SnapshotManifest manifest = SnapshotManifest.deserializeFromJsonFile(manifestFile); + + assertThat(manifest.getExpiresAt()).isNull(); + assertThat(manifest.getCreatedAt()).isNull(); + assertThat(manifest.getFiles()).contains("db1").contains("db2").contains("db3").hasSize(3); + } + + @Test + public void testIngoredFields() throws IOException { + Map<String, Object> map = new HashMap<>(); + map.put("files", Arrays.asList("db1", "db2", "db3")); + map.put("dummy", "dummy"); + ObjectMapper mapper = new ObjectMapper(); + File manifestFile = tempFolder.newFile("manifest.json"); + mapper.writeValue(manifestFile, map); + SnapshotManifest manifest = SnapshotManifest.deserializeFromJsonFile(manifestFile); + assertThat(manifest.getFiles()).contains("db1").contains("db2").contains("db3").hasSize(3); + } + + @Test + public void testSerializeAndDeserialize() throws Exception { + SnapshotManifest manifest = new SnapshotManifest(Arrays.asList("db1", "db2", "db3"), new Duration("2m")); + File manifestFile = tempFolder.newFile("manifest.json"); + manifest.serializeToJsonFile(manifestFile); + manifest = SnapshotManifest.deserializeFromJsonFile(manifestFile); + assertThat(manifest.getExpiresAt()).isNotNull(); + assertThat(manifest.getCreatedAt()).isNotNull(); + assertThat(manifest.getFiles()).contains("db1").contains("db2").contains("db3").hasSize(3); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
