blob: 0e361755a223d7a438493748f01f92c3d7625c5d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
package org.openslx.imagemaster.serverconnection;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.log4j.Logger;
import org.openslx.imagemaster.db.DbImage;
/**
* Helper class for ImageProcessor to save some infos about the images in the process list.
*/
public class UploadingImage
{
public static final Logger log = Logger.getLogger( UploadingImage.class );
/**
* Token for the satellite.
*/
private String token;
/**
* The missing blocks that need to be uploaded by the satellite.
*/
private List<Integer> missingBlocks;
/**
* The list of blocks that were requested but not checked
*/
private List<Integer> blocksToCheck = new LinkedList<>();
private Timestamp ts; // when did the server something for the last time
private DbImage dbImage = null; // the DB representation of this image
private String uuid;
private String filename;
private String crcFilename;
protected UploadingImage(String token, List<Integer> missingBlocks, Timestamp ts, String uuid, String filename, String crcFilename)
{
this.token = token;
this.missingBlocks = missingBlocks;
this.ts = ts;
this.uuid = uuid;
this.crcFilename = crcFilename;
}
protected void removeBlock( int number )
{
this.missingBlocks.remove( number );
dbImage.updateMissingBlocks( missingBlocks );
}
protected void removeBlocks( Collection<Integer> list )
{
this.missingBlocks.removeAll( list );
dbImage.updateMissingBlocks( missingBlocks );
}
protected void addBlockToCheck( int number )
{
synchronized ( blocksToCheck ) {
blocksToCheck.add( number );
}
log.debug( number + " added to check list..." );
}
protected List<Integer> getNotCheckedBlocks()
{
return this.blocksToCheck;
}
protected String getToken()
{
return this.token;
}
protected List<Integer> getAllMissingBlocks()
{
return this.missingBlocks;
}
protected Timestamp getTimestamp()
{
return this.ts;
}
protected DbImage getDbImage()
{
if ( dbImage == null ) {
dbImage = DbImage.getImageByUUID( this.uuid );
}
return this.dbImage;
}
protected String getFilename()
{
return this.filename;
}
protected String getCrcFilename()
{
return this.crcFilename;
}
public int amountOfMissingBlocks()
{
return missingBlocks.size();
}
public int removeMissingBlock( int index )
{
synchronized ( missingBlocks ) {
return missingBlocks.remove( index );
}
}
}
|