From ff02e1c9c2d5ad6f7d125b2c0dad30db84f32fb8 Mon Sep 17 00:00:00 2001 From: Mathias Herberts Date: Wed, 24 May 2023 17:24:17 +0200 Subject: [PATCH] Moved FDB/LevelDB function registrations in actual backend code --- .../main/java/io/warp10/fdb/FDBContext.java | 15 ++++++- .../main/java/io/warp10/leveldb/WarpDB.java | 22 ++++++++++- .../java/io/warp10/script/WarpScriptLib.java | 39 ------------------- 3 files changed, 35 insertions(+), 41 deletions(-) diff --git a/warp10/src/main/java/io/warp10/fdb/FDBContext.java b/warp10/src/main/java/io/warp10/fdb/FDBContext.java index ecbcf8ae7..f8a81fe06 100644 --- a/warp10/src/main/java/io/warp10/fdb/FDBContext.java +++ b/warp10/src/main/java/io/warp10/fdb/FDBContext.java @@ -1,5 +1,5 @@ // -// Copyright 2022 SenX S.A.S. +// Copyright 2022-2023 SenX S.A.S. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,12 +21,25 @@ import com.apple.foundationdb.Database; +import io.warp10.script.WarpScriptLib; + public class FDBContext { private final String clusterFile; private final byte[] tenantPrefix; private final byte[] tenantName; + static { + // + // FDB related functions + // + + WarpScriptLib.addNamedWarpScriptFunction(new FDBTENANT(WarpScriptLib.FDBTENANT)); + WarpScriptLib.addNamedWarpScriptFunction(new FDBSTATUS(WarpScriptLib.FDBSTATUS)); + WarpScriptLib.addNamedWarpScriptFunction(new FDBSIZE(WarpScriptLib.FDBSIZE)); + WarpScriptLib.addNamedWarpScriptFunction(new FDBGET(WarpScriptLib.FDBGET)); + } + /** * Field to keep track of the last seen read version. Used by FDBKVScanner to retry * getRange operations which encountered an error 1037 (process_behind) which may occur diff --git a/warp10/src/main/java/io/warp10/leveldb/WarpDB.java b/warp10/src/main/java/io/warp10/leveldb/WarpDB.java index 8fc1192c6..fde424269 100644 --- a/warp10/src/main/java/io/warp10/leveldb/WarpDB.java +++ b/warp10/src/main/java/io/warp10/leveldb/WarpDB.java @@ -44,6 +44,7 @@ import io.warp10.continuum.store.Constants; import io.warp10.script.WarpScriptException; +import io.warp10.script.WarpScriptLib; public class WarpDB extends Thread implements DB { @@ -79,6 +80,25 @@ public static enum WarpDBCommand { private final LinkedBlockingQueue commandQ = new LinkedBlockingQueue(16); + static { + // + // LevelDB related functions + // + + WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBOPEN(WarpScriptLib.LEVELDBOPEN)); + WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBCLOSE(WarpScriptLib.LEVELDBCLOSE)); + WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBREPAIR(WarpScriptLib.LEVELDBREPAIR)); + WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBCOMPACT(WarpScriptLib.LEVELDBCOMPACT)); + WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(WarpScriptLib.LEVELDBSNAPSHOT, false)); + WarpScriptLib.addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(WarpScriptLib.LEVELDBSNAPSHOTINC, true)); + WarpScriptLib.addNamedWarpScriptFunction(new SSTFIND(WarpScriptLib.SSTFIND)); + WarpScriptLib.addNamedWarpScriptFunction(new SSTINFO(WarpScriptLib.SSTINFO)); + WarpScriptLib.addNamedWarpScriptFunction(new SSTPURGE(WarpScriptLib.SSTPURGE)); + WarpScriptLib.addNamedWarpScriptFunction(new SSTREPORT(WarpScriptLib.SSTREPORT)); + WarpScriptLib.addNamedWarpScriptFunction(new SSTTIMESTAMP(WarpScriptLib.SSTTIMESTAMP)); + + } + private static final class WarpIterator implements DBIterator { private final DBIterator iter; @@ -154,7 +174,7 @@ public WarpDB(boolean nativedisabled, boolean javadisabled, String home, Options this.setDaemon(true); this.start(); - this.open(nativedisabled, javadisabled, home, options); + this.open(nativedisabled, javadisabled, home, options); } private synchronized void open(boolean nativedisabled, boolean javadisabled, String home, Options options) throws IOException { diff --git a/warp10/src/main/java/io/warp10/script/WarpScriptLib.java b/warp10/src/main/java/io/warp10/script/WarpScriptLib.java index f442a15e6..f28a15956 100644 --- a/warp10/src/main/java/io/warp10/script/WarpScriptLib.java +++ b/warp10/src/main/java/io/warp10/script/WarpScriptLib.java @@ -25,24 +25,10 @@ import io.warp10.continuum.gts.DISCORDS; import io.warp10.continuum.gts.FFT; import io.warp10.continuum.gts.GeoTimeSerie.TYPE; -import io.warp10.fdb.FDBGET; -import io.warp10.fdb.FDBSIZE; -import io.warp10.fdb.FDBSTATUS; -import io.warp10.fdb.FDBTENANT; import io.warp10.continuum.gts.IFFT; import io.warp10.continuum.gts.INTERPOLATE; import io.warp10.continuum.gts.LOCATIONOFFSET; import io.warp10.continuum.gts.ZIP; -import io.warp10.leveldb.LEVELDBOPEN; -import io.warp10.leveldb.LEVELDBCLOSE; -import io.warp10.leveldb.LEVELDBCOMPACT; -import io.warp10.leveldb.LEVELDBREPAIR; -import io.warp10.leveldb.LEVELDBSNAPSHOT; -import io.warp10.leveldb.SSTFIND; -import io.warp10.leveldb.SSTINFO; -import io.warp10.leveldb.SSTPURGE; -import io.warp10.leveldb.SSTREPORT; -import io.warp10.leveldb.SSTTIMESTAMP; import io.warp10.script.aggregator.And; import io.warp10.script.aggregator.Argminmax; import io.warp10.script.aggregator.CircularMean; @@ -3179,31 +3165,6 @@ public class WarpScriptLib { addNamedWarpScriptFunction(new WSAUDIT(WSAUDIT)); addNamedWarpScriptFunction(new WSAUDITMODE(WSAUDITMODE)); - // - // LevelDB - // - - addNamedWarpScriptFunction(new LEVELDBOPEN(LEVELDBOPEN)); - addNamedWarpScriptFunction(new LEVELDBCLOSE(LEVELDBCLOSE)); - addNamedWarpScriptFunction(new LEVELDBREPAIR(LEVELDBREPAIR)); - addNamedWarpScriptFunction(new LEVELDBCOMPACT(LEVELDBCOMPACT)); - addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(LEVELDBSNAPSHOT, false)); - addNamedWarpScriptFunction(new LEVELDBSNAPSHOT(LEVELDBSNAPSHOTINC, true)); - addNamedWarpScriptFunction(new SSTFIND(SSTFIND)); - addNamedWarpScriptFunction(new SSTINFO(SSTINFO)); - addNamedWarpScriptFunction(new SSTPURGE(SSTPURGE)); - addNamedWarpScriptFunction(new SSTREPORT(SSTREPORT)); - addNamedWarpScriptFunction(new SSTTIMESTAMP(SSTTIMESTAMP)); - - // - // FDB - // - - addNamedWarpScriptFunction(new FDBTENANT(FDBTENANT)); - addNamedWarpScriptFunction(new FDBSTATUS(FDBSTATUS)); - addNamedWarpScriptFunction(new FDBSIZE(FDBSIZE)); - addNamedWarpScriptFunction(new FDBGET(FDBGET)); - ///////////////////////// int nregs = Integer.parseInt(WarpConfig.getProperty(Configuration.CONFIG_WARPSCRIPT_REGISTERS, String.valueOf(WarpScriptStack.DEFAULT_REGISTERS)));