Skip to content

Commit 74ef2df

Browse files
committed
Merging 5.0 branch into master
2 parents 38f494e + f785d13 commit 74ef2df

File tree

89 files changed

+19068
-17768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+19068
-17768
lines changed

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,28 @@ buildscript {
2323

2424
dependencies {
2525
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
26-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
27-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
26+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
27+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
28+
classpath "gradle.plugin.net.ossindex:ossindex-gradle-plugin:0.2.0-beta"
2829
}
2930
}
3031

3132

3233
plugins {
33-
id "com.palantir.git-version" version "0.10.0"
34+
id "com.palantir.git-version" version "0.10.1"
3435
}
3536

3637
allprojects {
3738
group = 'com.spectralogic.ds3'
38-
version = '4.1.0'
39+
version = '5.0.3'
3940
}
4041

4142
subprojects {
4243
apply plugin: 'maven'
4344
apply plugin: 'java'
4445
apply plugin: 'kotlin'
4546
apply plugin: 'findbugs'
47+
apply plugin: 'net.ossindex.audit'
4648

4749
sourceCompatibility = JavaVersion.VERSION_1_8
4850
repositories {
@@ -62,7 +64,7 @@ subprojects {
6264
}
6365

6466
task wrapper(type: Wrapper) {
65-
gradleVersion = '4.5.1'
67+
gradleVersion = '4.7'
6668
}
6769

6870
project(':ds3-sdk') {

contract/4_0_0_contract.xml

Lines changed: 0 additions & 17222 deletions
This file was deleted.

contract/5_0_x_contract.xml

Lines changed: 17641 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2018 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.integration;
17+
18+
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
19+
import com.spectralogic.ds3client.models.bulk.Ds3Object;
20+
import com.spectralogic.ds3client.utils.ByteArraySeekableByteChannel;
21+
import org.apache.commons.io.IOUtils;
22+
23+
import java.io.IOException;
24+
import java.nio.ByteBuffer;
25+
import java.nio.channels.SeekableByteChannel;
26+
import java.util.HashMap;
27+
import java.util.List;
28+
import java.util.Map;
29+
30+
/**
31+
* Creates a channel builder that generates random data. All object keys and sizes need to be specified.
32+
*/
33+
public class RandomDataChannelBuilder implements Ds3ClientHelpers.ObjectChannelBuilder {
34+
35+
private static final int seed = 12345;
36+
private final Map<String, Long> objectMap = new HashMap();
37+
38+
public RandomDataChannelBuilder() {
39+
}
40+
41+
public RandomDataChannelBuilder(final List<Ds3Object> objects) {
42+
for (final Ds3Object obj : objects) {
43+
this.objectMap.put(obj.getName(), obj.getSize());
44+
}
45+
}
46+
47+
RandomDataChannelBuilder withObject(final String key, final Long size) {
48+
this.objectMap.put(key, size);
49+
return this;
50+
}
51+
52+
@Override
53+
public SeekableByteChannel buildChannel(final String key) throws IOException {
54+
if (!this.objectMap.containsKey(key)) {
55+
throw new IllegalArgumentException(String.format("Object with name '%s' was not defined for this channel builder.", key));
56+
}
57+
58+
final Long size = this.objectMap.get(key);
59+
final byte[] randomData = IOUtils.toByteArray(new RandomDataInputStream(seed, size));
60+
final ByteBuffer randomBuffer = ByteBuffer.wrap(randomData);
61+
62+
final ByteArraySeekableByteChannel channel = new ByteArraySeekableByteChannel(size.intValue());
63+
channel.write(randomBuffer);
64+
65+
return channel;
66+
}
67+
}

ds3-sdk-integration/src/main/java/com/spectralogic/ds3client/integration/Util.java

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,27 @@
1515

1616
package com.spectralogic.ds3client.integration;
1717

18+
import com.google.common.collect.ImmutableList;
1819
import com.spectralogic.ds3client.Ds3Client;
1920
import com.spectralogic.ds3client.Ds3ClientBuilder;
20-
import com.spectralogic.ds3client.commands.DeleteBucketRequest;
21-
import com.spectralogic.ds3client.commands.DeleteObjectRequest;
22-
import com.spectralogic.ds3client.commands.spectrads3.GetSystemInformationSpectraS3Request;
21+
import com.spectralogic.ds3client.commands.spectrads3.*;
2322
import com.spectralogic.ds3client.helpers.DeleteBucket;
2423
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
2524
import com.spectralogic.ds3client.helpers.channelbuilders.PrefixAdderObjectChannelBuilder;
26-
import com.spectralogic.ds3client.models.Contents;
25+
import com.spectralogic.ds3client.models.Bucket;
26+
import com.spectralogic.ds3client.models.Job;
27+
import com.spectralogic.ds3client.models.JobStatus;
2728
import com.spectralogic.ds3client.models.bulk.Ds3Object;
2829
import com.spectralogic.ds3client.utils.ResourceUtils;
2930
import org.slf4j.Logger;
3031
import org.slf4j.LoggerFactory;
3132

3233
import java.io.IOException;
3334
import java.net.URISyntaxException;
35+
import java.nio.channels.FileChannel;
3436
import java.nio.file.Files;
3537
import java.nio.file.Path;
38+
import java.nio.file.StandardOpenOption;
3639
import java.util.ArrayList;
3740
import java.util.List;
3841

@@ -60,6 +63,22 @@ public static Ds3Client insecureFromEnv() {
6063
return builder.build();
6164
}
6265

66+
/**
67+
* Goes through all buckets on a BP and attempts to delete them and all their contents. It cancels all active jobs
68+
* associated with this bucket. Created for cleaning up after cascade failures in functional tests.
69+
*
70+
* USE ONLY WHEN DELETING ALL BUCKETS AND ALL CONTENT IS YOUR GOAL.
71+
*/
72+
public static void forceCleanupBucketsOnBP(final Ds3Client client) throws IOException {
73+
final GetBucketsSpectraS3Request request = new GetBucketsSpectraS3Request();
74+
final GetBucketsSpectraS3Response response = client.getBucketsSpectraS3(request);
75+
76+
for (final Bucket bucket : response.getBucketListResult().getBuckets()) {
77+
cancelAllJobsForBucket(client, bucket.getName());
78+
client.deleteBucketSpectraS3(new DeleteBucketSpectraS3Request(bucket.getName()).withForce(true));
79+
}
80+
}
81+
6382
public static void assumeVersion1_2(final Ds3Client client) throws IOException {
6483
final int majorVersion = Integer.parseInt(client.getSystemInformationSpectraS3(
6584
new GetSystemInformationSpectraS3Request()).getSystemInformationResult().getBuildInformation().getVersion().split("\\.")[0]);
@@ -79,6 +98,19 @@ public static void loadBookTestData(final Ds3Client client, final String bucketN
7998
LOG.info("Finished loading test data...");
8099
}
81100

101+
/**
102+
* Loads a single test book to a BP with the specified object name.
103+
*/
104+
public static void loadTestBook(final Ds3Client client, final String fileName, final String objectName, final String bucketName) throws IOException, URISyntaxException {
105+
final Path filePath = ResourceUtils.loadFileResource(RESOURCE_BASE_NAME + fileName);
106+
final Ds3Object obj = new Ds3Object(objectName, Files.size(filePath));
107+
108+
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
109+
110+
final Ds3ClientHelpers.Job job = helpers.startWriteJob(bucketName, ImmutableList.of(obj));
111+
job.transfer(key -> FileChannel.open(filePath, StandardOpenOption.READ));
112+
}
113+
82114
public static Ds3ClientHelpers.Job getLoadJob(final Ds3Client client, final String bucketName, final String resourceBaseName) throws IOException, URISyntaxException {
83115
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
84116

@@ -118,4 +150,19 @@ public static void deleteBucketContents(final Ds3Client client, final String buc
118150
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
119151
DeleteBucket.INSTANCE.deleteBucketContents(helpers, bucketName);
120152
}
153+
154+
// Cancels all in-progress jobs associated with a bucket
155+
public static void cancelAllJobsForBucket(final Ds3Client client, final String bucketName) {
156+
try {
157+
final GetJobsSpectraS3Response getJobs = client.getJobsSpectraS3(new GetJobsSpectraS3Request().withBucketId(bucketName));
158+
159+
for (final Job job : getJobs.getJobListResult().getJobs()) {
160+
if (job.getStatus() == JobStatus.IN_PROGRESS) {
161+
client.cancelJobSpectraS3(new CancelJobSpectraS3Request(job.getJobId()));
162+
}
163+
}
164+
} catch (final IOException e) {
165+
LOG.debug("Could not cancel jobs for bucket '%s': %s", bucketName, e.getMessage());
166+
}
167+
}
121168
}

0 commit comments

Comments
 (0)