Search in sources :

Example 61 with HazelcastException

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);
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Method(java.lang.reflect.Method) HazelcastException(com.hazelcast.core.HazelcastException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 62 with HazelcastException

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);
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Config(com.hazelcast.config.Config)

Example 63 with HazelcastException

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;
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) IOException(java.io.IOException) ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 64 with HazelcastException

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastException(com.hazelcast.core.HazelcastException) Health(org.springframework.boot.actuate.health.Health) Test(org.junit.jupiter.api.Test)

Example 65 with HazelcastException

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");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastException(com.hazelcast.core.HazelcastException) ClientServiceNotFoundException(com.hazelcast.client.impl.spi.impl.ClientServiceNotFoundException) ServiceNotFoundException(com.hazelcast.spi.exception.ServiceNotFoundException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastException (com.hazelcast.core.HazelcastException)123 IOException (java.io.IOException)43 QuickTest (com.hazelcast.test.annotation.QuickTest)19 Test (org.junit.Test)19 TxQueueItem (com.hazelcast.collection.impl.txnqueue.TxQueueItem)14 TransactionException (com.hazelcast.transaction.TransactionException)14 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 File (java.io.File)13 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)8 FileInputStream (java.io.FileInputStream)8 FileNotFoundException (java.io.FileNotFoundException)8 Data (com.hazelcast.internal.serialization.Data)7 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)6 Future (java.util.concurrent.Future)6 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)5 OException (com.orientechnologies.common.exception.OException)5 OIOException (com.orientechnologies.common.io.OIOException)5 ODistributedRedirectException (com.orientechnologies.orient.enterprise.channel.binary.ODistributedRedirectException)5 EOFException (java.io.EOFException)5 ArrayList (java.util.ArrayList)5