Commit c56f6167 authored by Michael Ritter's avatar Michael Ritter
Browse files

Merge branch 'hotfix-distributions-1.1.1'

parents ad2fe4aa 5f753f89
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<packaging>jar</packaging>
......
......@@ -6,11 +6,11 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>chron-db</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<dependencies>
......
......@@ -5,12 +5,12 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>chron-common</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<name>Common</name>
<url>http://maven.apache.org</url>
<properties>
......
......@@ -7,12 +7,12 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>duracloud-backend</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<build>
<plugins>
......
......@@ -7,12 +7,12 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>duracloud-intake</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<build>
<plugins>
......
......@@ -7,12 +7,12 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>ingest-rest</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<build>
<plugins>
......
......@@ -42,18 +42,21 @@ public class BagInitializer {
@Autowired
public BagInitializer(NodeRepository repository, IngestSettings settings) {
this.settings = settings;
this.repository = repository;
BagInitializer.settings = settings;
BagInitializer.repository = repository;
}
/**
* Iterate through a list of node usernames and add them to the BagDistribution table
* TODO: Should we make distribution records for all nodes if the request is empty/null
* TODO: List<String> -> List<Node> for replicating nodes
* TODO: Use replicatingNodes size as number of required replications? (implicit association)
*
* @param bag
* @param replicatingNodes
*/
private static void createBagDistributions(Bag bag, List<String> replicatingNodes) {
int numDistributions = 0;
if (replicatingNodes == null) {
replicatingNodes = new ArrayList<>();
}
......@@ -63,10 +66,20 @@ public class BagInitializer {
if (node != null) {
log.debug("Creating dist record for {}", nodeName);
bag.addDistribution(node, DISTRIBUTE);
numDistributions++;
}
}
if (numDistributions < bag.getRequiredReplications()) {
for (Node node : repository.findAll()) {
log.debug("Creating dist record for {}", node.getUsername());
bag.addDistribution(node, DISTRIBUTE);
numDistributions++;
}
}
}
/**
* Set the location, fixity value, size, and total number of files for the bag
*
......@@ -101,7 +114,11 @@ public class BagInitializer {
bag.setSize(bagSize[0]);
bag.setTotalFiles(fileCount[0]);
bag.setFixityAlgorithm("SHA-256");
bag.setRequiredReplications(request.getRequiredReplications());
// could put this in the bag object...
if (request.getRequiredReplications() > 0) {
bag.setRequiredReplications(request.getRequiredReplications());
}
createBagDistributions(bag, request.getReplicatingNodes());
}
......
......@@ -4,6 +4,7 @@ import com.mysema.query.types.expr.BooleanExpression;
import org.chronopolis.ingest.IngestSettings;
import org.chronopolis.ingest.exception.NotFoundException;
import org.chronopolis.rest.models.Bag;
import org.chronopolis.rest.models.BagDistribution;
import org.chronopolis.rest.models.Node;
import org.chronopolis.rest.models.Replication;
import org.chronopolis.rest.models.ReplicationRequest;
......@@ -20,8 +21,10 @@ import javax.transaction.Transactional;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Set;
import static org.chronopolis.ingest.repository.PredicateUtil.setExpression;
import static org.chronopolis.rest.models.BagDistribution.BagDistributionStatus.DISTRIBUTE;
/**
* Class to help querying for replication objects based on various values.
......@@ -94,6 +97,21 @@ public class ReplicationService {
throw new NotFoundException("Bag " + request.getBagId());
}
// create a dist object if it's missing
BagDistribution bagDistribution = null;
Set<BagDistribution> distributions = bag.getDistributions();
for (BagDistribution distribution : distributions) {
if (distribution.getNode().equals(node)) {
bagDistribution = distribution;
}
}
if (bagDistribution == null) {
bag.addDistribution(node, DISTRIBUTE);
// not sure if this is the best place for this...
bagRepository.save(bag);
}
// vars to help create replication stuff
final String user = settings.getReplicationUser();
final String server = settings.getStorageServer();
......
......@@ -119,6 +119,7 @@ public class StagingControllerTest extends IngestTest {
request.setDepositor("test-depositor");
request.setLocation("test-depositor/new-bag-1");
request.setReplicatingNodes(ImmutableList.of("umiacs"));
request.setRequiredReplications(1);
ResponseEntity<Bag> bag = template.postForEntity(
"http://localhost:" + port + "/api/bags",
......
......@@ -5,11 +5,11 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>ingest-shell</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<packaging>jar</packaging>
<name>Ingest Shell</name>
<url>http://maven.apache.org</url>
......
......@@ -5,11 +5,11 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<groupId>org.chronopolis</groupId>
<artifactId>intake-shell</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<packaging>jar</packaging>
<name>Intake Shell</name>
<url>https://chron-git.umiacs.umd.edu/chron-core/</url>
......
......@@ -6,7 +6,7 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<packaging>jar</packaging>
......
......@@ -10,7 +10,7 @@
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<packaging>pom</packaging>
<name>Core Chronopolis</name>
......
......@@ -5,10 +5,10 @@
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<artifactId>replication-shell</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<name>Replication Shell</name>
<url>http://maven.apache.org</url>
<properties>
......
......@@ -6,12 +6,12 @@
<groupId>org.chronopolis</groupId>
<artifactId>rest-common</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
<parent>
<groupId>org.chronopolis</groupId>
<artifactId>chronopolis</artifactId>
<version>1.1.0-RELEASE</version>
<version>1.1.1-RELEASE</version>
</parent>
<dependencies>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment