diff --git a/adapter-milvus/pom.xml b/adapter-milvus/pom.xml index 135437a53..f4843048f 100644 --- a/adapter-milvus/pom.xml +++ b/adapter-milvus/pom.xml @@ -47,6 +47,11 @@ ${revision} compile + + com.google.protobuf + protobuf-java-util + 3.24.0 + io.milvus milvus-sdk-java diff --git a/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/MilvusOpMapper.java b/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/MilvusOpMapper.java index 71fe50235..33dc065ad 100644 --- a/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/MilvusOpMapper.java +++ b/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/MilvusOpMapper.java @@ -53,7 +53,7 @@ public class MilvusOpMapper implements OpMapper> { "type", "target" ); - logger.info(() -> "Using '" + typeAndTarget.enumId + "' statement form for '" + op.getName() + "'"); + logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'"); return switch (typeAndTarget.enumId) { case drop_collection -> new MilvusDropCollectionOpDispenser(adapter, op, typeAndTarget.targetFunction); diff --git a/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/ops/MilvusGetIndexBuildProgressOp.java b/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/ops/MilvusGetIndexBuildProgressOp.java index b9407194e..a156fea5f 100644 --- a/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/ops/MilvusGetIndexBuildProgressOp.java +++ b/adapter-milvus/src/main/java/io/nosqlbench/adapter/milvus/ops/MilvusGetIndexBuildProgressOp.java @@ -16,7 +16,12 @@ package io.nosqlbench.adapter.milvus.ops; +import com.google.protobuf.DescriptorProtos; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.util.JsonFormat; import io.milvus.client.MilvusServiceClient; +import io.milvus.grpc.GetIndexBuildProgressResponse; +import io.milvus.param.R; import io.milvus.param.index.GetIndexBuildProgressParam; public class MilvusGetIndexBuildProgressOp extends MilvusBaseOp { @@ -26,6 +31,13 @@ public class MilvusGetIndexBuildProgressOp extends MilvusBaseOp indexBuildProgress = client.getIndexBuildProgress(request); + GetIndexBuildProgressResponse r = indexBuildProgress.getData(); + try { + String responseJson = JsonFormat.printer().print(r); + return responseJson; + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } } } diff --git a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/DryRunOp.java b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/DryRunOp.java similarity index 89% rename from adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/DryRunOp.java rename to adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/DryRunOp.java index 9b5bdabd6..a5775f10a 100644 --- a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/DryRunOp.java +++ b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/DryRunOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 nosqlbench + * Copyright (c) 2022-2024 nosqlbench * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.nosqlbench.adapters.api.activityimpl.uniform; +package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp; diff --git a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/DryRunOpDispenserWrapper.java b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/DryRunOpDispenserWrapper.java similarity index 88% rename from adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/DryRunOpDispenserWrapper.java rename to adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/DryRunOpDispenserWrapper.java index 13bee89fa..11f3efabb 100644 --- a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/DryRunOpDispenserWrapper.java +++ b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/DryRunOpDispenserWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 nosqlbench + * Copyright (c) 2022-2024 nosqlbench * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,11 @@ * limitations under the License. */ -package io.nosqlbench.adapters.api.activityimpl.uniform; +package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers; import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser; import io.nosqlbench.adapters.api.activityimpl.OpDispenser; +import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op; import io.nosqlbench.adapters.api.templating.ParsedOp; diff --git a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/EmitterOp.java b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/EmitterOp.java similarity index 90% rename from adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/EmitterOp.java rename to adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/EmitterOp.java index 9abbda81a..8e03fa81c 100644 --- a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/EmitterOp.java +++ b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/EmitterOp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 nosqlbench + * Copyright (c) 2022-2024 nosqlbench * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.nosqlbench.adapters.api.activityimpl.uniform; +package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp; diff --git a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/EmitterOpDispenserWrapper.java b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/EmitterOpDispenserWrapper.java similarity index 88% rename from adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/EmitterOpDispenserWrapper.java rename to adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/EmitterOpDispenserWrapper.java index c82c5b1a9..28d74bad5 100644 --- a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/EmitterOpDispenserWrapper.java +++ b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/EmitterOpDispenserWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 nosqlbench + * Copyright (c) 2022-2024 nosqlbench * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,11 @@ * limitations under the License. */ -package io.nosqlbench.adapters.api.activityimpl.uniform; +package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers; import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser; import io.nosqlbench.adapters.api.activityimpl.OpDispenser; +import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op; import io.nosqlbench.adapters.api.templating.ParsedOp; diff --git a/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/PollingOp.java b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/PollingOp.java new file mode 100644 index 000000000..2cce02b77 --- /dev/null +++ b/adapters-api/src/main/java/io/nosqlbench/adapters/api/activityimpl/uniform/opwrappers/PollingOp.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 nosqlbench + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers; + +import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp; +import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op; +import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpGenerator; +import io.nosqlbench.adapters.api.evalctx.CycleFunction; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.function.Predicate; + +public class PollingOp implements CycleOp, OpGenerator { + private final static Logger logger = LogManager.getLogger(PollingOp.class); + + private final CycleOp innerOp; + private final CycleFunction untilCondition; + private PollingOp nextOp = null; + + public PollingOp(CycleOp innerOp, CycleFunction untilCondition) { + this.innerOp = innerOp; + this.untilCondition = untilCondition; + } + @Override + public synchronized T apply(long value) { + T result = this.innerOp.apply(value); + untilCondition.setVariable("result",result); + boolean conditionIsMet = untilCondition.apply(value); + if (conditionIsMet) { + onConditionMet(result); + this.nextOp=null; + } else { + this.nextOp=this; + onConditionUnmet(result); + } + return result; + } + + @Override + public synchronized Op getNextOp() { + return nextOp; + } + + protected void onConditionMet(T value) { + logger.debug("for op " + this + ": condition MET for result " + value); + } + + protected void onConditionUnmet(T value) { + logger.debug("for op " + this + ": condition UNMET for result " + value); + } +} diff --git a/engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java b/engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java index 5e060179e..b5807eaf7 100644 --- a/engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java +++ b/engine-core/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java @@ -16,8 +16,10 @@ package io.nosqlbench.engine.api.activityimpl; -import io.nosqlbench.adapters.api.activityimpl.uniform.EmitterOpDispenserWrapper; +import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser; +import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.EmitterOpDispenserWrapper; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp; +import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.PollingOpDispenserWrapper; import io.nosqlbench.engine.core.lifecycle.scenario.container.InvokableResult; import io.nosqlbench.nb.api.components.core.NBComponent; import io.nosqlbench.nb.api.components.events.ParamChange; @@ -50,7 +52,7 @@ import io.nosqlbench.adapters.api.activityconfig.yaml.OpsDocList; import io.nosqlbench.engine.api.activityapi.simrate.StrideRateSpec; import io.nosqlbench.engine.api.activityimpl.motor.RunStateTally; import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter; -import io.nosqlbench.adapters.api.activityimpl.uniform.DryRunOpDispenserWrapper; +import io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers.DryRunOpDispenserWrapper; import io.nosqlbench.adapters.api.activityimpl.uniform.decorators.SyntheticOpTemplateProvider; import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op; import io.nosqlbench.adapters.api.templating.ParsedOp; @@ -420,7 +422,7 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok protected OpSequence> createOpSourceFromParsedOps( // Map> adapterCache, // Map> mapperCache, - List> adapters, + List> adapters, List pops ) { try { @@ -470,7 +472,7 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok // } planner.addOp((OpDispenser) dispenser, ratio); } catch (Exception e) { - throw new OpConfigError("Error while mapping op from template named '" + pop.getName() + "': " + e.getMessage(),e); + throw new OpConfigError("Error while mapping op from template named '" + pop.getName() + "': " + e.getMessage(), e); } } if (0 < dryrunCount) { @@ -569,7 +571,8 @@ public class SimpleActivity extends NBStatusComponent implements Activity, Invok * @param opinit * A function to map an OpTemplate to the executable operation form required by * the native driver for this activity. - * @param defaultAdapter The adapter which will be used for any op templates with no explicit adapter + * @param defaultAdapter + * The adapter which will be used for any op templates with no explicit adapter * @return The sequence of operations as determined by filtering and ratios */ @Deprecated(forRemoval = true) diff --git a/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java b/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java index b71cd8316..5370ac8fb 100644 --- a/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java +++ b/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java @@ -1134,5 +1134,11 @@ public class ParsedTemplateMap implements LongFunction>, StaticFi } - + public Map getCombinedPrototype() { + Map prototype = new LinkedHashMap<>(); + prototype.putAll(getDynamicPrototype()); + prototype.putAll(getStaticPrototype()); + prototype.putAll(getConfigPrototype()); + return prototype; + } }