Skip to content

Commit

Permalink
IGNITE-20761 Added descriptions and values to the properties list com…
Browse files Browse the repository at this point in the history
…mand (#11027)
  • Loading branch information
Nastya828 authored Nov 9, 2023
1 parent 0f2fded commit 5727886
Show file tree
Hide file tree
Showing 29 changed files with 247 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public void testHelp() {
assertContains(log, out, "control.(sh|bat) --property help");

assertContains(log, out, "Print list of available properties:");
assertContains(log, out, "control.(sh|bat) --property list");
assertContains(log, out, "control.(sh|bat) --property list [--info]");
assertContains(log, out, "--info - Print detailed information: name, value, description.");

assertContains(log, out, "Get the property value:");
assertContains(log, out, "control.(sh|bat) --property get --name <property_name>");
Expand All @@ -80,6 +81,24 @@ public void testHelp() {
assertContains(log, out, "control.(sh|bat) --property set --name <property_name> --val <property_value>");
}

/**
* Check the command ' --property list [--info]'.
* Steps:
*/
@Test
public void testListWithValues() {
assertEquals(EXIT_CODE_OK, execute("--property", "list", "--info"));

String out = testOut.toString();

for (DistributedChangeableProperty<Serializable> pd : crd.context()
.distributedConfiguration().properties()) {
assertContains(log, out, pd.getName());
assertContains(log, out, String.valueOf(pd.get()));
assertContains(log, out, pd.description());
}
}

/**
* Check the command '--property list'.
* Steps:
Expand Down Expand Up @@ -111,7 +130,7 @@ public void testGet() {
}

/**
* Check the set command fro property 'sql.disabledFunctions'.
* Check the set command for property 'sql.disabledFunctions'.
* Steps:
*/
@Test
Expand Down Expand Up @@ -177,7 +196,7 @@ public void testPropertyCheckpointDeviation() throws IgniteCheckedException {
}

/**
* Check the set command fro property 'sql.defaultQueryTimeout'.
* Check the set command for property 'sql.defaultQueryTimeout'.
* Steps:
*/
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ public class DistributedBaselineConfiguration {

/** Value of manual baseline control or auto adjusting baseline. */
private final DistributedChangeableProperty<Boolean> baselineAutoAdjustEnabled =
detachedBooleanProperty("baselineAutoAdjustEnabled");
detachedBooleanProperty("baselineAutoAdjustEnabled", "Value of manual baseline control or auto" +
" adjusting baseline. True - If cluster in auto-adjust. False - If cluster in manual.");

/**
* Value of time which we would wait before the actual topology change since last discovery event(node join/exit).
*/
private final DistributedChangeableProperty<Long> baselineAutoAdjustTimeout =
detachedLongProperty("baselineAutoAdjustTimeout");
detachedLongProperty("baselineAutoAdjustTimeout",
"Number of milliseconds to wait before the actual topology change since last server topology " +
"change(node join/left/fail).");

/**
* @param isp Subscription processor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,52 @@ public class DistributedTransactionConfiguration {
* owner thread.
*/
private final DistributedChangeableProperty<Boolean> txOwnerDumpRequestsAllowed =
detachedBooleanProperty("txOwnerDumpRequestsAllowed");
detachedBooleanProperty("txOwnerDumpRequestsAllowed",
"Shows if dump requests from local node to near node are allowed, when " +
"long running transaction is found. If allowed, the compute request to near node will be made to get" +
" thread dump of transaction owner thread.");

/** Long operations dump timeout. */
private final DistributedChangeableProperty<Long> longOperationsDumpTimeout =
detachedLongProperty("longOperationsDumpTimeout");
detachedLongProperty("longOperationsDumpTimeout", "Cache operations that take more time than value " +
"of this property in milliseconds will be output to log. Set to 0 to disable.");

/**
* Threshold timeout for long transactions, if transaction exceeds it, it will be dumped in log with
* information about how much time did it spent in system time (time while aquiring locks, preparing,
* commiting, etc) and user time (time when client node runs some code while holding transaction and not
* waiting it). Equals 0 if not set. No transactions are dumped in log if this parameter is not set.
* waiting it). Equals 0 if not set.
*/
private final DistributedChangeableProperty<Long> longTransactionTimeDumpThreshold =
detachedLongProperty("longTransactionTimeDumpThreshold");
detachedLongProperty("longTransactionTimeDumpThreshold",
"Threshold timeout for long transactions, if transaction exceeds it, it will be dumped in log with " +
"information about how much time did it spent in system time (time while acquiring " +
"locks, preparing, committing, etc) and user time (time when client node runs some code while holding " +
"transaction and not waiting it). Equals 0 if not set.");

/** The coefficient for samples of completed transactions that will be dumped in log. */
private final DistributedChangeableProperty<Double> transactionTimeDumpSamplesCoefficient =
detachedDoubleProperty("transactionTimeDumpSamplesCoefficient");
detachedDoubleProperty("transactionTimeDumpSamplesCoefficient",
"The coefficient for samples of completed transactions that will be dumped " +
"in log. Must be float value between 0.0 and 1.0 inclusive.");

/**
* The limit of samples of completed transactions that will be dumped in log per second, if
* {@link #transactionTimeDumpSamplesCoefficient} is above <code>0.0</code>. Must be integer value
* greater than <code>0</code>.
*/
private final DistributedChangeableProperty<Integer> longTransactionTimeDumpSamplesPerSecondLimit =
detachedIntegerProperty("longTransactionTimeDumpSamplesPerSecondLimit");
detachedIntegerProperty("longTransactionTimeDumpSamplesPerSecondLimit",
"The limit of samples of completed transactions that will be dumped in log per second, if " +
IGNITE_TRANSACTION_TIME_DUMP_SAMPLES_COEFFICIENT + " is above 0.0. Must be integer value " +
"greater than 0.");

/** Collisions dump interval. */
private final DistributedChangeableProperty<Integer> collisionsDumpInterval =
detachedIntegerProperty("collisionsDumpInterval");
detachedIntegerProperty("collisionsDumpInterval",
"When above zero, prints tx key collisions once per interval. Each transaction besides " +
"OPTIMISTIC SERIALIZABLE capture locks on all enlisted keys, for some reasons per key lock queue may rise. " +
"This property sets the interval in milliseconds during which statistics are collected.");

/**
* @param ctx Kernal context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClus
/** Property for update policy of shutdown. */
private DistributedEnumProperty<ShutdownPolicy> shutdown = new DistributedEnumProperty<>(
"shutdown.policy",
"Policy of shutdown. The policy specifies data safety guarantees on ordinary shutdown" +
" of one or more cluster nodes. IMMEDIATE - Stop immediately as soon as all components are ready." +
" GRACEFUL - Node will stop if and only if it does not store any unique partitions, that don't have " +
"another copies in the cluster.",
(ordinal) -> ordinal == null ? null : ShutdownPolicy.fromOrdinal(ordinal),
(policy) -> policy == null ? null : policy.index(),
ShutdownPolicy.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Collections;
import org.apache.ignite.internal.dto.IgniteDataTransferObject;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.util.typedef.internal.U;

/**
Expand All @@ -34,8 +34,8 @@ public class PropertiesListResult extends IgniteDataTransferObject {
/** */
private static final long serialVersionUID = 0L;

/** Properties names. */
private Collection<String> props = Collections.emptyList();
/** Properties info: name, value, description. */
private Collection<T3<String, String, String>> props;

/**
* Constructor for optimized marshaller.
Expand All @@ -47,7 +47,7 @@ public PropertiesListResult() {
/**
* @param props Properties.
*/
public PropertiesListResult(Collection<String> props) {
public PropertiesListResult(Collection<T3<String, String, String>> props) {
this.props = props;
}

Expand All @@ -65,9 +65,9 @@ public PropertiesListResult(Collection<String> props) {
}

/**
* @return Properties (name, description) collection.
* @return Properties (name, value, description) collection.
*/
public Collection<String> properties() {
public Collection<T3<String, String, String>> properties() {
return props;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,33 @@

package org.apache.ignite.internal.management.property;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.ignite.IgniteException;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.internal.management.api.NoArg;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.lang.GridTuple3;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.VisorMultiNodeTask;
import org.apache.ignite.plugin.security.SecurityPermissionSet;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.plugin.security.SecurityPermission.ADMIN_READ_DISTRIBUTED_PROPERTY;
import static org.apache.ignite.plugin.security.SecurityPermissionSetBuilder.systemPermissions;

/**
* Task for property operations.
*/
@GridInternal
public class PropertiesListTask extends VisorMultiNodeTask<NoArg, PropertiesListResult, PropertiesListResult> {
public class PropertiesListTask extends VisorMultiNodeTask<PropertyListCommandArg, PropertiesListResult, PropertiesListResult> {
/** */
private static final long serialVersionUID = 0L;

/** {@inheritDoc} */
@Override protected VisorJob<NoArg, PropertiesListResult> job(NoArg arg) {
return new PropertiesListJob(debug);
@Override protected VisorJob<PropertyListCommandArg, PropertiesListResult> job(PropertyListCommandArg arg) {
return new PropertiesListJob(arg, debug);
}

/** {@inheritDoc} */
Expand All @@ -60,15 +63,15 @@ public class PropertiesListTask extends VisorMultiNodeTask<NoArg, PropertiesList
/**
* Job for property operations (get/set).
*/
private static class PropertiesListJob extends VisorJob<NoArg, PropertiesListResult> {
private static class PropertiesListJob extends VisorJob<PropertyListCommandArg, PropertiesListResult> {
/** */
private static final long serialVersionUID = 0L;

/**
* @param debug Debug.
*/
protected PropertiesListJob(boolean debug) {
super(null, debug);
protected PropertiesListJob(PropertyListCommandArg arg, boolean debug) {
super(arg, debug);
}

/** {@inheritDoc} */
Expand All @@ -77,10 +80,11 @@ protected PropertiesListJob(boolean debug) {
}

/** {@inheritDoc} */
@Override protected PropertiesListResult run(@Nullable NoArg arg) {
@Override protected PropertiesListResult run(@Nullable PropertyListCommandArg arg) {
return new PropertiesListResult(
ignite.context().distributedConfiguration().properties().stream()
.map(pd -> pd.getName())
.map(p -> new T3<>(p.getName(), String.valueOf(p.get()), p.description()))
.sorted(Comparator.comparing(GridTuple3::get1))
.collect(Collectors.toList())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@

package org.apache.ignite.internal.management.property;

import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.apache.ignite.internal.management.SystemViewCommand;
import org.apache.ignite.internal.management.SystemViewTask;
import org.apache.ignite.internal.management.api.ComputeCommand;
import org.apache.ignite.internal.management.api.NoArg;
import org.apache.ignite.internal.util.lang.GridTuple3;
import org.apache.ignite.internal.util.typedef.F;

/** */
public class PropertyListCommand implements ComputeCommand<NoArg, PropertiesListResult> {
public class PropertyListCommand implements ComputeCommand<PropertyListCommandArg, PropertiesListResult> {
/** {@inheritDoc} */
@Override public String description() {
return "Print list of available properties";
}

/** {@inheritDoc} */
@Override public Class<NoArg> argClass() {
return NoArg.class;
@Override public Class<PropertyListCommandArg> argClass() {
return PropertyListCommandArg.class;
}

/** {@inheritDoc} */
Expand All @@ -39,8 +44,21 @@ public class PropertyListCommand implements ComputeCommand<NoArg, PropertiesList
}

/** {@inheritDoc} */
@Override public void printResult(NoArg arg, PropertiesListResult res, Consumer<String> printer) {
for (String prop : res.properties())
printer.accept(prop);
@Override public void printResult(PropertyListCommandArg arg, PropertiesListResult res, Consumer<String> printer) {
if (arg.info()) {
List<SystemViewTask.SimpleType> types = F.asList("Name", "Value", "Description").stream()
.map(x -> SystemViewTask.SimpleType.STRING).collect(Collectors.toList());

List<List<?>> data = res.properties().stream()
.map(p -> F.asList(p.get1(), p.get2(), p.get3()))
.collect(Collectors.toList());

SystemViewCommand.printTable(F.asList("Name", "Value", "Description"), types, data, printer);
}
else {
res.properties().stream()
.map(GridTuple3::get1)
.forEach(printer);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.ignite.internal.management.property;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.apache.ignite.internal.dto.IgniteDataTransferObject;
import org.apache.ignite.internal.management.api.Argument;

/** */
public class PropertyListCommandArg extends IgniteDataTransferObject {
/** */
private static final long serialVersionUID = 0;

/** */
@Argument(optional = true, description = "Print detailed information: name, value, description")
private boolean info;

/** {@inheritDoc} */
@Override protected void writeExternalData(ObjectOutput out) throws IOException {
out.writeBoolean(info);
}

/** {@inheritDoc} */
@Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
info = in.readBoolean();
}

/** */
public boolean info() {
return info;
}

/** */
public void info(boolean info) {
this.info = info;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan

/** WAL rebalance threshold. */
private final SimpleDistributedProperty<Integer> historicalRebalanceThreshold =
new SimpleDistributedProperty<>(HISTORICAL_REBALANCE_THRESHOLD_DMS_KEY, Integer::parseInt);
new SimpleDistributedProperty<>(HISTORICAL_REBALANCE_THRESHOLD_DMS_KEY, Integer::parseInt,
"WAL rebalance threshold. Threshold value to use history or full rebalance for local partition.");

/** */
private GridKernalContext ctx;
Expand Down Expand Up @@ -539,7 +540,10 @@ private DataRegionConfiguration createDefragmentationMappingRegionConfig(long re
if (!kernalCtx.clientNode()) {
kernalCtx.internalSubscriptionProcessor().registerDatabaseListener(new MetastorageRecoveryLifecycle());

cpFreqDeviation = new SimpleDistributedProperty<>("checkpoint.deviation", Integer::parseInt);
cpFreqDeviation = new SimpleDistributedProperty<>("checkpoint.deviation", Integer::parseInt,
"Checkpoint frequency deviation from the configured frequency in percentage. " +
"Gets a checkpoint interval with a randomized delay. It helps when the cluster makes a checkpoint " +
"in the same time in every node.");

kernalCtx.internalSubscriptionProcessor().registerDistributedConfigurationListener(dispatcher -> {
cpFreqDeviation.addListener((name, oldVal, newVal) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ public class IgniteSnapshotManager extends GridCacheSharedManagerAdapter
private volatile @Nullable IncrementalSnapshotMarkWalFuture markWalFut;

/** Snapshot transfer rate limit in bytes/sec. */
private final DistributedLongProperty snapshotTransferRate = detachedLongProperty(SNAPSHOT_TRANSFER_RATE_DMS_KEY);
private final DistributedLongProperty snapshotTransferRate = detachedLongProperty(SNAPSHOT_TRANSFER_RATE_DMS_KEY,
"Snapshot transfer rate in bytes per second at which snapshot files are created. " +
"0 means there is no limit.");

/** Value of {@link IgniteSystemProperties#IGNITE_SNAPSHOT_SEQUENTIAL_WRITE}. */
private final boolean sequentialWrite =
Expand Down
Loading

0 comments on commit 5727886

Please sign in to comment.