Friday, June 3, 2016

How does backup of a virtual instance work in VMWare - a do it yourself approach:
Let us assume we know where to find the vmdk file for the virtual machine instance. A running instance may not have all its state flushed to disk. A powered off VM instance does. If the machine is powered off, we can use the virtual machine directly. If the machine is powered on, we can clone the vm so that we don't disturb the running instance. With a cloned vm, we can now access the vmdk with the state flushed to disk. Sometimes we can even do without powering off by requiring a restart so that the state is flushed to disk. We can use less intrusive techniques if the instance provides so.
Now that we have a vmdk, we package a ovf file. To do so, we create a descriptor using the ovfmanager and the virtual machine instance.
When we write the ovf file, we can then package the vmdks and the ovf file into an archive with an ova file extension. We just tar ball this in a specific layout to create the ova file.

We continue with a few more coding questions from our earlier posts this week.
#codingquestions
Find the maximum sum path across two arrays. We are given two sorted arrays and we can switch the arrays only on a common element. The sum is continuous along the path chosen.

int GetMaxSumPath(List<int> first, List<int> second)
{
int i =0;
int j =0;
int sum1=0;
int sum2=0;
int result =0;
while(i < first.count && j <second.count)
{
if (first[i] < second[j]){
    sum1 += first[i];
    i++;
    }
else if (first[i] > second[j]){
   sum2 += second[j];
   j++
}
else{
  // intersection
   result += max(sum1, sum2);
  sum1 = 0;
  sum2 = 0;
  while ( i < first.Count && j < second.Count && first[i] == second[j])
  {
    result = result + first[i];
    i++;
    j++;
  }
}
}
while (i < first.count)
{
  sum1 += first[i];
  i++;
}
while (j < second.count)
{
  sum2 += second[j];
  j++;
}
result += max(sum1, sum2);
return result;
}

None balls with one heavier than other. Find it
Int getheavier (List <int> balls)
{
var grp1 = balls.range (0,3);
var grp2 = balls.range (3,3);
var grp3 = balls.range (6,3);
var next = max (grp1,grp2,grp3);
Next = next.split ();
Return max (next);
}

No comments:

Post a Comment