/** * remove constraint * @param clusterName * @param constraintType * @param constraintId */ public void removeConstraint(String clusterName, String constraintType, String constraintId) { if (clusterName == null || constraintType == null || constraintId == null) { throw new IllegalArgumentException( "fail to remove constraint. missing clusterName|constraintType|constraintId"); } ConstraintType type = ConstraintType.valueOf(constraintType); _admin.removeConstraint(clusterName, type, constraintId); }
/** * remove constraint * @param clusterName * @param constraintType * @param constraintId */ public void removeConstraint(String clusterName, String constraintType, String constraintId) { if (clusterName == null || constraintType == null || constraintId == null) { throw new IllegalArgumentException( "fail to remove constraint. missing clusterName|constraintType|constraintId"); } ConstraintType type = ConstraintType.valueOf(constraintType); _admin.removeConstraint(clusterName, type, constraintId); }
/** * get constraints associated with given type * @param constraintType : constraint-type. e.g. MESSAGE_CONSTRAINT * @return json-formated constraints */ public String getConstraints(String clusterName, String constraintType) { if (clusterName == null || constraintType == null) { throw new IllegalArgumentException( "fail to get constraint. missing clusterName|constraintType"); } ConstraintType type = ConstraintType.valueOf(constraintType); ClusterConstraints constraints = _admin.getConstraints(clusterName, type); return new String(constraints.serialize(new ZNRecordSerializer())); }
ConstraintType constraintType = ConstraintType.valueOf(constraintTypeStr); ZkClient zkClient = ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
/** * set constraint * @param clusterName * @param constraintType * @param constraintId * @param constraintAttributesMap : csv-formated constraint key-value pairs */ public void setConstraint(String clusterName, String constraintType, String constraintId, String constraintAttributesMap) { if (clusterName == null || constraintType == null || constraintId == null || constraintAttributesMap == null) { throw new IllegalArgumentException( "fail to set constraint. missing clusterName|constraintType|constraintId|constraintAttributesMap"); } ConstraintType type = ConstraintType.valueOf(constraintType); ConstraintItemBuilder builder = new ConstraintItemBuilder(); Map<String, String> constraintAttributes = HelixUtil.parseCsvFormatedKeyValuePairs(constraintAttributesMap); ConstraintItem constraintItem = builder.addConstraintAttributes(constraintAttributes).build(); _admin.setConstraint(clusterName, type, constraintId, constraintItem); }
/** * set constraint * @param clusterName * @param constraintType * @param constraintId * @param constraintAttributesMap : csv-formated constraint key-value pairs */ public void setConstraint(String clusterName, String constraintType, String constraintId, String constraintAttributesMap) { if (clusterName == null || constraintType == null || constraintId == null || constraintAttributesMap == null) { throw new IllegalArgumentException( "fail to set constraint. missing clusterName|constraintType|constraintId|constraintAttributesMap"); } ConstraintType type = ConstraintType.valueOf(constraintType); ConstraintItemBuilder builder = new ConstraintItemBuilder(); Map<String, String> constraintAttributes = HelixUtil.parseCsvFormatedKeyValuePairs(constraintAttributesMap); ConstraintItem constraintItem = builder.addConstraintAttributes(constraintAttributes).build(); _admin.setConstraint(clusterName, type, constraintId, constraintItem); }
/** * get constraints associated with given type * @param constraintType : constraint-type. e.g. MESSAGE_CONSTRAINT * @return json-formated constraints */ public String getConstraints(String clusterName, String constraintType) { if (clusterName == null || constraintType == null) { throw new IllegalArgumentException( "fail to get constraint. missing clusterName|constraintType"); } ConstraintType type = ConstraintType.valueOf(constraintType); ClusterConstraints constraints = _admin.getConstraints(clusterName, type); return new String(constraints.serialize(new ZNRecordSerializer())); }