Changeset 89c2aac in trunk


Ignore:
Timestamp:
2021-11-16T22:08:31Z (4 years ago)
Author:
meejah <meejah@…>
Branches:
master
Children:
d4fc14f
Parents:
bf5e682
git-author:
meejah <meejah@…> (2021-10-25 21:52:01)
git-committer:
meejah <meejah@…> (2021-11-16 22:08:31)
Message:

working test of 'in the wild' data, working converters

Location:
src/allmydata
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/storage/crawler.py

    rbf5e682 r89c2aac  
    3535    """
    3636    # ["cycle-to-date"]["corrupt-shares"] from 2-tuple to list
    37     # ["leases-per-share-histogram"] gets str keys instead of int
     37    # ["cycle-to-date"]["leases-per-share-histogram"] gets str keys instead of int
    3838    # ["cycle-start-finish-times"] from 2-tuple to list
    3939    # ["configured-expiration-mode"] from 4-tuple to list
     
    4343            "Unknown version {version} in pickle state".format(**state)
    4444        )
    45 
    46     def convert_lpsh(value):
    47         return {
    48             str(k): v
    49             for k, v in value.items()
    50         }
    5145
    5246    def convert_cem(value):
     
    6054        ]
    6155
    62     def convert_history(value):
    63         print("convert history")
    64         print(value)
     56    def convert_ctd(value):
     57        ctd_converter = {
     58            "lease-age-histogram": lambda value: {
     59                "{},{}".format(k[0], k[1]): v
     60                for k, v in value.items()
     61            },
     62            "corrupt-shares": lambda value: [
     63                list(x)
     64                for x in value
     65            ],
     66        }
    6567        return {
    66             str(k): v
    67             for k, v in value
     68            k: ctd_converter.get(k, lambda z: z)(v)
     69            for k, v in value.items()
    6870        }
    6971
     72    # we don't convert "history" here because that's in a separate
     73    # file; see expirer.py
    7074    converters = {
    71         "cycle-to-date": list,
    72         "leases-per-share-histogram": convert_lpsh,
     75        "cycle-to-date": convert_ctd,
    7376        "cycle-starte-finish-times": list,
    7477        "configured-expiration-mode": convert_cem,
    75         "history": convert_history,
    7678    }
    7779
     
    117119    with state_path.open("r") as f:
    118120        state = pickle.load(f)
    119     state = convert_pickle(state)
     121    new_state = convert_pickle(state)
    120122    json_state_path = state_path.siblingExtension(".json")
    121123    with json_state_path.open("w") as f:
    122         json.dump(state, f)
     124        json.dump(new_state, f)
    123125    # we've written the JSON, delete the pickle
    124126    state_path.remove()
  • TabularUnified src/allmydata/test/test_storage_web.py

    rbf5e682 r89c2aac  
    11611161        self.assertTrue(test_pickle.siblingExtension(".json").exists())
    11621162
     1163        self.assertEqual(
     1164            serial.load(),
     1165            {
     1166                u'last-complete-prefix': None,
     1167                u'version': 1,
     1168                u'current-cycle-start-time': 1635003106.611748,
     1169                u'last-cycle-finished': 312,
     1170                u'cycle-to-date': {
     1171                    u'leases-per-share-histogram': {
     1172                        u'1': 36793,
     1173                        u'2': 1,
     1174                    },
     1175                    u'space-recovered': {
     1176                        u'examined-buckets-immutable': 17183,
     1177                        u'configured-buckets-mutable': 0,
     1178                        u'examined-shares-mutable': 1796,
     1179                        u'original-shares-mutable': 1563,
     1180                        u'configured-buckets-immutable': 0,
     1181                        u'original-shares-immutable': 27926,
     1182                        u'original-diskbytes-immutable': 431149056,
     1183                        u'examined-shares-immutable': 34998,
     1184                        u'original-buckets': 14661,
     1185                        u'actual-shares-immutable': 0,
     1186                        u'configured-shares': 0,
     1187                        u'original-buckets-mutable': 899,
     1188                        u'actual-diskbytes': 4096,
     1189                        u'actual-shares-mutable': 0,
     1190                        u'configured-buckets': 1,
     1191                        u'examined-buckets-unknown': 14,
     1192                        u'actual-sharebytes': 0,
     1193                        u'original-shares': 29489,
     1194                        u'actual-buckets-immutable': 0,
     1195                        u'original-sharebytes': 312664812,
     1196                        u'examined-sharebytes-immutable': 383801602,
     1197                        u'actual-shares': 0,
     1198                        u'actual-sharebytes-immutable': 0,
     1199                        u'original-diskbytes': 441643008,
     1200                        u'configured-diskbytes-mutable': 0,
     1201                        u'configured-sharebytes-immutable': 0,
     1202                        u'configured-shares-mutable': 0,
     1203                        u'actual-diskbytes-immutable': 0,
     1204                        u'configured-diskbytes-immutable': 0,
     1205                        u'original-diskbytes-mutable': 10489856,
     1206                        u'actual-sharebytes-mutable': 0,
     1207                        u'configured-sharebytes': 0,
     1208                        u'examined-shares': 36794,
     1209                        u'actual-diskbytes-mutable': 0,
     1210                        u'actual-buckets': 1,
     1211                        u'original-buckets-immutable': 13761,
     1212                        u'configured-sharebytes-mutable': 0,
     1213                        u'examined-sharebytes': 390369660,
     1214                        u'original-sharebytes-immutable': 308125753,
     1215                        u'original-sharebytes-mutable': 4539059,
     1216                        u'actual-buckets-mutable': 0,
     1217                        u'examined-buckets-mutable': 1043,
     1218                        u'configured-shares-immutable': 0,
     1219                        u'examined-diskbytes': 476598272,
     1220                        u'examined-diskbytes-mutable': 9154560,
     1221                        u'examined-sharebytes-mutable': 6568058,
     1222                        u'examined-buckets': 18241,
     1223                        u'configured-diskbytes': 4096,
     1224                        u'examined-diskbytes-immutable': 467443712},
     1225                    u'corrupt-shares': [
     1226                        [u'2dn6xnlnsqwtnapwxfdivpm3s4', 4],
     1227                        [u'2dn6xnlnsqwtnapwxfdivpm3s4', 1],
     1228                        [u'2rrzthwsrrxolevmwdvbdy3rqi', 4],
     1229                        [u'2rrzthwsrrxolevmwdvbdy3rqi', 1],
     1230                        [u'2skfngcto6h7eqmn4uo7ntk3ne', 4],
     1231                        [u'2skfngcto6h7eqmn4uo7ntk3ne', 1],
     1232                        [u'32d5swqpqx2mwix7xmqzvhdwje', 4],
     1233                        [u'32d5swqpqx2mwix7xmqzvhdwje', 1],
     1234                        [u'5mmayp66yflmpon3o6unsnbaca', 4],
     1235                        [u'5mmayp66yflmpon3o6unsnbaca', 1],
     1236                        [u'6ixhpvbtre7fnrl6pehlrlflc4', 4],
     1237                        [u'6ixhpvbtre7fnrl6pehlrlflc4', 1],
     1238                        [u'ewzhvswjsz4vp2bqkb6mi3bz2u', 4],
     1239                        [u'ewzhvswjsz4vp2bqkb6mi3bz2u', 1],
     1240                        [u'fu7pazf6ogavkqj6z4q5qqex3u', 4],
     1241                        [u'fu7pazf6ogavkqj6z4q5qqex3u', 1],
     1242                        [u'hbyjtqvpcimwxiyqbcbbdn2i4a', 4],
     1243                        [u'hbyjtqvpcimwxiyqbcbbdn2i4a', 1],
     1244                        [u'pmcjbdkbjdl26k3e6yja77femq', 4],
     1245                        [u'pmcjbdkbjdl26k3e6yja77femq', 1],
     1246                        [u'r6swof4v2uttbiiqwj5pi32cm4', 4],
     1247                        [u'r6swof4v2uttbiiqwj5pi32cm4', 1],
     1248                        [u't45v5akoktf53evc2fi6gwnv6y', 4],
     1249                        [u't45v5akoktf53evc2fi6gwnv6y', 1],
     1250                        [u'y6zb4faar3rdvn3e6pfg4wlotm', 4],
     1251                        [u'y6zb4faar3rdvn3e6pfg4wlotm', 1],
     1252                        [u'z3yghutvqoqbchjao4lndnrh3a', 4],
     1253                        [u'z3yghutvqoqbchjao4lndnrh3a', 1],
     1254                    ],
     1255                    u'lease-age-histogram': {
     1256                        "1641600,1728000": 78,
     1257                        "12441600,12528000": 78,
     1258                        "8640000,8726400": 32,
     1259                        "1814400,1900800": 1860,
     1260                        "2764800,2851200": 76,
     1261                        "11491200,11577600": 20,
     1262                        "10713600,10800000": 183,
     1263                        "47865600,47952000": 7,
     1264                        "3110400,3196800": 328,
     1265                        "10627200,10713600": 43,
     1266                        "45619200,45705600": 4,
     1267                        "12873600,12960000": 5,
     1268                        "7430400,7516800": 7228,
     1269                        "1555200,1641600": 492,
     1270                        "38880000,38966400": 3,
     1271                        "12528000,12614400": 193,
     1272                        "7344000,7430400": 12689,
     1273                        "2678400,2764800": 278,
     1274                        "2332800,2419200": 12,
     1275                        "9244800,9331200": 73,
     1276                        "12787200,12873600": 218,
     1277                        "49075200,49161600": 19,
     1278                        "10368000,10454400": 117,
     1279                        "4665600,4752000": 256,
     1280                        "7516800,7603200": 993,
     1281                        "42336000,42422400": 33,
     1282                        "10972800,11059200": 122,
     1283                        "39052800,39139200": 51,
     1284                        "12614400,12700800": 210,
     1285                        "7603200,7689600": 2004,
     1286                        "10540800,10627200": 16,
     1287                        "950400,1036800": 4435,
     1288                        "42076800,42163200": 4,
     1289                        "8812800,8899200": 57,
     1290                        "5788800,5875200": 954,
     1291                        "36374400,36460800": 3,
     1292                        "9331200,9417600": 12,
     1293                        "30499200,30585600": 5,
     1294                        "12700800,12787200": 25,
     1295                        "2073600,2160000": 388,
     1296                        "12960000,13046400": 8,
     1297                        "11923200,12009600": 89,
     1298                        "3369600,3456000": 79,
     1299                        "3196800,3283200": 628,
     1300                        "37497600,37584000": 11,
     1301                        "33436800,33523200": 7,
     1302                        "44928000,45014400": 2,
     1303                        "37929600,38016000": 3,
     1304                        "38966400,39052800": 61,
     1305                        "3283200,3369600": 86,
     1306                        "11750400,11836800": 7,
     1307                        "3801600,3888000": 32,
     1308                        "46310400,46396800": 1,
     1309                        "4838400,4924800": 386,
     1310                        "8208000,8294400": 38,
     1311                        "37411200,37497600": 4,
     1312                        "12009600,12096000": 329,
     1313                        "10454400,10540800": 1239,
     1314                        "40176000,40262400": 1,
     1315                        "3715200,3801600": 104,
     1316                        "44409600,44496000": 13,
     1317                        "38361600,38448000": 5,
     1318                        "12268800,12355200": 2,
     1319                        "28771200,28857600": 6,
     1320                        "41990400,42076800": 10,
     1321                        "2592000,2678400": 40,
     1322                    },
     1323                },
     1324                'current-cycle': None,
     1325                'last-complete-bucket': None,
     1326            }
     1327        )
    11631328
    11641329
Note: See TracChangeset for help on using the changeset viewer.