use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class MemberDomConfigProcessor method invokeSetter.
private void invokeSetter(Object target, Node node, String argument) {
Method method = getMethod(target, "set" + toPropertyName(cleanNodeName(node)), true);
if (method == null) {
throw new InvalidConfigurationException("Invalid element/attribute name in the configuration: " + cleanNodeName(node));
}
Class<?> arg = method.getParameterTypes()[0];
Object coercedArg = arg == String.class ? argument : arg == int.class ? Integer.valueOf(argument) : arg == long.class ? Long.valueOf(argument) : arg == boolean.class ? getBooleanValue(argument) : null;
if (coercedArg == null) {
throw new HazelcastException(String.format("Method %s has unsupported argument type %s", method.getName(), arg.getSimpleName()));
}
try {
method.invoke(target, coercedArg);
} catch (Exception e) {
throw new HazelcastException(e);
}
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class NodeThreadLeakTest method testFailingHazelcastCreation.
private void testFailingHazelcastCreation(DefaultNodeContext nodeContext) {
Set<Thread> threads = getThreads();
try {
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
HazelcastInstanceFactory.newHazelcastInstance(config, config.getInstanceName(), nodeContext);
fail("Starting the member should have failed");
} catch (HazelcastException expected) {
ignore(expected);
}
assertHazelcastThreadShutdown("There are still Hazelcast threads running after failed service initialization!", threads);
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class OperationPacketFilter method filterOperation.
private Action filterOperation(Packet packet, Address endpoint) {
try {
ObjectDataInput input = serializationService.createObjectDataInput(packet);
byte header = input.readByte();
boolean identified = (header & 1) != 0;
if (identified) {
boolean compressed = (header & 1 << 2) != 0;
int factory = compressed ? input.readByte() : input.readInt();
int type = compressed ? input.readByte() : input.readInt();
return filterOperation(endpoint, factory, type);
}
} catch (IOException e) {
throw new HazelcastException(e);
}
return Action.ALLOW;
}
use of com.hazelcast.core.HazelcastException in project spring-boot by spring-projects.
the class HazelcastHealthIndicatorTests method hazelcastDown.
@Test
void hazelcastDown() {
HazelcastInstance hazelcast = mock(HazelcastInstance.class);
given(hazelcast.executeTransaction(any())).willThrow(new HazelcastException());
Health health = new HazelcastHealthIndicator(hazelcast).health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
}
use of com.hazelcast.core.HazelcastException in project hazelcast by hazelcast.
the class ClientICacheManagerTest method getCache_when_serviceNotFoundExceptionIsThrown_then_illegalStateExceptionIsThrown.
@Test
public void getCache_when_serviceNotFoundExceptionIsThrown_then_illegalStateExceptionIsThrown() {
// when HazelcastException with ServiceNotFoundException cause was thrown by hzInstance.getDistributedObject
// (i.e. cache support is not available server-side)
HazelcastInstance hzInstance = mock(HazelcastInstance.class);
HazelcastException hzException = new HazelcastException("mock exception", new ServiceNotFoundException("mock exception"));
when(hzInstance.getDistributedObject(anyString(), anyString())).thenThrow(hzException);
ClientICacheManager clientCacheManager = new ClientICacheManager(hzInstance);
// then an IllegalStateException will be thrown by getCache
thrown.expect(IllegalStateException.class);
clientCacheManager.getCache("any-cache");
}
Aggregations