crystal-sds / filter-samples Goto Github PK
View Code? Open in Web Editor NEWCrystal ready-to-use storage filters (native and Storlet filters).
Home Page: http://cloudlab.urv.cat/crystal
License: GNU General Public License v3.0
Crystal ready-to-use storage filters (native and Storlet filters).
Home Page: http://cloudlab.urv.cat/crystal
License: GNU General Public License v3.0
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;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.