Giter VIP home page Giter VIP logo

glupy's Introduction

This is just the very start for a GlusterFS[1] meta-translator that will allow translator code to be written in Python. It's based on the standard Python embedding (not extending) techniques, plus a dash of the ctypes module. The interface is a pretty minimal adaptation of the dispatches and callbacks from the C API[2] to Python, as follows:

  • Dispatch functions and callbacks must be defined on an "xlator" class derived from gluster.Translator so that they'll be auto-registered with the C translator during initialization.

  • For each dispatch or callback function you want to intercept, you define a Python function using the xxx_fop_t or xxx_cbk_t decorator.

  • The arguments for each operation are different, so you'll need to refer to the C API. GlusterFS-specific types are used (though only loc_t is fully defined so far) and type correctness is enforced by ctypes.

  • If you do intercept a dispatch function, it is your responsibility to call xxx_wind (like STACK_WIND in the C API but operation-specific) to pass the request to the next translator. If you do not intercept a function, it will default the same way as for C (pass through to the same operation with the same arguments on the first child translator).

  • If you intercept a callback function, it is your responsibility to call xxx_unwind (like STACK_UNWIND_STRICT in the C API) to pass the request back to the caller.

Note that you can also use ctypes to get at anything not explicitly exposed to Python already.

If you're coming here because of the Linux Journal article, please note that the code has evolved since that was written. The version that matches the article is here:

https://github.com/jdarcy/glupy/tree/4bbae91ba459ea46ef32f2966562492e4ca9187a

Installation

1. Point Glupy at GlusterFS source dir

First, update the path to your GlusterFS source directory in the Makefile.

It's the GLFS_SRC variable.

$ vi Makefile

2. Compile and install Glupy

$ make
$ sudo make install

3. Let Python find gluster.py

Now copy gluster.py to some place in your PYTHONPATH.

On EL6/CentOS6 with GlusterFS compiled from git master, this would work:

$ sudo cp gluster.py /usr/lib64/glusterfs/3git/xlator/features/

That's it, Glupy is now installed. :)

Using it

This isn't yet quite as straight forward as it could be.

When you've created a Glupy based translator you want to use, you'll need to manually edit your .vol file to include it.

Glupy comes with an example "negative lookup" translator you can start with. It's the negative.py file in this repo.

To add a translator to your .vol file, open it in a text editor then:

  1. Add a new "volume" entry (copy an existing one)
  2. Change the volume name to something unique
  3. Change the "type" to be "features/glupy"

The filename of your translator (without the .py extension) is passed to Glupy using the "module-name" option.

So, for the "negative lookup" example translator, it would be something like this:

$ sudo vi /var/lib/glusterd/nfs/nfs-server.vol

volume myvolume-negative
    type features/glupy
    option module-name negative
    subvolumes myvolume-write-behind
end-volume

The name on the "subvolume" line in your .vol file will probably be different. You just need to adjust it so it's part of the chain of volumes. Take a look through the existing .vol file, noticing that each volume points to the one before it. Then adjust your new Glupy volume to do the same (eg fit it in somewhere).

When that's all done you need to start Gluster manually, telling it to use your new .vol file. eg:

$ sudo glusterfs -f /var/lib/glusterd/nfs/nfs-server.vol --debug

Things should now work normally. :)

glupy's People

Contributors

ajarr avatar jdarcy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glupy's Issues

ALways usable

Hi @jdarcy , I just want to know if this repo is this usable.
I'm about to start write xlator or modify existing ones (i.e dht). I want to know if I can use this repo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.