mirror of
https://github.com/ceph/ceph
synced 2025-02-08 19:38:47 +00:00
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
|
//
|
||
|
// $Id$
|
||
|
//
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include "../osd/rush.h"
|
||
|
|
||
|
main (int argc, char *argv[])
|
||
|
{
|
||
|
Rush rush;
|
||
|
char buf[200];
|
||
|
int i, j, k, numClusters;
|
||
|
int numKeys = 5;
|
||
|
int numReplicas = 4;
|
||
|
int curSize;
|
||
|
double curWeight;
|
||
|
int servers[1000];
|
||
|
|
||
|
if (argc > 1) {
|
||
|
numKeys = atoi (argv[1]);
|
||
|
}
|
||
|
if (argc > 2) {
|
||
|
numReplicas = atoi (argv[2]);
|
||
|
}
|
||
|
|
||
|
fgets (buf, sizeof (buf) - 2, stdin);
|
||
|
sscanf (buf, "%d", &numClusters);
|
||
|
for (i = 0; i < numClusters; i++) {
|
||
|
fgets (buf, sizeof (buf) - 2, stdin);
|
||
|
sscanf (buf, "%d %lf", &curSize, &curWeight);
|
||
|
rush.AddCluster (curSize, curWeight);
|
||
|
if (rush.Servers () < numReplicas) {
|
||
|
fprintf (stderr, "ERROR: must have at least %d disks in the system!\n",
|
||
|
rush.Clusters ());
|
||
|
exit (-1);
|
||
|
}
|
||
|
for (j = 0; j < numKeys; j++) {
|
||
|
rush.GetServersByKey (j, numReplicas, servers);
|
||
|
#if 0
|
||
|
printf ("%-3d %-6d ", i, j);
|
||
|
for (k = 0; k < numReplicas; k++) {
|
||
|
printf ("%-5d ", servers[k]);
|
||
|
}
|
||
|
putchar ('\n');
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
}
|