Skip to content

Commit ae4fb2c

Browse files
committed
- v0.5.13
- verbose mode improvements - close header is set when the request is smaller than the blocksize - Dial timeout and keep alive is set to 30 seconds.
1 parent 6cc7e56 commit ae4fb2c

File tree

8 files changed

+53
-29
lines changed

8 files changed

+53
-29
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Sources and targets are decoupled, this design enables the composition of variou
2929
Download, extract and set permissions:
3030

3131
```bash
32-
wget -O bp_linux.tar.gz https://github.com/Azure/blobporter/releases/download/v0.5.12/bp_linux.tar.gz
32+
wget -O bp_linux.tar.gz https://github.com/Azure/blobporter/releases/download/v0.5.13/bp_linux.tar.gz
3333
tar -xvf bp_linux.tar.gz linux_amd64/blobporter
3434
chmod +x ~/linux_amd64/blobporter
3535
cd ~/linux_amd64
@@ -46,7 +46,7 @@ export ACCOUNT_KEY=<STORAGE_ACCOUNT_KEY>
4646
4747
### Windows
4848

49-
Download [BlobPorter.exe](https://github.com/Azure/blobporter/releases/download/v0.5.12/bp_windows.zip)
49+
Download [BlobPorter.exe](https://github.com/Azure/blobporter/releases/download/v0.5.13/bp_windows.zip)
5050

5151
Set environment variables (if using the command prompt):
5252

blobporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const (
4949
// User can use environment variables to specify storage account information
5050
storageAccountNameEnvVar = "ACCOUNT_NAME"
5151
storageAccountKeyEnvVar = "ACCOUNT_KEY"
52-
programVersion = "0.5.12" // version number to show in help
52+
programVersion = "0.5.13" // version number to show in help
5353
)
5454

5555
const numOfWorkersFactor = 8

inttest._m.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fi
2525
echo "Creating working files..."
2626
mkdir -p $WORKING_DIR
2727

28-
dd if=/dev/urandom of=$F1 bs=64M count=1 iflag=fullblock
29-
dd if=/dev/urandom of=$P1 bs=64M count=1 iflag=fullblock
28+
dd if=/dev/urandom of=$F1 bs=64M count=8 iflag=fullblock
29+
dd if=/dev/urandom of=$P1 bs=64M count=2 iflag=fullblock
3030

3131

3232
#Scenario 1 - Simple upload/download with default values
@@ -47,14 +47,14 @@ calculateMD5 $P1 $DOWN_P1
4747

4848
#Scenario 3 - Silent page upload/download with default values
4949
#Upload vhd
50-
./blobporter -f $P1 -c $CONT -n $DOWN_p1 -t file-pageblob -q
50+
./blobporter -f $P1 -c $CONT -n $DOWN_P1 -t file-pageblob -q
5151
#Download vhd
5252
./blobporter -n $DOWN_P1 -c $CONT -t pageblob-file -q
5353
calculateMD5 $P1 $DOWN_P1
5454

5555
#Scenario 4 - Silent page upload/download with default values and md5
5656
#Upload vhd
57-
./blobporter -f $P1 -c $CONT -t -n $DOWN_p1 file-pageblob -q -m
57+
./blobporter -f $P1 -c $CONT -n $DOWN_P1 -t file-pageblob -q -m
5858
#Download vhd
5959
./blobporter -n $DOWN_P1 -c $CONT -t pageblob-file -q -m
6060
calculateMD5 $P1 $DOWN_P1
@@ -80,3 +80,24 @@ calculateMD5 vd1.mp4 vd1f.mp4
8080
#Download file
8181
./blobporter -n $DOWN_F1 -c $CONT -t blob-file -b 16MB
8282
calculateMD5 $F1 $DOWN_F1
83+
84+
85+
#Scenario 7 - Simple upload/download with file smaller than the block size
86+
dd if=/dev/urandom of=$F1 bs=16M count=1 iflag=fullblock
87+
88+
#Upload file
89+
./blobporter -f $F1 -c $CONT -n $DOWN_F1 -b 32MB
90+
91+
#Download file
92+
./blobporter -n $DOWN_F1 -c $CONT -t blob-file -b 32MB
93+
calculateMD5 $F1 $DOWN_F1
94+
95+
#Scenario 8 - Simple upload/download with file equal than the block size
96+
dd if=/dev/urandom of=$F1 bs=36M count=1 iflag=fullblock
97+
98+
#Upload file
99+
./blobporter -f $F1 -c $CONT -n $DOWN_F1 -b 32MB
100+
101+
#Download file
102+
./blobporter -n $DOWN_F1 -c $CONT -t blob-file -b 32MB
103+
calculateMD5 $F1 $DOWN_F1

sources/http.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ func (f *HTTPPipeline) ExecuteReader(partitionsQ chan pipeline.PartsPartition, p
149149

150150
header := fmt.Sprintf("bytes=%v-%v", p.Offset, p.Offset-1+uint64(p.BytesToRead))
151151
req.Header.Set("Range", header)
152-
req.Close = true
152+
153+
//set the close header only when the block is larger than the blob
154+
//to minimize the number of open when transfering small files.
155+
if p.BytesToRead < p.BlockSize {
156+
req.Close = true
157+
}
153158

154159
if res, err = f.HTTPClient.Do(req); err != nil || res.StatusCode != 206 {
155160
var status int
@@ -158,9 +163,8 @@ func (f *HTTPPipeline) ExecuteReader(partitionsQ chan pipeline.PartsPartition, p
158163
err = fmt.Errorf("Invalid status code in the response. Status: %v Bytes: %v", status, header)
159164
}
160165

161-
if util.Verbose {
162-
fmt.Printf("EH|R|%v|%v|%v|%v|%v\n", p.BlockID, p.BytesToRead, status, err, header)
163-
}
166+
util.PrintfIfDebug("ExecuteReader -> |%v|%v|%v|%v|%v", p.BlockID, p.BytesToRead, status, err, header)
167+
164168
return err
165169
}
166170
p.Data, err = ioutil.ReadAll(res.Body)
@@ -172,9 +176,9 @@ func (f *HTTPPipeline) ExecuteReader(partitionsQ chan pipeline.PartsPartition, p
172176
if f.includeMD5 {
173177
p.MD5()
174178
}
175-
if util.Verbose {
176-
fmt.Printf("OK|R|%v|%v|%v|%v|%v\n", p.BlockID, p.BytesToRead, res.StatusCode, res.ContentLength, header)
177-
}
179+
180+
util.PrintfIfDebug("ExecuteReader -> |%v|%v|%v|%v|%v", p.BlockID, p.BytesToRead, res.StatusCode, res.ContentLength, header)
181+
178182
return nil
179183
})
180184

sources/multifile.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ func (f *MultiFilePipeline) ExecuteReader(partitionsQ chan pipeline.PartsPartiti
195195
log.Fatal(err)
196196
}
197197

198-
if util.Verbose {
199-
fmt.Printf("OKR|R|%v|%v|%v|%v/n", part.BlockID, bytesRead, part.TargetAlias, part.BytesToRead)
200-
}
198+
util.PrintfIfDebug("ExecuteReader -> %v|%v|%v|%v", part.BlockID, bytesRead, part.TargetAlias, part.BytesToRead)
201199

202200
if f.includeMD5 {
203201
part.MD5()

targets/azureblock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (t *AzureBlock) CommitList(listInfo *pipeline.TargetCommittedListInfo, numb
5151
if util.Verbose {
5252
fmt.Printf("Final BlockList:\n")
5353
for j := 0; j < numberOfBlocks; j++ {
54-
fmt.Printf(" [%2d]: ID=%s, Status=%s", j, blockList[j].ID, blockList[j].Status)
54+
fmt.Printf(" [%2d]: ID=%s, Status=%s\n", j, blockList[j].ID, blockList[j].Status)
5555
}
5656
}
5757

targets/azurepage.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,13 @@ func (t *AzurePage) WritePart(part *pipeline.Part) (duration time.Duration, star
8888
headers["Content-MD5"] = part.MD5()
8989
}
9090
if err := (*t.StorageClient).PutPage(t.Container, part.TargetAlias, offset, endByte, "update", part.Data, headers); err != nil {
91-
if util.Verbose {
92-
fmt.Printf("EH|S|%v|%v|%v|%v\n", part.Offset, len(part.Data), part.TargetAlias, err)
93-
}
91+
util.PrintfIfDebug("WritePart -> |%v|%v|%v|%v", part.Offset, len(part.Data), part.TargetAlias, err)
9492
t.resetClient()
9593
return err
9694
}
9795

98-
if util.Verbose {
99-
fmt.Printf("OKA|S|%v|%v|%v|%v\n", part.Offset, len(part.Data), part.TargetAlias, err)
100-
}
96+
util.PrintfIfDebug("WritePart -> |%v|%v|%v", part.Offset, len(part.Data), part.TargetAlias)
97+
10198
return nil
10299
})
103100

util/util.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"fmt"
66
"log"
7+
"net"
78
"os"
89
"regexp"
910
"strconv"
@@ -199,10 +200,8 @@ func RetriableOperation(operation func(r int) error) (duration time.Duration, st
199200
}
200201
retries++
201202

202-
if Verbose {
203-
fmt.Printf(" R %v ", retries)
204-
fmt.Println(err.Error())
205-
}
203+
PrintfIfDebug("RetriableOperation -> |%v|%v", retries, err)
204+
206205
time.Sleep(retrySleepDuration)
207206
}
208207
}
@@ -391,12 +390,17 @@ func getStorageHTTPClient() *http.Client {
391390

392391
}
393392

394-
//NewHTTPClient creates a new HTTP client with the configured timeout and MaxIdleConnsPerHost = 100
393+
//NewHTTPClient creates a new HTTP client with the configured timeout and MaxIdleConnsPerHost = 50, keep alive dialer.
394+
395395
func NewHTTPClient() *http.Client {
396396

397397
c := http.Client{
398398
Timeout: time.Duration(HTTPClientTimeout) * time.Second,
399399
Transport: &http.Transport{
400+
Dial: (&net.Dialer{
401+
Timeout: 30 * time.Second, // dial timeout
402+
KeepAlive: 30 * time.Second,
403+
}).Dial,
400404
MaxIdleConns: maxIdleConns,
401405
MaxIdleConnsPerHost: maxIdleConnsPerHost}}
402406

0 commit comments

Comments
 (0)