Merge "Add functions to analyse the composition of payload."
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
{{ mapType.get(operation.type) }}
|
{{ mapType.get(operation.type) }}
|
||||||
<p v-if="operation.dataOffset !== null">
|
<p v-if="operation.hasOwnProperty('dataOffset')">
|
||||||
Data offset: {{ operation.dataOffset }}
|
Data offset: {{ operation.dataOffset }}
|
||||||
</p>
|
</p>
|
||||||
<p v-if="operation.dataLength !== null">
|
<p v-if="operation.hasOwnProperty('dataLength')">
|
||||||
Data length: {{ operation.dataLength }}
|
Data length: {{ operation.dataLength }}
|
||||||
</p>
|
</p>
|
||||||
<p v-if="operation.srcExtents !== null">
|
<p v-if="operation.hasOwnProperty('srcExtents')">
|
||||||
Source: {{ operation.srcExtents.length }} extents ({{ srcTotalBlocks }}
|
Source: {{ operation.srcExtents.length }} extents ({{ srcTotalBlocks }}
|
||||||
blocks)
|
blocks)
|
||||||
<br>
|
<br>
|
||||||
{{ srcBlocks }}
|
{{ srcBlocks }}
|
||||||
</p>
|
</p>
|
||||||
<p v-if="operation.dstExtents !== null">
|
<p v-if="operation.hasOwnProperty('dstExtents')">
|
||||||
Destination: {{ operation.dstExtents.length }} extents ({{ dstTotalBlocks }}
|
Destination: {{ operation.dstExtents.length }} extents ({{ dstTotalBlocks }}
|
||||||
blocks)
|
blocks)
|
||||||
<br>
|
<br>
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { numBlocks, displayBlocks } from '../services/payload_composition.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
operation: {
|
operation: {
|
||||||
@@ -51,16 +53,4 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function numBlocks(exts) {
|
|
||||||
const accumulator = (total, ext) => total + ext.numBlocks
|
|
||||||
return exts.reduce(accumulator, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
function displayBlocks(exts) {
|
|
||||||
const accumulator = (total, ext) =>
|
|
||||||
total + '(' + ext.startBlock + ',' + ext.numBlocks + ')'
|
|
||||||
return exts.reduce(accumulator, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -35,3 +35,14 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
ul > li {
|
||||||
|
display: inline-block;
|
||||||
|
list-style-type: none;
|
||||||
|
margin-left: 5%;
|
||||||
|
margin-right: 5%;
|
||||||
|
top: 0px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
71
tools/otagui/src/components/PayloadComposition.vue
Normal file
71
tools/otagui/src/components/PayloadComposition.vue
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<template>
|
||||||
|
<PartialCheckbox
|
||||||
|
v-model="partitionInclude"
|
||||||
|
:labels="updatePartitions"
|
||||||
|
/>
|
||||||
|
<button @click="updateChart">
|
||||||
|
Update the chart
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
v-if="listData"
|
||||||
|
class="list-data"
|
||||||
|
>
|
||||||
|
<pre>
|
||||||
|
{{ listData }}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PartialCheckbox from '@/components/PartialCheckbox.vue'
|
||||||
|
import { operatedBlockStatistics } from '../services/payload_composition.js'
|
||||||
|
import { EchartsData } from '../services/echarts_data.js'
|
||||||
|
import { chromeos_update_engine as update_metadata_pb } from '../services/update_metadata_pb.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
PartialCheckbox,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
manifest: {
|
||||||
|
type: update_metadata_pb.DeltaArchiveManifest,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
partitionInclude: new Map(),
|
||||||
|
echartsData: null,
|
||||||
|
listData: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
updatePartitions() {
|
||||||
|
return this.manifest.partitions.map((partition) => {
|
||||||
|
return partition.partitionName
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.manifest.partitions.forEach((partition) => {
|
||||||
|
this.partitionInclude.set(partition.partitionName, true)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateChart() {
|
||||||
|
let partitionSelected = this.manifest.partitions.filter((partition) =>
|
||||||
|
this.partitionInclude.get(partition.partitionName)
|
||||||
|
)
|
||||||
|
let statisticsData = operatedBlockStatistics(partitionSelected)
|
||||||
|
this.echartsData = new EchartsData(statisticsData)
|
||||||
|
this.listData = this.echartsData.listData()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.list-data {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -8,6 +8,10 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="payload">
|
<div v-if="payload">
|
||||||
|
<h3>Payload Compositin</h3>
|
||||||
|
<div v-if="payload.manifest">
|
||||||
|
<PayloadComposition :manifest="payload.manifest" />
|
||||||
|
</div>
|
||||||
<h3>Partition List</h3>
|
<h3>Partition List</h3>
|
||||||
<ul v-if="payload.manifest">
|
<ul v-if="payload.manifest">
|
||||||
<li
|
<li
|
||||||
@@ -38,11 +42,13 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import PartitionDetail from './PartitionDetail.vue'
|
import PartitionDetail from './PartitionDetail.vue'
|
||||||
|
import PayloadComposition from './PayloadComposition.vue'
|
||||||
import { Payload } from '@/services/payload.js'
|
import { Payload } from '@/services/payload.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
PartitionDetail,
|
PartitionDetail,
|
||||||
|
PayloadComposition,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
zipFile: {
|
zipFile: {
|
||||||
|
|||||||
14
tools/otagui/src/services/echarts_data.js
Normal file
14
tools/otagui/src/services/echarts_data.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// This function will be used later for generating a pie chart through eCharts
|
||||||
|
export class EchartsData {
|
||||||
|
constructor(statisticData) {
|
||||||
|
this.statisticData = statisticData
|
||||||
|
}
|
||||||
|
|
||||||
|
listData() {
|
||||||
|
let table = ''
|
||||||
|
for (let [key, value] of this.statisticData) {
|
||||||
|
table += key + ' : ' + value.toString() + ' Blocks' + '\n'
|
||||||
|
}
|
||||||
|
return table
|
||||||
|
}
|
||||||
|
}
|
||||||
73
tools/otagui/src/services/payload_composition.js
Normal file
73
tools/otagui/src/services/payload_composition.js
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { OpType } from '@/services/payload.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a statistics over the numbers of blocks (in destination) that are
|
||||||
|
* being operated by different installation operation (e.g. REPLACE, BSDIFF).
|
||||||
|
* Only partitions that are being passed in will be included.
|
||||||
|
* @param {Array<PartitionUpdate>} partitions
|
||||||
|
* @return {Map}
|
||||||
|
*/
|
||||||
|
export function operatedBlockStatistics(partitions) {
|
||||||
|
let operatedBlocks = new Map()
|
||||||
|
let opType = new OpType()
|
||||||
|
for (let partition of partitions) {
|
||||||
|
for (let operation of partition.operations) {
|
||||||
|
let operationType = opType.mapType.get(operation.type)
|
||||||
|
if (!operatedBlocks.get(operationType)) {
|
||||||
|
operatedBlocks.set(operationType, 0)
|
||||||
|
}
|
||||||
|
operatedBlocks.set(
|
||||||
|
operationType,
|
||||||
|
operatedBlocks.get(operationType) + numBlocks(operation.dstExtents)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return operatedBlocks
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a statistics over the disk usage of payload.bin, based on the type of
|
||||||
|
* installation operations. Only partitions that are being passed in will be
|
||||||
|
* included.
|
||||||
|
* @param {Array<PartitionUpdate>} partitions
|
||||||
|
* @return {Map}
|
||||||
|
*/
|
||||||
|
export function operatedPayloadStatistics(partitions) {
|
||||||
|
let operatedBlocks = new Map()
|
||||||
|
let opType = new OpType()
|
||||||
|
for (let partition of partitions) {
|
||||||
|
for (let operation of partition.operations) {
|
||||||
|
let operationType = opType.mapType.get(operation.type)
|
||||||
|
if (!operatedBlocks.get(operationType)) {
|
||||||
|
operatedBlocks.set(operationType, 0)
|
||||||
|
}
|
||||||
|
operatedBlocks.set(
|
||||||
|
operationType,
|
||||||
|
operatedBlocks.get(operationType) + operation.dataLength
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return operatedBlocks
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the number of blocks being operated
|
||||||
|
* @param {Array<InstallOperations>} exts
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
export function numBlocks(exts) {
|
||||||
|
const accumulator = (total, ext) => total + ext.numBlocks
|
||||||
|
return exts.reduce(accumulator, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string that indicates the blocks being operated
|
||||||
|
* in the manner of (start_block, block_length)
|
||||||
|
* @param {Array<InstallOperations} exts
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
export function displayBlocks(exts) {
|
||||||
|
const accumulator = (total, ext) =>
|
||||||
|
total + '(' + ext.startBlock + ',' + ext.numBlocks + ')'
|
||||||
|
return exts.reduce(accumulator, '')
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user