无法加载累积约束,导致 UnsatisfiableConstraint 失败
Could not load accumulo constraint, getting UnsatisfiableConstraint failure
我一直在尝试在 Accumulo 中处理自定义约束。我通过实施 org.apache.accumulo.core.constraints.Constraint .
创建了约束
但是将其应用于 table 时出现以下错误
Constraint Failures: ConstraintViolationSummary(constrainClass:org.apache.accumulo.tserver.constraints.UnsatisfiableConstraint,violationCode:-1,violationDescription:Failed to load constraints, not accepting mutations., numberOfViolatingMutations:1)
下面是我的代码片段
package samplepackageforconstraints;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.accumulo.core.constraints.Constraint;
import org.apache.accumulo.core.data.ColumnUpdate;
import org.apache.accumulo.core.data.Mutation;
public class LengthConstraintsTest implements Constraint{
private static final short NOT_ENOUGH_LENGTH = 1;
@Override
public List<Short> check(Environment env, Mutation mutation) {
List<Short> violations = null;
Collection<ColumnUpdate> updates = mutation.getUpdates();
for (ColumnUpdate columnUpdate : updates) {
if (!isLessThanThree(columnUpdate.getValue()))
violations = addViolation(violations, NOT_ENOUGH_LENGTH);
}
return violations;
}
@Override
public String getViolationDescription(short violationCode) {
switch (violationCode) {
case NOT_ENOUGH_LENGTH:
return "Value should be more than 3 character";
}
return null;
}
private List<Short> addViolation(List<Short> violations, short violation) {
if (violations == null) {
violations = new ArrayList<Short>();
violations.add(violation);
} else if (!violations.contains(violation)) {
violations.add(violation);
}
return violations;
}
private boolean isLessThanThree(byte[] value) {
if(value.length <3)
return false;
else
return true;
}
}
我已按照 user manual of accumulo version 1.7 中给出的步骤进行操作
还 cloudera 用于加载约束
我使用的版本:accumulo的1.6.0-cdh5.1.4
提前致谢:)
当无法加载约束时,这意味着从 class 路径(通常)加载 class 存在问题,或者(不太可能)class 没有对应Constraint
界面
您需要将包含自定义约束的 jar 添加到每个平板电脑服务器的 class路径中。
您可以通过检查引发此异常的节点上的 tserver 日志来进一步调试它。
我一直在尝试在 Accumulo 中处理自定义约束。我通过实施 org.apache.accumulo.core.constraints.Constraint .
创建了约束但是将其应用于 table 时出现以下错误
Constraint Failures: ConstraintViolationSummary(constrainClass:org.apache.accumulo.tserver.constraints.UnsatisfiableConstraint,violationCode:-1,violationDescription:Failed to load constraints, not accepting mutations., numberOfViolatingMutations:1)
下面是我的代码片段
package samplepackageforconstraints;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.accumulo.core.constraints.Constraint;
import org.apache.accumulo.core.data.ColumnUpdate;
import org.apache.accumulo.core.data.Mutation;
public class LengthConstraintsTest implements Constraint{
private static final short NOT_ENOUGH_LENGTH = 1;
@Override
public List<Short> check(Environment env, Mutation mutation) {
List<Short> violations = null;
Collection<ColumnUpdate> updates = mutation.getUpdates();
for (ColumnUpdate columnUpdate : updates) {
if (!isLessThanThree(columnUpdate.getValue()))
violations = addViolation(violations, NOT_ENOUGH_LENGTH);
}
return violations;
}
@Override
public String getViolationDescription(short violationCode) {
switch (violationCode) {
case NOT_ENOUGH_LENGTH:
return "Value should be more than 3 character";
}
return null;
}
private List<Short> addViolation(List<Short> violations, short violation) {
if (violations == null) {
violations = new ArrayList<Short>();
violations.add(violation);
} else if (!violations.contains(violation)) {
violations.add(violation);
}
return violations;
}
private boolean isLessThanThree(byte[] value) {
if(value.length <3)
return false;
else
return true;
}
}
我已按照 user manual of accumulo version 1.7 中给出的步骤进行操作 还 cloudera 用于加载约束
我使用的版本:accumulo的1.6.0-cdh5.1.4
提前致谢:)
当无法加载约束时,这意味着从 class 路径(通常)加载 class 存在问题,或者(不太可能)class 没有对应Constraint
界面
您需要将包含自定义约束的 jar 添加到每个平板电脑服务器的 class路径中。
您可以通过检查引发此异常的节点上的 tserver 日志来进一步调试它。