blob: 473593829a08a59073412842c29fb7ba4ad499d0 (
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
|
package org.openslx.imagemaster.serverconnection;
import java.util.HashMap;
import java.util.List;
/**
* Helper class for the ImageProcessor to know some things about the downloading client
*
*/
public class DownloadingClientInfos
{
public final HashMap<String, ImageInfos> downloadingImages = new HashMap<>();
DownloadingClientInfos()
{
}
public void addDownload( String uuid, int port, List<Integer> list, String token )
{
downloadingImages.put( uuid, new ImageInfos( uuid, port, list, token ) );
}
public void removeDownload( String uuid )
{
downloadingImages.remove( uuid );
}
public boolean isDownloading( String uuid )
{
return downloadingImages.containsKey( uuid );
}
public boolean hasDownloads()
{
return (downloadingImages.size() > 0);
}
public List<Integer> getLastRequestedBlocks( String uuid )
{
if ( !downloadingImages.containsKey( uuid ) )
return null;
return downloadingImages.get( uuid ).lastRequestedBlocks;
}
public void requestBlocks( String uuid, List<Integer> list )
{
if ( !downloadingImages.containsKey( uuid ) )
return;
downloadingImages.get( uuid ).lastRequestedBlocks = list;
}
public String getToken( String uuid )
{
if ( !downloadingImages.containsKey( uuid ) )
return null;
return downloadingImages.get( uuid ).token;
}
public int getPort( String uuid )
{
return downloadingImages.get( uuid ).port;
}
class ImageInfos
{
public final String uuid;
public final String token;
public final int port;
private List<Integer> lastRequestedBlocks;
ImageInfos(String uuid, int port, List<Integer> list, String token)
{
this.uuid = uuid;
this.lastRequestedBlocks = list;
this.token = token;
this.port = port;
}
}
}
|