-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Initial implementation of comparison strategy code. * Added tests and fixed small bug exposed by test. * Upped version number and introduced mockito for testing. * Updated documentation.
- Loading branch information
Showing
15 changed files
with
248 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@echo off | ||
java -Dlog4j.configuration=file:target/classes/log4j.xml -Ds3s3mirror.version=1.2.7 -jar target/s3s3mirror-1.2.7-SNAPSHOT.jar %* | ||
java -Dlog4j.configuration=file:target/classes/log4j.xml -Ds3s3mirror.version=1.2.8 -jar target/s3s3mirror-1.2.7-SNAPSHOT.jar %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/org/cobbzilla/s3s3mirror/comparisonstrategies/ComparisonStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.cobbzilla.s3s3mirror.comparisonstrategies; | ||
|
||
import com.amazonaws.services.s3.model.ObjectMetadata; | ||
import com.amazonaws.services.s3.model.S3ObjectSummary; | ||
|
||
public interface ComparisonStrategy { | ||
boolean sourceDifferent(S3ObjectSummary source, ObjectMetadata destination); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/org/cobbzilla/s3s3mirror/comparisonstrategies/ComparisonStrategyFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.cobbzilla.s3s3mirror.comparisonstrategies; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import org.cobbzilla.s3s3mirror.MirrorOptions; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ComparisonStrategyFactory { | ||
public static ComparisonStrategy getStrategy(MirrorOptions mirrorOptions) { | ||
if (mirrorOptions.isSizeOnly()) { | ||
return new SizeOnlyComparisonStrategy(); | ||
} else if (mirrorOptions.isSizeAndLastModified()) { | ||
return new SizeAndLastModifiedComparisonStrategy(); | ||
} else { | ||
return new EtagComparisonStrategy(); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/org/cobbzilla/s3s3mirror/comparisonstrategies/EtagComparisonStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.cobbzilla.s3s3mirror.comparisonstrategies; | ||
|
||
import com.amazonaws.services.s3.model.ObjectMetadata; | ||
import com.amazonaws.services.s3.model.S3ObjectSummary; | ||
|
||
public class EtagComparisonStrategy extends SizeOnlyComparisonStrategy { | ||
@Override | ||
public boolean sourceDifferent(S3ObjectSummary source, ObjectMetadata destination) { | ||
|
||
return super.sourceDifferent(source, destination) || !source.getETag().equals(destination.getETag()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
.../org/cobbzilla/s3s3mirror/comparisonstrategies/SizeAndLastModifiedComparisonStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.cobbzilla.s3s3mirror.comparisonstrategies; | ||
|
||
import com.amazonaws.services.s3.model.ObjectMetadata; | ||
import com.amazonaws.services.s3.model.S3ObjectSummary; | ||
|
||
public class SizeAndLastModifiedComparisonStrategy extends SizeOnlyComparisonStrategy { | ||
@Override | ||
public boolean sourceDifferent(S3ObjectSummary source, ObjectMetadata destination) { | ||
return super.sourceDifferent(source, destination) || source.getLastModified().after(destination.getLastModified()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/cobbzilla/s3s3mirror/comparisonstrategies/SizeOnlyComparisonStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.cobbzilla.s3s3mirror.comparisonstrategies; | ||
|
||
import com.amazonaws.services.s3.model.ObjectMetadata; | ||
import com.amazonaws.services.s3.model.S3ObjectSummary; | ||
|
||
public class SizeOnlyComparisonStrategy implements ComparisonStrategy { | ||
@Override | ||
public boolean sourceDifferent(S3ObjectSummary source, ObjectMetadata destination) { | ||
return source.getSize() != destination.getContentLength(); | ||
} | ||
} |
Oops, something went wrong.