|
@@ -45,6 +45,7 @@
|
|
#include <vector>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <unordered_map>
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
|
+#include <time.h>
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
//#define EXTRA_LOGGING
|
|
//#define EXTRA_LOGGING
|
|
@@ -176,6 +177,15 @@ static IPropertyTree *getEmptyAttr()
|
|
return createPTree("Attr");
|
|
return createPTree("Attr");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static double calcFileCost(const char * cluster, double sizeGB, double fileAgeDays)
|
|
|
|
+{
|
|
|
|
+ IPropertyTree * plane = queryStoragePlane(cluster);
|
|
|
|
+ if (!plane)
|
|
|
|
+ return 0.0;
|
|
|
|
+ double storageCostDaily = plane->getPropReal("cost/@storageAtRest", 0.0) * 12 / 365;
|
|
|
|
+ return storageCostDaily * sizeGB * fileAgeDays;
|
|
|
|
+}
|
|
|
|
+
|
|
RemoteFilename &constructPartFilename(IGroup *grp,unsigned partno,unsigned partmax,const char *name,const char *partmask,const char *partdir,unsigned copy,ClusterPartDiskMapSpec &mspec,RemoteFilename &rfn)
|
|
RemoteFilename &constructPartFilename(IGroup *grp,unsigned partno,unsigned partmax,const char *name,const char *partmask,const char *partdir,unsigned copy,ClusterPartDiskMapSpec &mspec,RemoteFilename &rfn)
|
|
{
|
|
{
|
|
partno--;
|
|
partno--;
|
|
@@ -4705,6 +4715,27 @@ public:
|
|
else
|
|
else
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+ virtual double getCost(const char * cluster) override
|
|
|
|
+ {
|
|
|
|
+ CDateTime dt;
|
|
|
|
+ getModificationTime(dt);
|
|
|
|
+ double fileAgeDays = difftime(time(nullptr), dt.getSimple())/(24*60*60);
|
|
|
|
+ double sizeGB = getDiskSize(true, false) / ((double)1024 * 1024 * 1024);
|
|
|
|
+
|
|
|
|
+ if (isEmptyString(cluster))
|
|
|
|
+ {
|
|
|
|
+ StringArray clusterNames;
|
|
|
|
+ unsigned countClusters = getClusterNames(clusterNames);
|
|
|
|
+ double totalCost = 0.0;
|
|
|
|
+ for (unsigned i = 0; i < countClusters; i++)
|
|
|
|
+ totalCost += calcFileCost(clusterNames[i], sizeGB, fileAgeDays);
|
|
|
|
+ return totalCost;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return calcFileCost(cluster, sizeGB, fileAgeDays);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
static unsigned findSubFileOrd(const char *name)
|
|
static unsigned findSubFileOrd(const char *name)
|
|
@@ -6654,6 +6685,18 @@ public:
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ virtual double getCost(const char * cluster) override
|
|
|
|
+ {
|
|
|
|
+ double totalCost = 0.0;
|
|
|
|
+ CriticalBlock block (sect);
|
|
|
|
+ ForEachItemIn(i,subfiles)
|
|
|
|
+ {
|
|
|
|
+ IDistributedFile &f = subfiles.item(i);
|
|
|
|
+ totalCost += f.getCost(cluster);
|
|
|
|
+ }
|
|
|
|
+ return totalCost;
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
// --------------------------------------------------------
|
|
// --------------------------------------------------------
|