Search in sources :

Example 1 with ClientListProxy

use of com.hazelcast.client.impl.proxy.ClientListProxy in project hazelcast by hazelcast.

the class ReadIListP method createTraverser.

@SuppressWarnings("rawtypes")
private Traverser<Data> createTraverser(HazelcastInstance instance, String name) {
    IList<Data> list = instance.getList(name);
    int size = list.size();
    if (list instanceof ClientListProxy) {
        ClientListProxy proxy = (ClientListProxy) list;
        return createTraverser(size, proxy::dataSubList);
    } else if (list instanceof ListProxyImpl) {
        ListProxyImpl proxy = (ListProxyImpl) list;
        return createTraverser(size, proxy::dataSubList);
    } else {
        throw new RuntimeException("Unexpected list class: " + list.getClass().getName());
    }
}
Also used : ClientListProxy(com.hazelcast.client.impl.proxy.ClientListProxy) ListProxyImpl(com.hazelcast.collection.impl.list.ListProxyImpl) Data(com.hazelcast.internal.serialization.Data)

Example 2 with ClientListProxy

use of com.hazelcast.client.impl.proxy.ClientListProxy in project hazelcast by hazelcast.

the class JobSerializerTest method when_serializerIsRegisteredWithTheHook_then_itIsAvailableForTheJob.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void when_serializerIsRegisteredWithTheHook_then_itIsAvailableForTheJob() {
    String listName = "list-3";
    Pipeline pipeline = Pipeline.create();
    pipeline.readFrom(TestSources.items("Mustang")).map(name -> Animal.newBuilder().setName(name).build()).writeTo(Sinks.list(listName));
    client().getJet().newJob(pipeline, new JobConfig()).join();
    // Protocol Buffer types implement Serializable, to make sure hook registered serializer is used we check the
    // type id
    ClientListProxy<Animal> proxy = ((ClientListProxy) client().getList(listName));
    assertThat(proxy.dataSubList(0, 1).get(0).getType()).isEqualTo(ANIMAL_TYPE_ID);
}
Also used : AssertionSinks(com.hazelcast.jet.pipeline.test.AssertionSinks) IntStream(java.util.stream.IntStream) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) BeforeClass(org.junit.BeforeClass) ServiceFactories.sharedService(com.hazelcast.jet.pipeline.ServiceFactories.sharedService) QuickTest(com.hazelcast.test.annotation.QuickTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Collections.singletonList(java.util.Collections.singletonList) JetException(com.hazelcast.jet.JetException) ClientListProxy(com.hazelcast.client.impl.proxy.ClientListProxy) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ClientConfig(com.hazelcast.client.config.ClientConfig) SerializerConfig(com.hazelcast.config.SerializerConfig) Animal(com.hazelcast.jet.protobuf.Messages.Animal) SimpleTestInClusterSupport(com.hazelcast.jet.SimpleTestInClusterSupport) Config(com.hazelcast.config.Config) Pipeline(com.hazelcast.jet.pipeline.Pipeline) JobConfig(com.hazelcast.jet.config.JobConfig) Sinks(com.hazelcast.jet.pipeline.Sinks) Test(org.junit.Test) Person(com.hazelcast.jet.protobuf.Messages.Person) Category(org.junit.experimental.categories.Category) Sources(com.hazelcast.jet.pipeline.Sources) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) FunctionEx.identity(com.hazelcast.function.FunctionEx.identity) Animal(com.hazelcast.jet.protobuf.Messages.Animal) JobConfig(com.hazelcast.jet.config.JobConfig) Pipeline(com.hazelcast.jet.pipeline.Pipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientListProxy (com.hazelcast.client.impl.proxy.ClientListProxy)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ListProxyImpl (com.hazelcast.collection.impl.list.ListProxyImpl)1 Config (com.hazelcast.config.Config)1 SerializerConfig (com.hazelcast.config.SerializerConfig)1 FunctionEx.identity (com.hazelcast.function.FunctionEx.identity)1 Data (com.hazelcast.internal.serialization.Data)1 JetException (com.hazelcast.jet.JetException)1 SimpleTestInClusterSupport (com.hazelcast.jet.SimpleTestInClusterSupport)1 JobConfig (com.hazelcast.jet.config.JobConfig)1 Pipeline (com.hazelcast.jet.pipeline.Pipeline)1 ServiceFactories.sharedService (com.hazelcast.jet.pipeline.ServiceFactories.sharedService)1 Sinks (com.hazelcast.jet.pipeline.Sinks)1 Sources (com.hazelcast.jet.pipeline.Sources)1 AssertionSinks (com.hazelcast.jet.pipeline.test.AssertionSinks)1 TestSources (com.hazelcast.jet.pipeline.test.TestSources)1 Animal (com.hazelcast.jet.protobuf.Messages.Animal)1 Person (com.hazelcast.jet.protobuf.Messages.Person)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1