Search in sources :

Example 1 with CallIdSequence

use of com.hazelcast.spi.impl.sequence.CallIdSequence in project hazelcast by hazelcast.

the class BackpressureRegulatorTest method newCallIdSequence_whenBackPressureDisabled.

@Test
public void newCallIdSequence_whenBackPressureDisabled() {
    Config config = new Config();
    config.setProperty(BACKPRESSURE_ENABLED.getName(), "false");
    HazelcastProperties hazelcastProperties = new HazelcastProperties(config);
    BackpressureRegulator backpressureRegulator = new BackpressureRegulator(hazelcastProperties, logger);
    CallIdSequence callIdSequence = backpressureRegulator.newCallIdSequence(ConcurrencyDetection.createDisabled());
    assertInstanceOf(CallIdSequenceWithoutBackpressure.class, callIdSequence);
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Config(com.hazelcast.config.Config) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CallIdSequence

use of com.hazelcast.spi.impl.sequence.CallIdSequence in project hazelcast by hazelcast.

the class ClientDelegatingFuture_SerializationExceptionTest method setup.

@Before
public void setup() {
    serializationService = new DefaultSerializationServiceBuilder().build();
    key = serializationService.toData("key");
    value = invalidData;
    logger = mock(ILogger.class);
    request = MapGetCodec.encodeRequest("test", key, 1L);
    response = MapGetCodec.encodeResponse(value);
    callIdSequence = mock(CallIdSequence.class);
    invocationFuture = new ClientInvocationFuture(mock(ClientInvocation.class), request, logger, callIdSequence);
    invocationFuture.complete(response);
    delegatingFuture = new ClientDelegatingFuture<>(invocationFuture, serializationService, MapGetCodec::decodeResponse, true);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ILogger(com.hazelcast.logging.ILogger) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) Before(org.junit.Before)

Example 3 with CallIdSequence

use of com.hazelcast.spi.impl.sequence.CallIdSequence in project hazelcast by hazelcast.

the class ClientDelegatingFutureTest method setup.

@Before
public void setup() {
    serializationService = new DefaultSerializationServiceBuilder().build();
    key = serializationService.toData("key");
    value = serializationService.toData(DESERIALIZED_VALUE);
    logger = mock(ILogger.class);
    request = MapGetCodec.encodeRequest("test", key, 1L);
    response = MapGetCodec.encodeResponse(value);
    callIdSequence = mock(CallIdSequence.class);
    invocationFuture = new ClientInvocationFuture(mock(ClientInvocation.class), request, logger, callIdSequence);
    delegatingFuture = new ClientDelegatingFuture<>(invocationFuture, serializationService, MapGetCodec::decodeResponse, true);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ILogger(com.hazelcast.logging.ILogger) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) Before(org.junit.Before)

Example 4 with CallIdSequence

use of com.hazelcast.spi.impl.sequence.CallIdSequence in project hazelcast by hazelcast.

the class BackpressureRegulatorTest method newCallIdSequence_whenBackPressureEnabled.

// ========================== newCallIdSequence =================
@Test
public void newCallIdSequence_whenBackPressureEnabled() {
    Config config = new Config();
    config.setProperty(BACKPRESSURE_ENABLED.getName(), "true");
    HazelcastProperties hazelcastProperties = new HazelcastProperties(config);
    BackpressureRegulator backpressureRegulator = new BackpressureRegulator(hazelcastProperties, logger);
    CallIdSequence callIdSequence = backpressureRegulator.newCallIdSequence(ConcurrencyDetection.createEnabled(100));
    assertInstanceOf(CallIdSequenceWithBackpressure.class, callIdSequence);
    assertEquals(backpressureRegulator.getMaxConcurrentInvocations(), callIdSequence.getMaxConcurrentInvocations());
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Config(com.hazelcast.config.Config) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with CallIdSequence

use of com.hazelcast.spi.impl.sequence.CallIdSequence in project hazelcast by hazelcast.

the class BackpressureRegulatorTest method testWriteThroughDoesntEnableBackPressure.

@Test
public void testWriteThroughDoesntEnableBackPressure() {
    Config config = new Config();
    HazelcastProperties hazelcastProperties = new HazelcastProperties(config);
    BackpressureRegulator regulator = new BackpressureRegulator(hazelcastProperties, logger);
    CallIdSequence callIdSequence = regulator.newCallIdSequence(ConcurrencyDetection.createEnabled(1000));
    assertEquals(Integer.MAX_VALUE, callIdSequence.getMaxConcurrentInvocations());
}
Also used : HazelcastProperties(com.hazelcast.spi.properties.HazelcastProperties) Config(com.hazelcast.config.Config) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CallIdSequence (com.hazelcast.spi.impl.sequence.CallIdSequence)5 Config (com.hazelcast.config.Config)3 HazelcastProperties (com.hazelcast.spi.properties.HazelcastProperties)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)2 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)2 ILogger (com.hazelcast.logging.ILogger)2 Before (org.junit.Before)2