Search in sources :

Example 76 with SerializationService

use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.

the class QueueContainer method setConfig.

public void setConfig(QueueConfig config, NodeEngine nodeEngine, QueueService service) {
    this.nodeEngine = nodeEngine;
    this.service = service;
    this.logger = nodeEngine.getLogger(QueueContainer.class);
    this.config = new QueueConfig(config);
    this.isPriorityQueue = config.isPriorityQueue();
    // init QueueStore
    QueueStoreConfig storeConfig = config.getQueueStoreConfig();
    SerializationService serializationService = nodeEngine.getSerializationService();
    ClassLoader classLoader = nodeEngine.getConfigClassLoader();
    // otherwise, no change is needed
    if (itemQueue != null && isPriorityQueue) {
        Queue<QueueItem> copy = createPriorityQueue();
        copy.addAll(itemQueue);
        itemQueue = copy;
    }
    this.store = QueueStoreWrapper.create(name, storeConfig, serializationService, classLoader);
    if (isPriorityQueue && store.isEnabled() && store.getMemoryLimit() < Integer.MAX_VALUE) {
        logger.warning("The queue '" + name + "' has both a comparator class and a store memory limit set. " + "The memory limit will be ignored.");
    }
}
Also used : QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) QueueConfig(com.hazelcast.config.QueueConfig) SerializationService(com.hazelcast.internal.serialization.SerializationService) TxQueueItem(com.hazelcast.collection.impl.txnqueue.TxQueueItem)

Example 77 with SerializationService

use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.

the class ListProxyImpl method subList.

@Override
public List<E> subList(int fromIndex, int toIndex) {
    ListSubOperation operation = new ListSubOperation(name, fromIndex, toIndex);
    SerializableList result = invoke(operation);
    List<Data> collection = result.getCollection();
    SerializationService serializationService = getNodeEngine().getSerializationService();
    return new UnmodifiableLazyList(collection, serializationService);
}
Also used : ListSubOperation(com.hazelcast.collection.impl.list.operations.ListSubOperation) SerializableList(com.hazelcast.spi.impl.SerializableList) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) UnmodifiableLazyList(com.hazelcast.spi.impl.UnmodifiableLazyList)

Example 78 with SerializationService

use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.

the class DurableExecutorServiceProxy method submitToPartition.

private <T> DurableExecutorServiceFuture<T> submitToPartition(@Nonnull Callable<T> task, int partitionId, T defaultValue) {
    checkNotNull(task, "task can't be null");
    SerializationService serializationService = getNodeEngine().getSerializationService();
    Data taskData = serializationService.toData(task);
    TaskOperation operation = new TaskOperation(name, taskData);
    operation.setPartitionId(partitionId);
    InternalCompletableFuture<Integer> future = invokeOnPartition(operation);
    int sequence;
    try {
        sequence = future.join();
    } catch (CompletionException t) {
        InternalCompletableFuture<T> completedFuture = completedExceptionally(t.getCause());
        return new DurableExecutorServiceDelegateFuture<T>(completedFuture, serializationService, null, -1);
    } catch (CancellationException e) {
        return new DurableExecutorServiceDelegateFuture<>(future, serializationService, null, -1);
    }
    Operation op = new RetrieveResultOperation(name, sequence).setPartitionId(partitionId);
    InternalCompletableFuture<T> internalCompletableFuture = invokeOnPartition(op);
    long taskId = Bits.combineToLong(partitionId, sequence);
    return new DurableExecutorServiceDelegateFuture<>(internalCompletableFuture, serializationService, defaultValue, taskId);
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) DisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation)

Example 79 with SerializationService

use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.

the class MemberImplTest method testSerialization.

private void testSerialization(Member member) {
    SerializationService serializationService = getSerializationService(hazelcastInstance);
    Data serialized = serializationService.toData(member);
    Member deserialized = serializationService.toObject(serialized);
    assertEquals(member, deserialized);
}
Also used : SerializationService(com.hazelcast.internal.serialization.SerializationService) Accessors.getSerializationService(com.hazelcast.test.Accessors.getSerializationService) Data(com.hazelcast.internal.serialization.Data) Member(com.hazelcast.cluster.Member)

Example 80 with SerializationService

use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.

the class WanBatchPublisherConfigTest method testSerialization.

@Test
public void testSerialization() {
    Map<String, Comparable> properties = new HashMap<>();
    properties.put("key1", "value1");
    properties.put("key2", "value2");
    WanBatchPublisherConfig config = new WanBatchPublisherConfig().setClusterName("myClusterName").setPublisherId("myPublisherId").setSnapshotEnabled(true).setInitialPublisherState(WanPublisherState.STOPPED).setQueueCapacity(23).setBatchSize(500).setBatchMaxDelayMillis(1000).setResponseTimeoutMillis(60000).setQueueFullBehavior(WanQueueFullBehavior.THROW_EXCEPTION).setAcknowledgeType(WanAcknowledgeType.ACK_ON_OPERATION_COMPLETE).setDiscoveryPeriodSeconds(20).setMaxTargetEndpoints(100).setMaxConcurrentInvocations(500).setUseEndpointPrivateAddress(true).setIdleMinParkNs(100).setIdleMaxParkNs(1000).setTargetEndpoints("a,b,c,d").setDiscoveryConfig(new DiscoveryConfig()).setSyncConfig(new WanSyncConfig()).setAwsConfig(new AwsConfig().setEnabled(true).setProperty("connection-timeout-seconds", "20")).setGcpConfig(new GcpConfig().setEnabled(true).setProperty("gcp", "gcp-val")).setAzureConfig(new AzureConfig().setEnabled(true).setProperty("azure", "azure-val")).setKubernetesConfig(new KubernetesConfig().setEnabled(true).setProperty("kubernetes", "kubernetes-val")).setEurekaConfig(new EurekaConfig().setEnabled(true).setProperty("eureka", "eureka-val")).setEndpoint("WAN").setProperties(properties).setImplementation(new DummyWanPublisher());
    SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
    Data serialized = serializationService.toData(config);
    WanBatchPublisherConfig deserialized = serializationService.toObject(serialized);
    assertWanPublisherConfig(config, deserialized);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) HashMap(java.util.HashMap) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

SerializationService (com.hazelcast.internal.serialization.SerializationService)170 Data (com.hazelcast.internal.serialization.Data)117 Test (org.junit.Test)100 QuickTest (com.hazelcast.test.annotation.QuickTest)99 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)50 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)43 ArrayList (java.util.ArrayList)15 SerializationConfig (com.hazelcast.config.SerializationConfig)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 Node (com.hazelcast.instance.impl.Node)12 CustomSerializationTest (com.hazelcast.internal.serialization.impl.CustomSerializationTest)12 Accessors.getNode (com.hazelcast.test.Accessors.getNode)12 GenericRecord (com.hazelcast.nio.serialization.GenericRecord)11 EmployeeDTO (example.serialization.EmployeeDTO)11 ExternalizableEmployeeDTO (example.serialization.ExternalizableEmployeeDTO)11 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)8 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8