querysub 0.368.0 → 0.370.0

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/bin/movelogs.js CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ process.argv.push("--nobreak");
4
+ process.argv.push("--public");
5
+
3
6
  require("typenode");
4
7
  require("../src/diagnostics/logs/IndexedLogs/moveLogsEntry");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.368.0",
3
+ "version": "0.370.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -109,6 +109,10 @@ export function isOwnNodeId(nodeId: string): boolean {
109
109
  return false;
110
110
  }
111
111
 
112
+ export function isNodeIdOnOwnMachineId(nodeId: string): boolean {
113
+ return certs.getMachineId(nodeId) === getOwnMachineId() || nodeId.startsWith("127-0-0-1.");
114
+ }
115
+
112
116
  let nodeOverrides: string[] | undefined;
113
117
  let beforeGetNodeAllId = async () => { };
114
118
  export async function getAllNodeIds() {
@@ -23,6 +23,7 @@ import { green, magenta } from "socket-function/src/formatting/logColors";
23
23
  import { parseFilterSelector } from "../misc/filterable";
24
24
  import path from "path";
25
25
  import { Querysub } from "../4-querysub/QuerysubController";
26
+ import { IndexedLogs } from "../diagnostics/logs/IndexedLogs/IndexedLogs";
26
27
 
27
28
  async function main() {
28
29
  Error.stackTraceLimit = 20;
@@ -39,6 +40,10 @@ async function main() {
39
40
 
40
41
  await Querysub.hostService("PathFunctionRunnerMain");
41
42
 
43
+ if (!isPublic()) {
44
+ IndexedLogs.runLogMoveLoop();
45
+ }
46
+
42
47
  // Use a fairly high stick time (the default is 10s), because having wait to sync data is very slow,
43
48
  // and the function runner SHOULD have more memory than the clients, and much faster network speeds
44
49
  // (it should be on the same local network as the path value authorities).
@@ -12,7 +12,7 @@ import { ArchivesMemoryCacheStats, createArchivesMemoryCache } from "../../../-a
12
12
  import { registerShutdownHandler } from "../../periodic";
13
13
  import { measureBlock, measureFnc } from "socket-function/src/profiling/measure";
14
14
  import { isNode } from "typesafecss";
15
- import { getOwnMachineId } from "../../../-f-node-discovery/NodeDiscovery";
15
+ import { getOwnMachineId, isNodeIdOnOwnMachineId, isOwnNodeId } from "../../../-f-node-discovery/NodeDiscovery";
16
16
  import { TimeFilePath, TimeFileTree } from "./TimeFileTree";
17
17
  import { LogStreamer } from "./LogStreamer";
18
18
  import { moveLogsToPublic } from "./moveIndexLogsToPublic";
@@ -226,10 +226,11 @@ export class IndexedLogs<T> {
226
226
 
227
227
  private machineNodeCache = new Map<string, string>();
228
228
  private async getMachineNodes(): Promise<string[]> {
229
- let ownMachineId = getOwnMachineId();
230
229
  let nodeIds = await getAllNodeIds();
230
+ nodeIds = nodeIds.filter(x => !isNodeIdOnOwnMachineId(x));
231
231
  let byMachineId = keyByArray(nodeIds, x => getMachineId(x));
232
- byMachineId.delete(ownMachineId);
232
+
233
+ let nextCache = new Map<string, string>();
233
234
 
234
235
  await Promise.all(Array.from(byMachineId.entries()).map(async ([machineId, nodeIds]) => {
235
236
  let added = false;
@@ -244,7 +245,7 @@ export class IndexedLogs<T> {
244
245
  }
245
246
  added = true;
246
247
 
247
- this.machineNodeCache.set(machineId, nodeId);
248
+ nextCache.set(machineId, nodeId);
248
249
  return true;
249
250
  };
250
251
  let cached = this.machineNodeCache.get(machineId);
@@ -261,6 +262,7 @@ export class IndexedLogs<T> {
261
262
  }
262
263
  }));
263
264
 
265
+ this.machineNodeCache = nextCache;
264
266
  return Array.from(this.machineNodeCache.values());
265
267
  }
266
268
 
@@ -358,7 +360,7 @@ export class IndexedLogs<T> {
358
360
  let allResults = new Map<string, IndexedLogResults>();
359
361
  let allDone: Promise<void>[] = [];
360
362
 
361
- if (!config.params.only && (config.params.forceReadPublic || isPublic())) {
363
+ if (config.params.only !== "local" && (config.params.forceReadPublic || isPublic())) {
362
364
  let machineNodes = await this.getMachineNodes();
363
365
  allDone.push(...machineNodes.map(async (machineNode) => {
364
366
  try {
@@ -385,6 +387,7 @@ export class IndexedLogs<T> {
385
387
 
386
388
  // If we're forcefully reading from the public server, but we're not public, the code above will be the only code which adds to results
387
389
  if (!isPublic() && config.params.forceReadPublic) {
390
+ await Promise.all(allDone);
388
391
  return getFinalResults();
389
392
  }
390
393
 
@@ -707,7 +710,6 @@ class IndexedLogClient {
707
710
  indexedLogsName: string;
708
711
  result: unknown;
709
712
  }) {
710
- if (isNode()) return;
711
713
  let indexedLogs = loggerByName.get(config.indexedLogsName);
712
714
  if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
713
715
  indexedLogs.onFindResult({
@@ -720,7 +722,6 @@ class IndexedLogClient {
720
722
  indexedLogsName: string;
721
723
  results: IndexedLogResults;
722
724
  }): Promise<boolean> {
723
- if (isNode()) return true;
724
725
  let indexedLogs = loggerByName.get(config.indexedLogsName);
725
726
  if (!indexedLogs) throw new Error(`Indexed logs ${config.indexedLogsName} not found`);
726
727
  return await indexedLogs.onResults({
@@ -371,7 +371,7 @@ export class LogViewer3 extends qreact.Component {
371
371
  let paths = await logger.clientGetPaths({
372
372
  startTime: range.startTime,
373
373
  endTime: range.endTime,
374
- only: excludePendingResults.value ? "local" : undefined,
374
+ only: excludePendingResults.value ? "public" : undefined,
375
375
  forceReadPublic: readPublicLogs.value,
376
376
  });
377
377
  allPaths.push(...paths);
@@ -682,7 +682,6 @@ export class LogViewer3 extends qreact.Component {
682
682
  return (
683
683
  <div className={css.vbox(20).pad2(20).fillBoth}>
684
684
  <div className={css.hbox(20)}>
685
- <div>Log Viewer 3</div>
686
685
  <InputLabelURL
687
686
  checkbox
688
687
  label="Exclude Pending Results"
@@ -19,17 +19,12 @@ IMPORTANT! Now I am properly calling shutdown, so none of the streamed logs shou
19
19
 
20
20
 
21
21
 
22
- 0) Deploy again
23
- 1) Verify isPublic searching works (from our local machine)
24
-
25
-
26
22
 
27
23
  2) Create lot of remote server logs
28
24
  - Via our refresh loop
29
25
 
30
-
31
- 3) Create and deploy service for movelogs
32
- 3.0) Update preferred entrypoint to be the movelogs entrypoint
26
+ 3) Deploy service for movelogs
27
+ "yarn movelogs"
33
28
 
34
29
  0) Run move logs in function runner, in development, just so we don't get too far behind
35
30