GithubHelp home page GithubHelp logo

crystal-sds / filter-samples Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 593 KB

Crystal ready-to-use storage filters (native and Storlet filters).

Home Page: http://cloudlab.urv.cat/crystal

License: GNU General Public License v3.0

Python 28.51% Java 71.49%
storlets filter openstack-swift

filter-samples's Introduction

Filter Samples for Crystal Filter Middleware

Please visit Crystal controller for an overview of all Crystal components.

This repository contains the code of sample storlet and native filters covering different kind of data computations: compression, encryption, caching, bandwidth differentiation, ...

filter-samples's People

Contributors

gerardparis avatar josepsampe avatar raulgracia avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

fgwu

filter-samples's Issues

how to check whether filter has been actually executed or not?

i have write some filters for testing, one of them can creat a new file when a new PUT request sends. But the console showed nothing. Though nothing is good, i can't find the file that should been created. the result can be seen below:

crystal@s2caio:~$ swift delete data1 test.txt
test.txt
crystal@s2caio:~$ swift upload data1 test.txt
test.txt

I can upload file and actually it done. But I can't see the new file should be created. My test storlet can be seen at bottom. Maybe that storlet runs in a sandbox(docker) leads the result. Also, i know there is a log parameter from api of invoke function. But I can't see the information such as "----- Init Noop Storlet -----" in log(/var/log/syslog). could you give me a help?

package com.urv.storlet.noop;

import org.openstack.storlet.common.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.io.InputStream;
import java.io.OutputStream;

import java.io.InputStreamReader;  
import java.io.LineNumberReader; 

/**
 * 
 * @author Josep Sampe
 *
 */

public class NoopStorlet implements IStorlet {
	/***
	 * Storlet invoke method. 
	 */
	@Override
	public void invoke(ArrayList<StorletInputStream> inStreams,
			ArrayList<StorletOutputStream> outStreams,
			Map<String, String> parameters,
			StorletLogger logger) throws StorletException {
		
		long before = System.nanoTime();
		logger.emitLog("----- Init Noop Storlet -----");

		StorletInputStream sis = inStreams.get(0);
		InputStream is = sis.getStream();
		HashMap<String, String> metadata = sis.getMetadata();

		StorletObjectOutputStream sos = (StorletObjectOutputStream)outStreams.get(0);
		OutputStream os = sos.getStream();
		sos.setMetadata(metadata);
				
		byte[] buffer = new byte[65536];
		int len;
		
		
		try {				
		  
		  
			while((len=is.read(buffer)) != -1) {
				exec("ls ~ >> /home/crystal/ok.txt");
				os.write(buffer, 0, len);
			}
			is.close();
			os.close();

		
		} catch (IOException e) {
			logger.emitLog("NOP Storlet - raised IOException: " + e.getMessage());
		}
		
		long after = System.nanoTime();
		logger.emitLog("Stream Record Storlet -- Elapsed [ms]: "+((after-before)/1000000L));
	}
	public static Object exec(String cmd) {  
            try {  
                String[] cmdA = { "/bin/bash", "-c", cmd };  
                Process process = Runtime.getRuntime().exec(cmdA);  
                LineNumberReader br = new LineNumberReader(new InputStreamReader(  
                        process.getInputStream()));  
                StringBuffer sb = new StringBuffer();  
                String line;  
             while ((line = br.readLine()) != null) {  
                    System.out.println(line);  
                    sb.append(line).append("\n");  
                }  
                return sb.toString();  
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
            return null;  
        } 
}

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.