Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@ pipeline {
sh 'mvn -B -V verify -Prun-its -Pci'
}
}
stage('Deploy') {
when { branch 'master' }
steps {
echo "Deploy"
sh 'mvn help:effective-settings -B -V deploy -e'
}
}
stage('Archive') {
steps {
echo "Archive"
archiveArtifacts artifacts: "$artifact", fingerprint: true
}
}
stage('Check Image Build Hook') {
when {
expression { env.IMG_BUILD_HOOKS != null }
Expand All @@ -54,6 +41,25 @@ pipeline {
}
}
}
stage('Deploy') {
when {
allOf {
expression { img_build_hook != null }
expression { env.CHANGE_ID == null } // Not pull request
branch 'master'
}
}
steps {
echo "Deploy"
sh 'mvn help:effective-settings -B -V deploy -e'
}
}
stage('Archive') {
steps {
echo "Archive"
archiveArtifacts artifacts: "$artifact", fingerprint: true
}
}
stage('Build & Push Image') {
when {
allOf {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ private TrackedContentEntryDTO constructContentEntryDTO( final TrackedContentEnt
entryDTO.setSha1( entry.getSha1() );
entryDTO.setSha256( entry.getSha256() );
entryDTO.setSize( entry.getSize() );
entryDTO.setTimestamps( entry.getTimestamps() );
return entryDTO;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,20 @@ public synchronized boolean recordArtifact( final TrackedContentEntry entry )

Logger logger = LoggerFactory.getLogger( getClass() );
logger.debug( "Adding tracking entry: {}", entry );
inProgressRecordCache.put( entry, entry );
return true;
return inProgressRecordCache.executeCache( (cache)->{
TrackedContentEntry existing = cache.get( entry );
if ( existing != null )
{
existing.merge( entry );
cache.put( existing, existing );
}
else
{
cache.put( entry, entry );
}

return true;
} );
}

@Measure( timers = @MetricNamed( DEFAULT ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void run() throws Exception
Set<TrackedContentEntryDTO> uploads = report.getUploads();
uploads.forEach( et -> {
System.out.println( ">>> md5: " + et.getMd5() + ", size=" + et.getSize() );
assertThat( et.getSize(), equalTo( (long) b2.length ) );
assertThat( "Mismatched size for: " + et.getPath(), et.getSize(), equalTo( (long) b2.length ) );
} );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.commonjava.indy.model.core.AccessChannel;
import org.commonjava.indy.model.core.StoreKey;

import java.util.Set;

public class TrackedContentEntryDTO
implements Comparable<TrackedContentEntryDTO>
{
Expand Down Expand Up @@ -48,6 +50,8 @@ public class TrackedContentEntryDTO

private Long size;

private Set<Long> timestamps;

public TrackedContentEntryDTO()
{
}
Expand Down Expand Up @@ -238,4 +242,13 @@ public String toString()
storeKey, accessChannel, path, originUrl, localUrl, size, md5, sha256 );
}

public Set<Long> getTimestamps()
{
return timestamps;
}

public void setTimestamps( final Set<Long> timestamps )
{
this.timestamps = timestamps;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import static org.commonjava.indy.model.core.AccessChannel.GENERIC_PROXY;
import static org.commonjava.indy.pkg.PackageTypeConstants.PKG_TYPE_GENERIC_HTTP;
Expand All @@ -31,7 +34,9 @@
public class TrackedContentEntry
implements Comparable<TrackedContentEntry>,Externalizable
{
private static final int VERSION = 2;
private static final long serialVersionUID = 6469004486206600578L;

private static final int VERSION = 3;

private TrackingKey trackingKey;

Expand All @@ -55,6 +60,8 @@ public class TrackedContentEntry

private long index = System.currentTimeMillis();

private Set<Long> timestamps;

public TrackedContentEntry()
{
}
Expand All @@ -74,6 +81,7 @@ public TrackedContentEntry( final TrackingKey trackingKey, final StoreKey storeK
this.sha1=sha1;
this.sha256=sha256;
this.size = size;
this.timestamps = new HashSet<>( Collections.singleton( System.currentTimeMillis() ) );
}

public String getOriginUrl()
Expand Down Expand Up @@ -278,6 +286,7 @@ public void writeExternal( final ObjectOutput out )
out.writeObject( sha256 == null ? "" : sha256 );
out.writeObject( size );
out.writeLong( index );
out.writeObject( timestamps );
}

@Override
Expand Down Expand Up @@ -357,6 +366,29 @@ else if ( whatIsThis instanceof TrackingKey )

index = in.readLong();

if ( version > 2 )
{
final Set<Long> tstamps = (Set<Long>) in.readObject();
timestamps = tstamps;
}
}

public Set<Long> getTimestamps()
{
return timestamps;
}

public void setTimestamps( final Set<Long> timestamps )
{
this.timestamps = timestamps;
}

public void merge( TrackedContentEntry from )
{
this.md5 = from.md5;
this.sha1 = from.sha1;
this.sha256 = from.sha256;
this.size = from.size;
this.timestamps.addAll( from.timestamps );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Set;

import static org.commonjava.indy.folo.model.StoreEffect.DOWNLOAD;
import static org.commonjava.indy.model.core.AccessChannel.GENERIC_PROXY;
Expand All @@ -33,6 +34,7 @@
import static org.commonjava.indy.pkg.PackageTypeConstants.PKG_TYPE_GENERIC_HTTP;
import static org.commonjava.indy.pkg.PackageTypeConstants.PKG_TYPE_MAVEN;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

public class TrackedContentEntryTest
Expand Down Expand Up @@ -86,6 +88,59 @@ public void externalizeAsV1_readCurrentVersion()
assertThat( out.getSha256(), equalTo( test.getSha256() ) );
}

/**
* We have to hack this test a bit in order to test the ability to deserialize this first version of
* TrackedContentEntry.
* @throws IOException
* @throws ClassNotFoundException
*/
@Test
public void externalizeAsV2_readCurrentVersion()
throws IOException, ClassNotFoundException
{
TrackedContentEntryV2 ev2 = new TrackedContentEntryV2( new TrackingKey( "test-key" ),
new StoreKey( PKG_TYPE_GENERIC_HTTP, remote,
"some-upstream" ), GENERIC_PROXY,
"http://some.upstream.url/path/to/file", "path/to/file",
DOWNLOAD, 10101010L, "aaaafffffccccceeeeddd",
"bbbcccceeeedddaaaaa", "aaadadaaaadaeee" );

TrackedContentEntry out = new TrackedContentEntry( new TrackingKey( "test-key2" ),
new StoreKey( PKG_TYPE_MAVEN, hosted,
"some-upstream2" ), MAVEN_REPO,
"http://some.upstream.url/path/to/file2", "path/to/file2",
DOWNLOAD, 10101011L, "aaaafffffccccceeeedddfffffff",
"bbbcccceeeedddaaaaaffffffff", "aaadadaaaadaeeeffffffff" );

// nullify this to make sure that reading from the old version of the object doesn't set it.
out.setTimestamps( null );

TrackedContentEntry test =
new TrackedContentEntry( ev2.getTrackingKey(), ev2.getStoreKey(), ev2.getAccessChannel(),
ev2.getOriginUrl(), ev2.getPath(), ev2.getEffect(), ev2.getSize(),
ev2.getMd5(), ev2.getSha1(), ev2.getSha256() );

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( baos );
ev2.writeExternal( oos );
oos.flush();

ObjectInputStream oin = new ObjectInputStream( new ByteArrayInputStream( baos.toByteArray() ) );
out.readExternal( oin );

assertThat( out.getTrackingKey(), equalTo( test.getTrackingKey() ) );
assertThat( out.getStoreKey(), equalTo( test.getStoreKey() ) );
assertThat( out.getAccessChannel(), equalTo( test.getAccessChannel() ) );
assertThat( out.getOriginUrl(), equalTo( test.getOriginUrl() ) );
assertThat( out.getPath(), equalTo( test.getPath() ) );
assertThat( out.getEffect(), equalTo( test.getEffect() ) );
assertThat( out.getSize(), equalTo( test.getSize() ) );
assertThat( out.getMd5(), equalTo( test.getMd5() ) );
assertThat( out.getSha1(), equalTo( test.getSha1() ) );
assertThat( out.getSha256(), equalTo( test.getSha256() ) );
assertThat( out.getTimestamps(), nullValue() );
}

@Test
public void serializeRoundTrip_CurrentVersion()
throws IOException, ClassNotFoundException
Expand Down Expand Up @@ -120,5 +175,6 @@ public void serializeRoundTrip_CurrentVersion()
assertThat( out.getMd5(), equalTo( test.getMd5() ) );
assertThat( out.getSha1(), equalTo( test.getSha1() ) );
assertThat( out.getSha256(), equalTo( test.getSha256() ) );
assertThat( out.getTimestamps(), equalTo( test.getTimestamps() ) );
}
}
Loading