Add OSDK driver for manifest

Now we can easily test performance and size differences between OSDK
and sqlite. The expectation here is we will use sqlite going forward,
but the extra validation for speed and size will be comforting.

Adds a new --driver option to generate_manifest.py to select between
osdk and sqlite

Change-Id: I59751080b3169d3d7bfd1f60a73edabe307d7fbf
This commit is contained in:
SamYaple 2016-01-09 02:30:24 +00:00
parent a9d13fc32f
commit d31e2ebef5
2 changed files with 63 additions and 1 deletions

53
ekko/manifest/osdk.py Normal file
View File

@ -0,0 +1,53 @@
# Copyright 2016 Sam Yaple
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# NOTE(SamYaple): This driver is an expiremental driver used for testing. It is
# an optimized file used to compare to and optimized the sqlite driver. This
# driver may fall in and out of maintenance and will only be used as a sanity
# check for the sqlite driver for as long as this NOTE is present.
import os
from struct import pack
from ekko.manifest import driver
class OSDKDriver(driver.ManifestDriver):
def initialize(self):
with open(self.manifest_file, 'wb', 4096) as f:
f.write(os.urandom(20))
def put_segments(self, segments):
with open(self.manifest_file, 'ab', 4096) as f:
for segment in segments:
f.write(pack(
'<16s2I2B20s',
segment.backupset_id,
segment.incremental,
segment.segment,
segment.compression,
segment.encryption,
segment.segment_hash
))
def put_metadata(self, metadata):
with open(self.manifest_file, 'ab', 4096) as f:
f.write(pack(
'<2IQ24s',
metadata.incremental,
metadata.segment_size,
metadata.sectors,
metadata.timestamp
))

View File

@ -27,6 +27,12 @@ from ekko.manifest import structure as manifest_structure
from six.moves import range
DRIVERS = {
'osdk': 'osdk.OSDKDriver',
'sqlite': 'sqlite.SQLiteDriver'
}
def parse_args():
parser = argparse.ArgumentParser(description='Backup Block Device')
parser.add_argument('--backupsize', required=True, type=int,
@ -35,6 +41,8 @@ def parse_args():
help='manifest file')
parser.add_argument('--cbt', required=False,
help='change block tracking info')
parser.add_argument('--driver', required=False, default='sqlite',
choices=['osdk', 'sqlite'], help='manifest driver')
return parser.parse_args()
@ -60,7 +68,8 @@ def main():
print('manifest exists; exiting')
return
manifest = manifest_driver.load_manifest_driver(args.manifest)
manifest = manifest_driver.load_manifest_driver(args.manifest,
DRIVERS[args.driver])
size_of_disk = args.backupsize * 1024**3 # Convert GB to B
num_of_sectors = int(size_of_disk / 512)