nodio-cli 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/user/commands.js +22 -6
package/package.json
CHANGED
package/src/user/commands.js
CHANGED
|
@@ -85,12 +85,28 @@ async function uploadFile(options) {
|
|
|
85
85
|
throw new Error(`placement failed for ${shardId}: expected ${replicas} replicas`);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
const successfulReplicas = [];
|
|
89
|
+
const failedReplicas = [];
|
|
90
|
+
|
|
88
91
|
for (const replica of plannedReplicas) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
try {
|
|
93
|
+
const putUrl = `${normalizeUrl(replica.url)}/shards/${shardId}`;
|
|
94
|
+
await axios.put(putUrl, encrypted.cipherText, {
|
|
95
|
+
headers: { 'Content-Type': 'application/octet-stream' },
|
|
96
|
+
timeout: 30000
|
|
97
|
+
});
|
|
98
|
+
successfulReplicas.push(replica);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
failedReplicas.push({ nodeId: replica.nodeId, url: replica.url, error: error.message });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (successfulReplicas.length === 0) {
|
|
105
|
+
throw new Error(`failed to write shard ${shardId} to any replica: ${failedReplicas.map((r) => `${r.url} (${r.error})`).join(', ')}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (failedReplicas.length > 0) {
|
|
109
|
+
console.warn(`[upload] shard ${shardId} failed on ${failedReplicas.length} replica(s), but succeeded on ${successfulReplicas.length}`);
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
await api.post('/shards/register', {
|
|
@@ -99,7 +115,7 @@ async function uploadFile(options) {
|
|
|
99
115
|
order,
|
|
100
116
|
sizeBytes: encrypted.cipherText.length,
|
|
101
117
|
checksum,
|
|
102
|
-
nodeIds:
|
|
118
|
+
nodeIds: successfulReplicas.map((replica) => replica.nodeId)
|
|
103
119
|
});
|
|
104
120
|
|
|
105
121
|
encryptionShardMeta.push({
|