use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class ClientDomConfigProcessor method buildConfig.
@Override
public void buildConfig(Node rootNode) {
for (Node node : childElements(rootNode)) {
String nodeName = cleanNodeName(node);
if (occurrenceSet.contains(nodeName)) {
throw new InvalidConfigurationException("Duplicate '" + nodeName + "' definition found in the configuration");
}
handleNode(node, nodeName);
if (!canOccurMultipleTimes(nodeName)) {
occurrenceSet.add(nodeName);
}
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class MergeOperation method runInternal.
@Override
protected void runInternal() {
// Check once in a minute as earliest to avoid log bursts.
if (shouldCheckNow(mapContainer.getLastInvalidMergePolicyCheckTime())) {
try {
checkMapMergePolicy(mapContainer.getMapConfig(), mergePolicy.getClass().getName(), getNodeEngine().getSplitBrainMergePolicyProvider());
} catch (InvalidConfigurationException e) {
logger().log(Level.WARNING, e.getMessage(), e);
}
}
hasMapListener = mapEventPublisher.hasEventListener(name);
hasWanReplication = mapContainer.isWanReplicationEnabled() && !disableWanReplicationEvent;
hasBackups = mapContainer.getTotalBackupCount() > 0;
hasInvalidation = mapContainer.hasInvalidationListener();
if (hasBackups) {
backupPairs = new ArrayList(2 * mergingEntries.size());
}
if (hasInvalidation) {
invalidationKeys = new ArrayList<>(mergingEntries.size());
}
// if currentIndex is not zero, this is a
// continuation of the operation after a NativeOOME
int size = mergingEntries.size();
while (currentIndex < size) {
merge(mergingEntries.get(currentIndex));
currentIndex++;
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class SplitBrainProtectionServiceImpl method validateSplitBrainProtectionParameters.
private void validateSplitBrainProtectionParameters(String splitBrainProtectionName, long value, String parameterName) {
HazelcastProperties nodeProperties = nodeEngine.getProperties();
long maxNoHeartbeatMillis = nodeProperties.getMillis(ClusterProperty.MAX_NO_HEARTBEAT_SECONDS);
long heartbeatIntervalMillis = nodeProperties.getMillis(ClusterProperty.HEARTBEAT_INTERVAL_SECONDS);
if (value > maxNoHeartbeatMillis) {
throw new InvalidConfigurationException("This member is configured with maximum no-heartbeat duration " + maxNoHeartbeatMillis + " millis. For the split brain protection '" + splitBrainProtectionName + "' to be effective, set " + parameterName + " to a lower value. Currently configured value is " + value + ", reconfigure to a value lower than " + maxNoHeartbeatMillis + ".");
} else if (value < heartbeatIntervalMillis) {
throw new InvalidConfigurationException("Split brain protection '" + splitBrainProtectionName + "' is misconfigured: the value of " + "acceptable heartbeat pause (" + value + ") must be greater than " + "the configured heartbeat interval (" + heartbeatIntervalMillis + "), otherwise split brain protection " + "will be always absent.");
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class YamlMemberDomConfigProcessor method handleSecurityPermissions.
@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:methodlength" })
protected void handleSecurityPermissions(Node node) {
String onJoinOp = getAttribute(node, "on-join-operation");
if (onJoinOp != null) {
OnJoinPermissionOperationName onJoinPermissionOperation = OnJoinPermissionOperationName.valueOf(upperCaseInternal(onJoinOp));
config.getSecurityConfig().setOnJoinPermissionOperation(onJoinPermissionOperation);
}
Iterable<Node> nodes = childElements(node);
for (Node child : nodes) {
String nodeName = cleanNodeName(child);
if (matches("on-join-operation", nodeName)) {
continue;
}
nodeName = matches("all", nodeName) ? nodeName + "-permissions" : nodeName + "-permission";
PermissionType type = PermissionConfig.PermissionType.getType(nodeName);
if (type == null) {
throw new InvalidConfigurationException("Security permission type is not valid " + nodeName);
}
if (PermissionConfig.PermissionType.CONFIG == type || PermissionConfig.PermissionType.ALL == type || PermissionConfig.PermissionType.TRANSACTION == type) {
handleSecurityPermission(child, type);
} else {
handleSecurityPermissionGroup(child, type);
}
}
}
use of com.hazelcast.config.InvalidConfigurationException in project hazelcast by hazelcast.
the class TcpClientConnectionManager method doConnectToCandidateCluster.
private boolean doConnectToCandidateCluster(CandidateClusterContext context, boolean switchingToNextCluster) {
Set<Address> triedAddresses = new HashSet<>();
try {
waitStrategy.reset();
do {
Set<Address> triedAddressesPerAttempt = new HashSet<>();
List<Member> memberList = new ArrayList<>(client.getClientClusterService().getMemberList());
if (shuffleMemberList) {
Collections.shuffle(memberList);
}
// try to connect to a member in the member list first
for (Member member : memberList) {
checkClientActive();
triedAddressesPerAttempt.add(member.getAddress());
Connection connection = connect(member, o -> getOrConnectToMember((Member) o, switchingToNextCluster));
if (connection != null) {
return true;
}
}
// try to connect to a member given via config(explicit config/discovery mechanisms)
for (Address address : getPossibleMemberAddresses(context.getAddressProvider())) {
checkClientActive();
if (!triedAddressesPerAttempt.add(address)) {
// if we can not add it means that it is already tried to be connected with the member list
continue;
}
Connection connection = connect(address, o -> getOrConnectToAddress((Address) o, switchingToNextCluster));
if (connection != null) {
return true;
}
}
triedAddresses.addAll(triedAddressesPerAttempt);
// and the lifecycle check is missing, hence we need to repeat the same check at this point.
if (triedAddressesPerAttempt.isEmpty()) {
checkClientActive();
}
} while (waitStrategy.sleep());
} catch (ClientNotAllowedInClusterException | InvalidConfigurationException e) {
logger.warning("Stopped trying on the cluster: " + context.getClusterName() + " reason: " + e.getMessage());
}
logger.info("Unable to connect to any address from the cluster with name: " + context.getClusterName() + ". The following addresses were tried: " + triedAddresses);
return false;
}
Aggregations