Create cache using thin protocol

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Create cache using thin protocol

Prachi Garg
Pavel,

I tried to create a cache with configuration, using the thin protocol.

1. Do I need to provide every configuration as mentioned in the wiki, or I
can just provide a few and the rest can be default?

2. Using the below code:

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

// Message length
writeIntLittleEndian(22, out);

// Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
writeShortLittleEndian(1053, out);

// Request id (can be anything)
long reqId = 1;
writeLongLittleEndian(reqId, out);

// CacheAtomicityMode
writeIntLittleEndian(0, out);

// Backups
writeIntLittleEndian(2, out);

// CacheMode
writeIntLittleEndian(2, out);

// Read result
DataInputStream in = new DataInputStream(socket.getInputStream());

// Response length
final int len = readIntLittleEndian(in);
System.out.println("len: " + len);

// Request id
long resReqId = readLongLittleEndian(in);
System.out.println("resReqId: " + resReqId);

// Success
int statusCode = readIntLittleEndian(in);
System.out.println("status code: " + statusCode);


I get the following error:

[2017-12-20 16:43:32,800][ERROR][client-connector-#45][ClientListenerNioListener]
Failed to parse client request.
class org.apache.ignite.binary.BinaryObjectException: Not enough data
to read the value [position=22, requiredBytes=4, remainingBytes=0]
        at org.apache.ignite.internal.binary.streams.BinaryAbstractInputStream.ensureEnoughData(BinaryAbstractInputStream.java:305)
        at org.apache.ignite.internal.binary.streams.BinaryAbstractInputStream.readInt(BinaryAbstractInputStream.java:127)
        at org.apache.ignite.internal.binary.BinaryReaderExImpl.readInt(BinaryReaderExImpl.java:743)
        at org.apache.ignite.internal.processors.platform.client.cache.ClientCacheConfigurationSerializer.read(ClientCacheConfigurationSerializer.java:125)
        at org.apache.ignite.internal.processors.platform.client.cache.ClientCacheCreateWithConfigurationRequest.<init>(ClientCacheCreateWithConfigurationRequest.java:45)
        at org.apache.ignite.internal.processors.platform.client.ClientMessageParser.decode(ClientMessageParser.java:333)
        at org.apache.ignite.internal.processors.platform.client.ClientMessageParser.decode(ClientMessageParser.java:220)
        at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:119)
        at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:40)
        at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
        at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
        at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
        at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Reply | Threaded
Open this post in threaded view
|

Re: Create cache using thin protocol

Pavel Tupitsyn-3
Hi Prachi,

Yes, you have to provide full configuration. The error is caused by
incomplete request message.

Alternatively, define cache templates on server (configs with * in them)
and then use OP_CACHE_CREATE_WITH_NAME from thin client.

Thanks,
Pavel

On Thu, Dec 21, 2017 at 3:47 AM, Prachi Garg <[hidden email]> wrote:

> Pavel,
>
> I tried to create a cache with configuration, using the thin protocol.
>
> 1. Do I need to provide every configuration as mentioned in the wiki, or I
> can just provide a few and the rest can be default?
>
> 2. Using the below code:
>
> DataOutputStream out = new DataOutputStream(socket.getOutputStream());
>
> // Message length
> writeIntLittleEndian(22, out);
>
> // Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
> writeShortLittleEndian(1053, out);
>
> // Request id (can be anything)
> long reqId = 1;
> writeLongLittleEndian(reqId, out);
>
> // CacheAtomicityMode
> writeIntLittleEndian(0, out);
>
> // Backups
> writeIntLittleEndian(2, out);
>
> // CacheMode
> writeIntLittleEndian(2, out);
>
> // Read result
> DataInputStream in = new DataInputStream(socket.getInputStream());
>
> // Response length
> final int len = readIntLittleEndian(in);
> System.out.println("len: " + len);
>
> // Request id
> long resReqId = readLongLittleEndian(in);
> System.out.println("resReqId: " + resReqId);
>
> // Success
> int statusCode = readIntLittleEndian(in);
> System.out.println("status code: " + statusCode);
>
>
> I get the following error:
>
> [2017-12-20 16:43:32,800][ERROR][client-connector-#45][ClientListenerNioListener] Failed to parse client request.
> class org.apache.ignite.binary.BinaryObjectException: Not enough data to read the value [position=22, requiredBytes=4, remainingBytes=0]
> at org.apache.ignite.internal.binary.streams.BinaryAbstractInputStream.ensureEnoughData(BinaryAbstractInputStream.java:305)
> at org.apache.ignite.internal.binary.streams.BinaryAbstractInputStream.readInt(BinaryAbstractInputStream.java:127)
> at org.apache.ignite.internal.binary.BinaryReaderExImpl.readInt(BinaryReaderExImpl.java:743)
> at org.apache.ignite.internal.processors.platform.client.cache.ClientCacheConfigurationSerializer.read(ClientCacheConfigurationSerializer.java:125)
> at org.apache.ignite.internal.processors.platform.client.cache.ClientCacheCreateWithConfigurationRequest.<init>(ClientCacheCreateWithConfigurationRequest.java:45)
> at org.apache.ignite.internal.processors.platform.client.ClientMessageParser.decode(ClientMessageParser.java:333)
> at org.apache.ignite.internal.processors.platform.client.ClientMessageParser.decode(ClientMessageParser.java:220)
> at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:119)
> at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:40)
> at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
> at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
> at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
> at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
> at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Create cache using thin protocol

dmagda
Hi Pavel,

If it’s supposed to be used this way then it’s better not to tell about this operation at all until it’s simplified from a user standpoint.

My suggestion would be to design the operation so that I can pass only those configuration parameters that need to be different from the defaults. How difficult is this and can the improvement go into 2.4?


Denis

> On Dec 20, 2017, at 10:48 PM, Pavel Tupitsyn <[hidden email]> wrote:
>
> Hi Prachi,
>
> Yes, you have to provide full configuration. The error is caused by
> incomplete request message.
>
> Alternatively, define cache templates on server (configs with * in them)
> and then use OP_CACHE_CREATE_WITH_NAME from thin client.
>
> Thanks,
> Pavel
>
> On Thu, Dec 21, 2017 at 3:47 AM, Prachi Garg <[hidden email]> wrote:
>
>> Pavel,
>>
>> I tried to create a cache with configuration, using the thin protocol.
>>
>> 1. Do I need to provide every configuration as mentioned in the wiki, or I
>> can just provide a few and the rest can be default?
>>
>> 2. Using the below code:
>>
>> DataOutputStream out = new DataOutputStream(socket.getOutputStream());
>>
>> // Message length
>> writeIntLittleEndian(22, out);
>>
>> // Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
>> writeShortLittleEndian(1053, out);
>>
>> // Request id (can be anything)
>> long reqId = 1;
>> writeLongLittleEndian(reqId, out);
>>
>> // CacheAtomicityMode
>> writeIntLittleEndian(0, out);
>>
>> // Backups
>> writeIntLittleEndian(2, out);
>>
>> // CacheMode
>> writeIntLittleEndian(2, out);
>>
>> // Read result
>> DataInputStream in = new DataInputStream(socket.getInputStream());
>>
>> // Response length
>> final int len = readIntLittleEndian(in);
>> System.out.println("len: " + len);
>>
>> // Request id
>> long resReqId = readLongLittleEndian(in);
>> System.out.println("resReqId: " + resReqId);
>>
>> // Success
>> int statusCode = readIntLittleEndian(in);
>> System.out.println("status code: " + statusCode);
>>
>>
>> I get the following error:
>>
>> [2017-12-20 16:43:32,800][ERROR][client-connector-#45][ClientListenerNioListener] Failed to parse client request.
>> class org.apache.ignite.binary.BinaryObjectException: Not enough data to read the value [position=22, requiredBytes=4, remainingBytes=0]
>> at org.apache.ignite.internal.binary.streams.BinaryAbstractInputStream.ensureEnoughData(BinaryAbstractInputStream.java:305)
>> at org.apache.ignite.internal.binary.streams.BinaryAbstractInputStream.readInt(BinaryAbstractInputStream.java:127)
>> at org.apache.ignite.internal.binary.BinaryReaderExImpl.readInt(BinaryReaderExImpl.java:743)
>> at org.apache.ignite.internal.processors.platform.client.cache.ClientCacheConfigurationSerializer.read(ClientCacheConfigurationSerializer.java:125)
>> at org.apache.ignite.internal.processors.platform.client.cache.ClientCacheCreateWithConfigurationRequest.<init>(ClientCacheCreateWithConfigurationRequest.java:45)
>> at org.apache.ignite.internal.processors.platform.client.ClientMessageParser.decode(ClientMessageParser.java:333)
>> at org.apache.ignite.internal.processors.platform.client.ClientMessageParser.decode(ClientMessageParser.java:220)
>> at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:119)
>> at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:40)
>> at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
>> at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
>> at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
>> at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>> at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>> at java.lang.Thread.run(Thread.java:745)
>>
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Create cache using thin protocol

Pavel Tupitsyn
Hi Denis,

I think we can assign an id to each parameter. It is not difficult to add.

> not to tell about this operation
Hiding stuff is not a good approach. Any decent engineer will have a look
at the server code and see it.

Pavel

On Fri, Dec 22, 2017 at 3:45 AM, Denis Magda <[hidden email]> wrote:

> Hi Pavel,
>
> If it’s supposed to be used this way then it’s better not to tell about
> this operation at all until it’s simplified from a user standpoint.
>
> My suggestion would be to design the operation so that I can pass only
> those configuration parameters that need to be different from the defaults.
> How difficult is this and can the improvement go into 2.4?
>
> —
> Denis
>
> > On Dec 20, 2017, at 10:48 PM, Pavel Tupitsyn <[hidden email]>
> wrote:
> >
> > Hi Prachi,
> >
> > Yes, you have to provide full configuration. The error is caused by
> > incomplete request message.
> >
> > Alternatively, define cache templates on server (configs with * in them)
> > and then use OP_CACHE_CREATE_WITH_NAME from thin client.
> >
> > Thanks,
> > Pavel
> >
> > On Thu, Dec 21, 2017 at 3:47 AM, Prachi Garg <[hidden email]> wrote:
> >
> >> Pavel,
> >>
> >> I tried to create a cache with configuration, using the thin protocol.
> >>
> >> 1. Do I need to provide every configuration as mentioned in the wiki,
> or I
> >> can just provide a few and the rest can be default?
> >>
> >> 2. Using the below code:
> >>
> >> DataOutputStream out = new DataOutputStream(socket.getOutputStream());
> >>
> >> // Message length
> >> writeIntLittleEndian(22, out);
> >>
> >> // Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
> >> writeShortLittleEndian(1053, out);
> >>
> >> // Request id (can be anything)
> >> long reqId = 1;
> >> writeLongLittleEndian(reqId, out);
> >>
> >> // CacheAtomicityMode
> >> writeIntLittleEndian(0, out);
> >>
> >> // Backups
> >> writeIntLittleEndian(2, out);
> >>
> >> // CacheMode
> >> writeIntLittleEndian(2, out);
> >>
> >> // Read result
> >> DataInputStream in = new DataInputStream(socket.getInputStream());
> >>
> >> // Response length
> >> final int len = readIntLittleEndian(in);
> >> System.out.println("len: " + len);
> >>
> >> // Request id
> >> long resReqId = readLongLittleEndian(in);
> >> System.out.println("resReqId: " + resReqId);
> >>
> >> // Success
> >> int statusCode = readIntLittleEndian(in);
> >> System.out.println("status code: " + statusCode);
> >>
> >>
> >> I get the following error:
> >>
> >> [2017-12-20 16:43:32,800][ERROR][client-connector-#45][ClientListenerNioListener]
> Failed to parse client request.
> >> class org.apache.ignite.binary.BinaryObjectException: Not enough data
> to read the value [position=22, requiredBytes=4, remainingBytes=0]
> >>      at org.apache.ignite.internal.binary.streams.
> BinaryAbstractInputStream.ensureEnoughData(BinaryAbstractInputStream.
> java:305)
> >>      at org.apache.ignite.internal.binary.streams.
> BinaryAbstractInputStream.readInt(BinaryAbstractInputStream.java:127)
> >>      at org.apache.ignite.internal.binary.BinaryReaderExImpl.
> readInt(BinaryReaderExImpl.java:743)
> >>      at org.apache.ignite.internal.processors.platform.client.cache.
> ClientCacheConfigurationSerializer.read(ClientCacheConfigurationSerial
> izer.java:125)
> >>      at org.apache.ignite.internal.processors.platform.client.cache.
> ClientCacheCreateWithConfigurationRequest.<init>(
> ClientCacheCreateWithConfigurationRequest.java:45)
> >>      at org.apache.ignite.internal.processors.platform.client.
> ClientMessageParser.decode(ClientMessageParser.java:333)
> >>      at org.apache.ignite.internal.processors.platform.client.
> ClientMessageParser.decode(ClientMessageParser.java:220)
> >>      at org.apache.ignite.internal.processors.odbc.
> ClientListenerNioListener.onMessage(ClientListenerNioListener.java:119)
> >>      at org.apache.ignite.internal.processors.odbc.
> ClientListenerNioListener.onMessage(ClientListenerNioListener.java:40)
> >>      at org.apache.ignite.internal.util.nio.GridNioFilterChain$
> TailFilter.onMessageReceived(GridNioFilterChain.java:279)
> >>      at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.
> proceedMessageReceived(GridNioFilterAdapter.java:109)
> >>      at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.
> body(GridNioAsyncNotifyFilter.java:97)
> >>      at org.apache.ignite.internal.util.worker.GridWorker.run(
> GridWorker.java:110)
> >>      at org.apache.ignite.internal.util.worker.GridWorkerPool$1.
> run(GridWorkerPool.java:70)
> >>      at java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
> >>      at java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
> >>      at java.lang.Thread.run(Thread.java:745)
> >>
> >>
> >>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Create cache using thin protocol

Pavel Tupitsyn
Ticket created: https://issues.apache.org/jira/browse/IGNITE-7288
I'll implement this next week.

On Fri, Dec 22, 2017 at 10:06 AM, Pavel Tupitsyn <[hidden email]>
wrote:

> Hi Denis,
>
> I think we can assign an id to each parameter. It is not difficult to add.
>
> > not to tell about this operation
> Hiding stuff is not a good approach. Any decent engineer will have a look
> at the server code and see it.
>
> Pavel
>
> On Fri, Dec 22, 2017 at 3:45 AM, Denis Magda <[hidden email]> wrote:
>
>> Hi Pavel,
>>
>> If it’s supposed to be used this way then it’s better not to tell about
>> this operation at all until it’s simplified from a user standpoint.
>>
>> My suggestion would be to design the operation so that I can pass only
>> those configuration parameters that need to be different from the defaults.
>> How difficult is this and can the improvement go into 2.4?
>>
>> —
>> Denis
>>
>> > On Dec 20, 2017, at 10:48 PM, Pavel Tupitsyn <[hidden email]>
>> wrote:
>> >
>> > Hi Prachi,
>> >
>> > Yes, you have to provide full configuration. The error is caused by
>> > incomplete request message.
>> >
>> > Alternatively, define cache templates on server (configs with * in them)
>> > and then use OP_CACHE_CREATE_WITH_NAME from thin client.
>> >
>> > Thanks,
>> > Pavel
>> >
>> > On Thu, Dec 21, 2017 at 3:47 AM, Prachi Garg <[hidden email]>
>> wrote:
>> >
>> >> Pavel,
>> >>
>> >> I tried to create a cache with configuration, using the thin protocol.
>> >>
>> >> 1. Do I need to provide every configuration as mentioned in the wiki,
>> or I
>> >> can just provide a few and the rest can be default?
>> >>
>> >> 2. Using the below code:
>> >>
>> >> DataOutputStream out = new DataOutputStream(socket.getOutputStream());
>> >>
>> >> // Message length
>> >> writeIntLittleEndian(22, out);
>> >>
>> >> // Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
>> >> writeShortLittleEndian(1053, out);
>> >>
>> >> // Request id (can be anything)
>> >> long reqId = 1;
>> >> writeLongLittleEndian(reqId, out);
>> >>
>> >> // CacheAtomicityMode
>> >> writeIntLittleEndian(0, out);
>> >>
>> >> // Backups
>> >> writeIntLittleEndian(2, out);
>> >>
>> >> // CacheMode
>> >> writeIntLittleEndian(2, out);
>> >>
>> >> // Read result
>> >> DataInputStream in = new DataInputStream(socket.getInputStream());
>> >>
>> >> // Response length
>> >> final int len = readIntLittleEndian(in);
>> >> System.out.println("len: " + len);
>> >>
>> >> // Request id
>> >> long resReqId = readLongLittleEndian(in);
>> >> System.out.println("resReqId: " + resReqId);
>> >>
>> >> // Success
>> >> int statusCode = readIntLittleEndian(in);
>> >> System.out.println("status code: " + statusCode);
>> >>
>> >>
>> >> I get the following error:
>> >>
>> >> [2017-12-20 16:43:32,800][ERROR][client-co
>> nnector-#45][ClientListenerNioListener] Failed to parse client request.
>> >> class org.apache.ignite.binary.BinaryObjectException: Not enough data
>> to read the value [position=22, requiredBytes=4, remainingBytes=0]
>> >>      at org.apache.ignite.internal.binary.streams.BinaryAbstractInpu
>> tStream.ensureEnoughData(BinaryAbstractInputStream.java:305)
>> >>      at org.apache.ignite.internal.binary.streams.BinaryAbstractInpu
>> tStream.readInt(BinaryAbstractInputStream.java:127)
>> >>      at org.apache.ignite.internal.binary.BinaryReaderExImpl.readInt
>> (BinaryReaderExImpl.java:743)
>> >>      at org.apache.ignite.internal.processors.platform.client.cache.
>> ClientCacheConfigurationSerializer.read(ClientCacheConfigura
>> tionSerializer.java:125)
>> >>      at org.apache.ignite.internal.processors.platform.client.cache.
>> ClientCacheCreateWithConfigurationRequest.<init>(ClientCache
>> CreateWithConfigurationRequest.java:45)
>> >>      at org.apache.ignite.internal.processors.platform.client.Client
>> MessageParser.decode(ClientMessageParser.java:333)
>> >>      at org.apache.ignite.internal.processors.platform.client.Client
>> MessageParser.decode(ClientMessageParser.java:220)
>> >>      at org.apache.ignite.internal.processors.odbc.ClientListenerNio
>> Listener.onMessage(ClientListenerNioListener.java:119)
>> >>      at org.apache.ignite.internal.processors.odbc.ClientListenerNio
>> Listener.onMessage(ClientListenerNioListener.java:40)
>> >>      at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailF
>> ilter.onMessageReceived(GridNioFilterChain.java:279)
>> >>      at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.pro
>> ceedMessageReceived(GridNioFilterAdapter.java:109)
>> >>      at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter
>> $3.body(GridNioAsyncNotifyFilter.java:97)
>> >>      at org.apache.ignite.internal.util.worker.GridWorker.run(GridWo
>> rker.java:110)
>> >>      at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(
>> GridWorkerPool.java:70)
>> >>      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1142)
>> >>      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:617)
>> >>      at java.lang.Thread.run(Thread.java:745)
>> >>
>> >>
>> >>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Create cache using thin protocol

dmagda
Pavel, thanks for a quick turnaround. Please ping Prachi when you merge the improvement so that she can update the readme doc.


Denis

> On Dec 22, 2017, at 4:43 AM, Pavel Tupitsyn <[hidden email]> wrote:
>
> Ticket created: https://issues.apache.org/jira/browse/IGNITE-7288
> I'll implement this next week.
>
> On Fri, Dec 22, 2017 at 10:06 AM, Pavel Tupitsyn <[hidden email]>
> wrote:
>
>> Hi Denis,
>>
>> I think we can assign an id to each parameter. It is not difficult to add.
>>
>>> not to tell about this operation
>> Hiding stuff is not a good approach. Any decent engineer will have a look
>> at the server code and see it.
>>
>> Pavel
>>
>> On Fri, Dec 22, 2017 at 3:45 AM, Denis Magda <[hidden email]> wrote:
>>
>>> Hi Pavel,
>>>
>>> If it’s supposed to be used this way then it’s better not to tell about
>>> this operation at all until it’s simplified from a user standpoint.
>>>
>>> My suggestion would be to design the operation so that I can pass only
>>> those configuration parameters that need to be different from the defaults.
>>> How difficult is this and can the improvement go into 2.4?
>>>
>>> —
>>> Denis
>>>
>>>> On Dec 20, 2017, at 10:48 PM, Pavel Tupitsyn <[hidden email]>
>>> wrote:
>>>>
>>>> Hi Prachi,
>>>>
>>>> Yes, you have to provide full configuration. The error is caused by
>>>> incomplete request message.
>>>>
>>>> Alternatively, define cache templates on server (configs with * in them)
>>>> and then use OP_CACHE_CREATE_WITH_NAME from thin client.
>>>>
>>>> Thanks,
>>>> Pavel
>>>>
>>>> On Thu, Dec 21, 2017 at 3:47 AM, Prachi Garg <[hidden email]>
>>> wrote:
>>>>
>>>>> Pavel,
>>>>>
>>>>> I tried to create a cache with configuration, using the thin protocol.
>>>>>
>>>>> 1. Do I need to provide every configuration as mentioned in the wiki,
>>> or I
>>>>> can just provide a few and the rest can be default?
>>>>>
>>>>> 2. Using the below code:
>>>>>
>>>>> DataOutputStream out = new DataOutputStream(socket.getOutputStream());
>>>>>
>>>>> // Message length
>>>>> writeIntLittleEndian(22, out);
>>>>>
>>>>> // Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
>>>>> writeShortLittleEndian(1053, out);
>>>>>
>>>>> // Request id (can be anything)
>>>>> long reqId = 1;
>>>>> writeLongLittleEndian(reqId, out);
>>>>>
>>>>> // CacheAtomicityMode
>>>>> writeIntLittleEndian(0, out);
>>>>>
>>>>> // Backups
>>>>> writeIntLittleEndian(2, out);
>>>>>
>>>>> // CacheMode
>>>>> writeIntLittleEndian(2, out);
>>>>>
>>>>> // Read result
>>>>> DataInputStream in = new DataInputStream(socket.getInputStream());
>>>>>
>>>>> // Response length
>>>>> final int len = readIntLittleEndian(in);
>>>>> System.out.println("len: " + len);
>>>>>
>>>>> // Request id
>>>>> long resReqId = readLongLittleEndian(in);
>>>>> System.out.println("resReqId: " + resReqId);
>>>>>
>>>>> // Success
>>>>> int statusCode = readIntLittleEndian(in);
>>>>> System.out.println("status code: " + statusCode);
>>>>>
>>>>>
>>>>> I get the following error:
>>>>>
>>>>> [2017-12-20 16:43:32,800][ERROR][client-co
>>> nnector-#45][ClientListenerNioListener] Failed to parse client request.
>>>>> class org.apache.ignite.binary.BinaryObjectException: Not enough data
>>> to read the value [position=22, requiredBytes=4, remainingBytes=0]
>>>>>     at org.apache.ignite.internal.binary.streams.BinaryAbstractInpu
>>> tStream.ensureEnoughData(BinaryAbstractInputStream.java:305)
>>>>>     at org.apache.ignite.internal.binary.streams.BinaryAbstractInpu
>>> tStream.readInt(BinaryAbstractInputStream.java:127)
>>>>>     at org.apache.ignite.internal.binary.BinaryReaderExImpl.readInt
>>> (BinaryReaderExImpl.java:743)
>>>>>     at org.apache.ignite.internal.processors.platform.client.cache.
>>> ClientCacheConfigurationSerializer.read(ClientCacheConfigura
>>> tionSerializer.java:125)
>>>>>     at org.apache.ignite.internal.processors.platform.client.cache.
>>> ClientCacheCreateWithConfigurationRequest.<init>(ClientCache
>>> CreateWithConfigurationRequest.java:45)
>>>>>     at org.apache.ignite.internal.processors.platform.client.Client
>>> MessageParser.decode(ClientMessageParser.java:333)
>>>>>     at org.apache.ignite.internal.processors.platform.client.Client
>>> MessageParser.decode(ClientMessageParser.java:220)
>>>>>     at org.apache.ignite.internal.processors.odbc.ClientListenerNio
>>> Listener.onMessage(ClientListenerNioListener.java:119)
>>>>>     at org.apache.ignite.internal.processors.odbc.ClientListenerNio
>>> Listener.onMessage(ClientListenerNioListener.java:40)
>>>>>     at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailF
>>> ilter.onMessageReceived(GridNioFilterChain.java:279)
>>>>>     at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.pro
>>> ceedMessageReceived(GridNioFilterAdapter.java:109)
>>>>>     at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter
>>> $3.body(GridNioAsyncNotifyFilter.java:97)
>>>>>     at org.apache.ignite.internal.util.worker.GridWorker.run(GridWo
>>> rker.java:110)
>>>>>     at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(
>>> GridWorkerPool.java:70)
>>>>>     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>>> Executor.java:1142)
>>>>>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>>> lExecutor.java:617)
>>>>>     at java.lang.Thread.run(Thread.java:745)
>>>>>
>>>>>
>>>>>
>>>
>>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Create cache using thin protocol

Pavel Tupitsyn
Changes merged to master, doc updated:
https://cwiki.apache.org/confluence/display/IGNITE/IEP-9+Thin+Client+Protocol

Note that OP_CACHE_GET_CONFIGURATION still returns full config,
but OP_CACHE_CREATE_WITH_CONFIGURATION now allows partial config in
key-value form.

Thanks,
Pavel

On Fri, Dec 22, 2017 at 8:25 PM, Denis Magda <[hidden email]> wrote:

> Pavel, thanks for a quick turnaround. Please ping Prachi when you merge
> the improvement so that she can update the readme doc.
>
> —
> Denis
>
> > On Dec 22, 2017, at 4:43 AM, Pavel Tupitsyn <[hidden email]>
> wrote:
> >
> > Ticket created: https://issues.apache.org/jira/browse/IGNITE-7288
> > I'll implement this next week.
> >
> > On Fri, Dec 22, 2017 at 10:06 AM, Pavel Tupitsyn <[hidden email]>
> > wrote:
> >
> >> Hi Denis,
> >>
> >> I think we can assign an id to each parameter. It is not difficult to
> add.
> >>
> >>> not to tell about this operation
> >> Hiding stuff is not a good approach. Any decent engineer will have a
> look
> >> at the server code and see it.
> >>
> >> Pavel
> >>
> >> On Fri, Dec 22, 2017 at 3:45 AM, Denis Magda <[hidden email]> wrote:
> >>
> >>> Hi Pavel,
> >>>
> >>> If it’s supposed to be used this way then it’s better not to tell about
> >>> this operation at all until it’s simplified from a user standpoint.
> >>>
> >>> My suggestion would be to design the operation so that I can pass only
> >>> those configuration parameters that need to be different from the
> defaults.
> >>> How difficult is this and can the improvement go into 2.4?
> >>>
> >>> —
> >>> Denis
> >>>
> >>>> On Dec 20, 2017, at 10:48 PM, Pavel Tupitsyn <[hidden email]>
> >>> wrote:
> >>>>
> >>>> Hi Prachi,
> >>>>
> >>>> Yes, you have to provide full configuration. The error is caused by
> >>>> incomplete request message.
> >>>>
> >>>> Alternatively, define cache templates on server (configs with * in
> them)
> >>>> and then use OP_CACHE_CREATE_WITH_NAME from thin client.
> >>>>
> >>>> Thanks,
> >>>> Pavel
> >>>>
> >>>> On Thu, Dec 21, 2017 at 3:47 AM, Prachi Garg <[hidden email]>
> >>> wrote:
> >>>>
> >>>>> Pavel,
> >>>>>
> >>>>> I tried to create a cache with configuration, using the thin
> protocol.
> >>>>>
> >>>>> 1. Do I need to provide every configuration as mentioned in the wiki,
> >>> or I
> >>>>> can just provide a few and the rest can be default?
> >>>>>
> >>>>> 2. Using the below code:
> >>>>>
> >>>>> DataOutputStream out = new DataOutputStream(socket.
> getOutputStream());
> >>>>>
> >>>>> // Message length
> >>>>> writeIntLittleEndian(22, out);
> >>>>>
> >>>>> // Op code = OP_CACHE_CREATE_WITH_CONFIGURATION
> >>>>> writeShortLittleEndian(1053, out);
> >>>>>
> >>>>> // Request id (can be anything)
> >>>>> long reqId = 1;
> >>>>> writeLongLittleEndian(reqId, out);
> >>>>>
> >>>>> // CacheAtomicityMode
> >>>>> writeIntLittleEndian(0, out);
> >>>>>
> >>>>> // Backups
> >>>>> writeIntLittleEndian(2, out);
> >>>>>
> >>>>> // CacheMode
> >>>>> writeIntLittleEndian(2, out);
> >>>>>
> >>>>> // Read result
> >>>>> DataInputStream in = new DataInputStream(socket.getInputStream());
> >>>>>
> >>>>> // Response length
> >>>>> final int len = readIntLittleEndian(in);
> >>>>> System.out.println("len: " + len);
> >>>>>
> >>>>> // Request id
> >>>>> long resReqId = readLongLittleEndian(in);
> >>>>> System.out.println("resReqId: " + resReqId);
> >>>>>
> >>>>> // Success
> >>>>> int statusCode = readIntLittleEndian(in);
> >>>>> System.out.println("status code: " + statusCode);
> >>>>>
> >>>>>
> >>>>> I get the following error:
> >>>>>
> >>>>> [2017-12-20 16:43:32,800][ERROR][client-co
> >>> nnector-#45][ClientListenerNioListener] Failed to parse client
> request.
> >>>>> class org.apache.ignite.binary.BinaryObjectException: Not enough
> data
> >>> to read the value [position=22, requiredBytes=4, remainingBytes=0]
> >>>>>     at org.apache.ignite.internal.binary.streams.BinaryAbstractInpu
> >>> tStream.ensureEnoughData(BinaryAbstractInputStream.java:305)
> >>>>>     at org.apache.ignite.internal.binary.streams.BinaryAbstractInpu
> >>> tStream.readInt(BinaryAbstractInputStream.java:127)
> >>>>>     at org.apache.ignite.internal.binary.BinaryReaderExImpl.readInt
> >>> (BinaryReaderExImpl.java:743)
> >>>>>     at org.apache.ignite.internal.processors.platform.client.cache.
> >>> ClientCacheConfigurationSerializer.read(ClientCacheConfigura
> >>> tionSerializer.java:125)
> >>>>>     at org.apache.ignite.internal.processors.platform.client.cache.
> >>> ClientCacheCreateWithConfigurationRequest.<init>(ClientCache
> >>> CreateWithConfigurationRequest.java:45)
> >>>>>     at org.apache.ignite.internal.processors.platform.client.Client
> >>> MessageParser.decode(ClientMessageParser.java:333)
> >>>>>     at org.apache.ignite.internal.processors.platform.client.Client
> >>> MessageParser.decode(ClientMessageParser.java:220)
> >>>>>     at org.apache.ignite.internal.processors.odbc.ClientListenerNio
> >>> Listener.onMessage(ClientListenerNioListener.java:119)
> >>>>>     at org.apache.ignite.internal.processors.odbc.ClientListenerNio
> >>> Listener.onMessage(ClientListenerNioListener.java:40)
> >>>>>     at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailF
> >>> ilter.onMessageReceived(GridNioFilterChain.java:279)
> >>>>>     at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.pro
> >>> ceedMessageReceived(GridNioFilterAdapter.java:109)
> >>>>>     at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter
> >>> $3.body(GridNioAsyncNotifyFilter.java:97)
> >>>>>     at org.apache.ignite.internal.util.worker.GridWorker.run(GridWo
> >>> rker.java:110)
> >>>>>     at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(
> >>> GridWorkerPool.java:70)
> >>>>>     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
> >>> Executor.java:1142)
> >>>>>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
> >>> lExecutor.java:617)
> >>>>>     at java.lang.Thread.run(Thread.java:745)
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >>
>
>