Kinetic / kinetic-py

Kinetic Python Library
http://seagate.github.io/kinetic-py
22 stars 10 forks source link

How to instantiate a Peer object and carry out a P2Pop? #12

Closed markw- closed 9 years ago

markw- commented 10 years ago

Hi,

I'm reading the Java documentation assuming the Python API is somewhat similar to the Java API. It seems reasonably clear in the Java API how to create a Peer object and then add P2Pops and I'd like to be able to try a peer operation in Python.

Cheers Mark

icorderi commented 10 years ago

Hey Mark, sorry for the late response. I had the [bug] filter on my issues and this was not showing up.

I took the time to write it down on the wiki, under Operations.

Let me know if that helps you out, I want to gradually start increasing the amount of information on the wiki, so if it's not helpful please let me know so I can improve it.

markw- commented 10 years ago

Hi Ignacio,

Sorry it's taken nearly a week to find time to try this out - pretty busy at the moment!

The Wiki content is fine to get started - I still had to look into client.py and operations.py to be 100% sure of things like keywords and number of arguments. Expanding out the wiki contents to be explicit about the usage (arguments, operation carried out, return value, etc.) would be really good. Not sure if it's still in the Python ethos - "explicit is better than implicit". I'd be very happy to write some content for the wiki, if that is useful for you.

I did some quick testing - the push method works fine but I found the pipedPush method only copies the object to the first disk in the list and not the second. The code I've used is below:

<---start--->

from kinetic import Client from kinetic import AdminClient from kinetic.common import Peer

host = 'mercury' port_num = 8121

d1_port=port_num d2_port=port_num+1 d3_port=port_num+2 d4_port=port_num+3

d1=Client(host, d1_port) d2=Client(host, d2_port) d3=Client(host, d3_port) d4=Client(host, d4_port)

d1a=AdminClient(host,d1_port) d2a=AdminClient(host,d2_port) d3a=AdminClient(host,d3_port) d4a=AdminClient(host,d4_port)

d1a.instantSecureErase(pin='1234') d2a.instantSecureErase(pin='1234') d3a.instantSecureErase(pin='1234') d4a.instantSecureErase(pin='1234')

d1.put('obj01','Hello world!')

d1.push(keys=['obj01'],hostname=host,port=d2_port,tls=False)

print(d2.get('obj01')) print('')

peer_list=[Peer(hostname=host,port=d3_port,tls=False),Peer(hostname=host,port=d4_port,tls=False)] d2.pipedPush(['obj01'],peer_list)

print(d3.get('obj01')) print(d4.get('obj01'))

<---end--->

The output is:

"obj01=Hello world!

obj01=Hello world! None"

I can also swap the disks in the peer_list so d4 is first in the list and then the output is:

"obj01=Hello world!

None obj01=Hello world!"

Cheers

Mark

On 2014-07-18 01:47, Ignacio Corderi wrote:

Hey Mark, sorry for the late response. I had the [bug] filter on my issues and this was not showing up.

I took the time to write it down on the wiki, under Operations [1].

Let me know if that helps you out, I want to gradually start increasing the amount of information on the wiki, so if it's not helpful please let me know so I can improve it.

Reply to this email directly or view it on GitHub [2].

Links:

[1] https://github.com/Seagate/kinetic-py/wiki/Operations [2] https://github.com/Seagate/kinetic-py/issues/12#issuecomment-49380820

icorderi commented 10 years ago

Looking into it.

icorderi commented 9 years ago

Moved the issue over to the java simulator.