1 package org.openslx.imagemaster.serverconnection;
4 import java.io.FileNotFoundException;
5 import java.nio.ByteBuffer;
6 import java.sql.SQLException;
10 import org.apache.logging.log4j.LogManager;
11 import org.apache.logging.log4j.Logger;
12 import org.
openslx.bwlp.thrift.iface.ImagePublishData;
13 import org.
openslx.bwlp.thrift.iface.TInvocationException;
14 import org.
openslx.bwlp.thrift.iface.TransferInformation;
15 import org.
openslx.filetransfer.util.ChunkStatus;
16 import org.
openslx.filetransfer.util.FileChunk;
17 import org.
openslx.filetransfer.util.IncomingTransferBase;
35 public IncomingTransfer( ImagePublishData img, List<ByteBuffer> blockHashes, File absDestination,
int plainPort,
int sslPort )
36 throws TInvocationException, FileNotFoundException
38 super( UUID.randomUUID().toString(), absDestination, img.fileSize, ThriftUtil.unwrapByteBufferList( blockHashes ), null );
39 this.imageVersionId = img.imageVersionId;
40 this.transferInfo =
new TransferInformation( getId(), plainPort, sslPort );
42 if ( absDestination.exists() && absDestination.length() > 0 ) {
45 if ( !statusList.isEmpty() ) {
46 getChunks().resumeFromStatusList( statusList, absDestination.length() );
47 for (
int i = 0; i < 3; ++i ) {
48 queueUnhashedChunk(
false );
51 }
catch ( SQLException e ) {
54 LOGGER.info(
"Incoming transfer started" );
67 getTmpFileName().delete();
82 potentialFinishTime.set( System.currentTimeMillis() );
85 }
catch ( SQLException e ) {
88 LOGGER.info(
"Incoming transfer ended" );
101 if ( chunk.getFailCount() > 6 ) {
103 LOGGER.warn(
"Server is cancelling upload of Version " + imageVersionId
104 +
": Hash check for block " + chunk.getChunkIndex()
105 +
" failed " + chunk.getFailCount()
108 ChunkStatus status = chunk.getStatus();
109 if ( status == ChunkStatus.MISSING || status == ChunkStatus.COMPLETE ) {
112 }
catch ( InterruptedException e ) {
static String getImageDir()
final String imageVersionId
IncomingTransfer(ImagePublishData img, List< ByteBuffer > blockHashes, File absDestination, int plainPort, int sslPort)
static List< Boolean > getMissingStatusList(String imageVersionId)
boolean hasEnoughFreeSpace()
Object getImageVersionId()
static String getRelativePath(File absolutePath, File parentDir)
boolean finishIncomingTransfer()
Representing an image in the database.
static boolean isReadOnlyMode()
synchronized void cancel()
Class to hold global constants and properties from 'config/global.properties'.
TransferInformation getTransferInfo()
static final long MIN_FREE_SPACE_BYTES
final TransferInformation transferInfo
void chunkStatusChanged(FileChunk chunk)
static void markValid(String imageVersionId, boolean isValid)
static final Logger LOGGER
Some utilities to make our lives easier.
static void asyncUpdate(String imageVersionId, FileChunk chunk)
static File getImagePath()